diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
commit | f008adb5a77e094eaf6abf3fc0f36958e66896a5 (patch) | |
tree | 8e9244c4d4957c36be81e15b566b4aa5ea26c982 /tools/kfile-plugins/ooo/kfile_ooo.cpp | |
parent | 1210f27b660efb7b37ff43ec68763e85a403471f (diff) | |
download | koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.tar.gz koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.zip |
TQt4 port koffice
This should enable compilation under both Qt3 and Qt4; fixes for any missed components will be forthcoming
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238284 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'tools/kfile-plugins/ooo/kfile_ooo.cpp')
-rw-r--r-- | tools/kfile-plugins/ooo/kfile_ooo.cpp | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/tools/kfile-plugins/ooo/kfile_ooo.cpp b/tools/kfile-plugins/ooo/kfile_ooo.cpp index 4f16a0af..ee3a5bcc 100644 --- a/tools/kfile-plugins/ooo/kfile_ooo.cpp +++ b/tools/kfile-plugins/ooo/kfile_ooo.cpp @@ -45,12 +45,12 @@ #include <KoStoreDevice.h> #include <kzip.h> #include <ktempfile.h> -#include <qptrstack.h> +#include <tqptrstack.h> -#include <qdom.h> -#include <qfile.h> -#include <qdatetime.h> -#include <qvalidator.h> +#include <tqdom.h> +#include <tqfile.h> +#include <tqdatetime.h> +#include <tqvalidator.h> #include <kdebug.h> #include <kio/netaccess.h> @@ -123,22 +123,22 @@ static const char * metadocstat = "meta:document-statistic"; static const char * metaname = "meta:name" ; static const char * metauserdef = "meta:user-defined"; static const char * metafile = "meta.xml" ; -KOfficePlugin::KOfficePlugin(QObject *parent, const char *name, - const QStringList &args) +KOfficePlugin::KOfficePlugin(TQObject *tqparent, const char *name, + const TQStringList &args) - : KFilePlugin(parent, name, args) + : KFilePlugin(tqparent, name, args) { int i = 0; while (mimetypes[i]) makeMimeTypeInfo( mimetypes[i++] ); } -void KOfficePlugin::makeMimeTypeInfo(const QString& mimeType) +void KOfficePlugin::makeMimeTypeInfo(const TQString& mimeType) { KFileMimeTypeInfo* info = addMimeTypeInfo( mimeType ); userdefined = addGroupInfo(info, UserDefined, i18n("User Defined")); - addVariableInfo(userdefined, QVariant::String, + addVariableInfo(userdefined, TQVariant::String, KFileMimeTypeInfo::Addable | KFileMimeTypeInfo::Removable | KFileMimeTypeInfo::Modifiable); @@ -149,7 +149,7 @@ void KOfficePlugin::makeMimeTypeInfo(const QString& mimeType) int i = 0; for (i = 0; Information[i]; i+=2){ item = addItemInfo(group, Information[i], i18n(Information[i+1]), - QVariant::String); + TQVariant::String); setAttributes(item, KFileMimeTypeInfo::Modifiable); switch (i){ case 0: @@ -165,18 +165,18 @@ void KOfficePlugin::makeMimeTypeInfo(const QString& mimeType) } item = addItemInfo(group, metakeyword, i18n("Keywords"), - QVariant::String); + TQVariant::String); setHint(item, KFileMimeTypeInfo::Description); setAttributes(item, KFileMimeTypeInfo::Modifiable); group = addGroupInfo(info, DocAdvanced, i18n("Document Advanced")); for (i = 0; Advanced[i]; i+=2){ // I should add the isDate property instead of testing the index, but it works well, who cares ? :-) - QVariant::Type typ = QVariant::String; + TQVariant::Type typ = TQVariant::String; if (i > 1 && i < 8) - typ = QVariant::DateTime; + typ = TQVariant::DateTime; if (i == 14) - typ = QVariant::String; + typ = TQVariant::String; item = addItemInfo(group, Advanced[i], i18n(Advanced[i+1]), typ); setHint(item, KFileMimeTypeInfo::Description); } @@ -184,7 +184,7 @@ void KOfficePlugin::makeMimeTypeInfo(const QString& mimeType) group = addGroupInfo(info, DocStatistics, i18n("Document Statistics")); for (i = 0; Statistics[i]; i+=2){ item = addItemInfo(group, Statistics[i], i18n(Statistics[i+1]), - QVariant::Int); + TQVariant::Int); setHint(item, KFileMimeTypeInfo::Length); } } @@ -196,7 +196,7 @@ void KOfficePlugin::makeMimeTypeInfo(const QString& mimeType) * @param the position to start to, updated to the next character NAN * @return the number parsed, 0 if number was not valid */ -int getNumber(QString &str, int * pos){ +int getNumber(TQString &str, int * pos){ int k = *pos; for (int len = str.length() ; str.at(k).isNumber() && k < len ; @@ -210,8 +210,8 @@ int getNumber(QString &str, int * pos){ } void KOfficePlugin::getEditingTime(KFileMetaInfoGroup group1, - const char * labelid, QString & txt){ - QString t; + const char * labelid, TQString & txt){ + TQString t; int days = 0; int hours = 0; int minutes = 0; @@ -241,7 +241,7 @@ void KOfficePlugin::getEditingTime(KFileMetaInfoGroup group1, int res = getNumber(txt, &pos); if (pos >= len) return; - switch (txt.at(pos).latin1()){ + switch (txt.tqat(pos).latin1()) { case 'H': hours = res; break; @@ -259,13 +259,13 @@ void KOfficePlugin::getEditingTime(KFileMetaInfoGroup group1, } hours += days * 24; appendItem(group1, labelid, - i18n("%1:%2.%3").arg(hours).arg(minutes, 2).arg(seconds,2 )); + i18n("%1:%2.%3").tqarg(hours).tqarg(minutes, 2).tqarg(seconds,2 )); } void KOfficePlugin::getDateTime(KFileMetaInfoGroup group1, - const char * labelid, QString & txt) + const char * labelid, TQString & txt) { - QDateTime dt = QDateTime::fromString( txt, Qt::ISODate); + TQDateTime dt = TQDateTime::fromString( txt, Qt::ISODate); appendItem( group1, labelid, dt); } @@ -275,20 +275,20 @@ bool KOfficePlugin::readInfo( KFileMetaInfo& info, uint /*what*/) return false; KFileMetaInfoGroup group = appendGroup(info, DocumentInfo); - QDomDocument doc = getMetaDocument(info.path()); + TQDomDocument doc = getMetaDocument(info.path()); if (doc.isNull()) return false; - QDomElement base = getBaseNode(doc).toElement(); + TQDomElement base = getBaseNode(doc).toElement(); if (base.isNull()) return false; for (int i = 0; Information[i]; i+=2) appendItem(group, Information[i], stringFromNode(base, Information[i])); // Special case for keyword - QDomNodeList keywordList = base.elementsByTagName( metakeyword ); - QString allKeywords; + TQDomNodeList keywordList = base.elementsByTagName( metakeyword ); + TQString allKeywords; for (uint i = 0; i < keywordList.length(); i++){ - QDomNode node = keywordList.item(i); + TQDomNode node = keywordList.item(i); if (node.isElement()){ if (i>0) allKeywords += ", "; @@ -300,7 +300,7 @@ bool KOfficePlugin::readInfo( KFileMetaInfo& info, uint /*what*/) KFileMetaInfoGroup group1 = appendGroup(info, DocAdvanced); for (int i = 0; Advanced[i]; i+=2){ - QString txt = stringFromNode(base, Advanced[i]); + TQString txt = stringFromNode(base, Advanced[i]); if (!txt.isEmpty()){ // A silly way to do it... switch (i){ @@ -317,66 +317,66 @@ bool KOfficePlugin::readInfo( KFileMetaInfo& info, uint /*what*/) } } - QDomNode dstat = base.namedItem(metadocstat); + TQDomNode dstat = base.namedItem(metadocstat); KFileMetaInfoGroup group2 = appendGroup(info, DocStatistics); if (!dstat.isNull() && dstat.isElement()){ - QDomElement dinfo = dstat.toElement(); + TQDomElement dinfo = dstat.toElement(); for (int i = 0; Statistics[i]; i+=2) addAttributeInfo(dinfo, group2, Statistics[i] ); } - QDomNodeList userList = base.elementsByTagName( metauserdef ); + TQDomNodeList userList = base.elementsByTagName( metauserdef ); KFileMetaInfoGroup groupuser = appendGroup(info, UserDefined); for (uint i = 0; i < userList.length(); i++){ - QDomNode node = userList.item(i); + TQDomNode node = userList.item(i); if (node.isElement()){ appendItem(groupuser, node.toElement().attribute(metaname, - QString("User %1").arg(i)), + TQString("User %1").tqarg(i)), node.toElement().text()); } } return true; } -QString KOfficePlugin::stringFromNode(const QDomNode &node, const QString &name) +TQString KOfficePlugin::stringFromNode(const TQDomNode &node, const TQString &name) { - QString value = node.namedItem(name).toElement().text(); - return value.isEmpty() ? QString::null : value; + TQString value = node.namedItem(name).toElement().text(); + return value.isEmpty() ? TQString() : value; } -void KOfficePlugin::addAttributeInfo(const QDomElement & elem, KFileMetaInfoGroup & group, const QString &attributeName) +void KOfficePlugin::addAttributeInfo(const TQDomElement & elem, KFileMetaInfoGroup & group, const TQString &attributeName) { if (!elem.hasAttribute(attributeName)){ return; } - QString m_attribute = elem.attribute(attributeName, "0"); + TQString m_attribute = elem.attribute(attributeName, "0"); if (m_attribute == "0") return; appendItem(group, attributeName, m_attribute); } -bool KOfficePlugin::writeTextNode(QDomDocument & doc, - QDomNode & parentNode, - const QString &nodeName, - const QString &value) const +bool KOfficePlugin::writeTextNode(TQDomDocument & doc, + TQDomNode & tqparentNode, + const TQString &nodeName, + const TQString &value) const { - if (parentNode.toElement().isNull()){ + if (tqparentNode.toElement().isNull()){ kdDebug(7034) << "Parent node is Null or not an Element, cannot write node " << nodeName << endl; return false; } // If the node does not exist, we create it... - if (parentNode.namedItem(nodeName).isNull()) - QDomNode ex = parentNode.appendChild(doc.createElement(nodeName)); + if (tqparentNode.namedItem(nodeName).isNull()) + TQDomNode ex = tqparentNode.appendChild(doc.createElement(nodeName)); // Now, we are sure we have a node - QDomElement nodeA = parentNode.namedItem(nodeName).toElement(); + TQDomElement nodeA = tqparentNode.namedItem(nodeName).toElement(); // Ooops... existing node were not of the good type... if (nodeA.isNull()){ @@ -385,21 +385,21 @@ bool KOfficePlugin::writeTextNode(QDomDocument & doc, return false; } - QDomText txtNode = doc.createTextNode(value); + TQDomText txtNode = doc.createTextNode(value); // If the node has already Text Child, we replace it. if (nodeA.firstChild().isNull()) nodeA.appendChild(txtNode); else - nodeA.replaceChild( txtNode, nodeA.firstChild()); + nodeA.tqreplaceChild( txtNode, nodeA.firstChild()); return true; } bool KOfficePlugin::writeInfo( const KFileMetaInfo& info) const { bool no_errors = true; - QDomDocument doc = getMetaDocument(info.path()); - QDomElement base = getBaseNode(doc).toElement(); + TQDomDocument doc = getMetaDocument(info.path()); + TQDomElement base = getBaseNode(doc).toElement(); if (base.isNull()) return false; for (int i = 0; Information[i]; i+=2) @@ -409,34 +409,34 @@ bool KOfficePlugin::writeInfo( const KFileMetaInfo& info) const // If we need a meta:keywords container, we create it. if (base.namedItem(metakeywords).isNull()) base.appendChild(doc.createElement(metakeywords)); - QDomNode metaKeyNode = base.namedItem(metakeywords); + TQDomNode metaKeyNode = base.namedItem(metakeywords); - QDomNodeList childs = doc.elementsByTagName(metakeyword); + TQDomNodeList childs = doc.elementsByTagName(metakeyword); for (int i = childs.length(); i >= 0; --i){ metaKeyNode.removeChild( childs.item(i) ); } - QStringList keywordList = QStringList::split(",", info[DocumentInfo][metakeyword].value().toString().stripWhiteSpace(), false); - for ( QStringList::Iterator it = keywordList.begin(); it != keywordList.end(); ++it ) { - QDomElement elem = doc.createElement(metakeyword); + TQStringList keywordList = TQStringList::split(",", info[DocumentInfo][metakeyword].value().toString().stripWhiteSpace(), false); + for ( TQStringList::Iterator it = keywordList.begin(); it != keywordList.end(); ++it ) { + TQDomElement elem = doc.createElement(metakeyword); metaKeyNode.appendChild(elem); elem.appendChild(doc.createTextNode((*it).stripWhiteSpace())); } // Now, we store the user-defined data - QDomNodeList theElements = base.elementsByTagName(metauserdef); + TQDomNodeList theElements = base.elementsByTagName(metauserdef); for (uint i = 0; i < theElements.length(); i++) { - QDomElement el = theElements.item(i).toElement(); + TQDomElement el = theElements.item(i).toElement(); if (el.isNull()){ kdDebug(7034) << metauserdef << " is not an Element" << endl; no_errors = false; } - QString s = info[UserDefined][el.attribute(metaname)].value().toString(); + TQString s = info[UserDefined][el.attribute(metaname)].value().toString(); if (s != el.text()){ - QDomText txt = doc.createTextNode(s); + TQDomText txt = doc.createTextNode(s); if (!el.firstChild().isNull()) - el.replaceChild(txt, el.firstChild()); + el.tqreplaceChild(txt, el.firstChild()); else el.appendChild(txt); } @@ -460,12 +460,12 @@ bool copyZipToZip( const KZip * src, KZip * dest) { KArchiveDirectory * src_dir; KArchiveFile * input_file; - QPtrStack<KArchiveDirectory> src_dirStack ; - QStringList dirEntries; - QStringList curDirName; - QStringList::Iterator it; + TQPtrStack<KArchiveDirectory> src_dirStack ; + TQStringList dirEntries; + TQStringList curDirName; + TQStringList::Iterator it; KArchiveEntry* curEntry; - QString filename = QString::null; + TQString filename = TQString(); src_dirStack.push ( src->directory() ); @@ -482,13 +482,13 @@ bool copyZipToZip( const KZip * src, KZip * dest) if (curEntry->isFile()) { input_file = dynamic_cast<KArchiveFile*>( curEntry ); - QByteArray b = input_file->data(); + TQByteArray b = input_file->data(); if (curDirName.isEmpty() || src_dir->name()=="/"){ filename = *it; } else { filename = curDirName.join("/") + "/" + *it; } - dest->writeFile(filename , QString::null, QString::null, b.count(), b.data() ); + dest->writeFile(filename , TQString(), TQString(), b.count(), b.data() ); } else if (curEntry->isDirectory()) { src_dirStack.push( dynamic_cast<KArchiveDirectory*>( curEntry ) ); @@ -503,8 +503,8 @@ bool copyZipToZip( const KZip * src, KZip * dest) return true; } -bool KOfficePlugin::writeMetaData(const QString & path, - const QDomDocument &doc) const +bool KOfficePlugin::writeMetaData(const TQString & path, + const TQDomDocument &doc) const { KTempFile tmp_file; tmp_file.setAutoDelete(true); @@ -513,11 +513,11 @@ bool KOfficePlugin::writeMetaData(const QString & path, /* To correct problem with OOo 1.1, we have to recreate the file from scratch */ if (!m_zip->open(IO_WriteOnly) || !current->open(IO_ReadOnly) ) return false; - QCString text = doc.toCString(); + TQCString text = doc.toCString(); m_zip->setCompression(KZip::DeflateCompression); if (!copyZipToZip(current, m_zip)) return false; - m_zip->writeFile(metafile, QString::null, QString::null,text.length(), + m_zip->writeFile(metafile, TQString(), TQString(),text.length(), text); delete current; delete m_zip; @@ -531,7 +531,7 @@ bool KOfficePlugin::writeMetaData(const QString & path, } -QIODevice* KOfficePlugin::getData(KArchive &m_zip, int fileMode) const +TQIODevice* KOfficePlugin::getData(KArchive &m_zip, int fileMode) const { if ( !m_zip.open(fileMode) || !m_zip.directory()) @@ -547,14 +547,14 @@ QIODevice* KOfficePlugin::getData(KArchive &m_zip, int fileMode) const return f->device(); } -QDomDocument KOfficePlugin::getMetaDocument(const QString &path) const +TQDomDocument KOfficePlugin::getMetaDocument(const TQString &path) const { - QDomDocument doc; + TQDomDocument doc; KZip m_zip(path); - QIODevice * io = getData(m_zip, IO_ReadOnly); + TQIODevice * io = getData(m_zip, IO_ReadOnly); if (!io || !io->isReadable()) return doc; - QString errorMsg; + TQString errorMsg; int errorLine, errorColumn; if ( !doc.setContent( io, &errorMsg, &errorLine, &errorColumn ) ){ kdDebug(7034) << "Error " << errorMsg.latin1() @@ -567,21 +567,21 @@ QDomDocument KOfficePlugin::getMetaDocument(const QString &path) const return doc; } -QDomNode KOfficePlugin::getBaseNode(const QDomDocument &doc) const +TQDomNode KOfficePlugin::getBaseNode(const TQDomDocument &doc) const { return doc.namedItem("office:document-meta").namedItem("office:meta"); } -QValidator * KOfficePlugin::createValidator(const QString &, /* mimetype */ - const QString & , /* group */ - const QString &key, - QObject * parent, +TQValidator * KOfficePlugin::createValidator(const TQString &, /* mimetype */ + const TQString & , /* group */ + const TQString &key, + TQObject * tqparent, const char * name ) const { if (key == dclanguage) - return new QRegExpValidator(QRegExp("[a-zA-Z-]{1,5}"), - parent, name); + return new TQRegExpValidator(TQRegExp("[a-zA-Z-]{1,5}"), + tqparent, name); return 0; } |