summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2020-09-10 14:42:55 +0200
committerRegina Henschel <rb.henschel@t-online.de>2020-09-19 14:27:24 +0200
commit6d7a72ab1c044f7e1f30f7c4133dafdb214dfcbf (patch)
treebc8487b52062767b2e881922a715c1aa5d6d0c6d /chart2
parent9bf4c5ac49b73cc2a8c89a87ff87238c061a579d (diff)
tdf#135366 Save line and fill of data labels to ODF
LibreOffice has line and fill properties of data labels in charts as loext attributes in the style of the <chart:series> or <chart:data-point> element. For ODF there has to be a <chart:data-label> element with line and fill properties in its style. This patch adds the needed <chart:data-label> elements and their associated <style:style> elements. The element <chart:data-lable> exists in ODF since version 1.2. The solution requires no extended namespace. The check is adapted in lcl_getCustomLabelField. Import was already done in commit 87d1ebeb11a00301745ee3c3c03fffb7033ab59d Change-Id: I829dae5433e8257c775aa4f08e511d514df4e936 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102381 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2geometry.cxx56
-rw-r--r--chart2/qa/extras/data/odt/tdf135366_data_label_export.odtbin0 -> 16069 bytes
-rw-r--r--chart2/qa/extras/data/pptx/tdf135366_CustomLabelText.pptxbin0 -> 36946 bytes
3 files changed, 56 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2geometry.cxx b/chart2/qa/extras/chart2geometry.cxx
index b3f537c372e0..be6d842d7780 100644
--- a/chart2/qa/extras/chart2geometry.cxx
+++ b/chart2/qa/extras/chart2geometry.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/saveopt.hxx>
#include <libxml/xpathInternals.h>
@@ -52,6 +53,8 @@ public:
void testTdf128345Legend_CS_TG_axial_import();
void testTdf135366LabelOnSeries();
void testTdf135366LabelOnPoint();
+ void testTdf135366LabelExport();
+ void testTdf135366_CustomLabelText();
CPPUNIT_TEST_SUITE(Chart2GeometryTest);
CPPUNIT_TEST(testTdf135184RoundLineCap);
@@ -66,6 +69,8 @@ public:
CPPUNIT_TEST(testTdf128345Legend_CS_TG_axial_import);
CPPUNIT_TEST(testTdf135366LabelOnSeries);
CPPUNIT_TEST(testTdf135366LabelOnPoint);
+ CPPUNIT_TEST(testTdf135366LabelExport);
+ CPPUNIT_TEST(testTdf135366_CustomLabelText);
CPPUNIT_TEST_SUITE_END();
@@ -502,6 +507,57 @@ void Chart2GeometryTest::testTdf135366LabelOnPoint()
nFillColor);
}
+void Chart2GeometryTest::testTdf135366LabelExport()
+{
+ // Error was, that line and fill properties were not exported as
+ // graphic-properties of a <chart:data-label> element, but only
+ // as loext chart-properties of the <chart:data-point> element.
+ load("/chart2/qa/extras/data/odt/", "tdf135366_data_label_export.odt");
+ xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "writer8");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // Find label style
+ const OString sLabelPath(
+ "//office:document-content/office:body/office:chart/chart:chart/chart:plot-area"
+ "/chart:series/chart:data-point[1]/chart:data-label/@chart:style-name");
+ const OUString sOULabelStyleName = getXPathContent(pXmlDoc, sLabelPath);
+
+ // Verify content of graphic properties of label style
+ const OString sStylePath(
+ "//office:document-content/office:automatic-styles/style:style[@style:name='"
+ + OU2O(sOULabelStyleName) + "']/style:graphic-properties");
+ assertXPath(pXmlDoc, sStylePath, 1);
+ assertXPath(pXmlDoc, sStylePath + "[@draw:fill='solid']");
+ assertXPath(pXmlDoc, sStylePath + "[@draw:fill-color='#5050a0']");
+ assertXPath(pXmlDoc, sStylePath + "[@draw:stroke='solid']");
+ assertXPath(pXmlDoc, sStylePath + "[@svg:stroke-width='0.254cm']");
+ assertXPath(pXmlDoc, sStylePath + "[@svg:stroke-color='#00ffff']");
+}
+
+void Chart2GeometryTest::testTdf135366_CustomLabelText()
+{
+ // Error was, that custom text in a data label was only exported in ODF extended,
+ // although the used <chart:data-label> element exists since ODF 1.2.
+ SvtSaveOptions aSaveOpt;
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(aSaveOpt.GetODFDefaultVersion());
+ aSaveOpt.SetODFDefaultVersion(SvtSaveOptions::ODFVER_012);
+ load("/chart2/qa/extras/data/pptx/", "tdf135366_CustomLabelText.pptx");
+ xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // Find custom text. As of version 7.0 it is in a <text:span> element.
+ const OString sCustomTextPath(
+ "//office:document-content/office:body/office:chart/chart:chart/chart:plot-area"
+ "/chart:series/chart:data-point[2]/chart:data-label/text:p/text:span");
+ assertXPath(pXmlDoc, sCustomTextPath, 1);
+
+ // Verify text content
+ const OUString sOUTextContent = getXPathContent(pXmlDoc, sCustomTextPath);
+ CPPUNIT_ASSERT_EQUAL(OUString("Custom"), sOUTextContent);
+
+ aSaveOpt.SetODFDefaultVersion(nCurrentODFVersion);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2GeometryTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/odt/tdf135366_data_label_export.odt b/chart2/qa/extras/data/odt/tdf135366_data_label_export.odt
new file mode 100644
index 000000000000..85759f2adeca
--- /dev/null
+++ b/chart2/qa/extras/data/odt/tdf135366_data_label_export.odt
Binary files differ
diff --git a/chart2/qa/extras/data/pptx/tdf135366_CustomLabelText.pptx b/chart2/qa/extras/data/pptx/tdf135366_CustomLabelText.pptx
new file mode 100644
index 000000000000..58d73fcd26c1
--- /dev/null
+++ b/chart2/qa/extras/data/pptx/tdf135366_CustomLabelText.pptx
Binary files differ