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 /lib/kofficecore/KoGenStyles.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 'lib/kofficecore/KoGenStyles.cpp')
-rw-r--r-- | lib/kofficecore/KoGenStyles.cpp | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/lib/kofficecore/KoGenStyles.cpp b/lib/kofficecore/KoGenStyles.cpp index 503b6802..0ee2e730 100644 --- a/lib/kofficecore/KoGenStyles.cpp +++ b/lib/kofficecore/KoGenStyles.cpp @@ -29,39 +29,39 @@ KoGenStyles::~KoGenStyles() { } -QString KoGenStyles::lookup( const KoGenStyle& style, const QString& name, int flags ) +TQString KoGenStyles::lookup( const KoGenStyle& style, const TQString& name, int flags ) { - StyleMap::iterator it = m_styleMap.find( style ); + StyleMap::iterator it = m_styleMap.tqfind( style ); if ( it == m_styleMap.end() ) { - // Not found, try if this style is in fact equal to its parent (the find above + // Not found, try if this style is in fact equal to its tqparent (the find above // wouldn't have found it, due to m_parentName being set). - if ( !style.parentName().isEmpty() ) { + if ( !style.tqparentName().isEmpty() ) { KoGenStyle testStyle( style ); - const KoGenStyle* parentStyle = this->style( style.parentName() ); // ## linear search - if( !parentStyle ) { - kdDebug(30003) << "KoGenStyles::lookup(" << name << "): parent style '" << style.parentName() << "' not found in collection" << endl; + const KoGenStyle* tqparentStyle = this->style( style.tqparentName() ); // ## linear search + if( !tqparentStyle ) { + kdDebug(30003) << "KoGenStyles::lookup(" << name << "): tqparent style '" << style.tqparentName() << "' not found in collection" << endl; } else { - if ( testStyle.m_familyName != parentStyle->m_familyName ) + if ( testStyle.m_familyName != tqparentStyle->m_familyName ) { - kdWarning(30003) << "KoGenStyles::lookup(" << name << ", family=" << testStyle.m_familyName << ") parent style '" << style.parentName() << "' has a different family: " << parentStyle->m_familyName << endl; + kdWarning(30003) << "KoGenStyles::lookup(" << name << ", family=" << testStyle.m_familyName << ") tqparent style '" << style.tqparentName() << "' has a different family: " << tqparentStyle->m_familyName << endl; } - testStyle.m_parentName = parentStyle->m_parentName; + testStyle.m_parentName = tqparentStyle->m_parentName; // Exclude the type from the comparison. It's ok for an auto style - // to have a user style as parent; they can still be identical - testStyle.m_type = parentStyle->m_type; - // Also it's ok to not have the display name of the parent style + // to have a user style as tqparent; they can still be identical + testStyle.m_type = tqparentStyle->m_type; + // Also it's ok to not have the display name of the tqparent style // in the auto style - QMap<QString, QString>::const_iterator it = parentStyle->m_attributes.find( "style:display-name" ); - if ( it != parentStyle->m_attributes.end() ) + TQMap<TQString, TQString>::const_iterator it = tqparentStyle->m_attributes.tqfind( "style:display-name" ); + if ( it != tqparentStyle->m_attributes.end() ) testStyle.addAttribute( "style:display-name", *it ); - if ( *parentStyle == testStyle ) - return style.parentName(); + if ( *tqparentStyle == testStyle ) + return style.tqparentName(); } } - QString styleName( name ); + TQString styleName( name ); if ( styleName.isEmpty() ) { styleName = 'A'; // for "auto". flags &= ~DontForceNumbering; // i.e. force numbering @@ -80,39 +80,39 @@ QString KoGenStyles::lookup( const KoGenStyle& style, const QString& name, int f return it.data(); } -QString KoGenStyles::makeUniqueName( const QString& base, int flags ) const +TQString KoGenStyles::makeUniqueName( const TQString& base, int flags ) const { // If this name is not used yet, and numbering isn't forced, then the given name is ok. if ( ( flags & DontForceNumbering ) - && m_autoStylesInStylesDotXml.find( base ) == m_autoStylesInStylesDotXml.end() - && m_styleNames.find( base ) == m_styleNames.end() ) + && m_autoStylesInStylesDotXml.tqfind( base ) == m_autoStylesInStylesDotXml.end() + && m_styleNames.tqfind( base ) == m_styleNames.end() ) return base; int num = 1; - QString name; + TQString name; do { name = base; - name += QString::number( num++ ); - } while ( m_autoStylesInStylesDotXml.find( name ) != m_autoStylesInStylesDotXml.end() - || m_styleNames.find( name ) != m_styleNames.end() ); + name += TQString::number( num++ ); + } while ( m_autoStylesInStylesDotXml.tqfind( name ) != m_autoStylesInStylesDotXml.end() + || m_styleNames.tqfind( name ) != m_styleNames.end() ); return name; } -QValueList<KoGenStyles::NamedStyle> KoGenStyles::styles( int type, bool markedForStylesXml ) const +TQValueList<KoGenStyles::NamedStyle> KoGenStyles::styles( int type, bool markedForStylesXml ) const { - QValueList<KoGenStyles::NamedStyle> lst; + TQValueList<KoGenStyles::NamedStyle> lst; const NameMap& nameMap = markedForStylesXml ? m_autoStylesInStylesDotXml : m_styleNames; StyleArray::const_iterator it = m_styleArray.begin(); const StyleArray::const_iterator end = m_styleArray.end(); for ( ; it != end ; ++it ) { // Look up if it's marked for styles.xml or not by looking up in the corresponding style map. - if ( (*it).style->type() == type && nameMap.find((*it).name) != nameMap.end() ) { + if ( (*it).style->type() == type && nameMap.tqfind((*it).name) != nameMap.end() ) { lst.append( *it ); } } return lst; } -const KoGenStyle* KoGenStyles::style( const QString& name ) const +const KoGenStyle* KoGenStyles::style( const TQString& name ) const { StyleArray::const_iterator it = m_styleArray.begin(); const StyleArray::const_iterator end = m_styleArray.end(); @@ -123,14 +123,14 @@ const KoGenStyle* KoGenStyles::style( const QString& name ) const return 0; } -KoGenStyle* KoGenStyles::styleForModification( const QString& name ) +KoGenStyle* KoGenStyles::styleForModification( const TQString& name ) { return const_cast<KoGenStyle *>( style( name ) ); } -void KoGenStyles::markStyleForStylesXml( const QString& name ) +void KoGenStyles::markStyleForStylesXml( const TQString& name ) { - Q_ASSERT( m_styleNames.find( name ) != m_styleNames.end() ); + Q_ASSERT( m_styleNames.tqfind( name ) != m_styleNames.end() ); m_styleNames.remove( name ); m_autoStylesInStylesDotXml.insert( name, true ); styleForModification( name )->setAutoStyleInStylesDotXml( true ); @@ -156,10 +156,10 @@ void KoGenStyles::dump() } // Returns -1, 0 (equal) or 1 -static int compareMap( const QMap<QString, QString>& map1, const QMap<QString, QString>& map2 ) +static int compareMap( const TQMap<TQString, TQString>& map1, const TQMap<TQString, TQString>& map2 ) { - QMap<QString, QString>::const_iterator it = map1.begin(); - QMap<QString, QString>::const_iterator oit = map2.begin(); + TQMap<TQString, TQString>::const_iterator it = map1.begin(); + TQMap<TQString, TQString>::const_iterator oit = map2.begin(); for ( ; it != map1.end(); ++it, ++oit ) { // both maps have been checked for size already if ( it.key() != oit.key() ) return it.key() < oit.key() ? -1 : +1; @@ -173,8 +173,8 @@ static int compareMap( const QMap<QString, QString>& map1, const QMap<QString, Q KoGenStyle::KoGenStyle( int type, const char* familyName, - const QString& parentName ) - : m_type( type ), m_familyName( familyName ), m_parentName( parentName ), + const TQString& tqparentName ) + : m_type( type ), m_familyName( familyName ), m_parentName( tqparentName ), m_autoStyleInStylesDotXml( false ), m_defaultStyle( false ) { } @@ -184,40 +184,40 @@ KoGenStyle::~KoGenStyle() } void KoGenStyle::writeStyleProperties( KoXmlWriter* writer, PropertyType i, - const char* elementName, const KoGenStyle* parentStyle ) const + const char* elementName, const KoGenStyle* tqparentStyle ) const { if ( !m_properties[i].isEmpty() ) { writer->startElement( elementName ); - QMap<QString, QString>::const_iterator it = m_properties[i].begin(); - const QMap<QString, QString>::const_iterator end = m_properties[i].end(); + TQMap<TQString, TQString>::const_iterator it = m_properties[i].begin(); + const TQMap<TQString, TQString>::const_iterator end = m_properties[i].end(); for ( ; it != end; ++it ) { - if ( !parentStyle || parentStyle->property( it.key(), i ) != it.data() ) + if ( !tqparentStyle || tqparentStyle->property( it.key(), i ) != it.data() ) writer->addAttribute( it.key().utf8(), it.data().utf8() ); } writer->endElement(); } } -void KoGenStyle::writeStyle( KoXmlWriter* writer, KoGenStyles& styles, const char* elementName, const QString& name, const char* propertiesElementName, bool closeElement, bool drawElement ) const +void KoGenStyle::writeStyle( KoXmlWriter* writer, KoGenStyles& styles, const char* elementName, const TQString& name, const char* propertiesElementName, bool closeElement, bool drawElement ) const { //kdDebug(30003) << "writing out style " << name << " display-name=" << m_attributes["style:display-name"] << " family=" << m_familyName << endl; writer->startElement( elementName ); - const KoGenStyle* parentStyle = 0; + const KoGenStyle* tqparentStyle = 0; if ( !m_defaultStyle ) { if ( !drawElement ) writer->addAttribute( "style:name", name ); else writer->addAttribute( "draw:name", name ); if ( !m_parentName.isEmpty() ) { - parentStyle = styles.style( m_parentName ); - if ( parentStyle && m_familyName.isEmpty() ) { - // get family from parent style, just in case + tqparentStyle = styles.style( m_parentName ); + if ( tqparentStyle && m_familyName.isEmpty() ) { + // get family from tqparent style, just in case // Note: this is saving code, don't convert to attributeNS! const_cast<KoGenStyle *>( this )-> - m_familyName = parentStyle->attribute( "style:family" ).latin1(); - //kdDebug(30003) << "Got familyname " << m_familyName << " from parent" << endl; + m_familyName = tqparentStyle->attribute( "style:family" ).latin1(); + //kdDebug(30003) << "Got familyname " << m_familyName << " from tqparent" << endl; } - writer->addAttribute( "style:parent-style-name", m_parentName ); + writer->addAttribute( "style:tqparent-style-name", m_parentName ); } } else { // default-style Q_ASSERT( qstrcmp( elementName, "style:default-style" ) == 0 ); @@ -225,7 +225,7 @@ void KoGenStyle::writeStyle( KoXmlWriter* writer, KoGenStyles& styles, const cha } if ( !m_familyName.isEmpty() ) const_cast<KoGenStyle *>( this )-> - addAttribute( "style:family", QString::fromLatin1( m_familyName ) ); + addAttribute( "style:family", TQString::tqfromLatin1( m_familyName ) ); else { if ( qstrcmp( elementName, "style:style" ) == 0 ) kdWarning(30003) << "User style " << name << " is without family - invalid. m_type=" << m_type << endl; @@ -234,21 +234,21 @@ void KoGenStyle::writeStyle( KoXmlWriter* writer, KoGenStyles& styles, const cha #if 0 // #ifndef NDEBUG kdDebug() << "style: " << name << endl; printDebug(); - if ( parentStyle ) { - kdDebug() << " parent: " << m_parentName << endl; - parentStyle->printDebug(); + if ( tqparentStyle ) { + kdDebug() << " tqparent: " << m_parentName << endl; + tqparentStyle->printDebug(); } #endif - // Write attributes [which differ from the parent style] - // We only look at the direct parent style because we assume + // Write attributes [which differ from the tqparent style] + // We only look at the direct tqparent style because we assume // that styles are fully specified, i.e. the inheritance is // only in the final file, not in the caller's code. - QMap<QString, QString>::const_iterator it = m_attributes.begin(); + TQMap<TQString, TQString>::const_iterator it = m_attributes.begin(); for ( ; it != m_attributes.end(); ++it ) { bool writeit = true; - if ( parentStyle && it.key() != "style:family" // always write the family out - && parentStyle->attribute( it.key() ) == it.data() ) + if ( tqparentStyle && it.key() != "style:family" // always write the family out + && tqparentStyle->attribute( it.key() ) == it.data() ) writeit = false; if ( writeit ) writer->addAttribute( it.key().utf8(), it.data().utf8() ); @@ -261,31 +261,31 @@ void KoGenStyle::writeStyle( KoXmlWriter* writer, KoGenStyles& styles, const cha writer->startElement( propertiesElementName ); // e.g. paragraph-properties it = m_properties[i].begin(); for ( ; it != m_properties[i].end(); ++it ) { - if ( !parentStyle || parentStyle->property( it.key(), i ) != it.data() ) + if ( !tqparentStyle || tqparentStyle->property( it.key(), i ) != it.data() ) writer->addAttribute( it.key().utf8(), it.data().utf8() ); } i = KoGenStyle::ChildElement; it = m_properties[i].begin(); for ( ; it != m_properties[i].end(); ++it ) { - if ( !parentStyle || parentStyle->property( it.key(), i ) != it.data() ) { + if ( !tqparentStyle || tqparentStyle->property( it.key(), i ) != it.data() ) { writer->addCompleteElement( it.data().utf8() ); } } if ( createPropertiesTag ) writer->endElement(); } - writeStyleProperties( writer, KoGenStyle::GraphicType, "style:graphic-properties", parentStyle ); - writeStyleProperties( writer, KoGenStyle::ParagraphType, "style:paragraph-properties", parentStyle ); - writeStyleProperties( writer, KoGenStyle::TextType, "style:text-properties", parentStyle ); + writeStyleProperties( writer, KoGenStyle::GraphicType, "style:graphic-properties", tqparentStyle ); + writeStyleProperties( writer, KoGenStyle::ParagraphType, "style:paragraph-properties", tqparentStyle ); + writeStyleProperties( writer, KoGenStyle::TextType, "style:text-properties", tqparentStyle ); // And now the style maps for ( uint i = 0; i < m_maps.count(); ++i ) { bool writeit = true; - if ( parentStyle && compareMap( m_maps[i], parentStyle->m_maps[i] ) == 0 ) + if ( tqparentStyle && compareMap( m_maps[i], tqparentStyle->m_maps[i] ) == 0 ) writeit = false; if ( writeit ) { writer->startElement( "style:map" ); - QMap<QString, QString>::const_iterator it = m_maps[i].begin(); + TQMap<TQString, TQString>::const_iterator it = m_maps[i].begin(); for ( ; it != m_maps[i].end(); ++it ) { writer->addAttribute( it.key().utf8(), it.data().utf8() ); } @@ -296,17 +296,17 @@ void KoGenStyle::writeStyle( KoXmlWriter* writer, KoGenStyles& styles, const cha writer->endElement(); } -void KoGenStyle::addPropertyPt( const QString& propName, double propValue, PropertyType type ) +void KoGenStyle::addPropertyPt( const TQString& propName, double propValue, PropertyType type ) { - QString str; + TQString str; str.setNum( propValue, 'g', DBL_DIG ); str += "pt"; m_properties[type].insert( propName, str ); } -void KoGenStyle::addAttributePt( const QString& attrName, double attrValue ) +void KoGenStyle::addAttributePt( const TQString& attrName, double attrValue ) { - QString str; + TQString str; str.setNum( attrValue, 'g', DBL_DIG ); str += "pt"; m_attributes.insert( attrName, str ); @@ -317,32 +317,32 @@ void KoGenStyle::printDebug() const { int i = DefaultType; kdDebug() << m_properties[i].count() << " properties." << endl; - for( QMap<QString,QString>::ConstIterator it = m_properties[i].begin(); it != m_properties[i].end(); ++it ) { + for( TQMap<TQString,TQString>::ConstIterator it = m_properties[i].begin(); it != m_properties[i].end(); ++it ) { kdDebug() << " " << it.key() << " = " << it.data() << endl; } i = TextType; kdDebug() << m_properties[i].count() << " text properties." << endl; - for( QMap<QString,QString>::ConstIterator it = m_properties[i].begin(); it != m_properties[i].end(); ++it ) { + for( TQMap<TQString,TQString>::ConstIterator it = m_properties[i].begin(); it != m_properties[i].end(); ++it ) { kdDebug() << " " << it.key() << " = " << it.data() << endl; } i = ParagraphType; kdDebug() << m_properties[i].count() << " paragraph properties." << endl; - for( QMap<QString,QString>::ConstIterator it = m_properties[i].begin(); it != m_properties[i].end(); ++it ) { + for( TQMap<TQString,TQString>::ConstIterator it = m_properties[i].begin(); it != m_properties[i].end(); ++it ) { kdDebug() << " " << it.key() << " = " << it.data() << endl; } i = ChildElement; kdDebug() << m_properties[i].count() << " child elements." << endl; - for( QMap<QString,QString>::ConstIterator it = m_properties[i].begin(); it != m_properties[i].end(); ++it ) { + for( TQMap<TQString,TQString>::ConstIterator it = m_properties[i].begin(); it != m_properties[i].end(); ++it ) { kdDebug() << " " << it.key() << " = " << it.data() << endl; } kdDebug() << m_attributes.count() << " attributes." << endl; - for( QMap<QString,QString>::ConstIterator it = m_attributes.begin(); it != m_attributes.end(); ++it ) { + for( TQMap<TQString,TQString>::ConstIterator it = m_attributes.begin(); it != m_attributes.end(); ++it ) { kdDebug() << " " << it.key() << " = " << it.data() << endl; } kdDebug() << m_maps.count() << " maps." << endl; for ( uint i = 0; i < m_maps.count(); ++i ) { kdDebug() << "map " << i << ":" << endl; - for( QMap<QString,QString>::ConstIterator it = m_maps[i].begin(); it != m_maps[i].end(); ++it ) { + for( TQMap<TQString,TQString>::ConstIterator it = m_maps[i].begin(); it != m_maps[i].end(); ++it ) { kdDebug() << " " << it.key() << " = " << it.data() << endl; } } |