/*************************************************************************** kvtmlwriter.cpp - description ------------------- copyright : (C) 2004 by Peter Hedlund email : peter.hedlund@kdemail.net ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "kvtmlwriter.h" KVTMLWriter::KVTMLWriter(TQFile *file) { outputFile = file; if(outputFile->open(IO_WriteOnly)) { outputStream.setDevice(TQT_TQIODEVICE(outputFile)); outputStream.setEncoding(TQTextStream::UnicodeUTF8); outputStream << "" << endl; outputStream << "" << endl; } } /*! \fn KVTMLWriter::addHeader(const TQString &generator, int cols, int rows, const TQString &title) */ void KVTMLWriter::addHeader(const TQString &generator, int cols, int rows, const TQString &title) { TQString s = TQString("") .arg(generator) .arg(cols) .arg(rows) .arg(title); outputStream << s << endl << endl; } /*! \fn KVTMLWriter::addFirstItem(const TQString &ll, int lwidth, const TQString &left, const TQString &rl, int rwidth, const TQString &right) */ void KVTMLWriter::addFirstItem(const TQString &ll, int lwidth, const TQString &left, const TQString &rl, int rwidth, const TQString &right) { outputStream << " " << endl; TQString s = TQString(" ") .arg(lwidth) .arg(ll); outputStream << s << escape(left) << "" << endl; s = TQString(" ") .arg(rwidth) .arg(rl); outputStream << s << escape(right) << "" << endl; outputStream << " " << endl; } /*! \fn KVTMLWriter::addItem(const TQString &left, const TQString &right) */ void KVTMLWriter::addItem(const TQString &left, const TQString &right) { outputStream << " " << endl; outputStream << " " << escape(left) << "" << endl; outputStream << " " << escape(right) << "" << endl; outputStream << " " << endl; } KVTMLWriter::~KVTMLWriter() { outputStream << "" << endl; outputFile->close(); } TQString KVTMLWriter::escape( const TQString & s) { TQString result = s; result.replace(TQChar('&'), "&"); //must be done first result.replace(TQChar('<'), "<"); result.replace(TQChar('>'), ">"); return result; }