Kaydet (Commit) ade1641a authored tarafından Dinesh Patil's avatar Dinesh Patil Kaydeden (comit) Michael Stahl

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/8561Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 66db6dd2
......@@ -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 )
{
......
......@@ -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;
}
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment