[Libreoffice-commits] .: 17 commits - oox/inc oox/source starmath/source

Lubos Lunak llunak at kemper.freedesktop.org
Tue Nov 29 12:20:42 PST 2011


 oox/inc/oox/mathml/importutils.hxx |   17 ++
 oox/source/mathml/importutils.cxx  |  124 +++++++++++++++--
 oox/source/token/tokens.pl         |   38 ++---
 starmath/source/mathtype.cxx       |    2 
 starmath/source/ooxmlexport.cxx    |    2 
 starmath/source/ooxmlimport.cxx    |  257 ++++++++++++++++++++++++++++++-------
 starmath/source/ooxmlimport.hxx    |    8 +
 7 files changed, 359 insertions(+), 89 deletions(-)

New commits:
commit a115442064c3c6a2ea398895159b62040d079cbb
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 21:18:39 2011 +0100

    import docx m:m

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 530195c..c0d84ab 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -122,6 +122,9 @@ OUString SmOoxmlImport::readOMathArg()
             case OPENING( M_TOKEN( groupChr )):
                 ret += handleGroupChr();
                 break;
+            case OPENING( M_TOKEN( m )):
+                ret += handleM();
+                break;
             case OPENING( M_TOKEN( r )):
                 ret += handleR();
                 break;
@@ -398,6 +401,29 @@ OUString SmOoxmlImport::handleGroupChr()
     return ret;
 }
 
