summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-11-29 16:19:53 +0100
committerLuboš Luňák <l.lunak@suse.cz>2011-11-29 21:20:25 +0100
commit7bdccfdc1d3dc070a19a604c4c76b28428cc5a0e (patch)
tree376dc3d04c2ffa89161080967c95f6968b2ebbd5 /oox
parente9ed9d4d4548751b50d45b7082f776d6e69204e3 (diff)
implement import of docx mathml m:d
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/oox/mathml/importutils.hxx13
-rw-r--r--oox/source/mathml/importutils.cxx16
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 ))