[Libreoffice-commits] .: 14 commits - starmath/source writerfilter/source
Lubos Lunak
llunak at kemper.freedesktop.org
Wed Nov 30 07:12:27 PST 2011
starmath/source/ooxmlexport.cxx | 76 ++++++++--
starmath/source/ooxmlimport.cxx | 263 ++++++++++++++++++++++++++++++------
starmath/source/ooxmlimport.hxx | 8 +
writerfilter/source/ooxml/model.xml | 1
4 files changed, 294 insertions(+), 54 deletions(-)
New commits:
commit d5effb40f2bfa95b8b1d19f56195754f125a75c5
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 15:51:56 2011 +0100
create placeholders properly in docx mathml import
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 62ad52f..233334d 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -29,6 +29,7 @@
#include "ooxmlimport.hxx"
+#include <comphelper/string.hxx>
#include <oox/token/tokens.hxx>
#include <oox/token/namespaces.hxx>
@@ -81,6 +82,12 @@ OUString SmOoxmlImport::handleStream()
ret += item;
}
stream.ensureClosingTag( M_TOKEN( oMath ));
+ // Placeholders are written out as nothing (i.e. nothing inside e.g. the <e> element),
+ // which will result in "{}" in the formula text. Fix this up.
+ ret = comphelper::string::searchAndReplaceAllAsciiWithAscii( ret, "{}", "<?>" );
+ // And as a result, empty parts of the formula that are not placeholders are written out
+ // as a single space, so fix that up too.
+ ret = comphelper::string::searchAndReplaceAllAsciiWithAscii( ret, "{ }", "{}" );
fprintf(stderr, "FORMULA: %s\n", rtl::OUStringToOString( ret, RTL_TEXTENCODING_UTF8 ).getStr());
return ret;
}
@@ -404,11 +411,11 @@ OUString SmOoxmlImport::handleLimLowUpp( LimLowUpp_t limlowupp )
OUString e = readOMathArgInElement( M_TOKEN( e ));
OUString lim = readOMathArgInElement( M_TOKEN( lim ));
stream.ensureClosingTag( token );
- // fix up overbrace/underbrace
- if( limlowupp == LimUpp && e.endsWithAsciiL( RTL_CONSTASCII_STRINGPARAM( " overbrace {}" )))
- return e.copy( 0, e.getLength() - 1 ) + lim + STR( "}" );
- if( limlowupp == LimLow && e.endsWithAsciiL( RTL_CONSTASCII_STRINGPARAM( " underbrace {}" )))
- return e.copy( 0, e.getLength() - 1 ) + lim + STR( "}" );
+ // fix up overbrace/underbrace (use { }, as {} will be converted to a placeholder)
+ if( limlowupp == LimUpp && e.endsWithAsciiL( RTL_CONSTASCII_STRINGPARAM( " overbrace { }" )))
+ return e.copy( 0, e.getLength() - 2 ) + lim + STR( "}" );
+ if( limlowupp == LimLow && e.endsWithAsciiL( RTL_CONSTASCII_STRINGPARAM( " underbrace { }" )))
+ return e.copy( 0, e.getLength() - 2 ) + lim + STR( "}" );
return e + ( limlowupp == LimLow ? STR( " csub {" ) : STR( " csup {" )) + lim + STR( "}" );
}
@@ -435,9 +442,9 @@ OUString SmOoxmlImport::handleGroupChr()
OUString e = readOMathArgInElement( M_TOKEN( e ));
stream.ensureClosingTag( M_TOKEN( groupChr ));
if( pos == top && chr == sal_Unicode( 0x23de ))
- return STR( "{" ) + e + STR( "} overbrace {}" );
+ return STR( "{" ) + e + STR( "} overbrace { }" );
if( pos == bot && chr == sal_Unicode( 0x23df ))
- return STR( "{" ) + e + STR( "} underbrace {}" );
+ return STR( "{" ) + e + STR( "} underbrace { }" );
if( pos == top )
return STR( "{" ) + e + STR( "} csup {" ) + OUString( chr ) + STR( "}" );
else
commit baaf0aa0295a052f6c47079438b10952f79718cd
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 15:39:20 2011 +0100
do not add unnecessary spaces in docx mathml import
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 9993bd4..62ad52f 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -224,7 +224,7 @@ OUString SmOoxmlImport::handleAcc()
}
OUString e = readOMathArgInElement( M_TOKEN( e ));
stream.ensureClosingTag( M_TOKEN( acc ));
- return acc + STR( " { " ) + e + STR( " }" );
+ return acc + STR( " {" ) + e + STR( "}" );
}
OUString SmOoxmlImport::handleBar()
@@ -246,9 +246,9 @@ OUString SmOoxmlImport::handleBar()
OUString e = readOMathArgInElement( M_TOKEN( e ));
stream.ensureClosingTag( M_TOKEN( bar ));
if( topbot == top )
- return STR( "bar { " ) + e + STR( " }" );
+ return STR( "bar {" ) + e + STR( "}" );
else
- return STR( "underline { " ) + e + STR( " }" );
+ return STR( "underline {" ) + e + STR( "}" );
}
OUString SmOoxmlImport::handleBox()
@@ -279,7 +279,7 @@ OUString SmOoxmlImport::handleBorderBox()
OUString e = readOMathArgInElement( M_TOKEN( e ));
stream.ensureClosingTag( M_TOKEN( borderBox ));
if( isStrikeH )
- return STR( "overstrike { " ) + e + STR( " }" );
+ return STR( "overstrike {" ) + e + STR( "}" );
// LO does not seem to implement anything for handling the other cases
return e;
}
@@ -380,7 +380,7 @@ OUString SmOoxmlImport::handleF()
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( " }" );
+ return STR( "binom {" ) + num + STR( "} {" ) + den + STR( "}" );
}
}
@@ -435,13 +435,13 @@ OUString SmOoxmlImport::handleGroupChr()
OUString e = readOMathArgInElement( M_TOKEN( e ));
stream.ensureClosingTag( M_TOKEN( groupChr ));
if( pos == top && chr == sal_Unicode( 0x23de ))
- return STR( "{ " ) + e + STR( "} overbrace {}" );
+ return STR( "{" ) + e + STR( "} overbrace {}" );
if( pos == bot && chr == sal_Unicode( 0x23df ))
- return STR( "{ " ) + e + STR( "} underbrace {}" );
+ return STR( "{" ) + e + STR( "} underbrace {}" );
if( pos == top )
- return STR( "{ " ) + e + STR( "} csup {" ) + OUString( chr ) + STR( "}" );
+ return STR( "{" ) + e + STR( "} csup {" ) + OUString( chr ) + STR( "}" );
else
- return STR( "{ " ) + e + STR( "} csub {" ) + OUString( chr ) + STR( "}" );
+ return STR( "{" ) + e + STR( "} csub {" ) + OUString( chr ) + STR( "}" );
}
OUString SmOoxmlImport::handleM()
@@ -591,7 +591,7 @@ OUString SmOoxmlImport::handleRad()
if( degHide )
return STR( "sqrt {" ) + e + STR( "}" );
else
- return STR( "nroot {" ) + deg + STR( "}{" ) + e + STR( "}" );
+ return STR( "nroot {" ) + deg + STR( "} {" ) + e + STR( "}" );
}
OUString SmOoxmlImport::handleSpre()
commit f606abf36ba12fe59b8e809db93b512799166c0b
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 15:36:00 2011 +0100
try with at least somewhat more generic handling of docx m:groupChr
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index c4298b9..9993bd4 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -404,15 +404,26 @@ OUString SmOoxmlImport::handleLimLowUpp( LimLowUpp_t limlowupp )
OUString e = readOMathArgInElement( M_TOKEN( e ));
OUString lim = readOMathArgInElement( M_TOKEN( lim ));
stream.ensureClosingTag( token );
+ // fix up overbrace/underbrace
+ if( limlowupp == LimUpp && e.endsWithAsciiL( RTL_CONSTASCII_STRINGPARAM( " overbrace {}" )))
+ return e.copy( 0, e.getLength() - 1 ) + lim + STR( "}" );
+ if( limlowupp == LimLow && e.endsWithAsciiL( RTL_CONSTASCII_STRINGPARAM( " underbrace {}" )))
+ return e.copy( 0, e.getLength() - 1 ) + lim + STR( "}" );
return e + ( limlowupp == LimLow ? STR( " csub {" ) : STR( " csup {" )) + lim + STR( "}" );
}
OUString SmOoxmlImport::handleGroupChr()
{
stream.ensureOpeningTag( M_TOKEN( groupChr ));
+ sal_Unicode chr = 0x23df;
enum pos_t { top, bot } pos = bot;
if( stream.checkOpeningTag( M_TOKEN( groupChrPr )))
{
+ if( XmlStream::Tag chrTag = stream.checkOpeningTag( M_TOKEN( chr )))
+ {
+ chr = chrTag.attribute( M_TOKEN( val ), chr );
+ stream.ensureClosingTag( M_TOKEN( chr ));
+ }
if( XmlStream::Tag posTag = stream.checkOpeningTag( M_TOKEN( pos )))
{
if( posTag.attribute( M_TOKEN( val ), STR( "bot" )) == STR( "top" ))
@@ -421,10 +432,16 @@ OUString SmOoxmlImport::handleGroupChr()
}
stream.ensureClosingTag( M_TOKEN( groupChrPr ));
}
- OUString ret = STR( "{ " ) + readOMathArgInElement( M_TOKEN( e ))
- + ( pos == top ? STR( "} overbrace" ) : STR( "} underbrace" ));
+ OUString e = readOMathArgInElement( M_TOKEN( e ));
stream.ensureClosingTag( M_TOKEN( groupChr ));
- return ret;
+ if( pos == top && chr == sal_Unicode( 0x23de ))
+ return STR( "{ " ) + e + STR( "} overbrace {}" );
+ if( pos == bot && chr == sal_Unicode( 0x23df ))
+ return STR( "{ " ) + e + STR( "} underbrace {}" );
+ if( pos == top )
+ return STR( "{ " ) + e + STR( "} csup {" ) + OUString( chr ) + STR( "}" );
+ else
+ return STR( "{ " ) + e + STR( "} csub {" ) + OUString( chr ) + STR( "}" );
}
OUString SmOoxmlImport::handleM()
commit 0ca8b2c7008694532d3135cc50fc4505ed2c5d64
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 15:09:11 2011 +0100
do not ignore docx m:box contents (but m:box itself is not implemented)
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 31a7a40..c4298b9 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -100,6 +100,9 @@ OUString SmOoxmlImport::readOMathArg()
case OPENING( M_TOKEN( bar )):
ret += handleBar();
break;
+ case OPENING( M_TOKEN( box )):
+ ret += handleBox();
+ break;
case OPENING( M_TOKEN( borderBox )):
ret += handleBorderBox();
break;
@@ -248,6 +251,17 @@ OUString SmOoxmlImport::handleBar()
return STR( "underline { " ) + e + STR( " }" );
}
+OUString SmOoxmlImport::handleBox()
+{
+ // there does not seem to be functionality in LO to actually implement this
+ // (or is there), but at least read in the contents instead of ignoring them
+ stream.ensureOpeningTag( M_TOKEN( box ));
+ OUString e = readOMathArgInElement( M_TOKEN( e ));
+ stream.ensureClosingTag( M_TOKEN( box ));
+ return e;
+}
+
+
OUString SmOoxmlImport::handleBorderBox()
{
stream.ensureOpeningTag( M_TOKEN( borderBox ));
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index 08c357d..5bea975 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -46,6 +46,7 @@ private:
rtl::OUString handleStream();
rtl::OUString handleAcc();
rtl::OUString handleBar();
+ rtl::OUString handleBox();
rtl::OUString handleBorderBox();
rtl::OUString handleD();
rtl::OUString handleE();
commit 0f7fb6868011ea8f7b51a6a326d552254269a63c
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 15:04:55 2011 +0100
read m:oMathPara
I'm unsure on what the difference to o:Math actually is, so just make
sure the element and its contents are not ignored and each contained
m:oMath will be read in separately.
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 0a1d77a..12d29a5 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -23624,5 +23624,6 @@
<resource name="glossaryDocument" resource="Stream" tag="content"/>
<resource name="CT_TxbxContent" resource="Stream" tag="shape"/>
<resource name="CT_OMath" resource="Math" tag="math"/>
+ <resource name="CT_OMathPara" resource="Stream" tag="math"/>
</namespace>
</model>
commit 03f950d64f99be1a16a0da98cd0cf1d41dfb8649
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 14:54:01 2011 +0100
import docx m:limUpp/m:limLow properly
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index dcdeab2..31a7a40 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -376,8 +376,8 @@ OUString SmOoxmlImport::handleFunc()
stream.ensureOpeningTag( M_TOKEN( func ));
OUString fname = readOMathArgInElement( M_TOKEN( fName ));
// fix the various functions
- if( fname.match( STR( "lim {" ), 0 )) // startsWith()
- fname = STR( "lim from {" ) + fname.copy( 5 );
+ if( fname.match( STR( "lim csub {" ), 0 )) // startsWith()
+ fname = STR( "lim from {" ) + fname.copy( 10 );
OUString ret = fname + STR( " {" ) + readOMathArgInElement( M_TOKEN( e )) + STR( "}" );
stream.ensureClosingTag( M_TOKEN( func ));
return ret;
@@ -390,7 +390,7 @@ OUString SmOoxmlImport::handleLimLowUpp( LimLowUpp_t limlowupp )
OUString e = readOMathArgInElement( M_TOKEN( e ));
OUString lim = readOMathArgInElement( M_TOKEN( lim ));
stream.ensureClosingTag( token );
- return e + STR( " {" ) + lim + STR( "}" );
+ return e + ( limlowupp == LimLow ? STR( " csub {" ) : STR( " csup {" )) + lim + STR( "}" );
}
OUString SmOoxmlImport::handleGroupChr()
commit c56e4ab6675a83da09bfbe69bf63f6a4cedcb566
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 14:48:53 2011 +0100
export all sub/superscripts LO can handle to docx mathml
diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index 1bab1f2..d3d7c05 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -546,18 +546,24 @@ void SmOoxmlExport::HandleSubSupScript( const SmSubSupNode* pNode, int nLevel )
| ( pNode->GetSubSup( RSUP ) != NULL ? ( 1 << RSUP ) : 0 )
| ( pNode->GetSubSup( LSUB ) != NULL ? ( 1 << LSUB ) : 0 )
| ( pNode->GetSubSup( LSUP ) != NULL ? ( 1 << LSUP ) : 0 );
- if( flags == 0 ) // none
- return;
HandleSubSupScriptInternal( pNode, nLevel, flags );
}
void SmOoxmlExport::HandleSubSupScriptInternal( const SmSubSupNode* pNode, int nLevel, int flags )
{
- if( flags == ( 1 << RSUP | 1 << RSUB ))
+// docx supports only a certain combination of sub/super scripts, but LO can have any,
+// so try to merge it using several tags if necessary
+ if( flags == 0 ) // none
+ return;
+ if(( flags & ( 1 << RSUP | 1 << RSUB )) == ( 1 << RSUP | 1 << RSUB ))
{ // m:sSubSup
m_pSerializer->startElementNS( XML_m, XML_sSubSup, FSEND );
m_pSerializer->startElementNS( XML_m, XML_e, FSEND );
- HandleNode( pNode->GetBody(), nLevel + 1 );
+ flags &= ~( 1 << RSUP | 1 << RSUB );
+ if( flags == 0 )
+ HandleNode( pNode->GetBody(), nLevel + 1 );
+ else
+ HandleSubSupScriptInternal( pNode, nLevel, flags );
m_pSerializer->endElementNS( XML_m, XML_e );
m_pSerializer->startElementNS( XML_m, XML_sub, FSEND );
HandleNode( pNode->GetSubSup( RSUB ), nLevel + 1 );
@@ -567,29 +573,37 @@ void SmOoxmlExport::HandleSubSupScriptInternal( const SmSubSupNode* pNode, int n
m_pSerializer->endElementNS( XML_m, XML_sup );
m_pSerializer->endElementNS( XML_m, XML_sSubSup );
}
- else if( flags == 1 << RSUB )
+ else if(( flags & ( 1 << RSUB )) == 1 << RSUB )
{ // m:sSub
m_pSerializer->startElementNS( XML_m, XML_sSub, FSEND );
m_pSerializer->startElementNS( XML_m, XML_e, FSEND );
- HandleNode( pNode->GetBody(), nLevel + 1 );
+ flags &= ~( 1 << RSUB );
+ if( flags == 0 )
+ HandleNode( pNode->GetBody(), nLevel + 1 );
+ else
+ HandleSubSupScriptInternal( pNode, nLevel, flags );
m_pSerializer->endElementNS( XML_m, XML_e );
m_pSerializer->startElementNS( XML_m, XML_sub, FSEND );
HandleNode( pNode->GetSubSup( RSUB ), nLevel + 1 );
m_pSerializer->endElementNS( XML_m, XML_sub );
m_pSerializer->endElementNS( XML_m, XML_sSub );
}
- else if( flags == 1 << RSUP )
+ else if(( flags & ( 1 << RSUP )) == 1 << RSUP )
{ // m:sSup
m_pSerializer->startElementNS( XML_m, XML_sSup, FSEND );
m_pSerializer->startElementNS( XML_m, XML_e, FSEND );
- HandleNode( pNode->GetBody(), nLevel + 1 );
+ flags &= ~( 1 << RSUP );
+ if( flags == 0 )
+ HandleNode( pNode->GetBody(), nLevel + 1 );
+ else
+ HandleSubSupScriptInternal( pNode, nLevel, flags );
m_pSerializer->endElementNS( XML_m, XML_e );
m_pSerializer->startElementNS( XML_m, XML_sup, FSEND );
HandleNode( pNode->GetSubSup( RSUP ), nLevel + 1 );
m_pSerializer->endElementNS( XML_m, XML_sup );
m_pSerializer->endElementNS( XML_m, XML_sSup );
}
- else if( flags == ( 1 << LSUP | 1 << LSUB ))
+ else if(( flags & ( 1 << LSUP | 1 << LSUB )) == ( 1 << LSUP | 1 << LSUB ))
{ // m:sPre
m_pSerializer->startElementNS( XML_m, XML_sPre, FSEND );
m_pSerializer->startElementNS( XML_m, XML_sub, FSEND );
@@ -599,14 +613,49 @@ void SmOoxmlExport::HandleSubSupScriptInternal( const SmSubSupNode* pNode, int n
HandleNode( pNode->GetSubSup( LSUP ), nLevel + 1 );
m_pSerializer->endElementNS( XML_m, XML_sup );
m_pSerializer->startElementNS( XML_m, XML_e, FSEND );
- HandleNode( pNode->GetBody(), nLevel + 1 );
+ flags &= ~( 1 << LSUP | 1 << LSUB );
+ if( flags == 0 )
+ HandleNode( pNode->GetBody(), nLevel + 1 );
+ else
+ HandleSubSupScriptInternal( pNode, nLevel, flags );
m_pSerializer->endElementNS( XML_m, XML_e );
m_pSerializer->endElementNS( XML_m, XML_sPre );
}
+ else if(( flags & ( 1 << CSUB )) == ( 1 << CSUB ))
+ { // m:limLow looks like a good element for central superscript
+ m_pSerializer->startElementNS( XML_m, XML_limLow, FSEND );
+ m_pSerializer->startElementNS( XML_m, XML_e, FSEND );
+ flags &= ~( 1 << CSUB );
+ if( flags == 0 )
+ HandleNode( pNode->GetBody(), nLevel + 1 );
+ else
+ HandleSubSupScriptInternal( pNode, nLevel, flags );
+ m_pSerializer->endElementNS( XML_m, XML_e );
+ m_pSerializer->startElementNS( XML_m, XML_lim, FSEND );
+ HandleNode( pNode->GetSubSup( CSUB ), nLevel + 1 );
+ m_pSerializer->endElementNS( XML_m, XML_lim );
+ m_pSerializer->endElementNS( XML_m, XML_limLow );
+ }
+ else if(( flags & ( 1 << CSUP )) == ( 1 << CSUP ))
+ { // m:limUpp looks like a good element for central superscript
+ m_pSerializer->startElementNS( XML_m, XML_limUpp, FSEND );
+ m_pSerializer->startElementNS( XML_m, XML_e, FSEND );
+ flags &= ~( 1 << CSUP );
+ if( flags == 0 )
+ HandleNode( pNode->GetBody(), nLevel + 1 );
+ else
+ HandleSubSupScriptInternal( pNode, nLevel, flags );
+ m_pSerializer->endElementNS( XML_m, XML_e );
+ m_pSerializer->startElementNS( XML_m, XML_lim, FSEND );
+ HandleNode( pNode->GetSubSup( CSUP ), nLevel + 1 );
+ m_pSerializer->endElementNS( XML_m, XML_lim );
+ m_pSerializer->endElementNS( XML_m, XML_limUpp );
+ }
else
{
OSL_FAIL( "Unhandled sub/sup combination" );
- HandleAllSubNodes( pNode, nLevel );
+ // TODO do not do anything, this should be probably an assert()
+ // HandleAllSubNodes( pNode, nLevel );
}
}
commit 53c9a92cc82baaabd05b182152541e0c7d2bd3d0
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 12:57:39 2011 +0100
fix writing of docx m:sPre
diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index 7bfa6ec..1bab1f2 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -544,7 +544,7 @@ void SmOoxmlExport::HandleSubSupScript( const SmSubSupNode* pNode, int nLevel )
| ( pNode->GetSubSup( CSUP ) != NULL ? ( 1 << CSUP ) : 0 )
| ( pNode->GetSubSup( RSUB ) != NULL ? ( 1 << RSUB ) : 0 )
| ( pNode->GetSubSup( RSUP ) != NULL ? ( 1 << RSUP ) : 0 )
- | ( pNode->GetSubSup( LSUB ) != NULL ? ( 1 << RSUB ) : 0 )
+ | ( pNode->GetSubSup( LSUB ) != NULL ? ( 1 << LSUB ) : 0 )
| ( pNode->GetSubSup( LSUP ) != NULL ? ( 1 << LSUP ) : 0 );
if( flags == 0 ) // none
return;
@@ -601,7 +601,7 @@ void SmOoxmlExport::HandleSubSupScriptInternal( const SmSubSupNode* pNode, int n
m_pSerializer->startElementNS( XML_m, XML_e, FSEND );
HandleNode( pNode->GetBody(), nLevel + 1 );
m_pSerializer->endElementNS( XML_m, XML_e );
- m_pSerializer->endElementNS( XML_m, XML_sSubSup );
+ m_pSerializer->endElementNS( XML_m, XML_sPre );
}
else
{
commit cb0965a860b6a08333eb1373b8018454da3b260f
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 12:43:00 2011 +0100
import docx m:sPre, m:sSub, m:sSubSup and m:Sup
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index f2ef21b..dcdeab2 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -133,6 +133,18 @@ OUString SmOoxmlImport::readOMathArg()
case OPENING( M_TOKEN( rad )):
ret += handleRad();
break;
+ case OPENING( M_TOKEN( sPre )):
+ ret += handleSpre();
+ break;
+ case OPENING( M_TOKEN( sSub )):
+ ret += handleSsub();
+ break;
+ case OPENING( M_TOKEN( sSubSup )):
+ ret += handleSsubsup();
+ break;
+ case OPENING( M_TOKEN( sSup )):
+ ret += handleSsup();
+ break;
default:
stream.handleUnexpectedTag();
break;
@@ -551,4 +563,42 @@ OUString SmOoxmlImport::handleRad()
return STR( "nroot {" ) + deg + STR( "}{" ) + e + STR( "}" );
}
+OUString SmOoxmlImport::handleSpre()
+{
+ stream.ensureOpeningTag( M_TOKEN( sPre ));
+ OUString sub = readOMathArgInElement( M_TOKEN( sub ));
+ OUString sup = readOMathArgInElement( M_TOKEN( sup ));
+ OUString e = readOMathArgInElement( M_TOKEN( e ));
+ stream.ensureClosingTag( M_TOKEN( sPre ));
+ return STR( "{" ) + e + STR( "} lsub {" ) + sub + STR( "} lsup {" ) + sup + STR( "}" );
+}
+
+OUString SmOoxmlImport::handleSsub()
+{
+ stream.ensureOpeningTag( M_TOKEN( sSub ));
+ OUString e = readOMathArgInElement( M_TOKEN( e ));
+ OUString sub = readOMathArgInElement( M_TOKEN( sub ));
+ stream.ensureClosingTag( M_TOKEN( sSub ));
+ return STR( "{" ) + e + STR( "} rsub {" ) + sub + STR( "}" );
+}
+
+OUString SmOoxmlImport::handleSsubsup()
+{
+ stream.ensureOpeningTag( M_TOKEN( sSubSup ));
+ OUString e = readOMathArgInElement( M_TOKEN( e ));
+ OUString sub = readOMathArgInElement( M_TOKEN( sub ));
+ OUString sup = readOMathArgInElement( M_TOKEN( sup ));
+ stream.ensureClosingTag( M_TOKEN( sSubSup ));
+ return STR( "{" ) + e + STR( "} rsub {" ) + sub + STR( "} rsup {" ) + sup + STR( "}" );
+}
+
+OUString SmOoxmlImport::handleSsup()
+{
+ stream.ensureOpeningTag( M_TOKEN( sSup ));
+ OUString e = readOMathArgInElement( M_TOKEN( e ));
+ OUString sup = readOMathArgInElement( M_TOKEN( sup ));
+ stream.ensureClosingTag( M_TOKEN( sSup ));
+ return STR( "{" ) + e + STR( "} ^ {" ) + sup + STR( "}" );
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index 8618a56..08c357d 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -58,6 +58,10 @@ private:
rtl::OUString handleNary();
rtl::OUString handleR();
rtl::OUString handleRad();
+ rtl::OUString handleSpre();
+ rtl::OUString handleSsub();
+ rtl::OUString handleSsubsup();
+ rtl::OUString handleSsup();
rtl::OUString readOMathArg();
rtl::OUString readOMathArgInElement( int token );
oox::formulaimport::XmlStream& stream;
commit e6ba4a206f4e3ad7bac35a9dee1438e396d39998
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 12:25:15 2011 +0100
helper for reading docx OMathArg
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 6b4e7e2..f2ef21b 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 fe88dfa..8618a56 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;
};
commit 9414d02629e3267e47ac4d93a318b13ef2efc39e
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 12:01:02 2011 +0100
implement docx m:rad
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 3f884e5..6b4e7e2 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -131,6 +131,9 @@ OUString SmOoxmlImport::readOMathArg()
case OPENING( M_TOKEN( r )):
ret += handleR();
break;
+ case OPENING( M_TOKEN( rad )):
+ ret += handleRad();
+ break;
default:
stream.handleUnexpectedTag();
break;
@@ -538,4 +541,28 @@ OUString SmOoxmlImport::handleR()
return text;
}
+OUString SmOoxmlImport::handleRad()
+{
+ stream.ensureOpeningTag( M_TOKEN( rad ));
+ bool degHide = false;
+ if( stream.checkOpeningTag( M_TOKEN( radPr )))
+ {
+ if( XmlStream::Tag degHideTag = stream.checkOpeningTag( M_TOKEN( degHide )))
+ {
+ degHide = degHideTag.attribute( M_TOKEN( val ), degHide );
+ stream.ensureClosingTag( M_TOKEN( degHide ));
+ }
+ stream.ensureClosingTag( M_TOKEN( radPr ));
+ }
+ stream.ensureOpeningTag( M_TOKEN( deg ));
+ OUString deg = readOMathArg();
+ stream.ensureClosingTag( M_TOKEN( deg ));
+ OUString e = handleE();
+ stream.ensureClosingTag( M_TOKEN( rad ));
+ if( degHide )
+ return STR( "sqrt {" ) + e + STR( "}" );
+ else
+ return STR( "nroot {" ) + deg + STR( "}{" ) + e + STR( "}" );
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index 350ff3f..fe88dfa 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -57,6 +57,7 @@ private:
rtl::OUString handleM();
rtl::OUString handleNary();
rtl::OUString handleR();
+ rtl::OUString handleRad();
rtl::OUString readOMathArg();
oox::formulaimport::XmlStream& stream;
};
commit f28c6c55ad902a399cc7a7f8cb426c09da5ba58c
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 11:48:45 2011 +0100
warn about unknown m:chr in m:acc
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 5c4b90e..3f884e5 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -142,18 +142,19 @@ OUString SmOoxmlImport::readOMathArg()
OUString SmOoxmlImport::handleAcc()
{
stream.ensureOpeningTag( M_TOKEN( acc ));
- OUString acc;
+ sal_Unicode accChr = 0x302;
if( XmlStream::Tag accPr = stream.checkOpeningTag( M_TOKEN( accPr )))
{
if( XmlStream::Tag chr = stream.checkOpeningTag( M_TOKEN( chr )))
{
- acc = chr.attribute( M_TOKEN( val ));
+ accChr = chr.attribute( M_TOKEN( val ), accChr );
stream.ensureClosingTag( M_TOKEN( chr ));
}
stream.ensureClosingTag( M_TOKEN( accPr ));
}
// see aTokenTable in parse.cxx
- switch( acc.isEmpty() ? sal_Unicode( MS_ACUTE ) : acc[ 0 ] )
+ OUString acc;
+ switch( accChr )
{
case MS_CHECK:
acc = STR( "check" );
@@ -193,6 +194,7 @@ OUString SmOoxmlImport::handleAcc()
break;
default:
acc = STR( "acute" );
+ fprintf( stderr, "Unknown m:chr in m:acc '%d'\n", accChr );
break;
}
OUString e = handleE();
commit 8168d6d3df3245fc776152ccc46bfa28c5ea7d32
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 11:45:09 2011 +0100
implement sum properly in docx mathml
diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index 5e18ad4..7bfa6ec 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -472,6 +472,7 @@ void SmOoxmlExport::HandleOperator( const SmOperNode* pNode, int nLevel )
case TLLLINT:
case TPROD:
case TCOPROD:
+ case TSUM:
{
const SmSubSupNode* subsup = pNode->GetSubNode( 0 )->GetType() == NSUBSUP
? static_cast< const SmSubSupNode* >( pNode->GetSubNode( 0 )) : NULL;
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index c9353c0..5c4b90e 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -486,6 +486,9 @@ OUString SmOoxmlImport::handleNary()
case MS_COPROD:
ret = STR( "coprod" );
break;
+ case MS_SUM:
+ ret = STR( "sum" );
+ break;
default:
fprintf( stderr, "Unknown m:nary chr '%d'\n", chr );
break;
commit 500b6af7773a9991425a1a031ebf8901b3549de2
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Nov 30 11:42:37 2011 +0100
implement docx m:nary
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index c0d84ab..c9353c0 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -125,6 +125,9 @@ OUString SmOoxmlImport::readOMathArg()
case OPENING( M_TOKEN( m )):
ret += handleM();
break;
+ case OPENING( M_TOKEN( nary )):
+ ret += handleNary();
+ break;
case OPENING( M_TOKEN( r )):
ret += handleR();
break;
@@ -424,6 +427,78 @@ OUString SmOoxmlImport::handleM()
return STR( "matrix {" ) + allrows + STR( "}" );
}
+OUString SmOoxmlImport::handleNary()
+{
+ stream.ensureOpeningTag( M_TOKEN( nary ));
+ sal_Unicode chr = 0x222b;
+ bool subHide = false;
+ bool supHide = false;
+ if( stream.checkOpeningTag( M_TOKEN( naryPr )))
+ {
+ if( XmlStream::Tag chrTag = stream.checkOpeningTag( M_TOKEN( chr )))
+ {
+ chr = chrTag.attribute( M_TOKEN( val ), chr );
+ stream.ensureClosingTag( M_TOKEN( chr ));
+ }
+ if( XmlStream::Tag subHideTag = stream.checkOpeningTag( M_TOKEN( subHide )))
+ {
+ subHide = subHideTag.attribute( M_TOKEN( val ), subHide );
+ stream.ensureClosingTag( M_TOKEN( subHide ));
+ }
+ if( XmlStream::Tag supHideTag = stream.checkOpeningTag( M_TOKEN( supHide )))
+ {
+ supHide = supHideTag.attribute( M_TOKEN( val ), supHide );
+ stream.ensureClosingTag( M_TOKEN( supHide ));
+ }
+ 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 ret;
+ switch( chr )
+ {
+ case MS_INT:
+ ret = STR( "int" );
+ break;
+ case MS_IINT:
+ ret = STR( "liint" );
+ break;
+ case MS_IIINT:
+ ret = STR( "liiint" );
+ break;
+ case MS_LINT:
+ ret = STR( "lint" );
+ break;
+ case MS_LLINT:
+ ret = STR( "llint" );
+ break;
+ case MS_LLLINT:
+ ret = STR( "lllint" );
+ break;
+ case MS_PROD:
+ ret = STR( "prod" );
+ break;
+ case MS_COPROD:
+ ret = STR( "coprod" );
+ break;
+ default:
+ fprintf( stderr, "Unknown m:nary chr '%d'\n", chr );
+ break;
+ }
+ if( !subHide )
+ ret += STR( " from {" ) + sub + STR( "}" );
+ if( !supHide )
+ ret += STR( " to {" ) + sup + STR( "}" );
+ ret += STR( " {" ) + e + STR( "}" );
+ stream.ensureClosingTag( M_TOKEN( nary ));
+ return ret;
+}
+
// NOT complete
OUString SmOoxmlImport::handleR()
{
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index 05963d6..350ff3f 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -55,6 +55,7 @@ private:
rtl::OUString handleLimLowUpp( LimLowUpp_t limlowupp );
rtl::OUString handleGroupChr();
rtl::OUString handleM();
+ rtl::OUString handleNary();
rtl::OUString handleR();
rtl::OUString readOMathArg();
oox::formulaimport::XmlStream& stream;
More information about the Libreoffice-commits
mailing list