[Libreoffice-commits] core.git: starmath/source

Frédéric Wang fred.wang at free.fr
Tue Jul 2 16:26:10 PDT 2013


 starmath/source/mathmlexport.cxx |   26 ++++++++++++--------------
 starmath/source/mathmlexport.hxx |    3 ++-
 2 files changed, 14 insertions(+), 15 deletions(-)

New commits:
commit 6f86d931b4266d00fec75c0124ac9fc3026a4f1b
Author: Frédéric Wang <fred.wang at free.fr>
Date:   Sun Jun 30 17:34:40 2013 +0200

     fdo#66283 - MathML export: remove useless mrow/mstyle with font commands
    
    Change-Id: I57870a22ef915950fe177dcb75ab31a25f2520c8
    Reviewed-on: https://gerrit.libreoffice.org/4634
    Reviewed-by: Khaled Hosny <khaledhosny at eglug.org>
    Tested-by: Khaled Hosny <khaledhosny at eglug.org>

diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index a10765e..a523693 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -780,13 +780,15 @@ void SmXMLExport::ExportUnaryHorizontal(const SmNode *pNode, int nLevel)
     ExportExpression(pNode, nLevel);
 }
 
-void SmXMLExport::ExportExpression(const SmNode *pNode, int nLevel)
+void SmXMLExport::ExportExpression(const SmNode *pNode, int nLevel,
+                                   bool bNoMrowContainer /*=false*/)
 {
     SvXMLElementExport *pRow=0;
     sal_uLong  nSize = pNode->GetNumSubNodes();
 
     // #i115443: nodes of type expression always need to be grouped with mrow statement
-    if (nSize > 1 || (pNode && pNode->GetType() == NEXPRESSION))
+    if (!bNoMrowContainer &&
+        (nSize > 1 || (pNode && pNode->GetType() == NEXPRESSION)))
         pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW, sal_True, sal_True);
 
     for (sal_uInt16 i = 0; i < nSize; i++)
@@ -1290,8 +1292,6 @@ static bool lcl_HasEffectOnMathvariant( const SmTokenType eType )
 
 void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
 {
-    SvXMLElementExport *pElement = 0;
-
     //
     // gather the mathvariant attribut relevant data from all
     // successively following SmFontNodes...
@@ -1328,10 +1328,8 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
 
     switch (pNode->GetToken().eType)
     {
-        //wrap a phantom element around everything*/
         case TPHANTOM:
-            pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
-                XML_MPHANTOM, sal_True,sal_True);
+            // No attribute needed. An <mphantom> element will be used below.
             break;
         case TBLACK:
             AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_BLACK);
@@ -1455,15 +1453,15 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
             break;
 
     }
-    //for now we will just always export with a style and not worry about
-    //anyone else for the moment.
     {
-        //wrap a style around it
-        SvXMLElementExport aStyle(*this, XML_NAMESPACE_MATH, XML_MSTYLE, sal_True,sal_True);
-        ExportExpression(pNode, nLevel);
+        // Wrap everything in an <mphantom> or <mstyle> element. These elements
+        // are mrow-like, so ExportExpression doesn't need to add an explicit
+        // <mrow> element. See #fdo 66283.
+        SvXMLElementExport aElement(*this, XML_NAMESPACE_MATH,
+            pNode->GetToken().eType == TPHANTOM ? XML_MPHANTOM : XML_MSTYLE,
+            sal_True, sal_True);
+        ExportExpression(pNode, nLevel, true);
     }
-
-    delete pElement;
 }
 
 
diff --git a/starmath/source/mathmlexport.hxx b/starmath/source/mathmlexport.hxx
index 3cbaaae..d7ca75a 100644
--- a/starmath/source/mathmlexport.hxx
+++ b/starmath/source/mathmlexport.hxx
@@ -84,7 +84,8 @@ protected:
     void ExportNodes(const SmNode *pNode, int nLevel);
     void ExportTable(const SmNode *pNode, int nLevel);
     void ExportLine(const SmNode *pNode, int nLevel);
-    void ExportExpression(const SmNode *pNode, int nLevel);
+    void ExportExpression(const SmNode *pNode, int nLevel,
+                          bool bNoMrowContainer = false);
     void ExportText(const SmNode *pNode, int nLevel);
     void ExportMath(const SmNode *pNode, int nLevel);
     void ExportPolygon(const SmNode *pNode, int nLevel);


More information about the Libreoffice-commits mailing list