[Libreoffice-commits] core.git: chart2/qa sw/source
umeshkadam
umesh.kadam at synerzip.com
Thu Feb 13 09:56:07 CET 2014
chart2/qa/extras/chart2export.cxx | 23 +++++++++++++++++++++++
chart2/qa/extras/data/docx/FDO74430.docx |binary
sw/source/filter/ww8/docxattributeoutput.cxx | 8 ++++++--
sw/source/filter/ww8/docxattributeoutput.hxx | 1 -
4 files changed, 29 insertions(+), 3 deletions(-)
New commits:
commit 9d5005a70cc42ee9f45104cc32aa099d0c3d6630
Author: umeshkadam <umesh.kadam at synerzip.com>
Date: Fri Feb 7 17:27:49 2014 +0530
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
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 6288d3d..c15f5af 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 0000000..f4a68b5
Binary files /dev/null and b/chart2/qa/extras/data/docx/FDO74430.docx differ
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 78b01dc..1467692 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 c7965c8..8d167c0 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.
More information about the Libreoffice-commits
mailing list