+OUString SmOoxmlImport::handleM()
+{
+    stream.ensureOpeningTag( M_TOKEN( m ));
+    OUString allrows;
+    do // there must be at least one m:mr
+    {
+        stream.ensureOpeningTag( M_TOKEN( mr ));
+        OUString row;
+        do // there must be at least one m:e
+        {
+            if( !row.isEmpty())
+                row += STR( " # " );
+            row += handleE();
+        } while( !stream.atEnd() && stream.currentToken() == OPENING( M_TOKEN( e )));
+        if( !allrows.isEmpty())
+            allrows += STR( " ## " );
+        allrows += row;
+        stream.ensureClosingTag( M_TOKEN( mr ));
+    } while( !stream.atEnd() && stream.currentToken() == OPENING( M_TOKEN( mr )));
+    stream.ensureClosingTag( M_TOKEN( m ));
+    return STR( "matrix {" ) + allrows + STR( "}" );
+}
+
 // NOT complete
 OUString SmOoxmlImport::handleR()
 {
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index c0786bc..05963d6 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -54,6 +54,7 @@ private:
     enum LimLowUpp_t { LimLow, LimUpp };
     rtl::OUString handleLimLowUpp( LimLowUpp_t limlowupp );
     rtl::OUString handleGroupChr();
+    rtl::OUString handleM();
     rtl::OUString handleR();
     rtl::OUString readOMathArg();
     oox::formulaimport::XmlStream& stream;
commit 82c78e8790f341373c84f4b5bae5b3834b7b18ce
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 21:09:43 2011 +0100

    finish reading in while() also when end of stream, just in case

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 2a29d0a..530195c 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -89,7 +89,7 @@ OUString SmOoxmlImport::handleStream()
 OUString SmOoxmlImport::readOMathArg()
 {
     OUString ret;
-    while( stream.currentToken() != CLOSING( stream.currentToken()))
+    while( !stream.atEnd() && stream.currentToken() != CLOSING( stream.currentToken()))
     {
         if( !ret.isEmpty())
             ret += STR( " " );
@@ -409,7 +409,7 @@ OUString SmOoxmlImport::handleR()
         stream.ensureClosingTag( OOX_TOKEN( doc, rPr ));
     }
     OUString text;
-    while( stream.currentToken() != CLOSING( stream.currentToken()))
+    while( !stream.atEnd() && stream.currentToken() != CLOSING( stream.currentToken()))
     {
         switch( stream.currentToken())
         {
commit ad1a6c6d507f2480efa582ad8b864d65dede1314
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 21:06:44 2011 +0100

    improve import of docx m:d

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 6d3e4c9..2a29d0a 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -243,9 +243,9 @@ OUString SmOoxmlImport::handleBorderBox()
 OUString SmOoxmlImport::handleD()
 {
     stream.ensureOpeningTag( M_TOKEN( d ));
-    sal_Unicode opening = '(';
-    sal_Unicode closing = ')';
-    sal_Unicode separator = '|';
+    OUString opening = STR( "(" );
+    OUString closing = STR( ")" );
+    OUString separator = STR( "|" );
     if( XmlStream::Tag dPr = stream.checkOpeningTag( M_TOKEN( dPr )))
     {
         if( XmlStream::Tag begChr = stream.checkOpeningTag( M_TOKEN( begChr )))
@@ -265,15 +265,40 @@ OUString SmOoxmlImport::handleD()
         }
         stream.ensureClosingTag( M_TOKEN( dPr ));
     }
+    if( opening == STR( "{" ))
+        opening = STR( "left lbrace " );
+    if( closing == STR( "}" ))
+        closing = STR( " right rbrace" );
+    if( opening == OUString( sal_Unicode( 0x27e6 )))
+        opening = STR( "left ldbracket " );
+    if( closing == OUString( sal_Unicode( 0x27e7 )))
+        closing = STR( " right rdbracket" );
+    if( opening == STR( "|" ))
+        opening = STR( "left lline " );
+    if( closing == STR( "|" ))
+        closing = STR( " right rline" );
+    if( opening == OUString( sal_Unicode( 0x2225 )))
+        opening = STR( "left ldline " );
+    if( closing == OUString( sal_Unicode( 0x2225 )))
+        closing = STR( " right rdline" );
+    if( opening == OUString( sal_Unicode( 0x2329 )))
+        opening = STR( "left langle " );
+    if( closing == OUString( sal_Unicode( 0x232a )))
+        closing = STR( " right rangle" );
+    // use scalable brackets (the explicit "left" or "right")
+    if( opening == STR( "(" ) || opening == STR( "[" ))
+        opening = STR( "left " ) + opening;
+    if( closing == STR( ")" ) || closing == STR( "]" ))
+        closing = STR( " right " ) + closing;
+    if( separator == STR( "|" )) // plain "|" would be actually "V" (logical or)
+        separator = STR( " mline " );
     OUStringBuffer ret;
     ret.append( opening );
     bool first = true;
     while( stream.currentToken() == OPENING( M_TOKEN( e )))
     {
         if( !first )
-        { // plain "|" would be actually "V" (logical or)
-            ret.append( separator == '|' ? STR( " mline " ) : STR( "|" ));
-        }
+            ret.append( separator );
         first = false;
         ret.append( handleE());
     }
commit d193f127db5fe22207caf0b34d387390a985b398
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 20:27:46 2011 +0100

    docx OMathArg can actually be more than one element

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 99ba16a..6d3e4c9 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -88,36 +88,49 @@ OUString SmOoxmlImport::handleStream()
 
 OUString SmOoxmlImport::readOMathArg()
 {
+    OUString ret;
     while( stream.currentToken() != CLOSING( stream.currentToken()))
     {
+        if( !ret.isEmpty())
+            ret += STR( " " );
         switch( stream.currentToken())
         {
             case OPENING( M_TOKEN( acc )):
-                return handleAcc();
+                ret += handleAcc();
+                break;
             case OPENING( M_TOKEN( bar )):
-                return handleBar();
+                ret += handleBar();
+                break;
             case OPENING( M_TOKEN( borderBox )):
-                return handleBorderBox();
+                ret += handleBorderBox();
+                break;
             case OPENING( M_TOKEN( d )):
-                return handleD();
+                ret += handleD();
+                break;
             case OPENING( M_TOKEN( f )):
-                return handleF();
+                ret += handleF();
+                break;
             case OPENING( M_TOKEN( func )):
-                return handleFunc();
+                ret += handleFunc();
+                break;
             case OPENING( M_TOKEN( limLow )):
-                return handleLimLowUpp( LimLow );
+                ret += handleLimLowUpp( LimLow );
+                break;
             case OPENING( M_TOKEN( limUpp )):
-                return handleLimLowUpp( LimUpp );
+                ret += handleLimLowUpp( LimUpp );
+                break;
             case OPENING( M_TOKEN( groupChr )):
-                return handleGroupChr();
+                ret += handleGroupChr();
+                break;
             case OPENING( M_TOKEN( r )):
-                return handleR();
+                ret += handleR();
+                break;
             default:
                 stream.handleUnexpectedTag();
                 break;
         }
     }
-    return OUString();
+    return ret;
 }
 
 OUString SmOoxmlImport::handleAcc()
commit dff36f4c4c75a94cb6ef61f34d03fa2503def92a
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 20:25:39 2011 +0100

    docx m:r can contain multiple m:t

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 300d818..99ba16a 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -370,13 +370,26 @@ OUString SmOoxmlImport::handleR()
 //        stream.ensureClosingTag( OOX_TOKEN( doc, rFonts ));
         stream.ensureClosingTag( OOX_TOKEN( doc, rPr ));
     }
-    // TODO can there be more t's ?
-    XmlStream::Tag rtag = stream.ensureOpeningTag( M_TOKEN( t ));
-    // TODO bail out if failure?
-    OUString text = rtag.text;
-    if( rtag.attribute( OOX_TOKEN( xml, space )) != STR( "preserve" ))
-        text = text.trim();
-    stream.ensureClosingTag( M_TOKEN( t ));
+    OUString text;
+    while( stream.currentToken() != CLOSING( stream.currentToken()))
+    {
+        switch( stream.currentToken())
+        {
+            case OPENING( M_TOKEN( t )):
+            {
+                XmlStream::Tag rtag = stream.ensureOpeningTag( M_TOKEN( t ));
+                if( rtag.attribute( OOX_TOKEN( xml, space )) != STR( "preserve" ))
+                    text += rtag.text.trim();
+                else
+                    text += rtag.text;
+                stream.ensureClosingTag( M_TOKEN( t ));
+                break;
+            }
+            default:
+                stream.handleUnexpectedTag();
+                break;
+        }
+    }
     stream.ensureClosingTag( M_TOKEN( r ));
     return text;
 }
commit 34e2e7dd8441148fa8f05c1e9ca324003058ed11
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 20:19:11 2011 +0100

    implement docx m:groupChr

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 760505c..300d818 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -108,6 +108,8 @@ OUString SmOoxmlImport::readOMathArg()
                 return handleLimLowUpp( LimLow );
             case OPENING( M_TOKEN( limUpp )):
                 return handleLimLowUpp( LimUpp );
+            case OPENING( M_TOKEN( groupChr )):
+                return handleGroupChr();
             case OPENING( M_TOKEN( r )):
                 return handleR();
             default:
@@ -319,6 +321,9 @@ OUString SmOoxmlImport::handleFunc()
     stream.ensureOpeningTag( M_TOKEN( fName ));
     OUString fname = readOMathArg();
     stream.ensureClosingTag( 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( "}" );
     stream.ensureClosingTag( M_TOKEN( func ));
     return ret;
@@ -333,7 +338,26 @@ OUString SmOoxmlImport::handleLimLowUpp( LimLowUpp_t limlowupp )
     OUString lim = readOMathArg();
     stream.ensureClosingTag( M_TOKEN( lim ));
     stream.ensureClosingTag( token );
-    return e + STR( " from {" ) + lim + STR( "}" );
+    return e + STR( " {" ) + lim + STR( "}" );
+}
+
+OUString SmOoxmlImport::handleGroupChr()
+{
+    stream.ensureOpeningTag( M_TOKEN( groupChr ));
+    enum pos_t { top, bot } pos = bot;
+    if( stream.checkOpeningTag( M_TOKEN( groupChrPr )))
+    {
+        if( XmlStream::Tag posTag = stream.checkOpeningTag( M_TOKEN( pos )))
+        {
+            if( posTag.attribute( M_TOKEN( val ), STR( "bot" )) == STR( "top" ))
+                pos = top;
+            stream.ensureClosingTag( M_TOKEN( pos ));
+        }
+        stream.ensureClosingTag( M_TOKEN( groupChrPr ));
+    }
+    OUString ret = STR( "{ " ) + handleE() + ( pos == top ? STR( "} overbrace" ) : STR( "} underbrace" ));
+    stream.ensureClosingTag( M_TOKEN( groupChr ));
+    return ret;
 }
 
 // NOT complete
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index af7d1ca..c0786bc 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -53,6 +53,7 @@ private:
     rtl::OUString handleFunc();
     enum LimLowUpp_t { LimLow, LimUpp };
     rtl::OUString handleLimLowUpp( LimLowUpp_t limlowupp );
+    rtl::OUString handleGroupChr();
     rtl::OUString handleR();
     rtl::OUString readOMathArg();
     oox::formulaimport::XmlStream& stream;
commit 6e91e7d4e7c283e40ae3f6a3fe520da392d84bb5
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 19:58:24 2011 +0100

    implement m:func, m:limLow, m:limUpp

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 6fc869c..760505c 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -102,6 +102,12 @@ OUString SmOoxmlImport::readOMathArg()
                 return handleD();
             case OPENING( M_TOKEN( f )):
                 return handleF();
+            case OPENING( M_TOKEN( func )):
+                return handleFunc();
+            case OPENING( M_TOKEN( limLow )):
+                return handleLimLowUpp( LimLow );
+            case OPENING( M_TOKEN( limUpp )):
+                return handleLimLowUpp( LimUpp );
             case OPENING( M_TOKEN( r )):
                 return handleR();
             default:
@@ -306,6 +312,30 @@ OUString SmOoxmlImport::handleF()
     }
 }
 
