From 19a47cb97860a11e57deccb912f47ae19ffc1b65 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Thu, 24 Nov 2011 17:14:21 +0100 Subject: mathml docx import - handle m:fPr --- starmath/source/ooxmlimport.cxx | 42 +++++++++++++++++++++++++++++++++-------- starmath/source/ooxmlimport.hxx | 1 + 2 files changed, 35 insertions(+), 8 deletions(-) (limited to 'starmath') 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; }; -- cgit