include/xmloff/xmltoken.hxx      |    1 
 starmath/source/mathmlexport.cxx |   56 ++++++++++++++++++++-------------------
 xmloff/source/core/xmltoken.cxx  |    1 
 3 files changed, 31 insertions(+), 27 deletions(-)

New commits:
commit c61f35275c613cf7ba6f1aa7bc8235340f9df8f7
Author: Frédéric Wang <fred.w...@free.fr>
Date:   Sun Jun 30 16:15:14 2013 +0200

     fdo#66282 - MathML export: improve ExportBrace
    
    Change-Id: If15038f8942c649703659e05868162c31785c762
    Reviewed-on: https://gerrit.libreoffice.org/4632
    Reviewed-by: Khaled Hosny <khaledho...@eglug.org>
    Tested-by: Khaled Hosny <khaledho...@eglug.org>

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 690aad0..2523ad1 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -736,6 +736,7 @@ namespace xmloff { namespace token {
         XML_FALSE,
         XML_FAMILY,
         XML_FAST,
+        XML_FENCE,
         XML_FIELD_NUMBER,
         XML_FILE_NAME,
         XML_FILL,
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index a523693..1dd1634 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -1144,51 +1144,53 @@ void SmXMLExport::ExportBrace(const SmNode *pNode, int 
nLevel)
     const SmNode *pTemp;
     const SmNode *pLeft=pNode->GetSubNode(0);
     const SmNode *pRight=pNode->GetSubNode(2);
-    SvXMLElementExport *pFences=0,*pRow=0;
-    if ( ((pLeft) && (pLeft->GetToken().eType != TNONE)) &&
-        ((pRight) && (pRight->GetToken().eType != TNONE)) &&
-        (pNode->GetScaleMode() == SCALE_HEIGHT))
-    {
-        sal_Unicode nArse[2];
-        nArse[1] = 0;
-        nArse[0] = static_cast<
-            const SmMathSymbolNode* >(pLeft)->GetText()[0];
-        OSL_ENSURE(nArse[0] != 0xffff,"Non existent symbol");
-        AddAttribute(XML_NAMESPACE_MATH, XML_OPEN,nArse);
-        nArse[0] = static_cast<
-            const SmMathSymbolNode* >(pRight)->GetText()[0];
-        OSL_ENSURE(nArse[0] != 0xffff,"Non existent symbol");
-        AddAttribute(XML_NAMESPACE_MATH, XML_CLOSE,nArse);
-        pFences = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, 
XML_MFENCED,
-            sal_True,sal_True);
-    }
-    else if (pLeft && (pLeft->GetToken().eType != TNONE))
+    SvXMLElementExport *pRow=0;
+
+    // This used to generate <mfenced> or <mrow>+<mo> elements according to
+    // the stretchiness of fences. The MathML recommendation defines an
+    // <mrow>+<mo> construction that is equivalent to the <mfenced> element:
+    // http://www.w3.org/TR/MathML3/chapter3.html#presm.mfenced
+    // To simplify our code and avoid issues with mfenced implementations in
+    // MathML rendering engines, we now always generate <mrow>+<mo> elements.
+    // See #fdo 66282.
+
+    // <mrow>
+    pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW,
+        sal_True, sal_True);
+
+    //   <mo fence="true"> opening-fence </mo>
+    if (pLeft && (pLeft->GetToken().eType != TNONE))
     {
-        pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW,
-            sal_True, sal_True);
+        AddAttribute(XML_NAMESPACE_MATH, XML_FENCE, XML_TRUE);
         if (pNode->GetScaleMode() == SCALE_HEIGHT)
             AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
         else
             AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE);
         ExportNodes(pLeft, nLevel+1);
     }
-    else
-        pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW,
-            sal_True, sal_True);
 
     if (NULL != (pTemp = pNode->GetSubNode(1)))
+    {
+        // <mrow>
+        SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW,
+            sal_True, sal_True);
         ExportNodes(pTemp, nLevel+1);
-    if (pFences)
-        delete pFences;
-    else if (pRight && (pRight->GetToken().eType != TNONE))
+        // </mrow>
+    }
+
+    //   <mo fence="true"> closing-fence </mo>
+    if (pRight && (pRight->GetToken().eType != TNONE))
     {
+        AddAttribute(XML_NAMESPACE_MATH, XML_FENCE, XML_TRUE);
         if (pNode->GetScaleMode() == SCALE_HEIGHT)
             AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
         else
             AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE);
         ExportNodes(pRight, nLevel+1);
     }
+
     delete pRow;
+    // </mrow>
 }
 
 void SmXMLExport::ExportRoot(const SmNode *pNode, int nLevel)
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 164f03c..1de3179 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -741,6 +741,7 @@ namespace xmloff { namespace token {
         TOKEN( "false",                           XML_FALSE ),
         TOKEN( "family",                          XML_FAMILY ),
         TOKEN( "fast",                            XML_FAST ),
+        TOKEN( "fence",                           XML_FENCE ),
         TOKEN( "field-number",                    XML_FIELD_NUMBER ),
         TOKEN( "file-name",                       XML_FILE_NAME ),
         TOKEN( "fill",                            XML_FILL ),
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to