From a211c754003f98bc8f7761224a0b265bd224f61f Mon Sep 17 00:00:00 2001 From: Sourav Date: Tue, 15 Apr 2014 16:39:52 +0530 Subject: fdo77216-Charts-Scattered chart: Chart gets distorted on RT In case there is some text entered in place of X coordinates for scatter chart then x coordinates should be taken as 1,2,3.... MS Word does the same thing Change-Id: I1db0fd64c6ac0f4d5e77a9676812f5e26577ecf6 Reviewed-on: https://gerrit.libreoffice.org/9011 Tested-by: Markus Mohrhard Reviewed-by: Markus Mohrhard --- chart2/qa/extras/chart2export.cxx | 38 +++++++++++++++++++++++++++++++ chart2/qa/extras/data/docx/fdo77216.docx | Bin 0 -> 23974 bytes 2 files changed, 38 insertions(+) create mode 100644 chart2/qa/extras/data/docx/fdo77216.docx (limited to 'chart2/qa') diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index bc1dcd3f61ee..eded887bbb3f 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -36,6 +36,7 @@ public: void testStockChart(); void testBarChart(); void testCrosses(); + void testScatterChart(); void testChartDataTable(); void testChartExternalData(); void testEmbeddingsGrabBag(); @@ -64,6 +65,7 @@ public: CPPUNIT_TEST(testStockChart); CPPUNIT_TEST(testBarChart); CPPUNIT_TEST(testCrosses); + CPPUNIT_TEST(testScatterChart); CPPUNIT_TEST(testChartDataTable); CPPUNIT_TEST(testChartExternalData); CPPUNIT_TEST(testEmbeddingsGrabBag); @@ -117,6 +119,14 @@ protected: * Same as the assertXPath(), but don't assert: return the string instead. */ OUString getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute); + /** + Assert that rXPath exists, and its content equals rContent. + */ + void assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent); + /** + Same as the assertXPathContent(), but don't assert: return the string instead. + */ + OUString getXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath); private: }; @@ -211,6 +221,24 @@ void Chart2ExportTest::assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfNodes, xmlXPathNodeSetGetLength(pXmlNodes)); } +void Chart2ExportTest::assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent) +{ + CPPUNIT_ASSERT_EQUAL_MESSAGE("XPath contents of child does not match", rContent, getXPathContent(pXmlDoc, rXPath)); +} + +OUString Chart2ExportTest::getXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath) +{ + xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath); + + CPPUNIT_ASSERT_MESSAGE(OString("XPath '" + rXPath + "' not found").getStr(), + xmlXPathNodeSetGetLength(pXmlNodes) > 0); + + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; + + _xmlNode *pNode = &(pXmlNode->children[0]); + return pNode ? OUString::createFromAscii((const char*)((pXmlNode->children[0]).content)) : OUString(); +} + OUString Chart2ExportTest::getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute) { xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath); @@ -479,6 +507,16 @@ void Chart2ExportTest::testCrosses() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:crosses", "val", "autoZero"); } +void Chart2ExportTest::testScatterChart() +{ + load("/chart2/qa/extras/data/docx/", "fdo77216.docx"); + xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + if (!pXmlDoc) + return; + + assertXPathContent(pXmlDoc, "//c:scatterChart/c:ser[1]/c:xVal[1]/c:numRef[1]/c:numCache[1]/c:pt[1]/c:v[1]", "1"); +} + void Chart2ExportTest::testChartDataTable() { load("/chart2/qa/extras/data/docx/", "testChartDataTable.docx"); diff --git a/chart2/qa/extras/data/docx/fdo77216.docx b/chart2/qa/extras/data/docx/fdo77216.docx new file mode 100644 index 000000000000..b741bbce2157 Binary files /dev/null and b/chart2/qa/extras/data/docx/fdo77216.docx differ -- cgit