diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-02 06:40:27 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-02 06:40:27 +0000 |
commit | 2595a15ebeb6fc46b7cb241d01ec0c2460ec2111 (patch) | |
tree | 18a8f0f4ac5a86dacfa74c3537551ec39bc85e75 /src/translators/xslthandler.cpp | |
parent | 1d90725a4001fab9d3922b2cbcceeee5e2d1686f (diff) | |
download | tellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.tar.gz tellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.zip |
TQt4 port tellico
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1239054 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/translators/xslthandler.cpp')
-rw-r--r-- | src/translators/xslthandler.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/translators/xslthandler.cpp b/src/translators/xslthandler.cpp index e25eef5..bdbe8f2 100644 --- a/src/translators/xslthandler.cpp +++ b/src/translators/xslthandler.cpp @@ -16,8 +16,8 @@ #include "../tellico_debug.h" #include "../tellico_utils.h" -#include <qdom.h> -#include <qtextcodec.h> +#include <tqdom.h> +#include <tqtextcodec.h> #include <kurl.h> @@ -35,22 +35,22 @@ static const int xml_options = XML_PARSE_NOENT | XML_PARSE_NONET | XML_PARSE_NOC static const int xslt_options = xml_options; /* some functions to pass to the XSLT libs */ -static int writeToQString(void* context, const char* buffer, int len) { - QString* t = static_cast<QString*>(context); - *t += QString::fromUtf8(buffer, len); +static int writeToTQString(void* context, const char* buffer, int len) { + TQString* t = static_cast<TQString*>(context); + *t += TQString::fromUtf8(buffer, len); return len; } -static void closeQString(void* context) { - QString* t = static_cast<QString*>(context); - *t += QString::fromLatin1("\n"); +static void closeTQString(void* context) { + TQString* t = static_cast<TQString*>(context); + *t += TQString::tqfromLatin1("\n"); } using Tellico::XSLTHandler; -XSLTHandler::XMLOutputBuffer::XMLOutputBuffer() : m_res(QString::null) { - m_buf = xmlOutputBufferCreateIO((xmlOutputWriteCallback)writeToQString, - (xmlOutputCloseCallback)closeQString, +XSLTHandler::XMLOutputBuffer::XMLOutputBuffer() : m_res(TQString()) { + m_buf = xmlOutputBufferCreateIO((xmlOutputWriteCallback)writeToTQString, + (xmlOutputCloseCallback)closeTQString, &m_res, 0); if(m_buf) { m_buf->written = 0; @@ -68,12 +68,12 @@ XSLTHandler::XMLOutputBuffer::~XMLOutputBuffer() { int XSLTHandler::s_initCount = 0; -XSLTHandler::XSLTHandler(const QCString& xsltFile_) : +XSLTHandler::XSLTHandler(const TQCString& xsltFile_) : m_stylesheet(0), m_docIn(0), m_docOut(0) { init(); - QString file = KURL::encode_string(QString::fromLocal8Bit(xsltFile_)); + TQString file = KURL::encode_string(TQString::fromLocal8Bit(xsltFile_)); if(!file.isEmpty()) { xmlDocPtr xsltDoc = xmlReadFile(file.utf8(), NULL, xslt_options); m_stylesheet = xsltParseStylesheetDoc(xsltDoc); @@ -97,12 +97,12 @@ XSLTHandler::XSLTHandler(const KURL& xsltURL_) : } } -XSLTHandler::XSLTHandler(const QDomDocument& xsltDoc_, const QCString& xsltFile_, bool translate_) : +XSLTHandler::XSLTHandler(const TQDomDocument& xsltDoc_, const TQCString& xsltFile_, bool translate_) : m_stylesheet(0), m_docIn(0), m_docOut(0) { init(); - QString file = KURL::encode_string(QString::fromLocal8Bit(xsltFile_)); + TQString file = KURL::encode_string(TQString::fromLocal8Bit(xsltFile_)); if(!xsltDoc_.isNull() && !file.isEmpty()) { setXSLTDoc(xsltDoc_, file.utf8(), translate_); } @@ -143,16 +143,16 @@ void XSLTHandler::init() { m_params.clear(); } -void XSLTHandler::setXSLTDoc(const QDomDocument& dom_, const QCString& xsltFile_, bool translate_) { +void XSLTHandler::setXSLTDoc(const TQDomDocument& dom_, const TQCString& xsltFile_, bool translate_) { bool utf8 = true; // XML defaults to utf-8 // need to find out if utf-8 or not - const QDomNodeList childs = dom_.childNodes(); + const TQDomNodeList childs = dom_.childNodes(); for(uint j = 0; j < childs.count(); ++j) { if(childs.item(j).isProcessingInstruction()) { - QDomProcessingInstruction pi = childs.item(j).toProcessingInstruction(); - if(pi.data().lower().contains(QString::fromLatin1("encoding"))) { - if(!pi.data().lower().contains(QString::fromLatin1("utf-8"))) { + TQDomProcessingInstruction pi = childs.item(j).toProcessingInstruction(); + if(pi.data().lower().tqcontains(TQString::tqfromLatin1("encoding"))) { + if(!pi.data().lower().tqcontains(TQString::tqfromLatin1("utf-8"))) { utf8 = false; // } else { // myDebug() << "XSLTHandler::setXSLTDoc() - PI = " << pi.data() << endl; @@ -162,7 +162,7 @@ void XSLTHandler::setXSLTDoc(const QDomDocument& dom_, const QCString& xsltFile_ } } - QString s; + TQString s; if(translate_) { s = Tellico::i18nReplace(dom_.toString(0 /* indent */)); } else { @@ -186,29 +186,29 @@ void XSLTHandler::setXSLTDoc(const QDomDocument& dom_, const QCString& xsltFile_ // xmlFreeDoc(xsltDoc); // this causes a crash for some reason } -void XSLTHandler::addStringParam(const QCString& name_, const QCString& value_) { - QCString value = value_; - value.replace('\'', "'"); - addParam(name_, QCString("'") + value + QCString("'")); +void XSLTHandler::addStringParam(const TQCString& name_, const TQCString& value_) { + TQCString value = value_; + value.tqreplace('\'', "'"); + addParam(name_, TQCString("'") + value + TQCString("'")); } -void XSLTHandler::addParam(const QCString& name_, const QCString& value_) { +void XSLTHandler::addParam(const TQCString& name_, const TQCString& value_) { m_params.insert(name_, value_); // myDebug() << "XSLTHandler::addParam() - " << name_ << ":" << value_ << endl; } -void XSLTHandler::removeParam(const QCString& name_) { +void XSLTHandler::removeParam(const TQCString& name_) { m_params.remove(name_); } -const QCString& XSLTHandler::param(const QCString& name_) { +const TQCString& XSLTHandler::param(const TQCString& name_) { return m_params[name_]; } -QString XSLTHandler::applyStylesheet(const QString& text_) { +TQString XSLTHandler::applyStylesheet(const TQString& text_) { if(!m_stylesheet) { myDebug() << "XSLTHandler::applyStylesheet() - null stylesheet pointer!" << endl; - return QString::null; + return TQString(); } m_docIn = xmlReadDoc(reinterpret_cast<xmlChar*>(text_.utf8().data()), NULL, NULL, xml_options); @@ -216,16 +216,16 @@ QString XSLTHandler::applyStylesheet(const QString& text_) { return process(); } -QString XSLTHandler::process() { +TQString XSLTHandler::process() { if(!m_docIn) { myDebug() << "XSLTHandler::process() - error parsing input string!" << endl; - return QString::null; + return TQString(); } - QMemArray<const char*> params(2*m_params.count() + 1); + TQMemArray<const char*> params(2*m_params.count() + 1); params[0] = NULL; - QMap<QCString, QCString>::ConstIterator it = m_params.constBegin(); - QMap<QCString, QCString>::ConstIterator end = m_params.constEnd(); + TQMap<TQCString, TQCString>::ConstIterator it = m_params.constBegin(); + TQMap<TQCString, TQCString>::ConstIterator end = m_params.constEnd(); for(uint i = 0; it != end; ++it) { params[i ] = qstrdup(it.key()); params[i+1] = qstrdup(it.data()); @@ -239,7 +239,7 @@ QString XSLTHandler::process() { } if(!m_docOut) { myDebug() << "XSLTHandler::applyStylesheet() - error applying stylesheet!" << endl; - return QString::null; + return TQString(); } XMLOutputBuffer output; @@ -253,13 +253,13 @@ QString XSLTHandler::process() { } //static -QDomDocument& XSLTHandler::setLocaleEncoding(QDomDocument& dom_) { - const QDomNodeList childs = dom_.documentElement().childNodes(); +TQDomDocument& XSLTHandler::setLocaleEncoding(TQDomDocument& dom_) { + const TQDomNodeList childs = dom_.documentElement().childNodes(); for(unsigned j = 0; j < childs.count(); ++j) { if(childs.item(j).isElement() && childs.item(j).nodeName() == Latin1Literal("xsl:output")) { - QDomElement e = childs.item(j).toElement(); - const QString encoding = QString::fromLatin1(QTextCodec::codecForLocale()->name()); - e.setAttribute(QString::fromLatin1("encoding"), encoding); + TQDomElement e = childs.item(j).toElement(); + const TQString encoding = TQString::tqfromLatin1(TQTextCodec::codecForLocale()->name()); + e.setAttribute(TQString::tqfromLatin1("encoding"), encoding); break; } } |