From 96a29c12a9d8734c9d2a812f38fc6654b5df9c48 Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Thu, 15 Aug 2019 11:25:02 +0200 Subject: tdf#101322 Chart OOXML Export: fix missing subtitle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Concatenate subtitle and main title texts, if both exist, just like at the XLS/DOC export, because OOXML does not support subtitles. If we only have a subtitle, export the whole subtitle shape instead of the title shape, keeping its properties. Change-Id: If6a27c023fcce58f4549a0edad44027bb0348b93 Reviewed-on: https://gerrit.libreoffice.org/77499 Reviewed-by: László Németh Tested-by: László Németh --- chart2/qa/extras/chart2export.cxx | 33 +++++++++++++++++++++ .../extras/data/ods/testChartMainWithSubTitle.ods | Bin 0 -> 12317 bytes chart2/qa/extras/data/ods/testChartSubTitle.ods | Bin 0 -> 12598 bytes 3 files changed, 33 insertions(+) create mode 100644 chart2/qa/extras/data/ods/testChartMainWithSubTitle.ods create mode 100644 chart2/qa/extras/data/ods/testChartSubTitle.ods (limited to 'chart2') diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index ab932ac2bc68..78a763ee7bb6 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -103,6 +103,8 @@ public: void testTitleManualLayoutXLSX(); void testPlotAreaManualLayoutXLSX(); void testLegendManualLayoutXLSX(); + void testChartSubTitle(); + void testChartMainWithSubTitle(); void testChartTitlePropertiesColorFillXLSX(); void testChartTitlePropertiesGradientFillXLSX(); void testChartTitlePropertiesBitmapFillXLSX(); @@ -203,6 +205,8 @@ public: CPPUNIT_TEST(testTitleManualLayoutXLSX); CPPUNIT_TEST(testPlotAreaManualLayoutXLSX); CPPUNIT_TEST(testLegendManualLayoutXLSX); + CPPUNIT_TEST(testChartSubTitle); + CPPUNIT_TEST(testChartMainWithSubTitle); CPPUNIT_TEST(testChartTitlePropertiesColorFillXLSX); CPPUNIT_TEST(testChartTitlePropertiesGradientFillXLSX); CPPUNIT_TEST(testChartTitlePropertiesBitmapFillXLSX); @@ -1645,6 +1649,35 @@ void Chart2ExportTest::testLegendManualLayoutXLSX() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:txPr/a:p/a:pPr/a:defRPr", "sz", "900"); } +void Chart2ExportTest::testChartSubTitle() +{ + load("/chart2/qa/extras/data/ods/", "testChartSubTitle.ods"); + xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + // test properties of subtitle + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "sz", "1100"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "b", "1"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr", "val", "00a933"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr/a:latin", "typeface", "Times New Roman"); + assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:t", "It is a Subtitle"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", "b2b2b2"); +} + +void Chart2ExportTest::testChartMainWithSubTitle() +{ + load("/chart2/qa/extras/data/ods/", "testChartMainWithSubTitle.ods"); + xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + // test properties of title + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "sz", "1300"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "b", "0"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "i", "1"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr", "val", "f10d0c"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr/a:latin", "typeface", "Arial"); + assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:t", "It is a Maintitle\nIt is a Subtitle"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", "81d41a"); +} + void Chart2ExportTest::testChartTitlePropertiesColorFillXLSX() { load("/chart2/qa/extras/data/xlsx/", "testChartTitlePropertiesColorFill.xlsx"); diff --git a/chart2/qa/extras/data/ods/testChartMainWithSubTitle.ods b/chart2/qa/extras/data/ods/testChartMainWithSubTitle.ods new file mode 100644 index 000000000000..5ae4fa7d99a7 Binary files /dev/null and b/chart2/qa/extras/data/ods/testChartMainWithSubTitle.ods differ diff --git a/chart2/qa/extras/data/ods/testChartSubTitle.ods b/chart2/qa/extras/data/ods/testChartSubTitle.ods new file mode 100644 index 000000000000..1c7814195d17 Binary files /dev/null and b/chart2/qa/extras/data/ods/testChartSubTitle.ods differ -- cgit