+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 ret = fname + STR( " {" ) + handleE() + STR( "}" );
+    stream.ensureClosingTag( M_TOKEN( func ));
+    return ret;
+}
+
+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 ));
+    stream.ensureClosingTag( token );
+    return e + STR( " from {" ) + lim + STR( "}" );
+}
+
 // NOT complete
 OUString SmOoxmlImport::handleR()
 {
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index a32cda3..af7d1ca 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -50,6 +50,9 @@ private:
     rtl::OUString handleD();
     rtl::OUString handleE();
     rtl::OUString handleF();
+    rtl::OUString handleFunc();
+    enum LimLowUpp_t { LimLow, LimUpp };
+    rtl::OUString handleLimLowUpp( LimLowUpp_t limlowupp );
     rtl::OUString handleR();
     rtl::OUString readOMathArg();
     oox::formulaimport::XmlStream& stream;
commit 49987bbb47962f46b2522345a764bb99fe5a742a
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 19:57:06 2011 +0100

    fix reading when the next tag can be one of several

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 566b3d7..6fc869c 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -73,7 +73,7 @@ OUString SmOoxmlImport::handleStream()
     {
         // 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 ));
+        OUString item = readOMathArg();
         if( item.isEmpty())
             continue;
         if( !ret.isEmpty())
@@ -86,42 +86,30 @@ OUString SmOoxmlImport::handleStream()
 }
 
 
-OUString SmOoxmlImport::readOMathArg( int endtoken )
+OUString SmOoxmlImport::readOMathArg()
 {
-    OUString ret;
-    while( !stream.atEnd())
+    while( stream.currentToken() != CLOSING( stream.currentToken()))
     {
-        XmlStream::Tag tag = stream.currentTag();
-        if( tag.token == CLOSING( endtoken ))
-            break;
-        if( !ret.isEmpty())
-            ret += STR( " " );
-        switch( tag.token )
+        switch( stream.currentToken())
         {
             case OPENING( M_TOKEN( acc )):
-                ret += handleAcc();
-                break;
+                return handleAcc();
             case OPENING( M_TOKEN( bar )):
-                ret += handleBar();
-                break;
+                return handleBar();
             case OPENING( M_TOKEN( borderBox )):
-                ret += handleBorderBox();
-                break;
+                return handleBorderBox();
             case OPENING( M_TOKEN( d )):
-                ret += handleD();
-                break;
+                return handleD();
             case OPENING( M_TOKEN( f )):
-                ret += handleF();
-                break;
+                return handleF();
             case OPENING( M_TOKEN( r )):
-                ret += handleR();
-                break;
+                return handleR();
             default:
                 stream.handleUnexpectedTag();
                 break;
         }
     }
-    return ret;
+    return OUString();
 }
 
 OUString SmOoxmlImport::handleAcc()
@@ -276,7 +264,7 @@ OUString SmOoxmlImport::handleD()
 OUString SmOoxmlImport::handleE()
 {
     stream.ensureOpeningTag( M_TOKEN( e ));
-    OUString ret = readOMathArg( M_TOKEN( e ));
+    OUString ret = readOMathArg();
     stream.ensureClosingTag( M_TOKEN( e ));
     return ret;
 }
@@ -301,10 +289,10 @@ OUString SmOoxmlImport::handleF()
         stream.ensureClosingTag( M_TOKEN( fPr ));
     }
     stream.ensureOpeningTag( M_TOKEN( num ));
