1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #include "charttest.hxx"
11 
12 #include <test/xmltesttools.hxx>
13 
14 #include <com/sun/star/chart2/XChartDocument.hpp>
15 #include <com/sun/star/chart2/XDataSeries.hpp>
16 #include <com/sun/star/drawing/FillStyle.hpp>
17 #include <com/sun/star/drawing/LineStyle.hpp>
18 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
19 
20 #include <unotools/ucbstreamhelper.hxx>
21 #include <unotools/saveopt.hxx>
22 
23 #include <libxml/xpathInternals.h>
24 
25 #include <algorithm>
26 #include <string_view>
27 
28 using uno::Reference;
29 using beans::XPropertySet;
30 
31 class Chart2GeometryTest : public ChartTest
32 {
33 protected:
34     virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override;
35 
36 public:
Chart2GeometryTest()37     Chart2GeometryTest()
38         : ChartTest()
39     {
40     }
41     // Mostly tests for line and fill properties
42     void testTdf135184RoundLineCap();
43     void testTdf135184RoundLineCap2();
44     void testTdf135184RoundLineCap3();
45     void testTdf135184RoundLineCap4();
46     void testTdf128345ChartArea_CG_TS_export();
47     void testTdf128345ChartArea_CG_TS_import();
48     void testTdf128345ChartWall_CS_TG_export();
49     void testTdf128345ChartWall_CS_TG_import();
50     void testTdf128345Legend_CS_TG_axial_export();
51     void testTdf128345Legend_CS_TG_axial_import();
52     void testTdf135366LabelOnSeries();
53     void testTdf135366LabelOnPoint();
54     void testTdf135366LabelExport();
55     void testTdf135366_CustomLabelText();
56 
57     CPPUNIT_TEST_SUITE(Chart2GeometryTest);
58     CPPUNIT_TEST(testTdf135184RoundLineCap);
59     CPPUNIT_TEST(testTdf135184RoundLineCap2);
60     CPPUNIT_TEST(testTdf135184RoundLineCap3);
61     CPPUNIT_TEST(testTdf135184RoundLineCap4);
62     CPPUNIT_TEST(testTdf128345ChartArea_CG_TS_export);
63     CPPUNIT_TEST(testTdf128345ChartArea_CG_TS_import);
64     CPPUNIT_TEST(testTdf128345ChartWall_CS_TG_export);
65     CPPUNIT_TEST(testTdf128345ChartWall_CS_TG_import);
66     CPPUNIT_TEST(testTdf128345Legend_CS_TG_axial_export);
67     CPPUNIT_TEST(testTdf128345Legend_CS_TG_axial_import);
68     CPPUNIT_TEST(testTdf135366LabelOnSeries);
69     CPPUNIT_TEST(testTdf135366LabelOnPoint);
70     CPPUNIT_TEST(testTdf135366LabelExport);
71     CPPUNIT_TEST(testTdf135366_CustomLabelText);
72 
73     CPPUNIT_TEST_SUITE_END();
74 };
75 
registerNamespaces(xmlXPathContextPtr & pXmlXPathCtx)76 void Chart2GeometryTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx)
77 {
78     XmlTestTools::registerOOXMLNamespaces(pXmlXPathCtx);
79     XmlTestTools::registerODFNamespaces(pXmlXPathCtx);
80 }
81 
OU2O(std::u16string_view sOUSource)82 static OString OU2O(std::u16string_view sOUSource)
83 {
84     return rtl::OUStringToOString(sOUSource, RTL_TEXTENCODING_UTF8);
85 }
86 
87 // Without the patch for tdf#135184, charts were not able to use linecap at all.
88 // These two tests verify, that round linecaps in the xlsx file are saved in ods.
testTdf135184RoundLineCap()89 void Chart2GeometryTest::testTdf135184RoundLineCap()
90 {
91     // It tests chart area, data series line and regression-curve line.
92     load(u"/chart2/qa/extras/data/xlsx/", "tdf135184RoundLineCap.xlsx");
93     xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "calc8");
94     CPPUNIT_ASSERT(pXmlDoc);
95 
96     const OString sStyleStart("/office:document-content/office:automatic-styles");
97     const OString sCap("/style:graphic-properties[@svg:stroke-linecap='round']");
98     const OString sChartStart("/office:document-content/office:body/office:chart/chart:chart");
99     OString sPredicate;
100     // chart area
101     const OUString sOUAreaStyleName = getXPathContent(pXmlDoc, sChartStart + "/@chart:style-name");
102     sPredicate = "[@style:name='" + OU2O(sOUAreaStyleName) + "']";
103     assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
104     // data series line
105     const OString sSeries(sChartStart + "/chart:plot-area/chart:series");
106     const OUString sOUSeriesStyleName = getXPathContent(pXmlDoc, sSeries + "/@chart:style-name");
107     sPredicate = "[@style:name='" + OU2O(sOUSeriesStyleName) + "']";
108     assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
109     // regression-curve (trend line)
110     const OString sTrend(sChartStart + "/chart:plot-area/chart:series/chart:regression-curve");
111     const OUString sOUTrendStyleName = getXPathContent(pXmlDoc, sTrend + "/@chart:style-name");
112     sPredicate = "[@style:name='" + OU2O(sOUTrendStyleName) + "']";
113     assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
114 }
115 
testTdf135184RoundLineCap2()116 void Chart2GeometryTest::testTdf135184RoundLineCap2()
117 {
118     // It tests legend, data series sector and title.
119     load(u"/chart2/qa/extras/data/xlsx/", "tdf135184RoundLineCap2.xlsx");
120     xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "calc8");
121     CPPUNIT_ASSERT(pXmlDoc);
122 
123     const OString sStyleStart("/office:document-content/office:automatic-styles");
124     const OString sCap("/style:graphic-properties[@svg:stroke-linecap='round']");
125     const OString sChartStart("/office:document-content/office:body/office:chart/chart:chart");
126     OString sPredicate;
127     // legend
128     const OString sLegend(sChartStart + "/chart:legend");
129     const OUString sOULegendStyleName = getXPathContent(pXmlDoc, sLegend + "/@chart:style-name");
130     sPredicate = "[@style:name='" + OU2O(sOULegendStyleName) + "']";
131     assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
132     // title
133     const OString sTitle(sChartStart + "/chart:title");
134     const OUString sOUTitleStyleName = getXPathContent(pXmlDoc, sTitle + "/@chart:style-name");
135     sPredicate = "[@style:name='" + OU2O(sOUTitleStyleName) + "']";
136     assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
137     // sector
138     const OString sSector(sChartStart + "/chart:plot-area/chart:series/chart:data-point[3]");
139     const OUString sOUSectorStyleName = getXPathContent(pXmlDoc, sSector + "/@chart:style-name");
140     sPredicate = "[@style:name='" + OU2O(sOUSectorStyleName) + "']";
141     assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
142 }
143 
144 // These two tests verify the round-trip of preset dash styles in the xlsx file.
testTdf135184RoundLineCap3()145 void Chart2GeometryTest::testTdf135184RoundLineCap3()
146 {
147     // It tests chart area, data series line and regression-curve line.
148     load(u"/chart2/qa/extras/data/xlsx/", "tdf135184RoundLineCap.xlsx");
149     xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
150     CPPUNIT_ASSERT(pXmlDoc);
151 
152     const OString sDash("/c:spPr/a:ln/a:prstDash");
153     // chart area
154     assertXPath(pXmlDoc, "/c:chartSpace" + sDash, "val", "dashDot");
155     // data series line
156     const OString sStart("/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser");
157     assertXPath(pXmlDoc, sStart + sDash, "val", "dash");
158     // regression-curve (trendline)
159     assertXPath(pXmlDoc, sStart + "/c:trendline" + sDash, "val", "sysDot");
160 }
161 
testTdf135184RoundLineCap4()162 void Chart2GeometryTest::testTdf135184RoundLineCap4()
163 {
164     // It tests legend, data series sector and title.
165     load(u"/chart2/qa/extras/data/xlsx/", "tdf135184RoundLineCap2.xlsx");
166     xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
167     CPPUNIT_ASSERT(pXmlDoc);
168 
169     const OString sChartStart("/c:chartSpace/c:chart");
170     const OString sDash("/c:spPr/a:ln/a:prstDash");
171     assertXPath(pXmlDoc, sChartStart + "/c:legend" + sDash, "val", "sysDot");
172     const OString sSeries(sChartStart + "/c:plotArea/c:pieChart/c:ser/c:dPt[3]");
173     assertXPath(pXmlDoc, sSeries + sDash, "val", "dash");
174     assertXPath(pXmlDoc, sChartStart + "/c:title" + sDash, "val", "dashDot");
175 }
176 
testTdf128345ChartArea_CG_TS_export()177 void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_export()
178 {
179     // chart area with color gradient and solid transparency
180     // Without the patch the transparency was lost in saved pptx file.
181     load(u"/chart2/qa/extras/data/odp/", "tdf128345_ChartArea_CG_TS.odp");
182 
183     // Make sure the chart area has a transparency in gradient stops in saved pptx file.
184     xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
185     CPPUNIT_ASSERT(pXmlDoc);
186 
187     OString sPathStart("//c:chartSpace/c:spPr/a:gradFill");
188     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 2);
189     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "30000");
190     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "30000");
191 }
192 
testTdf128345ChartArea_CG_TS_import()193 void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_import()
194 {
195     // This works on the file, which was exported from file tdf128345_ChartArea_CG_TS.odp to pptx.
196     // It has gradient stops with identical transparency values.
197     // Make sure chart area has transparency when pptx document is opened and resaved as odp.
198     // As of Aug 2020, the import generates a transparency gradient. When import is changed to
199     // generate solid transparency, the test needs to be adapted.
200     load(u"/chart2/qa/extras/data/pptx/", "tdf128345_ChartArea_CG_TS.pptx");
201 
202     // Find transparency gradient name
203     xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
204     CPPUNIT_ASSERT(pXmlDoc);
205     const OUString sOUChartStyleName = getXPathContent(
206         pXmlDoc,
207         "//office:document-content/office:body/office:chart/chart:chart/@chart:style-name");
208     const OString sStylePath(
209         "//office:document-content/office:automatic-styles/style:style[@style:name='"
210         + OU2O(sOUChartStyleName) + "']");
211     assertXPath(pXmlDoc, sStylePath, 1);
212     assertXPath(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name", 1);
213     const OUString sOUOpacityName
214         = getXPathContent(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name");
215 
216     // Verify the content of the opacity definition
217     xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml", "impress8");
218     CPPUNIT_ASSERT(pXmlDoc2);
219     const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
220     const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
221     assertXPath(pXmlDoc2, sStart + "]", 1);
222     assertXPath(pXmlDoc2, sStart + " and @draw:style='linear']");
223     assertXPath(pXmlDoc2, sStart + " and @draw:start='30%']");
224     assertXPath(pXmlDoc2, sStart + " and @draw:end='30%']");
225     assertXPath(pXmlDoc2, sStart + " and @draw:angle='30deg']");
226     assertXPath(pXmlDoc2, sStart + " and @draw:border='20%']");
227 }
228 
testTdf128345ChartWall_CS_TG_export()229 void Chart2GeometryTest::testTdf128345ChartWall_CS_TG_export()
230 {
231     // chart wall with solid color and transparency gradient
232     // Without the patch the transparency was lost.
233     load(u"/chart2/qa/extras/data/odp/", "tdf128345_ChartWall_CS_TG.odp");
234 
235     // Make sure the chart has a gradient with transparency in gradient stops in saved pptx file.
236     xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
237     CPPUNIT_ASSERT(pXmlDoc);
238 
239     OString sPathStart("//c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill");
240     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 2); //linear
241     // MS Office has opacity, so 100% transparency is val="0"
242     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "0");
243     // no element for 0% transparent
244     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", 0);
245 }
246 
testTdf128345ChartWall_CS_TG_import()247 void Chart2GeometryTest::testTdf128345ChartWall_CS_TG_import()
248 {
249     // This works on the file, which was exported from file tdf128345_ChartWall_CS_TG.odp to pptx.
250     // Make sure chart wall has transparency when pptx document is resaved as odp.
251     load(u"/chart2/qa/extras/data/pptx/", "tdf128345_ChartWall_CS_TG.pptx");
252 
253     // Find transparency gradient name
254     xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
255     CPPUNIT_ASSERT(pXmlDoc);
256     const OUString sOUChartStyleName
257         = getXPathContent(pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/"
258                                    "chart:plot-area/chart:wall/@chart:style-name");
259     const OString sStylePath(
260         "//office:document-content/office:automatic-styles/style:style[@style:name='"
261         + OU2O(sOUChartStyleName) + "']");
262     assertXPath(pXmlDoc, sStylePath, 1);
263     assertXPath(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name", 1);
264     const OUString sOUOpacityName
265         = getXPathContent(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name");
266 
267     // Verify content of the opacity definition
268     xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml", "impress8");
269     CPPUNIT_ASSERT(pXmlDoc2);
270     const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
271     const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
272     assertXPath(pXmlDoc2, sStart + "]", 1);
273     assertXPath(pXmlDoc2, sStart + " and @draw:style='linear']");
274     assertXPath(pXmlDoc2, sStart + " and @draw:start='0%']");
275     assertXPath(pXmlDoc2, sStart + " and @draw:end='100%']");
276 }
277 
testTdf128345Legend_CS_TG_axial_export()278 void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_export()
279 {
280     // legend with solid color and transparency gradient
281     // Without the patch the transparency was lost.
282     load(u"/chart2/qa/extras/data/odp/", "tdf128345_Legend_CS_TG_axial.odp");
283 
284     // Make sure the chart has a gradient with transparency in gradient stops in saved pptx file.
285     xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
286     CPPUNIT_ASSERT(pXmlDoc);
287 
288     OString sPathStart("//c:chartSpace/c:chart/c:legend/c:spPr/a:gradFill");
289     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 3); // axial
290     // no element for 0% transparent
291     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", 0);
292     // 100% transparent = opacity 0. It comes from "axial", therefore it is in the middle.
293     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "0");
294     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]", "pos", "50000");
295     assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[3]/a:srgbClr/a:alpha", 0);
296 }
297 
testTdf128345Legend_CS_TG_axial_import()298 void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_import()
299 {
300     // This works on the file, which was exported from file tdf128345_Legend_CS_TG_axial.odp to pptx.
301     // Error was, that in case of axial not the middle value was taken but start and end value.
302     load(u"/chart2/qa/extras/data/pptx/", "tdf128345_Legend_CS_TG_axial.pptx");
303 
304     // Find transparency gradient name
305     xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
306     CPPUNIT_ASSERT(pXmlDoc);
307     const OUString sOUChartStyleName
308         = getXPathContent(pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/"
309                                    "chart:legend/@chart:style-name");
310     const OString sStylePath(
311         "//office:document-content/office:automatic-styles/style:style[@style:name='"
312         + OU2O(sOUChartStyleName) + "']");
313     assertXPath(pXmlDoc, sStylePath, 1);
314     assertXPath(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name", 1);
315     const OUString sOUOpacityName
316         = getXPathContent(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name");
317 
318     // Verify content of the opacity definition
319     xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml", "impress8");
320     CPPUNIT_ASSERT(pXmlDoc2);
321     const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
322     const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
323     assertXPath(pXmlDoc2, sStart + "]", 1);
324     assertXPath(pXmlDoc2, sStart + " and @draw:style='axial']");
325     assertXPath(pXmlDoc2, sStart + " and @draw:start='0%']");
326     assertXPath(pXmlDoc2, sStart + " and @draw:end='100%']");
327 }
328 
testTdf135366LabelOnSeries()329 void Chart2GeometryTest::testTdf135366LabelOnSeries()
330 {
331     // Error was, that the fill and line properties of a <chart:data-label> were not
332     // imported at all. Here they should be at the series.
333     load(u"/chart2/qa/extras/data/ods/", "tdf135366_data_label_series.ods");
334     uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
335     CPPUNIT_ASSERT(xChartDoc.is());
336     Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
337     CPPUNIT_ASSERT(xDataSeries.is());
338     Reference<beans::XPropertySet> xPropSet(xDataSeries, UNO_QUERY_THROW);
339     uno::Any aAny;
340 
341     aAny = xPropSet->getPropertyValue("LabelBorderStyle");
342     drawing::LineStyle eLineStyle;
343     CPPUNIT_ASSERT_MESSAGE("No LabelBorderStyle set.", aAny >>= eLineStyle);
344     CPPUNIT_ASSERT_EQUAL_MESSAGE("solid line expected", drawing::LineStyle_SOLID, eLineStyle);
345 
346     sal_Int32 nBorderWidth;
347     sal_Int32 nExpectedWidth = 95;
348     xPropSet->getPropertyValue("LabelBorderWidth") >>= nBorderWidth;
349     CPPUNIT_ASSERT_EQUAL_MESSAGE("LabelBorderWidth", nExpectedWidth, nBorderWidth);
350 
351     sal_Int32 nLineColor;
352     sal_Int32 nExpectedLineColor = 255;
353     xPropSet->getPropertyValue("LabelBorderColor") >>= nLineColor;
354     CPPUNIT_ASSERT_EQUAL_MESSAGE("line color blue, 255=#0000FF", nExpectedLineColor, nLineColor);
355 
356     aAny = xPropSet->getPropertyValue("LabelFillStyle");
357     drawing::FillStyle eFillStyle;
358     CPPUNIT_ASSERT_MESSAGE("No LabelFillStyle set", aAny >>= eFillStyle);
359     CPPUNIT_ASSERT_EQUAL_MESSAGE("solid fill expected", drawing::FillStyle_SOLID, eFillStyle);
360 
361     sal_Int32 nFillColor;
362     sal_Int32 nExpectedFillColor = 65280;
363     xPropSet->getPropertyValue("LabelFillColor") >>= nFillColor;
364     CPPUNIT_ASSERT_EQUAL_MESSAGE("fill color green, 65280=#00FF00", nExpectedFillColor, nFillColor);
365 }
366 
testTdf135366LabelOnPoint()367 void Chart2GeometryTest::testTdf135366LabelOnPoint()
368 {
369     // Error was, that the fill and line properties of a <chart:data-label> were not
370     // imported at all. Here they should be at point 2.
371     load(u"/chart2/qa/extras/data/odt/", "tdf135366_data_label_point.odt");
372     uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
373     CPPUNIT_ASSERT(xChartDoc.is());
374     Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
375     CPPUNIT_ASSERT(xDataSeries.is());
376     Reference<beans::XPropertySet> xPropSet(xDataSeries->getDataPointByIndex(2),
377                                             uno::UNO_SET_THROW);
378     uno::Any aAny;
379 
380     aAny = xPropSet->getPropertyValue("LabelBorderStyle");
381     drawing::LineStyle eLineStyle;
382     CPPUNIT_ASSERT_MESSAGE("No LabelBorderStyle set.", aAny >>= eLineStyle);
383     CPPUNIT_ASSERT_EQUAL_MESSAGE("solid line expected", drawing::LineStyle_SOLID, eLineStyle);
384 
385     sal_Int32 nBorderWidth;
386     sal_Int32 nExpectedWidth = 381;
387     xPropSet->getPropertyValue("LabelBorderWidth") >>= nBorderWidth;
388     CPPUNIT_ASSERT_EQUAL_MESSAGE("LabelBorderWidth", nExpectedWidth, nBorderWidth);
389 
390     sal_Int32 nLineTransparency;
391     sal_Int32 nExpectedTransparency = 30;
392     xPropSet->getPropertyValue("LabelBorderTransparency") >>= nLineTransparency;
393     CPPUNIT_ASSERT_EQUAL_MESSAGE("line transparency", nExpectedTransparency, nLineTransparency);
394 
395     sal_Int32 nLineColor;
396     sal_Int32 nExpectedLineColor = 10206041;
397     xPropSet->getPropertyValue("LabelBorderColor") >>= nLineColor;
398     CPPUNIT_ASSERT_EQUAL_MESSAGE("line color greenish, 10206041=#9BBB59", nExpectedLineColor,
399                                  nLineColor);
400 
401     aAny = xPropSet->getPropertyValue("LabelFillStyle");
402     drawing::FillStyle eFillStyle;
403     CPPUNIT_ASSERT_MESSAGE("No LabelFillStyle set", aAny >>= eFillStyle);
404     CPPUNIT_ASSERT_EQUAL_MESSAGE("solid fill expected", drawing::FillStyle_SOLID, eFillStyle);
405 
406     sal_Int32 nFillColor;
407     sal_Int32 nExpectedFillColor = 14277081;
408     xPropSet->getPropertyValue("LabelFillColor") >>= nFillColor;
409     CPPUNIT_ASSERT_EQUAL_MESSAGE("fill color gray, 14277081=#d9d9d9", nExpectedFillColor,
410                                  nFillColor);
411 }
412 
testTdf135366LabelExport()413 void Chart2GeometryTest::testTdf135366LabelExport()
414 {
415     // Error was, that line and fill properties were not exported as
416     // graphic-properties of a <chart:data-label> element, but only
417     // as loext chart-properties of the <chart:data-point> element.
418     load(u"/chart2/qa/extras/data/odt/", "tdf135366_data_label_export.odt");
419     xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "writer8");
420     CPPUNIT_ASSERT(pXmlDoc);
421 
422     // Find label style
423     const OUString sOULabelStyleName = getXPathContent(
424         pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/chart:plot-area"
425                  "/chart:series/chart:data-point[1]/chart:data-label/@chart:style-name");
426 
427     // Verify content of graphic properties of label style
428     const OString sStylePath(
429         "//office:document-content/office:automatic-styles/style:style[@style:name='"
430         + OU2O(sOULabelStyleName) + "']/style:graphic-properties");
431     assertXPath(pXmlDoc, sStylePath, 1);
432     assertXPath(pXmlDoc, sStylePath + "[@draw:fill='solid']");
433     assertXPath(pXmlDoc, sStylePath + "[@draw:fill-color='#5050a0']");
434     assertXPath(pXmlDoc, sStylePath + "[@draw:stroke='solid']");
435     assertXPath(pXmlDoc, sStylePath + "[@svg:stroke-width='0.254cm']");
436     assertXPath(pXmlDoc, sStylePath + "[@svg:stroke-color='#00ffff']");
437 }
438 
testTdf135366_CustomLabelText()439 void Chart2GeometryTest::testTdf135366_CustomLabelText()
440 {
441     // Error was, that custom text in a data label was only exported in ODF extended,
442     // although the used <chart:data-label> element exists since ODF 1.2.
443     SvtSaveOptions aSaveOpt;
444     const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(aSaveOpt.GetODFDefaultVersion());
445     aSaveOpt.SetODFDefaultVersion(SvtSaveOptions::ODFVER_012);
446     load(u"/chart2/qa/extras/data/pptx/", "tdf135366_CustomLabelText.pptx");
447     xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
448     CPPUNIT_ASSERT(pXmlDoc);
449 
450     // Find custom text. As of version 7.0 it is in a <text:span> element.
451     const OString sCustomTextPath(
452         "//office:document-content/office:body/office:chart/chart:chart/chart:plot-area"
453         "/chart:series/chart:data-point[2]/chart:data-label/text:p/text:span");
454     assertXPath(pXmlDoc, sCustomTextPath, 1);
455 
456     // Verify text content
457     const OUString sOUTextContent = getXPathContent(pXmlDoc, sCustomTextPath);
458     CPPUNIT_ASSERT_EQUAL(OUString("Custom"), sOUTextContent);
459 
460     aSaveOpt.SetODFDefaultVersion(nCurrentODFVersion);
461 }
462 
463 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2GeometryTest);
464 
465 CPPUNIT_PLUGIN_IMPLEMENT();
466 
467 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
468