summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oox/inc/oox/mathml/importutils.hxx13
-rw-r--r--oox/source/mathml/importutils.cxx16
-rw-r--r--starmath/source/ooxmlimport.cxx47
-rw-r--r--starmath/source/ooxmlimport.hxx1
4 files changed, 77 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 ))
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 4b187ad90ce8..2394fa54bf11 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -35,6 +35,7 @@
using namespace oox;
using namespace oox::formulaimport;
using rtl::OUString;
+using rtl::OUStringBuffer;
/*
The primary internal data structure for the formula is the text representation
@@ -84,6 +85,9 @@ OUString SmOoxmlImport::handleStream()
case OPENING( M_TOKEN( borderBox )):
ret += STR( " " ) + handleBorderBox();
break;
+ case OPENING( M_TOKEN( d )):
+ ret += STR( " " ) + handleD();
+ break;
case OPENING( M_TOKEN( f )):
ret += STR( " " ) + handleF();
break;
@@ -93,6 +97,7 @@ OUString SmOoxmlImport::handleStream()
}
}
stream.ensureClosingTag( M_TOKEN( oMath ));
+ fprintf(stderr, "FORMULA: %s\n", rtl::OUStringToOString( ret, RTL_TEXTENCODING_UTF8 ).getStr());
return ret;
}
@@ -203,6 +208,48 @@ OUString SmOoxmlImport::handleBorderBox()
return e;
}
+OUString SmOoxmlImport::handleD()
+{
+ stream.ensureOpeningTag( M_TOKEN( d ));
+ sal_Unicode opening = '(';
+ sal_Unicode closing = ')';
+ sal_Unicode separator = '|';
+ if( XmlStream::Tag dPr = stream.checkOpeningTag( M_TOKEN( dPr )))
+ {
+ if( XmlStream::Tag begChr = stream.checkOpeningTag( M_TOKEN( begChr )))
+ {
+ opening = begChr.attribute( M_TOKEN( val ), opening );
+ stream.ensureClosingTag( M_TOKEN( begChr ));
+ }
+ if( XmlStream::Tag sepChr = stream.checkOpeningTag( M_TOKEN( sepChr )))
+ {
+ separator = sepChr.attribute( M_TOKEN( val ), separator );
+ stream.ensureClosingTag( M_TOKEN( sepChr ));
+ }
+ if( XmlStream::Tag endChr = stream.checkOpeningTag( M_TOKEN( endChr )))
+ {
+ closing = endChr.attribute( M_TOKEN( val ), closing );
+ stream.ensureClosingTag( M_TOKEN( endChr ));
+ }
+ stream.ensureClosingTag( M_TOKEN( dPr ));
+ }
+ OUStringBuffer ret;
+ ret.append( opening );
+ bool first = true;
+ while( stream.currentToken() == OPENING( M_TOKEN( e )))
+ {
+ if( !first )
+ { // plain "|" would be actually "V" (logical or)
+ ret.append( separator == '|' ? STR( " mline " ) : STR( "|" ));
+ }
+ first = false;
+ ret.append( handleE());
+ }
+ ret.append( closing );
+ stream.ensureClosingTag( M_TOKEN( d ));
+ return ret.makeStringAndClear();
+}
+
OUString SmOoxmlImport::handleE()
{
stream.ensureOpeningTag( M_TOKEN( e ));
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index 8d587f7fe69b..6c31e0d59909 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -47,6 +47,7 @@ private:
rtl::OUString handleAcc();
rtl::OUString handleBar();
rtl::OUString handleBorderBox();
+ rtl::OUString handleD();
rtl::OUString handleE();
rtl::OUString handleF();
rtl::OUString handleR();