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
This commit is contained in:
@@ -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();
|
||||
|
BIN
chart2/qa/extras/data/docx/FDO74430.docx
Normal file
BIN
chart2/qa/extras/data/docx/FDO74430.docx
Normal file
Binary file not shown.
@@ -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 ),
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user