From 9d5005a70cc42ee9f45104cc32aa099d0c3d6630 Mon Sep 17 00:00:00 2001 From: umeshkadam Date: Fri, 7 Feb 2014 17:27:49 +0530 Subject: FDO#74430: File Corruption due to repetition of docPr Id Issue : - If there is a scenario where a chart is followed by a shape (may it be in the footer or on a different page ) which is being exported as an alternate content then, the docPr Id is being repeated, ECMA 20.4.2.5 says that the docPr Id should be unique. - Two different variables were been used as counters for the docPr Id, hence there were repitions in the docPr Id. Implementation : - ensured that a single counter is used to track the docPr Id. Conflicts: chart2/qa/extras/chart2export.cxx Reviewed on: https://gerrit.libreoffice.org/7916 Change-Id: I1c105be184d045ef058423f03259eb8c634fcbbe --- chart2/qa/extras/chart2export.cxx | 23 +++++++++++++++++++++++ chart2/qa/extras/data/docx/FDO74430.docx | Bin 0 -> 19199 bytes 2 files changed, 23 insertions(+) create mode 100644 chart2/qa/extras/data/docx/FDO74430.docx (limited to 'chart2/qa/extras') diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 6288d3d3f74e..c15f5af2f5c1 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -46,6 +46,7 @@ public: void testFdo74115WallGradientFill(); void testFdo74115WallBitmapFill(); void testBarChartRotation(); + void testShapeFollowedByChart(); CPPUNIT_TEST_SUITE(Chart2ExportTest); CPPUNIT_TEST(test); @@ -64,6 +65,7 @@ public: // CPPUNIT_TEST(testFdo74115WallGradientFill); CPPUNIT_TEST(testFdo74115WallBitmapFill); CPPUNIT_TEST(testBarChartRotation); + CPPUNIT_TEST(testShapeFollowedByChart); CPPUNIT_TEST_SUITE_END(); protected: @@ -169,6 +171,10 @@ xmlNodeSetPtr Chart2ExportTest::getXPathNode(xmlDocPtr pXmlDoc, const OString& r xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("v"), BAD_CAST("urn:schemas-microsoft-com:vml")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("c"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("mc"), BAD_CAST("http://schemas.openxmlformats.org/markup-compatibility/2006")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wps"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingShape")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wpg"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wp"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")); xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx); return pXmlXpathObj->nodesetval; } @@ -578,6 +584,23 @@ void Chart2ExportTest::testBarChartRotation() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:view3D/c:rotY", "val", "50"); } +void Chart2ExportTest::testShapeFollowedByChart() +{ + /* If there is a scenario where a chart is followed by a shape + which is being exported as an alternate content then, the + docPr Id is being repeated, ECMA 20.4.2.5 says that the + docPr Id should be unique, ensuring the same here. + */ + load("/chart2/qa/extras/data/docx/", "FDO74430.docx"); + xmlDocPtr pXmlDoc = parseExport("word/document", "Office Open XML Text" ); + CPPUNIT_ASSERT(pXmlDoc); + + OUString aValueOfFirstDocPR = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/w:drawing[1]/wp:inline[1]/wp:docPr[1]", "id"); + OUString aValueOfSecondDocPR = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[2]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:docPr[1]", "id"); + CPPUNIT_ASSERT( aValueOfFirstDocPR != aValueOfSecondDocPR ); + +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/docx/FDO74430.docx b/chart2/qa/extras/data/docx/FDO74430.docx new file mode 100644 index 000000000000..f4a68b519db2 Binary files /dev/null and b/chart2/qa/extras/data/docx/FDO74430.docx differ -- cgit