diff options
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/mathml/importutils.hxx | 13 | ||||
-rw-r--r-- | oox/source/mathml/importutils.cxx | 16 |
2 files changed, 29 insertions, 0 deletions
diff --git a/oox/inc/oox/mathml/importutils.hxx b/oox/inc/oox/mathml/importutils.hxx index ca212aad8029..1bf7157d80aa 100644 --- a/oox/inc/oox/mathml/importutils.hxx +++ b/oox/inc/oox/mathml/importutils.hxx @@ -76,6 +76,8 @@ public: bool hasAttribute( int token ) const; rtl::OUString attribute( int token, const rtl::OUString& def = rtl::OUString()) const; bool attribute( int token, bool def ) const; + sal_Unicode attribute( int token, sal_Unicode def ) const; + // when adding more attribute() overloads, add also to XmlStream itself protected: std::map< int, rtl::OUString > attrs; }; @@ -100,6 +102,11 @@ public: */ bool attribute( int token, bool def ) const; /** + @overload + */ + sal_Unicode attribute( int token, sal_Unicode def ) const; + // when adding more attribute() overloads, add also to XmlStream::AttributeList and inline below + /** 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 ))'. */ @@ -190,6 +197,12 @@ bool XmlStream::Tag::attribute( int t, bool def ) const return attributes.attribute( t, def ); } +inline +sal_Unicode XmlStream::Tag::attribute( int t, sal_Unicode def ) const +{ + return attributes.attribute( t, def ); +} + } // namespace } // namespace diff --git a/oox/source/mathml/importutils.cxx b/oox/source/mathml/importutils.cxx index c6bf80ca0194..69fa1fc14f02 100644 --- a/oox/source/mathml/importutils.cxx +++ b/oox/source/mathml/importutils.cxx @@ -99,6 +99,22 @@ bool XmlStream::AttributeList::attribute( int token, bool def ) const return def; } +sal_Unicode XmlStream::AttributeList::attribute( int token, sal_Unicode def ) const +{ + std::map< int, rtl::OUString >::const_iterator find = attrs.find( token ); + if( find != attrs.end()) + { + if( find->second.getLength() >= 1 ) + { + if( find->second.getLength() != 1 ) + fprintf( stderr, "Cannot convert \'%s\' to sal_Unicode, stripping.\n", + rtl::OUStringToOString( find->second, RTL_TEXTENCODING_UTF8 ).getStr()); + return find->second[ 0 ]; + } + } + return def; +} + XmlStream::Tag::Tag( int t, const uno::Reference< xml::sax::XFastAttributeList >& a, const rtl::OUString& txt ) : token( t ) , attributes( AttributeListBuilder( a )) |