-    OUString num = readOMathArg( M_TOKEN( num ));
+    OUString num = readOMathArg();
     stream.ensureClosingTag( M_TOKEN( num ));
     stream.ensureOpeningTag( M_TOKEN( den ));
-    OUString den = readOMathArg( M_TOKEN( den ));
+    OUString den = readOMathArg();
     stream.ensureClosingTag( M_TOKEN( den ));
     stream.ensureClosingTag( M_TOKEN( f ));
     if( operation == bar )
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index 6c31e0d..a32cda3 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -51,7 +51,7 @@ private:
     rtl::OUString handleE();
     rtl::OUString handleF();
     rtl::OUString handleR();
-    rtl::OUString readOMathArg( int endtoken );
+    rtl::OUString readOMathArg();
     oox::formulaimport::XmlStream& stream;
 };
 
commit 5c897753a6cc16f1b9b8c51721cb93e80b3bfc01
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 19:54:54 2011 +0100

    better debug output when skipping an element

diff --git a/oox/inc/oox/mathml/importutils.hxx b/oox/inc/oox/mathml/importutils.hxx
index 68f6a0a..9f75930 100644
--- a/oox/inc/oox/mathml/importutils.hxx
+++ b/oox/inc/oox/mathml/importutils.hxx
@@ -163,7 +163,8 @@ public:
     void handleUnexpectedTag();
 protected:
     Tag checkTag( int token, bool optional );
-    bool recoverAndFindTagHelper( int token, bool silent );
+    bool recoverAndFindTagInternal( int token, bool silent );
+    void skipElementInternal( int token, bool silent );
     std::vector< Tag > tags;
     unsigned int pos;
 };
