diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2011-11-30 12:25:15 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2011-11-30 16:11:44 +0100 |
commit | e6ba4a206f4e3ad7bac35a9dee1438e396d39998 (patch) | |
tree | 6638d986961cc8f74783fa1573521aea8bee64b2 /starmath | |
parent | 9414d02629e3267e47ac4d93a318b13ef2efc39e (diff) |
helper for reading docx OMathArg
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/ooxmlimport.cxx | 66 | ||||
-rw-r--r-- | starmath/source/ooxmlimport.hxx | 1 |
2 files changed, 27 insertions, 40 deletions
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx index 6b4e7e20dae5..f2ef21be8d98 100644 --- a/starmath/source/ooxmlimport.cxx +++ b/starmath/source/ooxmlimport.cxx @@ -85,7 +85,6 @@ OUString SmOoxmlImport::handleStream() return ret; } - OUString SmOoxmlImport::readOMathArg() { OUString ret; @@ -142,6 +141,14 @@ OUString SmOoxmlImport::readOMathArg() return ret; } +OUString SmOoxmlImport::readOMathArgInElement( int token ) +{ + stream.ensureOpeningTag( token ); + OUString ret = readOMathArg(); + stream.ensureClosingTag( token ); + return ret; +} + OUString SmOoxmlImport::handleAcc() { stream.ensureOpeningTag( M_TOKEN( acc )); @@ -200,7 +207,7 @@ OUString SmOoxmlImport::handleAcc() fprintf( stderr, "Unknown m:chr in m:acc '%d'\n", accChr ); break; } - OUString e = handleE(); + OUString e = readOMathArgInElement( M_TOKEN( e )); stream.ensureClosingTag( M_TOKEN( acc )); return acc + STR( " { " ) + e + STR( " }" ); } @@ -221,7 +228,7 @@ OUString SmOoxmlImport::handleBar() } stream.ensureClosingTag( M_TOKEN( barPr )); } - OUString e = handleE(); + OUString e = readOMathArgInElement( M_TOKEN( e )); stream.ensureClosingTag( M_TOKEN( bar )); if( topbot == top ) return STR( "bar { " ) + e + STR( " }" ); @@ -243,7 +250,7 @@ OUString SmOoxmlImport::handleBorderBox() } stream.ensureClosingTag( M_TOKEN( borderBoxPr )); } - OUString e = handleE(); + OUString e = readOMathArgInElement( M_TOKEN( e )); stream.ensureClosingTag( M_TOKEN( borderBox )); if( isStrikeH ) return STR( "overstrike { " ) + e + STR( " }" ); @@ -311,21 +318,13 @@ OUString SmOoxmlImport::handleD() if( !first ) ret.append( separator ); first = false; - ret.append( handleE()); + ret.append( readOMathArgInElement( M_TOKEN( e ))); } ret.append( closing ); stream.ensureClosingTag( M_TOKEN( d )); return ret.makeStringAndClear(); } -OUString SmOoxmlImport::handleE() -{ - stream.ensureOpeningTag( M_TOKEN( e )); - OUString ret = readOMathArg(); - stream.ensureClosingTag( M_TOKEN( e )); - return ret; -} - OUString SmOoxmlImport::handleF() { stream.ensureOpeningTag( M_TOKEN( f )); @@ -345,12 +344,8 @@ OUString SmOoxmlImport::handleF() } stream.ensureClosingTag( M_TOKEN( fPr )); } - stream.ensureOpeningTag( M_TOKEN( num )); - OUString num = readOMathArg(); - stream.ensureClosingTag( M_TOKEN( num )); - stream.ensureOpeningTag( M_TOKEN( den )); - OUString den = readOMathArg(); - stream.ensureClosingTag( M_TOKEN( den )); + OUString num = readOMathArgInElement( M_TOKEN( num )); + OUString den = readOMathArgInElement( M_TOKEN( den )); stream.ensureClosingTag( M_TOKEN( f )); if( operation == bar ) return STR( "{" ) + num + STR( "} over {" ) + den + STR( "}" ); @@ -367,13 +362,11 @@ OUString SmOoxmlImport::handleFunc() { //lim from{x rightarrow 1} x stream.ensureOpeningTag( M_TOKEN( func )); - stream.ensureOpeningTag( M_TOKEN( fName )); - OUString fname = readOMathArg(); - stream.ensureClosingTag( M_TOKEN( fName )); + OUString fname = readOMathArgInElement( M_TOKEN( fName )); // fix the various functions if( fname.match( STR( "lim {" ), 0 )) // startsWith() fname = STR( "lim from {" ) + fname.copy( 5 ); - OUString ret = fname + STR( " {" ) + handleE() + STR( "}" ); + OUString ret = fname + STR( " {" ) + readOMathArgInElement( M_TOKEN( e )) + STR( "}" ); stream.ensureClosingTag( M_TOKEN( func )); return ret; } @@ -382,10 +375,8 @@ OUString SmOoxmlImport::handleLimLowUpp( LimLowUpp_t limlowupp ) { int token = limlowupp == LimLow ? M_TOKEN( limLow ) : M_TOKEN( limUpp ); stream.ensureOpeningTag( token ); - OUString e = handleE(); - stream.ensureOpeningTag( M_TOKEN( lim )); - OUString lim = readOMathArg(); - stream.ensureClosingTag( M_TOKEN( lim )); + OUString e = readOMathArgInElement( M_TOKEN( e )); + OUString lim = readOMathArgInElement( M_TOKEN( lim )); stream.ensureClosingTag( token ); return e + STR( " {" ) + lim + STR( "}" ); } @@ -404,7 +395,8 @@ OUString SmOoxmlImport::handleGroupChr() } stream.ensureClosingTag( M_TOKEN( groupChrPr )); } - OUString ret = STR( "{ " ) + handleE() + ( pos == top ? STR( "} overbrace" ) : STR( "} underbrace" )); + OUString ret = STR( "{ " ) + readOMathArgInElement( M_TOKEN( e )) + + ( pos == top ? STR( "} overbrace" ) : STR( "} underbrace" )); stream.ensureClosingTag( M_TOKEN( groupChr )); return ret; } @@ -421,7 +413,7 @@ OUString SmOoxmlImport::handleM() { if( !row.isEmpty()) row += STR( " # " ); - row += handleE(); + row += readOMathArgInElement( M_TOKEN( e )); } while( !stream.atEnd() && stream.currentToken() == OPENING( M_TOKEN( e ))); if( !allrows.isEmpty()) allrows += STR( " ## " ); @@ -457,13 +449,9 @@ OUString SmOoxmlImport::handleNary() } stream.ensureClosingTag( M_TOKEN( naryPr )); } - stream.ensureOpeningTag( M_TOKEN( sub )); - OUString sub = readOMathArg(); - stream.ensureClosingTag( M_TOKEN( sub )); - stream.ensureOpeningTag( M_TOKEN( sup )); - OUString sup = readOMathArg(); - stream.ensureClosingTag( M_TOKEN( sup )); - OUString e = handleE(); + OUString sub = readOMathArgInElement( M_TOKEN( sub )); + OUString sup = readOMathArgInElement( M_TOKEN( sup )); + OUString e = readOMathArgInElement( M_TOKEN( e )); OUString ret; switch( chr ) { @@ -554,10 +542,8 @@ OUString SmOoxmlImport::handleRad() } stream.ensureClosingTag( M_TOKEN( radPr )); } - stream.ensureOpeningTag( M_TOKEN( deg )); - OUString deg = readOMathArg(); - stream.ensureClosingTag( M_TOKEN( deg )); - OUString e = handleE(); + OUString deg = readOMathArgInElement( M_TOKEN( deg )); + OUString e = readOMathArgInElement( M_TOKEN( e )); stream.ensureClosingTag( M_TOKEN( rad )); if( degHide ) return STR( "sqrt {" ) + e + STR( "}" ); diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx index fe88dfa52417..8618a5636f96 100644 --- a/starmath/source/ooxmlimport.hxx +++ b/starmath/source/ooxmlimport.hxx @@ -59,6 +59,7 @@ private: rtl::OUString handleR(); rtl::OUString handleRad(); rtl::OUString readOMathArg(); + rtl::OUString readOMathArgInElement( int token ); oox::formulaimport::XmlStream& stream; }; |