diff options
author | umeshkadam <umesh.kadam@synerzip.com> | 2014-02-07 17:27:49 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-13 09:55:36 +0100 |
commit | 9d5005a70cc42ee9f45104cc32aa099d0c3d6630 (patch) | |
tree | b73dba609fa7d0e13e16a5ff1f1886826f28830b | |
parent | 8f8bc0dcf3bc253ae49159d52db049767f476ced (diff) |
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
-rw-r--r-- | chart2/qa/extras/chart2export.cxx | 23 | ||||
-rw-r--r-- | chart2/qa/extras/data/docx/FDO74430.docx | bin | 0 -> 19199 bytes | |||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 1 |
4 files changed, 29 insertions, 3 deletions
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 Binary files differnew file mode 100644 index 000000000000..f4a68b519db2 --- /dev/null +++ b/chart2/qa/extras/data/docx/FDO74430.docx diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 78b01dcbd8d1..1467692bac2a 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3211,8 +3211,13 @@ void DocxAttributeOutput::WritePostponedChart() if( xNamed.is() ) sName = xNamed->getName(); + /* 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. + */ m_pSerializer->singleElementNS( XML_wp, XML_docPr, - XML_id, I32S( ++m_docPrID ), + XML_id, I32S( m_anchorId++ ), XML_name, USS( sName ), FSEND ); @@ -6281,7 +6286,6 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_pFootnotesList( new ::docx::FootnotesList() ), m_pEndnotesList( new ::docx::FootnotesList() ), m_footnoteEndnoteRefTag( 0 ), - m_docPrID(0), m_pSectionInfo( NULL ), m_pRedlineData( NULL ), m_nRedlineId( 0 ), diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index c7965c8f6ca4..8d167c0dc92a 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -691,7 +691,6 @@ private: ::docx::FootnotesList *m_pFootnotesList; ::docx::FootnotesList *m_pEndnotesList; int m_footnoteEndnoteRefTag; - int m_docPrID; boost::scoped_ptr< const WW8_SepInfo > m_pSectionInfo; /// Redline data to remember in the text run. |