diff --git a/oox/source/mathml/importutils.cxx b/oox/source/mathml/importutils.cxx
index 703e96b..912f0f6 100644
--- a/oox/source/mathml/importutils.cxx
+++ b/oox/source/mathml/importutils.cxx
@@ -229,7 +229,7 @@ XmlStream::Tag XmlStream::checkTag( int token, bool optional )
     if( optional )
     { // avoid printing debug messages about skipping tags if the optional one
       // will not be found and the position will be reset back
-        if( currentToken() != token && !recoverAndFindTagHelper( token, true ))
+        if( currentToken() != token && !recoverAndFindTagInternal( token, true ))
         {
             pos = savedPos;
             return Tag();
@@ -253,10 +253,10 @@ XmlStream::Tag XmlStream::checkTag( int token, bool optional )
 
 bool XmlStream::recoverAndFindTag( int token )
 {
-    return recoverAndFindTagHelper( token, false );
+    return recoverAndFindTagInternal( token, false );
 }
 
-bool XmlStream::recoverAndFindTagHelper( int token, bool silent )
+bool XmlStream::recoverAndFindTagInternal( int token, bool silent )
 {
     int depth = 0;
     for(;
@@ -305,15 +305,25 @@ bool XmlStream::recoverAndFindTagHelper( int token, bool silent )
 
 void XmlStream::skipElement( int token )
 {
+    return skipElementInternal( token, true ); // no debug about skipping if called from outside
+}
+
+void XmlStream::skipElementInternal( int token, bool silent )
+{
     int closing = ( token & ~TAG_OPENING ) | TAG_CLOSING; // make it a closing tag
     assert( currentToken() == OPENING( token ));
+    if( !silent )
+        fprintf( stderr, "Skipping unexpected element %s\n", CSTR( tokenToString( currentToken())));
     moveToNextTag();
     // and just find the matching closing tag
     if( recoverAndFindTag( closing ))
     {
+        if( !silent )
+            fprintf( stderr, "Skipped unexpected element %s\n", CSTR( tokenToString( token )));
         moveToNextTag(); // and skip it too
         return;
     }
+    // this one is an unexpected problem, do not silent it
     fprintf( stderr, "Expected end of element %s not found.\n", CSTR( tokenToString( token )));
 }
 
@@ -323,10 +333,11 @@ void XmlStream::handleUnexpectedTag()
         return;
     if( currentToken() == CLOSING( currentToken()))
     {
+        fprintf( stderr, "Skipping unexpected tag %s\n", CSTR( tokenToString( currentToken())));
         moveToNextTag(); // just skip it
         return;
     }
-    skipElement( currentToken()); // otherwise skip the entire element
+    skipElementInternal( currentToken(), false ); // otherwise skip the entire element
 }
 
 
commit f92bb660961a3f2dee392eac214bdd568ba2ea52
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 19:17:35 2011 +0100

    no debug about skipping tags if not actually skipping

diff --git a/oox/inc/oox/mathml/importutils.hxx b/oox/inc/oox/mathml/importutils.hxx
index a90028d..68f6a0a 100644
--- a/oox/inc/oox/mathml/importutils.hxx
+++ b/oox/inc/oox/mathml/importutils.hxx
@@ -163,6 +163,7 @@ public:
     void handleUnexpectedTag();
 protected:
     Tag checkTag( int token, bool optional );
+    bool recoverAndFindTagHelper( int token, bool silent );
     std::vector< Tag > tags;
     unsigned int pos;
 };
diff --git a/oox/source/mathml/importutils.cxx b/oox/source/mathml/importutils.cxx
index 3a21bad..703e96b 100644
--- a/oox/source/mathml/importutils.cxx
+++ b/oox/source/mathml/importutils.cxx
@@ -42,6 +42,11 @@
 #define CSTR( str ) ( rtl::OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr())
 
 
+// HACK - TODO convert to the real debug stuff
+#undef SAL_LOG_LEVEL
+#define SAL_LOG_LEVEL 2
+
+
 using namespace com::sun::star;
 using rtl::OUString;
 
@@ -220,6 +225,17 @@ XmlStream::Tag XmlStream::checkTag( int token, bool optional )
 {
     // either it's the following tag, or find it
     int savedPos = pos;
+#if SAL_LOG_LEVEL >= 2
+    if( optional )
+    { // avoid printing debug messages about skipping tags if the optional one
+      // will not be found and the position will be reset back
+        if( currentToken() != token && !recoverAndFindTagHelper( token, true ))
+        {
+            pos = savedPos;
+            return Tag();
+        }
+    }
+#endif
     if( currentToken() == token || recoverAndFindTag( token ))
     {
         Tag ret = currentTag();
@@ -237,6 +253,11 @@ XmlStream::Tag XmlStream::checkTag( int token, bool optional )
 
 bool XmlStream::recoverAndFindTag( int token )
 {
+    return recoverAndFindTagHelper( token, false );
+}
+
+bool XmlStream::recoverAndFindTagHelper( int token, bool silent )
+{
     int depth = 0;
     for(;
          !atEnd();
@@ -246,17 +267,20 @@ bool XmlStream::recoverAndFindTag( int token )
         {
             if( currentToken() == OPENING( currentToken()))
             {
-                fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
+                if( !silent )
+                    fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
                 ++depth;
             }
             else if( currentToken() == CLOSING( currentToken()))
-            { // TODO debug output without the OPENING/CLOSING bits set
-                fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
+            {
+                if( !silent )
+                    fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
                 --depth;
             }
             else
             {
-                fprintf( stderr, "Malformed token %d (%s)\n", currentToken(), CSTR( tokenToString( currentToken())));
+                if( !silent )
+                    fprintf( stderr, "Malformed token %d (%s)\n", currentToken(), CSTR( tokenToString( currentToken())));
                 abort();
             }
             continue;
@@ -267,13 +291,15 @@ bool XmlStream::recoverAndFindTag( int token )
             return false; // that would be leaving current element, so not found
         if( currentToken() == OPENING( currentToken()))
         {
-            fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
+            if( !silent )
+                fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
             ++depth;
         }
         else
             abort();
     }
-    fprintf( stderr, "Unexpected end of stream reached.\n" );
+    if( !silent )
+        fprintf( stderr, "Unexpected end of stream reached.\n" );
     return false;
 }
 
commit 6bbca34846fd9e2d26d035dc7255bb3d77e2869b
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 19:05:52 2011 +0100

    make debug output print tags as strings rather than id numbers

diff --git a/oox/inc/oox/mathml/importutils.hxx b/oox/inc/oox/mathml/importutils.hxx
index 1bf7157..a90028d 100644
--- a/oox/inc/oox/mathml/importutils.hxx
+++ b/oox/inc/oox/mathml/importutils.hxx
@@ -162,7 +162,7 @@ public:
     */
     void handleUnexpectedTag();
 protected:
-    Tag checkTag( int token, bool optional, const char* txt );
+    Tag checkTag( int token, bool optional );
     std::vector< Tag > tags;
     unsigned int pos;
 };
diff --git a/oox/source/mathml/importutils.cxx b/oox/source/mathml/importutils.cxx
index 69fa1fc..3a21bad 100644
--- a/oox/source/mathml/importutils.cxx
+++ b/oox/source/mathml/importutils.cxx
@@ -31,10 +31,19 @@
 #include <assert.h>
 #include <stdio.h>
 
+#include <oox/token/namespacemap.hxx>
+#include <oox/token/tokenmap.hxx>
 #include <oox/token/tokens.hxx>
 #include <oox/token/namespaces.hxx>
+#include <rtl/string.hxx>
+
+// *sigh*
+#define STR( str ) OUString( RTL_CONSTASCII_USTRINGPARAM( str ))
+#define CSTR( str ) ( rtl::OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr())
+
 
 using namespace com::sun::star;
+using rtl::OUString;
 
 namespace oox
 {
@@ -67,6 +76,40 @@ AttributeListBuilder::AttributeListBuilder( const uno::Reference< xml::sax::XFas
         attrs[ pFastAttr[ i ].Token ] = pFastAttr[ i ].Value;
     }
 }
+
+static OUString tokenToString( int token )
+{
+    OUString tokenname = StaticTokenMap::get().getUnicodeTokenName( token & TOKEN_MASK );
+    if( tokenname.isEmpty())
+        tokenname = STR( "???" );
+    int nmsp = ( token & NMSP_MASK & ~( TAG_OPENING | TAG_CLOSING ));
+#if 0 // this is awfully long
+    OUString namespacename = StaticNamespaceMap::get().count( nmsp ) != 0
+        ? StaticNamespaceMap::get()[ nmsp ] : STR( "???" );
+#else
+    OUString namespacename;
+    // only few are needed actually
+    switch( nmsp )
+    {
+        case NMSP_officeMath:
+            namespacename = STR( "m" );
+            break;
+        case NMSP_doc:
+            namespacename = STR( "w" );
+            break;
+        default:
+            namespacename = STR( "?" );
+            break;
+    }
+#endif
+    if( token == OPENING( token ))
+        return STR( "<" ) + namespacename + STR( ":" ) + tokenname + STR ( ">" );
+    if( token == CLOSING( token ))
+        return STR( "</" ) + namespacename + STR( ":" ) + tokenname + STR ( ">" );
+    // just the name itself, not specified whether opening or closing
+    return namespacename + STR( ":" ) + tokenname;
+}
+
 } // namespace
 
 bool XmlStream::AttributeList::hasAttribute( int token ) const
@@ -93,8 +136,7 @@ bool XmlStream::AttributeList::attribute( int token, bool def ) const
         if( find->second.equalsIgnoreAsciiCaseAscii( "false" ) || find->second.equalsIgnoreAsciiCaseAscii( "off" )
             || find->second.equalsIgnoreAsciiCaseAscii( "f" ) || find->second.equalsIgnoreAsciiCaseAscii( "0" ))
             return false;
-        fprintf( stderr, "Cannot convert \'%s\' to bool.\n",
-            rtl::OUStringToOString( find->second, RTL_TEXTENCODING_UTF8 ).getStr());
+        fprintf( stderr, "Cannot convert \'%s\' to bool.\n", CSTR( find->second ));
     }
     return def;
 }
@@ -107,8 +149,7 @@ sal_Unicode XmlStream::AttributeList::attribute( int token, sal_Unicode def ) co
         if( find->second.getLength() >= 1 )
         {
             if( find->second.getLength() != 1 )
-                fprintf( stderr, "Cannot convert \'%s\' to sal_Unicode, stripping.\n",
-                    rtl::OUStringToOString( find->second, RTL_TEXTENCODING_UTF8 ).getStr());
+                fprintf( stderr, "Cannot convert \'%s\' to sal_Unicode, stripping.\n", CSTR( find->second ));
             return find->second[ 0 ];
         }
     }
@@ -162,20 +203,20 @@ void XmlStream::moveToNextTag()
 
 XmlStream::Tag XmlStream::ensureOpeningTag( int token )
 {
-    return checkTag( OPENING( token ), false, "opening" );
+    return checkTag( OPENING( token ), false );
 }
 
 XmlStream::Tag XmlStream::checkOpeningTag( int token )
 {
-    return checkTag( OPENING( token ), true, "opening" );
+    return checkTag( OPENING( token ), true );
 }
 
 void XmlStream::ensureClosingTag( int token )
 {
-    checkTag( CLOSING( token ), false, "closing" );
+    checkTag( CLOSING( token ), false );
 }
 
-XmlStream::Tag XmlStream::checkTag( int token, bool optional, const char* txt )
+XmlStream::Tag XmlStream::checkTag( int token, bool optional )
 {
     // either it's the following tag, or find it
     int savedPos = pos;
@@ -190,7 +231,7 @@ XmlStream::Tag XmlStream::checkTag( int token, bool optional, const char* txt )
         pos = savedPos;
         return Tag();
     }
-    fprintf( stderr, "Expected %s tag %d not found.\n", txt, token );
+    fprintf( stderr, "Expected tag %s not found.\n", CSTR( tokenToString( token )));
     return Tag();
 }
 
