diff options
Diffstat (limited to 'filters/liboofilter/ooutils.cc')
-rw-r--r-- | filters/liboofilter/ooutils.cc | 188 |
1 files changed, 94 insertions, 94 deletions
diff --git a/filters/liboofilter/ooutils.cc b/filters/liboofilter/ooutils.cc index b543f879..0e023618 100644 --- a/filters/liboofilter/ooutils.cc +++ b/filters/liboofilter/ooutils.cc @@ -22,15 +22,15 @@ #include "ooutils.h" #include <KoDocument.h> #include <KoStyleStack.h> -#include <qdom.h> -#include <qcolor.h> -#include <qimage.h> +#include <tqdom.h> +#include <tqcolor.h> +#include <tqimage.h> #include <KoUnit.h> -#include <qregexp.h> +#include <tqregexp.h> #include <kdebug.h> #include <kzip.h> #include <KoDom.h> -#include <qxml.h> +#include <tqxml.h> const char* const ooNS::office="http://openoffice.org/2000/office"; const char* const ooNS::style="http://openoffice.org/2000/style"; @@ -46,28 +46,28 @@ const char* const ooNS::dc="http://purl.org/dc/elements/1.1/"; const char* const ooNS::meta="http://openoffice.org/2000/meta"; const char* const ooNS::config="http://openoffice.org/2001/config"; -QString OoUtils::expandWhitespace(const QDomElement& tag) +TQString OoUtils::expandWhitespace(const TQDomElement& tag) { //tags like <text:s text:c="4"> int howmany=1; if (tag.hasAttributeNS( ooNS::text, "c")) - howmany = tag.attributeNS( ooNS::text, "c", QString::null).toInt(); + howmany = tag.attributeNS( ooNS::text, "c", TQString()).toInt(); - QString result; + TQString result; return result.fill(32, howmany); } -bool OoUtils::parseBorder(const QString & tag, double * width, int * style, QColor * color) +bool OoUtils::parseBorder(const TQString & tag, double * width, int * style, TQColor * color) { //string like "0.088cm solid #800000" if (tag.isEmpty() || tag=="none" || tag=="hidden") // in fact no border return false; - QString _width = tag.section(' ', 0, 0); - QString _style = tag.section(' ', 1, 1); - QString _color = tag.section(' ', 2, 2); + TQString _width = tag.section(' ', 0, 0); + TQString _style = tag.section(' ', 1, 1); + TQString _color = tag.section(' ', 2, 2); *width = KoUnit::parseValue(_width, 1.0); @@ -85,14 +85,14 @@ bool OoUtils::parseBorder(const QString & tag, double * width, int * style, QCol *style = 0; if (_color.isEmpty()) - *color = QColor(); + *color = TQColor(); else color->setNamedColor(_color); return true; } -void OoUtils::importIndents( QDomElement& parentElement, const KoStyleStack& styleStack ) +void OoUtils::importIndents( TQDomElement& tqparentElement, const KoStyleStack& styleStack ) { if ( styleStack.hasAttributeNS( ooNS::fo, "margin-left" ) || // 3.11.19 styleStack.hasAttributeNS( ooNS::fo, "margin-right" ) ) @@ -111,27 +111,27 @@ void OoUtils::importIndents( QDomElement& parentElement, const KoStyleStack& sty if ( marginLeft != 0 || marginRight != 0 || first != 0 ) { - QDomElement indent = parentElement.ownerDocument().createElement( "INDENTS" ); + TQDomElement indent = tqparentElement.ownerDocument().createElement( "INDENTS" ); if( marginLeft != 0 ) indent.setAttribute( "left", marginLeft ); if( marginRight != 0 ) indent.setAttribute( "right", marginRight ); if( first != 0 ) indent.setAttribute( "first", first ); - parentElement.appendChild( indent ); + tqparentElement.appendChild( indent ); } } } -void OoUtils::importLineSpacing( QDomElement& parentElement, const KoStyleStack& styleStack ) +void OoUtils::importLineSpacing( TQDomElement& tqparentElement, const KoStyleStack& styleStack ) { if( styleStack.hasAttributeNS( ooNS::fo, "line-height") ) { // Fixed line height - QString value = styleStack.attributeNS( ooNS::fo, "line-height" ); // 3.11.1 + TQString value = styleStack.attributeNS( ooNS::fo, "line-height" ); // 3.11.1 if ( value != "normal" ) { - QDomElement lineSpacing = parentElement.ownerDocument().createElement( "LINESPACING" ); + TQDomElement lineSpacing = tqparentElement.ownerDocument().createElement( "LINESPACING" ); if ( value.endsWith("%" ) ) { @@ -153,22 +153,22 @@ void OoUtils::importLineSpacing( QDomElement& parentElement, const KoStyleStack& kdWarning(30519) << "Unhandled value for fo:line-height: " << value << endl; lineSpacing.setAttribute("type","single"); // fallback } - parentElement.appendChild( lineSpacing ); + tqparentElement.appendChild( lineSpacing ); } } // Line-height-at-least is mutually exclusive with line-height else if ( styleStack.hasAttributeNS( ooNS::style, "line-height-at-least") ) // 3.11.2 { - QString value = styleStack.attributeNS( ooNS::style, "line-height-at-least" ); + TQString value = styleStack.attributeNS( ooNS::style, "line-height-at-least" ); // kotext has "at least" but that's for the linespacing, not for the entire line height! // Strange. kotext also has "at least" for the whole line height.... // Did we make the wrong choice in kotext? //kdWarning(30519) << "Unimplemented support for style:line-height-at-least: " << value << endl; // Well let's see if this makes a big difference. - QDomElement lineSpacing = parentElement.ownerDocument().createElement("LINESPACING"); + TQDomElement lineSpacing = tqparentElement.ownerDocument().createElement("LINESPACING"); lineSpacing.setAttribute("type", "atleast"); lineSpacing.setAttribute("spacingvalue", KoUnit::parseValue(value)); - parentElement.appendChild(lineSpacing); + tqparentElement.appendChild(lineSpacing); } // Line-spacing is mutually exclusive with line-height and line-height-at-least else if ( styleStack.hasAttributeNS( ooNS::style, "line-spacing") ) // 3.11.3 @@ -176,16 +176,16 @@ void OoUtils::importLineSpacing( QDomElement& parentElement, const KoStyleStack& double value = KoUnit::parseValue( styleStack.attributeNS( ooNS::style, "line-spacing" ) ); if ( value != 0.0 ) { - QDomElement lineSpacing = parentElement.ownerDocument().createElement( "LINESPACING" ); + TQDomElement lineSpacing = tqparentElement.ownerDocument().createElement( "LINESPACING" ); lineSpacing.setAttribute( "type", "custom" ); lineSpacing.setAttribute( "spacingvalue", value ); - parentElement.appendChild( lineSpacing ); + tqparentElement.appendChild( lineSpacing ); } } } -void OoUtils::importTopBottomMargin( QDomElement& parentElement, const KoStyleStack& styleStack ) +void OoUtils::importTopBottomMargin( TQDomElement& tqparentElement, const KoStyleStack& styleStack ) { if( styleStack.hasAttributeNS( ooNS::fo, "margin-top") || // 3.11.22 styleStack.hasAttributeNS( ooNS::fo, "margin-bottom")) @@ -194,29 +194,29 @@ void OoUtils::importTopBottomMargin( QDomElement& parentElement, const KoStyleSt double mbottom = KoUnit::parseValue( styleStack.attributeNS( ooNS::fo, "margin-bottom" ) ); if( mtop != 0 || mbottom != 0 ) { - QDomElement offset = parentElement.ownerDocument().createElement( "OFFSETS" ); + TQDomElement offset = tqparentElement.ownerDocument().createElement( "OFFSETS" ); if( mtop != 0 ) offset.setAttribute( "before", mtop ); if( mbottom != 0 ) offset.setAttribute( "after", mbottom ); - parentElement.appendChild( offset ); + tqparentElement.appendChild( offset ); } } } -void OoUtils::importTabulators( QDomElement& parentElement, const KoStyleStack& styleStack ) +void OoUtils::importTabulators( TQDomElement& tqparentElement, const KoStyleStack& styleStack ) { if ( !styleStack.hasChildNodeNS( ooNS::style, "tab-stops" ) ) // 3.11.10 return; - QDomElement tabStops = styleStack.childNodeNS( ooNS::style, "tab-stops" ); - //kdDebug(30519) << k_funcinfo << tabStops.childNodes().count() << " tab stops in layout." << endl; - for ( QDomNode it = tabStops.firstChild(); !it.isNull(); it = it.nextSibling() ) + TQDomElement tabStops = styleStack.childNodeNS( ooNS::style, "tab-stops" ); + //kdDebug(30519) << k_funcinfo << tabStops.childNodes().count() << " tab stops in tqlayout." << endl; + for ( TQDomNode it = tabStops.firstChild(); !it.isNull(); it = it.nextSibling() ) { - QDomElement tabStop = it.toElement(); + TQDomElement tabStop = it.toElement(); Q_ASSERT( tabStop.tagName() == "style:tab-stop" ); - QString type = tabStop.attributeNS( ooNS::style, "type", QString::null ); // left, right, center or char + TQString type = tabStop.attributeNS( ooNS::style, "type", TQString() ); // left, right, center or char - QDomElement elem = parentElement.ownerDocument().createElement( "TABULATOR" ); + TQDomElement elem = tqparentElement.ownerDocument().createElement( "TABULATOR" ); int kOfficeType = 0; if ( type == "left" ) kOfficeType = 0; @@ -225,23 +225,23 @@ void OoUtils::importTabulators( QDomElement& parentElement, const KoStyleStack& else if ( type == "right" ) kOfficeType = 2; else if ( type == "char" ) { - QString delimiterChar = tabStop.attributeNS( ooNS::style, "char", QString::null ); // single character + TQString delimiterChar = tabStop.attributeNS( ooNS::style, "char", TQString() ); // single character elem.setAttribute( "alignchar", delimiterChar ); - kOfficeType = 3; // "alignment on decimal point" + kOfficeType = 3; // "tqalignment on decimal point" } elem.setAttribute( "type", kOfficeType ); - double pos = KoUnit::parseValue( tabStop.attributeNS( ooNS::style, "position", QString::null ) ); + double pos = KoUnit::parseValue( tabStop.attributeNS( ooNS::style, "position", TQString() ) ); elem.setAttribute( "ptpos", pos ); - // TODO Convert leaderChar's unicode value to the KOffice enum + // TODO Convert leaderChar's tqunicode value to the KOffice enum // (blank/dots/line/dash/dash-dot/dash-dot-dot, 0 to 5) - QString leaderChar = tabStop.attributeNS( ooNS::style, "leader-char", QString::null ); // single character + TQString leaderChar = tabStop.attributeNS( ooNS::style, "leader-char", TQString() ); // single character if ( !leaderChar.isEmpty() ) { int filling = 0; - QChar ch = leaderChar[0]; + TQChar ch = leaderChar[0]; switch (ch.latin1()) { case '.': filling = 1; break; @@ -255,21 +255,21 @@ void OoUtils::importTabulators( QDomElement& parentElement, const KoStyleStack& } elem.setAttribute( "filling", filling ); } - parentElement.appendChild( elem ); + tqparentElement.appendChild( elem ); } } -void OoUtils::importBorders( QDomElement& parentElement, const KoStyleStack& styleStack ) +void OoUtils::importBorders( TQDomElement& tqparentElement, const KoStyleStack& styleStack ) { if (styleStack.hasAttributeNS( ooNS::fo, "border","left")) { double width; int style; - QColor color; + TQColor color; if (OoUtils::parseBorder(styleStack.attributeNS( ooNS::fo, "border", "left"), &width, &style, &color)) { - QDomElement lbElem = parentElement.ownerDocument().createElement("LEFTBORDER"); + TQDomElement lbElem = tqparentElement.ownerDocument().createElement("LEFTBORDER"); lbElem.setAttribute("width", width); lbElem.setAttribute("style", style); if (color.isValid()) { @@ -277,7 +277,7 @@ void OoUtils::importBorders( QDomElement& parentElement, const KoStyleStack& sty lbElem.setAttribute("green", color.green()); lbElem.setAttribute("blue", color.blue()); } - parentElement.appendChild(lbElem); + tqparentElement.appendChild(lbElem); } } @@ -285,10 +285,10 @@ void OoUtils::importBorders( QDomElement& parentElement, const KoStyleStack& sty { double width; int style; - QColor color; + TQColor color; if (OoUtils::parseBorder(styleStack.attributeNS( ooNS::fo, "border", "right"), &width, &style, &color)) { - QDomElement lbElem = parentElement.ownerDocument().createElement("RIGHTBORDER"); + TQDomElement lbElem = tqparentElement.ownerDocument().createElement("RIGHTBORDER"); lbElem.setAttribute("width", width); lbElem.setAttribute("style", style); if (color.isValid()) { @@ -296,7 +296,7 @@ void OoUtils::importBorders( QDomElement& parentElement, const KoStyleStack& sty lbElem.setAttribute("green", color.green()); lbElem.setAttribute("blue", color.blue()); } - parentElement.appendChild(lbElem); + tqparentElement.appendChild(lbElem); } } @@ -304,10 +304,10 @@ void OoUtils::importBorders( QDomElement& parentElement, const KoStyleStack& sty { double width; int style; - QColor color; + TQColor color; if (OoUtils::parseBorder(styleStack.attributeNS( ooNS::fo, "border", "top"), &width, &style, &color)) { - QDomElement lbElem = parentElement.ownerDocument().createElement("TOPBORDER"); + TQDomElement lbElem = tqparentElement.ownerDocument().createElement("TOPBORDER"); lbElem.setAttribute("width", width); lbElem.setAttribute("style", style); if (color.isValid()) { @@ -315,7 +315,7 @@ void OoUtils::importBorders( QDomElement& parentElement, const KoStyleStack& sty lbElem.setAttribute("green", color.green()); lbElem.setAttribute("blue", color.blue()); } - parentElement.appendChild(lbElem); + tqparentElement.appendChild(lbElem); } } @@ -323,10 +323,10 @@ void OoUtils::importBorders( QDomElement& parentElement, const KoStyleStack& sty { double width; int style; - QColor color; + TQColor color; if (OoUtils::parseBorder(styleStack.attributeNS( ooNS::fo, "border", "bottom"), &width, &style, &color)) { - QDomElement lbElem = parentElement.ownerDocument().createElement("BOTTOMBORDER"); + TQDomElement lbElem = tqparentElement.ownerDocument().createElement("BOTTOMBORDER"); lbElem.setAttribute("width", width); lbElem.setAttribute("style", style); if (color.isValid()) { @@ -334,12 +334,12 @@ void OoUtils::importBorders( QDomElement& parentElement, const KoStyleStack& sty lbElem.setAttribute("green", color.green()); lbElem.setAttribute("blue", color.blue()); } - parentElement.appendChild(lbElem); + tqparentElement.appendChild(lbElem); } } } -void OoUtils::importUnderline( const QString& in, QString& underline, QString& styleline ) +void OoUtils::importUnderline( const TQString& in, TQString& underline, TQString& styleline ) { underline = "single"; if ( in == "none" ) @@ -383,16 +383,16 @@ void OoUtils::importUnderline( const QString& in, QString& underline, QString& s kdWarning(30519) << k_funcinfo << " unsupported text-underline value: " << in << endl; } -void OoUtils::importTextPosition( const QString& text_position, QString& value, QString& relativetextsize ) +void OoUtils::importTextPosition( const TQString& text_position, TQString& value, TQString& relativetextsize ) { //OO: <vertical position (% or sub or super)> [<size as %>] //Examples: "super" or "super 58%" or "82% 58%" (where 82% is the vertical position) // TODO in kword: vertical positions other than sub/super - QStringList lst = QStringList::split( ' ', text_position ); + TQStringList lst = TQStringList::split( ' ', text_position ); if ( !lst.isEmpty() ) { - QString textPos = lst.front().stripWhiteSpace(); - QString textSize; + TQString textPos = lst.front().stripWhiteSpace(); + TQString textSize; lst.pop_front(); if ( !lst.isEmpty() ) textSize = lst.front().stripWhiteSpace(); @@ -421,27 +421,27 @@ void OoUtils::importTextPosition( const QString& text_position, QString& value, { textSize.truncate( textSize.length() - 1 ); double textSizeValue = textSize.toDouble() / 100; // e.g. 0.58 - relativetextsize = QString::number( textSizeValue ); + relativetextsize = TQString::number( textSizeValue ); } } else value = "0"; } -void OoUtils::createDocumentInfo(QDomDocument &_meta, QDomDocument & docinfo) +void OoUtils::createDocumentInfo(TQDomDocument &_meta, TQDomDocument & docinfo) { - QDomNode meta = KoDom::namedItemNS( _meta, ooNS::office, "document-meta" ); - QDomNode office = KoDom::namedItemNS( meta, ooNS::office, "meta" ); + TQDomNode meta = KoDom::namedItemNS( _meta, ooNS::office, "document-meta" ); + TQDomNode office = KoDom::namedItemNS( meta, ooNS::office, "meta" ); if ( office.isNull() ) return; - QDomElement elementDocInfo = docinfo.documentElement(); + TQDomElement elementDocInfo = docinfo.documentElement(); - QDomElement e = KoDom::namedItemNS( office, ooNS::dc, "creator" ); + TQDomElement e = KoDom::namedItemNS( office, ooNS::dc, "creator" ); if ( !e.isNull() && !e.text().isEmpty() ) { - QDomElement author = docinfo.createElement( "author" ); - QDomElement t = docinfo.createElement( "full-name" ); + TQDomElement author = docinfo.createElement( "author" ); + TQDomElement t = docinfo.createElement( "full-name" ); author.appendChild( t ); t.appendChild( docinfo.createTextNode( e.text() ) ); elementDocInfo.appendChild( author); @@ -450,8 +450,8 @@ void OoUtils::createDocumentInfo(QDomDocument &_meta, QDomDocument & docinfo) e = KoDom::namedItemNS( office, ooNS::dc, "title" ); if ( !e.isNull() && !e.text().isEmpty() ) { - QDomElement about = docinfo.createElement( "about" ); - QDomElement title = docinfo.createElement( "title" ); + TQDomElement about = docinfo.createElement( "about" ); + TQDomElement title = docinfo.createElement( "title" ); about.appendChild( title ); title.appendChild( docinfo.createTextNode( e.text() ) ); elementDocInfo.appendChild( about ); @@ -460,46 +460,46 @@ void OoUtils::createDocumentInfo(QDomDocument &_meta, QDomDocument & docinfo) e = KoDom::namedItemNS( office, ooNS::dc, "description" ); if ( !e.isNull() && !e.text().isEmpty() ) { - QDomElement about = elementDocInfo.namedItem( "about" ).toElement(); + TQDomElement about = elementDocInfo.namedItem( "about" ).toElement(); if ( about.isNull() ) { about = docinfo.createElement( "about" ); elementDocInfo.appendChild( about ); } - QDomElement title = docinfo.createElement( "abstract" ); + TQDomElement title = docinfo.createElement( "abstract" ); about.appendChild( title ); title.appendChild( docinfo.createTextNode( e.text() ) ); } e = KoDom::namedItemNS( office, ooNS::dc, "subject" ); if ( !e.isNull() && !e.text().isEmpty() ) { - QDomElement about = elementDocInfo.namedItem( "about" ).toElement(); + TQDomElement about = elementDocInfo.namedItem( "about" ).toElement(); if ( about.isNull() ) { about = docinfo.createElement( "about" ); elementDocInfo.appendChild( about ); } - QDomElement subject = docinfo.createElement( "subject" ); + TQDomElement subject = docinfo.createElement( "subject" ); about.appendChild( subject ); subject.appendChild( docinfo.createTextNode( e.text() ) ); } e = KoDom::namedItemNS( office, ooNS::meta, "keywords" ); if ( !e.isNull() ) { - QDomElement about = elementDocInfo.namedItem( "about" ).toElement(); + TQDomElement about = elementDocInfo.namedItem( "about" ).toElement(); if ( about.isNull() ) { about = docinfo.createElement( "about" ); elementDocInfo.appendChild( about ); } - QDomElement tmp = KoDom::namedItemNS( e, ooNS::meta, "keyword" ); + TQDomElement tmp = KoDom::namedItemNS( e, ooNS::meta, "keyword" ); if ( !tmp.isNull() && !tmp.text().isEmpty() ) { - QDomElement keyword = docinfo.createElement( "keyword" ); + TQDomElement keyword = docinfo.createElement( "keyword" ); about.appendChild( keyword ); keyword.appendChild( docinfo.createTextNode( tmp.text() ) ); } } } -KoFilter::ConversionStatus OoUtils::loadAndParse(const QString& fileName, QDomDocument& doc, KoStore *m_store ) +KoFilter::ConversiontqStatus OoUtils::loadAndParse(const TQString& fileName, TQDomDocument& doc, KoStore *m_store ) { kdDebug(30518) << "loadAndParse: Trying to open " << fileName << endl; @@ -508,21 +508,21 @@ KoFilter::ConversionStatus OoUtils::loadAndParse(const QString& fileName, QDomDo kdWarning(30519) << "Entry " << fileName << " not found!" << endl; return KoFilter::FileNotFound; } - KoFilter::ConversionStatus convertStatus = loadAndParse( m_store->device(),doc, fileName ); + KoFilter::ConversiontqStatus converttqStatus = loadAndParse( m_store->device(),doc, fileName ); m_store->close(); - return convertStatus; + return converttqStatus; } -KoFilter::ConversionStatus OoUtils::loadAndParse(QIODevice* io, QDomDocument& doc, const QString & fileName) +KoFilter::ConversiontqStatus OoUtils::loadAndParse(TQIODevice* io, TQDomDocument& doc, const TQString & fileName) { - QXmlInputSource source( io ); - // Copied from QDomDocumentPrivate::setContent, to change the whitespace thing - QXmlSimpleReader reader; + TQXmlInputSource source( io ); + // Copied from TQDomDocumentPrivate::setContent, to change the whitespace thing + TQXmlSimpleReader reader; KoDocument::setupXmlReader( reader, true /*namespaceProcessing*/ ); - // Error variables for QDomDocument::setContent - QString errorMsg; + // Error variables for TQDomDocument::setContent + TQString errorMsg; int errorLine, errorColumn; if ( !doc.setContent( &source, &reader, &errorMsg, &errorLine, &errorColumn ) ) { @@ -538,7 +538,7 @@ KoFilter::ConversionStatus OoUtils::loadAndParse(QIODevice* io, QDomDocument& do } -KoFilter::ConversionStatus OoUtils::loadAndParse(const QString& filename, QDomDocument& doc, KZip * m_zip) +KoFilter::ConversiontqStatus OoUtils::loadAndParse(const TQString& filename, TQDomDocument& doc, KZip * m_zip) { kdDebug(30519) << "Trying to open " << filename << endl; @@ -561,15 +561,15 @@ KoFilter::ConversionStatus OoUtils::loadAndParse(const QString& filename, QDomDo } const KZipFileEntry* f = static_cast<const KZipFileEntry *>(entry); kdDebug(30519) << "Entry " << filename << " has size " << f->size() << endl; - QIODevice* io = f->device(); - KoFilter::ConversionStatus convertStatus = loadAndParse( io,doc, filename ); + TQIODevice* io = f->device(); + KoFilter::ConversiontqStatus converttqStatus = loadAndParse( io,doc, filename ); delete io; - return convertStatus; + return converttqStatus; } -KoFilter::ConversionStatus OoUtils::loadThumbnail( QImage& thumbnail, KZip * m_zip ) +KoFilter::ConversiontqStatus OoUtils::loadThumbnail( TQImage& thumbnail, KZip * m_zip ) { - const QString filename( "Thumbnails/thumbnail.png" ); + const TQString filename( "Thumbnails/thumbnail.png" ); kdDebug(30519) << "Trying to open thumbnail " << filename << endl; if (!m_zip) @@ -590,7 +590,7 @@ KoFilter::ConversionStatus OoUtils::loadThumbnail( QImage& thumbnail, KZip * m_z return KoFilter::WrongFormat; } const KZipFileEntry* f = static_cast<const KZipFileEntry *>(entry); - QIODevice* io=f->device(); + TQIODevice* io=f->device(); kdDebug(30519) << "Entry " << filename << " has size " << f->size() << endl; if ( ! io->open( IO_ReadOnly ) ) @@ -600,7 +600,7 @@ KoFilter::ConversionStatus OoUtils::loadThumbnail( QImage& thumbnail, KZip * m_z return KoFilter::StupidError; } - QImageIO imageIO( io, "PNG" ); + TQImageIO imageIO( io, "PNG" ); if ( ! imageIO.read() ) { kdWarning(30519) << "Thumbnail could not be read!" <<endl; |