From eb31865c852ac1843ab6060fdc401cf5cc2bf13c Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 29 Nov 2011 18:09:46 +0100 Subject: merge processing of OMathArg and OMath, for now --- starmath/source/ooxmlimport.cxx | 56 ++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 32 deletions(-) (limited to 'starmath') diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx index 9dcad23a3862..566b3d7e9c2a 100644 --- a/starmath/source/ooxmlimport.cxx +++ b/starmath/source/ooxmlimport.cxx @@ -68,11 +68,31 @@ OUString SmOoxmlImport::ConvertToStarMath() OUString SmOoxmlImport::handleStream() { stream.ensureOpeningTag( M_TOKEN( oMath )); + OUString ret; + while( !stream.atEnd() && stream.currentToken() != CLOSING( M_TOKEN( oMath ))) + { + // strictly speaking, it is not OMathArg here, but currently supported + // functionality is the same like OMathArg, in the future this may need improving + OUString item = readOMathArg( M_TOKEN( oMath )); + if( item.isEmpty()) + continue; + if( !ret.isEmpty()) + ret += STR( " " ); + ret += item; + } + stream.ensureClosingTag( M_TOKEN( oMath )); + fprintf(stderr, "FORMULA: %s\n", rtl::OUStringToOString( ret, RTL_TEXTENCODING_UTF8 ).getStr()); + return ret; +} + + +OUString SmOoxmlImport::readOMathArg( int endtoken ) +{ OUString ret; while( !stream.atEnd()) { XmlStream::Tag tag = stream.currentTag(); - if( tag.token == CLOSING( M_TOKEN( oMath ))) + if( tag.token == CLOSING( endtoken )) break; if( !ret.isEmpty()) ret += STR( " " ); @@ -93,13 +113,14 @@ OUString SmOoxmlImport::handleStream() case OPENING( M_TOKEN( f )): ret += handleF(); break; + case OPENING( M_TOKEN( r )): + ret += handleR(); + break; default: stream.handleUnexpectedTag(); break; } } - stream.ensureClosingTag( M_TOKEN( oMath )); - fprintf(stderr, "FORMULA: %s\n", rtl::OUStringToOString( ret, RTL_TEXTENCODING_UTF8 ).getStr()); return ret; } @@ -260,35 +281,6 @@ OUString SmOoxmlImport::handleE() 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( endtoken )) - break; - if( !ret.isEmpty()) - ret += STR( " " ); - switch( tag.token ) - { - case OPENING( M_TOKEN( acc )): - ret += handleAcc(); - break; - case OPENING( M_TOKEN( f )): - ret += handleF(); - break; - case OPENING( M_TOKEN( r )): - ret += handleR(); - break; - default: - stream.handleUnexpectedTag(); - break; - } - } - return ret; -} - OUString SmOoxmlImport::handleF() { stream.ensureOpeningTag( M_TOKEN( f )); -- cgit