@@ -205,17 +246,17 @@ bool XmlStream::recoverAndFindTag( int token )
         {
             if( currentToken() == OPENING( currentToken()))
             {
-                fprintf( stderr, "Skipping opening tag %d\n", currentToken());
+                fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
                 ++depth;
             }
             else if( currentToken() == CLOSING( currentToken()))
             { // TODO debug output without the OPENING/CLOSING bits set
-                fprintf( stderr, "Skipping closing tag %d\n", currentToken());
+                fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
                 --depth;
             }
             else
             {
-                fprintf( stderr, "Malformed token %d\n", currentToken());
+                fprintf( stderr, "Malformed token %d (%s)\n", currentToken(), CSTR( tokenToString( currentToken())));
                 abort();
             }
             continue;
@@ -226,7 +267,7 @@ bool XmlStream::recoverAndFindTag( int token )
             return false; // that would be leaving current element, so not found
         if( currentToken() == OPENING( currentToken()))
         {
-            fprintf( stderr, "Skipping opening tag %d\n", currentToken());
+            fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
             ++depth;
         }
         else
@@ -247,7 +288,7 @@ void XmlStream::skipElement( int token )
         moveToNextTag(); // and skip it too
         return;
     }
-    fprintf( stderr, "Expected end of element %d not found.\n", token );
+    fprintf( stderr, "Expected end of element %s not found.\n", CSTR( tokenToString( token )));
 }
 
 void XmlStream::handleUnexpectedTag()
commit eb31865c852ac1843ab6060fdc401cf5cc2bf13c
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 18:09:46 2011 +0100

    merge processing of OMathArg and OMath, for now

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 9dcad23..566b3d7 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -69,10 +69,30 @@ 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 ));
commit 09f94dc9d8d4b9501179399249dc2be7b95f8de8
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 16:31:30 2011 +0100

    m:f docx import is reasonably done

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 71d2189..9dcad23 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -289,7 +289,6 @@ OUString SmOoxmlImport::readOMathArg( int endtoken )
     return ret;
 }
 
