summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-11-24 17:14:21 +0100
committerLuboš Luňák <l.lunak@suse.cz>2011-11-24 18:44:00 +0100
commit19a47cb97860a11e57deccb912f47ae19ffc1b65 (patch)
tree64601805b8a2f57dc5822a65f2941f2677de4313 /starmath
parenta685e8fb72614eaa678a7fc244f3e6cf85c80c0f (diff)
mathml docx import - handle m:fPr
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/ooxmlimport.cxx42
-rw-r--r--starmath/source/ooxmlimport.hxx1
2 files changed, 35 insertions, 8 deletions
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index c0a52deca0e0..5bbb71119d55 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -162,12 +162,19 @@ OUString SmOoxmlImport::handleAcc()
OUString SmOoxmlImport::handleE()
{
- OUString ret;
stream.ensureOpeningTag( M_TOKEN( e ));
+ OUString ret = readOMathArg( M_TOKEN( e ));
+ stream.ensureClosingTag( M_TOKEN( e ));
+ return ret;
+}
+
+OUString SmOoxmlImport::readOMathArg( int endtoken )
+{
+ OUString ret;
while( !stream.atEnd())
{ // TODO can there really be more or just one sub-elements?
XmlStream::Tag tag = stream.currentTag();
- if( tag.token == CLOSING( M_TOKEN( e )))
+ if( tag.token == CLOSING( endtoken ))
break;
switch( tag.token )
{
@@ -185,7 +192,6 @@ OUString SmOoxmlImport::handleE()
break;
}
}
- stream.ensureClosingTag( M_TOKEN( e ));
return ret;
}
@@ -193,18 +199,38 @@ OUString SmOoxmlImport::handleE()
OUString SmOoxmlImport::handleF()
{
stream.ensureOpeningTag( M_TOKEN( f ));
- if( stream.currentToken() == OPENING_TAG( M_TOKEN( fPr )))
+ enum operation_t { bar, lin, noBar } operation = bar;
+ OUString oper = STR( "over" );
+ if( stream.checkOpeningTag( M_TOKEN( fPr )))
{
- // TODO
+ if( XmlStream::Tag type = stream.checkOpeningTag( M_TOKEN( type )))
+ {
+ if( type.attributes.attribute( M_TOKEN( val )) == STR( "bar" ))
+ operation = bar;
+ else if( type.attributes.attribute( M_TOKEN( val )) == STR( "lin" ))
+ operation = lin;
+ else if( type.attributes.attribute( M_TOKEN( val )) == STR( "noBar" ))
+ operation = noBar;
+ stream.ensureClosingTag( M_TOKEN( type ));
+ }
+ stream.ensureClosingTag( M_TOKEN( fPr ));
}
stream.ensureOpeningTag( M_TOKEN( num ));
- OUString num = handleR();
+ OUString num = readOMathArg( M_TOKEN( num ));
stream.ensureClosingTag( M_TOKEN( num ));
stream.ensureOpeningTag( M_TOKEN( den ));
- OUString den = handleR();
+ OUString den = readOMathArg( M_TOKEN( den ));
stream.ensureClosingTag( M_TOKEN( den ));
stream.ensureClosingTag( M_TOKEN( f ));
- return STR( "{" ) + num + STR( "} over {" ) + den + STR( "}" );
+ if( operation == bar )
+ return STR( "{" ) + num + STR( "} over {" ) + den + STR( "}" );
+ else if( operation == lin )
+ return STR( "{" ) + num + STR( "} / {" ) + den + STR( "}" );
+ else // noBar
+ { // TODO we write out stack of 3 items as recursive m:f, so merge here back
+ // to 'stack { x # y # z }'
+ return STR( "binom { " ) + num + STR( " } { " ) + den + STR( " }" );
+ }
}
// NOT complete
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index 5cf3bf52c14f..42fbd050f5be 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -48,6 +48,7 @@ private:
rtl::OUString handleE();
rtl::OUString handleF();
rtl::OUString handleR();
+ rtl::OUString readOMathArg( int endtoken );
oox::formulaimport::XmlStream& stream;
};