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

Dinesh Patil dinesh.patil at synerzip.com
Thu Mar 13 08:50:37 PDT 2014


 starmath/source/ooxmlexport.cxx                         |   21 ++++++++++++----
 sw/qa/extras/inc/swmodeltestbase.hxx                    |    1 
 sw/qa/extras/ooxmlexport/data/2120112713.docx           |binary
 sw/qa/extras/ooxmlexport/data/2120112713_OpenBrace.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx                |   18 +++++++++++++
 5 files changed, 36 insertions(+), 4 deletions(-)

New commits:
commit ade1641ab632565820ede720b6151435aca4dd78
Author: Dinesh Patil <dinesh.patil at synerzip.com>
Date:   Wed Mar 12 20:04:16 2014 +0530

    fdo#76078: LO Crashes while saving the docx file containing only opening brace
    
    - System handles an equation having opening brace and closing brace.
    - Whereas it fails to handle equations having only opening brace and no closing
      brace, due to which LO crashes with assertion while exporting.
    - Fixed this issue and added unit test case for the same.
    - Also fixed the same for closing brace alone.
    
    Change-Id: I34a8a635b42bfdfac265fb70b977c0001cd2b4ff
    Reviewed-on: https://gerrit.libreoffice.org/8561
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index 8d1c808..0a98d98 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -453,8 +453,15 @@ void SmOoxmlExport::HandleBrace( const SmBraceNode* pNode, int nLevel )
 {
     m_pSerializer->startElementNS( XML_m, XML_d, FSEND );
     m_pSerializer->startElementNS( XML_m, XML_dPr, FSEND );
-    m_pSerializer->singleElementNS( XML_m, XML_begChr,
-        FSNS( XML_m, XML_val ), mathSymbolToString( pNode->OpeningBrace()).getStr(), FSEND );
+
+    //check if the node has an opening brace
+    if( TNONE == pNode->GetSubNode(0)->GetToken().eType )
+        m_pSerializer->singleElementNS( XML_m, XML_begChr,
+            FSNS( XML_m, XML_val ), "", FSEND );
+    else
+        m_pSerializer->singleElementNS( XML_m, XML_begChr,
+            FSNS( XML_m, XML_val ), mathSymbolToString( pNode->OpeningBrace()).getStr(), FSEND );
+
     std::vector< const SmNode* > subnodes;
     if( pNode->Body()->GetType() == NBRACEBODY )
     {
@@ -479,8 +486,14 @@ void SmOoxmlExport::HandleBrace( const SmBraceNode* pNode, int nLevel )
     }
     else
         subnodes.push_back( pNode->Body());
-    m_pSerializer->singleElementNS( XML_m, XML_endChr,
-        FSNS( XML_m, XML_val ), mathSymbolToString( pNode->ClosingBrace()).getStr(), FSEND );
+
+    if( TNONE == pNode->GetSubNode(2)->GetToken().eType )
+        m_pSerializer->singleElementNS( XML_m, XML_endChr,
+            FSNS( XML_m, XML_val ), "", FSEND );
+    else
+        m_pSerializer->singleElementNS( XML_m, XML_endChr,
+            FSNS( XML_m, XML_val ), mathSymbolToString( pNode->ClosingBrace()).getStr(), FSEND );
+
     m_pSerializer->endElementNS( XML_m, XML_dPr );
     for( unsigned int i = 0; i < subnodes.size(); ++i )
     {
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index a3c3dec..d2f3b29 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -551,6 +551,7 @@ protected:
         xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("pic"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/picture"));
         xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("rels"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/relationships"));
         xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w14"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordml"));
+        xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("m"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/math"));
         xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx);
         return pXmlXpathObj->nodesetval;
     }
diff --git a/sw/qa/extras/ooxmlexport/data/2120112713.docx b/sw/qa/extras/ooxmlexport/data/2120112713.docx
new file mode 100644
index 0000000..5de6378
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/2120112713.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/2120112713_OpenBrace.docx b/sw/qa/extras/ooxmlexport/data/2120112713_OpenBrace.docx
new file mode 100644
index 0000000..10dfd31
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/2120112713_OpenBrace.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 045d41e..a0ea664 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2710,6 +2710,15 @@ DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(2014), sal_Int32(aDate.Year));
 }
 
+DECLARE_OOXMLEXPORT_TEST(test_OpeningBrace, "2120112713_OpenBrace.docx")
+{
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    if (!pXmlDoc)
+        return;
+    // Checking for OpeningBrace tag
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[1]/m:dPr[1]/m:begChr[1]","val","");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx")
 {
     // check XML
@@ -2744,6 +2753,15 @@ DECLARE_OOXMLEXPORT_TEST(testOLEObjectinHeader, "2129393649.docx")
     assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship[1]","Id","rId1");
 }
 
+DECLARE_OOXMLEXPORT_TEST(test_ClosingBrace, "2120112713.docx")
+{
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    if (!pXmlDoc)
+        return;
+    // Checking for ClosingBrace tag
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[2]/m:dPr[1]/m:endChr[1]","val","");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testlvlPicBulletId, "lvlPicBulletId.docx")
 {
     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");


More information about the Libreoffice-commits mailing list