From c2b36cd6f7cf70e77dac5938f18146b0687523e6 Mon Sep 17 00:00:00 2001 From: Tamas Bunth Date: Thu, 3 Oct 2019 19:49:57 +0200 Subject: tdf#123206 Import/Export chart custom label text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OOX import supports custom label texts in chart diagrams (produced by e.g. double clicking on a data label, and write custom text), but - since embedded objects are exported and imported to odf right after migration - it is not displayed in case of a Writer document. In order to make it work, we have to support custom label text in the odf structure. This commit only allows the import/export of pure text, it should be improved to store and load formatted string. A new XML token is added, which currently refers to an attribute of the chart:data-point tag. If we want to store formatted string, something more clever has to be done. Change-Id: I80c4a3a0dbcf59f1dc732d795fb716da318411cb Reviewed-on: https://gerrit.libreoffice.org/80156 Tested-by: Jenkins Reviewed-by: Tamás Bunth --- chart2/qa/extras/chart2export.cxx | 16 ++++++++++++++++ chart2/qa/extras/data/docx/tdf123206.docx | Bin 0 -> 24223 bytes 2 files changed, 16 insertions(+) create mode 100755 chart2/qa/extras/data/docx/tdf123206.docx (limited to 'chart2') diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 8d42c8ac93ac..1645c1c1d1ae 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -149,6 +149,7 @@ public: void testTdf121744(); void testTdf122031(); void testTdf115012(); + void testTdf123206_customLabelText(); CPPUNIT_TEST_SUITE(Chart2ExportTest); CPPUNIT_TEST(testErrorBarXLSX); @@ -261,6 +262,8 @@ public: CPPUNIT_TEST(testTdf121744); CPPUNIT_TEST(testTdf122031); CPPUNIT_TEST(testTdf115012); + CPPUNIT_TEST(testTdf123206_customLabelText); + CPPUNIT_TEST_SUITE_END(); protected: @@ -2386,6 +2389,19 @@ void Chart2ExportTest::testTdf115012() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "zero"); } +void Chart2ExportTest::testTdf123206_customLabelText() +{ + load("/chart2/qa/extras/data/docx/", "tdf123206.docx"); + + Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/c:rich/a:p/a:r/a:t", "kiscica"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/docx/tdf123206.docx b/chart2/qa/extras/data/docx/tdf123206.docx new file mode 100755 index 000000000000..f47089fe3b1b Binary files /dev/null and b/chart2/qa/extras/data/docx/tdf123206.docx differ -- cgit