diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2011-11-25 13:16:04 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2011-11-29 13:27:42 +0100 |
commit | f034c452c5aad4f8a38045530486a6afd27aa215 (patch) | |
tree | e185a3b5d7c79344ebd0b2709caf0834c7126646 | |
parent | 0dfdf8ed71c53c56c980e5b7117f963834cd32b8 (diff) |
simplify attribute retrieval syntax a bit
-rw-r--r-- | oox/inc/oox/mathml/importutils.hxx | 21 | ||||
-rw-r--r-- | starmath/source/ooxmlimport.cxx | 16 |
2 files changed, 29 insertions, 8 deletions
diff --git a/oox/inc/oox/mathml/importutils.hxx b/oox/inc/oox/mathml/importutils.hxx index 3a59320317aa..ca212aad8029 100644 --- a/oox/inc/oox/mathml/importutils.hxx +++ b/oox/inc/oox/mathml/importutils.hxx @@ -91,6 +91,15 @@ public: AttributeList attributes; rtl::OUString text; /** + This function returns value of the given attribute, or the passed default value if not found. + The type of the default value selects the return type (OUString here). + */ + rtl::OUString attribute( int token, const rtl::OUString& def = rtl::OUString()) const; + /** + @overload + */ + bool attribute( int token, bool def ) const; + /** Converts to true if the tag has a valid token, false otherwise. Allows simple usage in if(), for example 'if( XmlStream::Tag foo = stream.checkOpeningTag( footoken ))'. */ @@ -169,6 +178,18 @@ public: void appendCharacters( const rtl::OUString& characters ); }; +inline +rtl::OUString XmlStream::Tag::attribute( int t, const rtl::OUString& def ) const +{ + return attributes.attribute( t, def ); +} + +inline +bool XmlStream::Tag::attribute( int t, bool def ) const +{ + return attributes.attribute( t, def ); +} + } // namespace } // namespace diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx index f3094424af1f..4b187ad90ce8 100644 --- a/starmath/source/ooxmlimport.cxx +++ b/starmath/source/ooxmlimport.cxx @@ -104,7 +104,7 @@ OUString SmOoxmlImport::handleAcc() { if( XmlStream::Tag chr = stream.checkOpeningTag( M_TOKEN( chr ))) { - acc = chr.attributes.attribute( M_TOKEN( val )); + acc = chr.attribute( M_TOKEN( val )); stream.ensureClosingTag( M_TOKEN( chr )); } stream.ensureClosingTag( M_TOKEN( accPr )); @@ -165,9 +165,9 @@ OUString SmOoxmlImport::handleBar() { if( XmlStream::Tag pos = stream.checkOpeningTag( M_TOKEN( pos ))) { - if( pos.attributes.attribute( M_TOKEN( val )) == STR( "top" )) + if( pos.attribute( M_TOKEN( val )) == STR( "top" )) topbot = top; - else if( pos.attributes.attribute( M_TOKEN( val )) == STR( "bot" )) + else if( pos.attribute( M_TOKEN( val )) == STR( "bot" )) topbot = bot; stream.ensureClosingTag( M_TOKEN( pos )); } @@ -189,7 +189,7 @@ OUString SmOoxmlImport::handleBorderBox() { if( XmlStream::Tag strikeH = stream.checkOpeningTag( M_TOKEN( strikeH ))) { - if( strikeH.attributes.attribute( M_TOKEN( val ), false )) + if( strikeH.attribute( M_TOKEN( val ), false )) isStrikeH = true; stream.ensureClosingTag( M_TOKEN( strikeH )); } @@ -248,11 +248,11 @@ OUString SmOoxmlImport::handleF() { if( XmlStream::Tag type = stream.checkOpeningTag( M_TOKEN( type ))) { - if( type.attributes.attribute( M_TOKEN( val )) == STR( "bar" )) + if( type.attribute( M_TOKEN( val )) == STR( "bar" )) operation = bar; - else if( type.attributes.attribute( M_TOKEN( val )) == STR( "lin" )) + else if( type.attribute( M_TOKEN( val )) == STR( "lin" )) operation = lin; - else if( type.attributes.attribute( M_TOKEN( val )) == STR( "noBar" )) + else if( type.attribute( M_TOKEN( val )) == STR( "noBar" )) operation = noBar; stream.ensureClosingTag( M_TOKEN( type )); } @@ -290,7 +290,7 @@ OUString SmOoxmlImport::handleR() XmlStream::Tag rtag = stream.ensureOpeningTag( M_TOKEN( t )); // TODO bail out if failure? OUString text = rtag.text; - if( rtag.attributes.attribute( OOX_TOKEN( xml, space )) != STR( "preserve" )) + if( rtag.attribute( OOX_TOKEN( xml, space )) != STR( "preserve" )) text = text.trim(); stream.ensureClosingTag( M_TOKEN( t )); stream.ensureClosingTag( M_TOKEN( r )); |