summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDinesh Patil <dinesh.patil@synerzip.com>2014-03-12 20:04:16 +0530
committerMichael Stahl <mstahl@redhat.com>2014-03-13 10:50:15 -0500
commitade1641ab632565820ede720b6151435aca4dd78 (patch)
treeb6effce13b14666df8148b0cfd628bcb18aef65a
parent66db6dd2bebefced1bc7e097710c2bf79f720d82 (diff)
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@redhat.com> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--starmath/source/ooxmlexport.cxx21
-rw-r--r--sw/qa/extras/inc/swmodeltestbase.hxx1
-rw-r--r--sw/qa/extras/ooxmlexport/data/2120112713.docxbin0 -> 41022 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/data/2120112713_OpenBrace.docxbin0 -> 23146 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx18
5 files changed, 36 insertions, 4 deletions
diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index 8d1c80809a71..0a98d985dc1d 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 a3c3decf1edb..d2f3b2933ef8 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 000000000000..5de6378b77c8
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/2120112713.docx
Binary files 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 000000000000..10dfd31ab208
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/2120112713_OpenBrace.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 045d41e14a03..a0ea66438947 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");