From e3b03a028538e38337bcabbe5453b043920c23a8 Mon Sep 17 00:00:00 2001 From: YogeshBharate Date: Tue, 4 Feb 2014 19:34:09 +0530 Subject: Added unit test for fdo#73872: - Issue related to footer reference. - Added unit test to check footer1.xml.rels is contains in doc after roundtrip. - Also check Id = rId1 in footer1.xml.rels file. Conflicts: chart2/qa/extras/chart2export.cxx Reviewed on: https://gerrit.libreoffice.org/7851 Change-Id: I52fa8017abb7552c7752185873ff2bfb46689367 --- sw/CppunitTest_sw_ooxmlexport.mk | 2 ++ sw/qa/extras/ooxmlexport/data/chart-in-footer.docx | Bin 0 -> 29207 bytes sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 27 +++++++++++++++++++-- writerfilter/source/ooxml/OOXMLDocumentImpl.cxx | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/chart-in-footer.docx diff --git a/sw/CppunitTest_sw_ooxmlexport.mk b/sw/CppunitTest_sw_ooxmlexport.mk index 4ebff325d6a2..6d09ca211495 100644 --- a/sw/CppunitTest_sw_ooxmlexport.mk +++ b/sw/CppunitTest_sw_ooxmlexport.mk @@ -51,6 +51,8 @@ $(eval $(call gb_CppunitTest_use_ure,sw_ooxmlexport)) $(eval $(call gb_CppunitTest_use_components,sw_ooxmlexport,\ basic/util/sb \ canvas/source/factory/canvasfactory \ + chart2/source/chartcore \ + chart2/source/controller/chartcontroller \ comphelper/util/comphelp \ configmgr/source/configmgr \ drawinglayer/drawinglayer \ diff --git a/sw/qa/extras/ooxmlexport/data/chart-in-footer.docx b/sw/qa/extras/ooxmlexport/data/chart-in-footer.docx new file mode 100644 index 000000000000..293ee076bc28 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/chart-in-footer.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 46d7adfe7ead..ab4e745affeb 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -155,6 +155,7 @@ xmlNodeSetPtr Test::getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath) xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wp"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main")); 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")); xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx); return pXmlXpathObj->nodesetval; } @@ -3198,8 +3199,6 @@ DECLARE_OOXMLEXPORT_TEST(testExtentValue, "fdo74605.docx") assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:extent","cx","0"); } -#endif - DECLARE_OOXMLEXPORT_TEST( testChildNodesOfCubicBezierTo, "FDO74774.docx") { /* Number of children required by cubicBexTo is 3 of type "pt". @@ -3215,6 +3214,30 @@ DECLARE_OOXMLEXPORT_TEST( testChildNodesOfCubicBezierTo, "FDO74774.docx") "/w:document/w:body/w:p[2]/w:r[1]/mc:AlternateContent[1]/mc:Choice/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wpg:wgp[1]/wps:wsp[3]/wps:spPr[1]/a:custGeom[1]/a:pathLst[1]/a:path[1]/a:cubicBezTo[2]/a:pt[3]"); } +DECLARE_OOXMLEXPORT_TEST(testChartInFooter, "chart-in-footer.docx") +{ + // fdo#73872: document contains chart in footer. + // The problem was that footer1.xml.rels files for footer1.xml + // files were missing from docx file after roundtrip. + xmlDocPtr pXmlDoc = parseExport("word/_rels/footer1.xml.rels"); + if(!pXmlDoc) + return; + + // Check footer1.xml.rels contains in doc after roundtrip. + // Check Id = rId1 in footer1.xml.rels + assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship","Id","rId1"); + + uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + if (xDrawPageSupplier.is()) + { + // If xDrawPage->getCount()==1, then document conatins one shape. + uno::Reference xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount()); // One shape in the doc + } +} + +#endif + CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx index 4b90d114b4ab..2981f9fe2e34 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx @@ -178,6 +178,7 @@ void OOXMLDocumentImpl::importSubStreamRelations(OOXMLStream::Pointer_t pStream, { SAL_WARN("writerfilter", "importSubStreamRelations: exception while " "importing stream " << nType << " : " << e.Message); + return; } uno::Reference xcpInputStream = -- cgit