-// NOT complete
 OUString SmOoxmlImport::handleF()
 {
     stream.ensureOpeningTag( M_TOKEN( f ));
commit 020eddb20aa6fe68851dbc05aafeaf1eca0f8c11
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 16:22:13 2011 +0100

    try to avoid unnecessary space in created formula

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 2394fa5..71d2189 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -74,22 +74,24 @@ OUString SmOoxmlImport::handleStream()
         XmlStream::Tag tag = stream.currentTag();
         if( tag.token == CLOSING( M_TOKEN( oMath )))
             break;
+        if( !ret.isEmpty())
+            ret += STR( " " );
         switch( tag.token )
         {
             case OPENING( M_TOKEN( acc )):
-                ret += STR( " " ) + handleAcc();
+                ret += handleAcc();
                 break;
             case OPENING( M_TOKEN( bar )):
-                ret += STR( " " ) + handleBar();
+                ret += handleBar();
                 break;
             case OPENING( M_TOKEN( borderBox )):
-                ret += STR( " " ) + handleBorderBox();
+                ret += handleBorderBox();
                 break;
             case OPENING( M_TOKEN( d )):
-                ret += STR( " " ) + handleD();
+                ret += handleD();
                 break;
             case OPENING( M_TOKEN( f )):
-                ret += STR( " " ) + handleF();
+                ret += handleF();
                 break;
             default:
                 stream.handleUnexpectedTag();
@@ -266,16 +268,18 @@ OUString SmOoxmlImport::readOMathArg( int endtoken )
         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 += STR( " " ) + handleAcc();
+                ret += handleAcc();
                 break;
             case OPENING( M_TOKEN( f )):
-                ret += STR( " " ) + handleF();
+                ret += handleF();
                 break;
             case OPENING( M_TOKEN( r )):
-                ret += STR( " " ) + handleR();
+                ret += handleR();
                 break;
             default:
                 stream.handleUnexpectedTag();
commit 7bdccfdc1d3dc070a19a604c4c76b28428cc5a0e
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 16:19:53 2011 +0100

    implement import of docx mathml m:d

diff --git a/oox/inc/oox/mathml/importutils.hxx b/oox/inc/oox/mathml/importutils.hxx
index ca212aa..1bf7157 100644
--- a/oox/inc/oox/mathml/importutils.hxx
+++ b/oox/inc/oox/mathml/importutils.hxx
@@ -76,6 +76,8 @@ public:
         bool hasAttribute( int token ) const;
         rtl::OUString attribute( int token, const rtl::OUString& def = rtl::OUString()) const;
         bool attribute( int token, bool def ) const;
+        sal_Unicode attribute( int token, sal_Unicode def ) const;
+        // when adding more attribute() overloads, add also to XmlStream itself
     protected:
         std::map< int, rtl::OUString > attrs;
     };
@@ -100,6 +102,11 @@ public:
         */
         bool attribute( int token, bool def ) const;
         /**
+         @overload
+        */
+        sal_Unicode attribute( int token, sal_Unicode def ) const;
+        // when adding more attribute() overloads, add also to XmlStream::AttributeList and inline below
+        /**
          Converts to true if the tag has a valid token, false otherwise. Allows simple
          usage in if(), for example 'if( XmlStream::Tag foo = stream.checkOpeningTag( footoken ))'.
         */
@@ -190,6 +197,12 @@ bool XmlStream::Tag::attribute( int t, bool def ) const
     return attributes.attribute( t, def );
 }
 
+inline
+sal_Unicode XmlStream::Tag::attribute( int t, sal_Unicode def ) const
+{
+    return attributes.attribute( t, def );
+}
+
 } // namespace
 } // namespace
 
diff --git a/oox/source/mathml/importutils.cxx b/oox/source/mathml/importutils.cxx
index c6bf80c..69fa1fc 100644
--- a/oox/source/mathml/importutils.cxx
+++ b/oox/source/mathml/importutils.cxx
@@ -99,6 +99,22 @@ bool XmlStream::AttributeList::attribute( int token, bool def ) const
     return def;
 }
 
+sal_Unicode XmlStream::AttributeList::attribute( int token, sal_Unicode def ) const
+{
+    std::map< int, rtl::OUString >::const_iterator find = attrs.find( token );
+    if( find != attrs.end())
+    {
+        if( find->second.getLength() >= 1 )
+        {
+            if( find->second.getLength() != 1 )
+                fprintf( stderr, "Cannot convert \'%s\' to sal_Unicode, stripping.\n",
+                    rtl::OUStringToOString( find->second, RTL_TEXTENCODING_UTF8 ).getStr());
+            return find->second[ 0 ];
+        }
+    }
+    return def;
+}
+
 XmlStream::Tag::Tag( int t, const uno::Reference< xml::sax::XFastAttributeList >& a, const rtl::OUString& txt )
 : token( t )
 , attributes( AttributeListBuilder( a ))
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 4b187ad..2394fa5 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -35,6 +35,7 @@
 using namespace oox;
 using namespace oox::formulaimport;
 using rtl::OUString;
+using rtl::OUStringBuffer;
 
 /*
 The primary internal data structure for the formula is the text representation
@@ -84,6 +85,9 @@ OUString SmOoxmlImport::handleStream()
             case OPENING( M_TOKEN( borderBox )):
                 ret += STR( " " ) + handleBorderBox();
                 break;
+            case OPENING( M_TOKEN( d )):
+                ret += STR( " " ) + handleD();
+                break;
             case OPENING( M_TOKEN( f )):
                 ret += STR( " " ) + handleF();
                 break;
@@ -93,6 +97,7 @@ OUString SmOoxmlImport::handleStream()
         }
     }
     stream.ensureClosingTag( M_TOKEN( oMath ));
+    fprintf(stderr, "FORMULA: %s\n", rtl::OUStringToOString( ret, RTL_TEXTENCODING_UTF8 ).getStr());
     return ret;
 }
 
@@ -203,6 +208,48 @@ OUString SmOoxmlImport::handleBorderBox()
     return e;
 }
 
+OUString SmOoxmlImport::handleD()
+{
+    stream.ensureOpeningTag( M_TOKEN( d ));
+    sal_Unicode opening = '(';
+    sal_Unicode closing = ')';
+    sal_Unicode separator = '|';
+    if( XmlStream::Tag dPr = stream.checkOpeningTag( M_TOKEN( dPr )))
+    {
+        if( XmlStream::Tag begChr = stream.checkOpeningTag( M_TOKEN( begChr )))
+        {
+            opening = begChr.attribute( M_TOKEN( val ), opening );
+            stream.ensureClosingTag( M_TOKEN( begChr ));
+        }
+        if( XmlStream::Tag sepChr = stream.checkOpeningTag( M_TOKEN( sepChr )))
+        {
+            separator = sepChr.attribute( M_TOKEN( val ), separator );
+            stream.ensureClosingTag( M_TOKEN( sepChr ));
+        }
+        if( XmlStream::Tag endChr = stream.checkOpeningTag( M_TOKEN( endChr )))
+        {
+            closing = endChr.attribute( M_TOKEN( val ), closing );
+            stream.ensureClosingTag( M_TOKEN( endChr ));
+        }
+        stream.ensureClosingTag( M_TOKEN( dPr ));
+    }
+    OUStringBuffer ret;
+    ret.append( opening );
+    bool first = true;
+    while( stream.currentToken() == OPENING( M_TOKEN( e )))
+    {
+        if( !first )
+        { // plain "|" would be actually "V" (logical or)
+            ret.append( separator == '|' ? STR( " mline " ) : STR( "|" ));
+        }
+        first = false;
+        ret.append( handleE());
+    }
+    ret.append( closing );
+    stream.ensureClosingTag( M_TOKEN( d ));
+    return ret.makeStringAndClear();
+}
+
 OUString SmOoxmlImport::handleE()
 {
     stream.ensureOpeningTag( M_TOKEN( e ));
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index 8d587f7..6c31e0d 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -47,6 +47,7 @@ private:
     rtl::OUString handleAcc();
     rtl::OUString handleBar();
     rtl::OUString handleBorderBox();
+    rtl::OUString handleD();
     rtl::OUString handleE();
     rtl::OUString handleF();
     rtl::OUString handleR();
commit e9ed9d4d4548751b50d45b7082f776d6e69204e3
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 15:40:51 2011 +0100

    do no re-sort oox tokens
    
    Search me why writerfilter rolls its own, but otherwise they use
    different ids, because writerfilter does not sort them.

diff --git a/oox/source/token/tokens.pl b/oox/source/token/tokens.pl
index a951cee..7aefd28 100644
--- a/oox/source/token/tokens.pl
+++ b/oox/source/token/tokens.pl
@@ -30,25 +30,6 @@ $ARGV1 = shift @ARGV;
 $ARGV2 = shift @ARGV;
 $ARGV3 = shift @ARGV;
 
-open( INFILE, $ARGV0 ) or die "Error: cannot open input file: $!";
-my %tokens;
-while ( <INFILE> )
-{
-    # trim newline
-    chomp( $_ );
-    # trim leading/trailing whitespace
-    $_ =~ s/^\s*//g;
-    $_ =~ s/\s*$//g;
-    # check for valid characters
-    $_ =~ /^[a-zA-Z0-9-_]+$/ or die "Error: invalid character in token '$_'";
-    $id = "XML_$_";
-    $id =~ s/-/_/g;
-    $tokens{$_} = $id;
-}
-close ( INFILE );
-
-# generate output files
-
 open ( IDFILE, ">$ARGV1" ) or die "Error: cannot open output file: $!";
 open ( NAMEFILE, ">$ARGV2" ) or die "Error: cannot open output file: $!";
 open ( GPERFFILE, ">$ARGV3" ) or die "Error: cannot open output file: $!";
@@ -63,14 +44,27 @@ print( GPERFFILE "    sal_Int32 nToken;\n" );
 print( GPERFFILE "};\n" );
 print( GPERFFILE "%%\n" );
 
+open( INFILE, $ARGV0 ) or die "Error: cannot open input file: $!";
+
 $i = 0;
-foreach( sort( keys( %tokens ) ) )
+while ( <INFILE> )
 {
-    print( IDFILE "const sal_Int32 $tokens{$_} = $i;\n" );
+    # trim newline
+    chomp( $_ );
+    # trim leading/trailing whitespace
+    $_ =~ s/^\s*//g;
+    $_ =~ s/\s*$//g;
+    # check for valid characters
+    $_ =~ /^[a-zA-Z0-9-_]+$/ or die "Error: invalid character in token '$_'";
+    $id = "XML_$_";
+    $id =~ s/-/_/g;
+    $tokens{$_} = $id;
+    print( IDFILE "const sal_Int32 $id = $i;\n" );
     print( NAMEFILE "\"$_\",\n" );
-    print( GPERFFILE "$_,$tokens{$_}\n" );
+    print( GPERFFILE "$_,$id\n" );
     ++$i;
 }
+close ( INFILE );
 
 print( IDFILE "const sal_Int32 XML_TOKEN_COUNT = $i;\n" );
 print( GPERFFILE "%%\n" );
commit 86927dd6e88fae25e55748cb3a475518351b8dd7
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Nov 29 14:27:13 2011 +0100

    static const

diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx
index 6306135..bd5386f 100644
--- a/starmath/source/mathtype.cxx
+++ b/starmath/source/mathtype.cxx
@@ -36,7 +36,7 @@
 static sal_Unicode Convert(sal_Unicode nIn)
 {
     //Find the best match in accepted unicode for our private area symbols
-    static sal_Unicode aStarMathPrivateToUnicode[] =
+    static const sal_Unicode aStarMathPrivateToUnicode[] =
     {
         0x2030, 0xF613, 0xF612, 0x002B, 0x003C, 0x003E, 0xE425, 0xE421, 0xE088, 0x2208,
         0x0192, 0x2026, 0x2192, 0x221A, 0x221A, 0x221A, 0xE090, 0x005E, 0x02C7, 0x02D8,
diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index 191ace9..5e18ad4 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -39,7 +39,7 @@ using namespace oox::core;
 static sal_Unicode Convert(sal_Unicode nIn)
 {
     //Find the best match in accepted unicode for our private area symbols
-    static sal_Unicode aStarMathPrivateToUnicode[] =
+    static const sal_Unicode aStarMathPrivateToUnicode[] =
     {
         0x2030, 0xF613, 0xF612, 0x002B, 0x003C, 0x003E, 0xE425, 0xE421, 0xE088, 0x2208,
         0x0192, 0x2026, 0x2192, 0x221A, 0x221A, 0x221A, 0xE090, 0x005E, 0x02C7, 0x02D8,


More information about the Libreoffice-commits mailing list