Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / chart2 / qa / extras / chart2geometry.cxx
blobf560d46ba054fb3eac0798da7ccd67b6a6aa8e6d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include "charttest.hxx"
12 #include <test/xmltesttools.hxx>
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>
19 #include <unotools/saveopt.hxx>
21 #include <string_view>
23 using uno::Reference;
24 using beans::XPropertySet;
26 class Chart2GeometryTest : public ChartTest
28 public:
29 Chart2GeometryTest()
30 : ChartTest("/chart2/qa/extras/data/")
33 // Mostly tests for line and fill properties
34 void testTdf135184RoundLineCap();
35 void testTdf135184RoundLineCap2();
36 void testTdf135184RoundLineCap3();
37 void testTdf135184RoundLineCap4();
38 void testTdf128345ChartArea_CG_TS_export();
39 void testTdf128345ChartArea_CG_TS_import();
40 void testTdf128345ChartWall_CS_TG_export();
41 void testTdf128345ChartWall_CS_TG_import();
42 void testTdf128345Legend_CS_TG_axial_export();
43 void testTdf128345Legend_CS_TG_axial_import();
44 void testTdf135366LabelOnSeries();
45 void testTdf135366LabelOnPoint();
46 void testTdf135366LabelExport();
47 void testTdf135366_CustomLabelText();
49 CPPUNIT_TEST_SUITE(Chart2GeometryTest);
50 CPPUNIT_TEST(testTdf135184RoundLineCap);
51 CPPUNIT_TEST(testTdf135184RoundLineCap2);
52 CPPUNIT_TEST(testTdf135184RoundLineCap3);
53 CPPUNIT_TEST(testTdf135184RoundLineCap4);
54 CPPUNIT_TEST(testTdf128345ChartArea_CG_TS_export);
55 CPPUNIT_TEST(testTdf128345ChartArea_CG_TS_import);
56 CPPUNIT_TEST(testTdf128345ChartWall_CS_TG_export);
57 CPPUNIT_TEST(testTdf128345ChartWall_CS_TG_import);
58 CPPUNIT_TEST(testTdf128345Legend_CS_TG_axial_export);
59 CPPUNIT_TEST(testTdf128345Legend_CS_TG_axial_import);
60 CPPUNIT_TEST(testTdf135366LabelOnSeries);
61 CPPUNIT_TEST(testTdf135366LabelOnPoint);
62 CPPUNIT_TEST(testTdf135366LabelExport);
63 CPPUNIT_TEST(testTdf135366_CustomLabelText);
65 CPPUNIT_TEST_SUITE_END();
68 static OString OU2O(std::u16string_view sOUSource)
70 return rtl::OUStringToOString(sOUSource, RTL_TEXTENCODING_UTF8);
73 // Without the patch for tdf#135184, charts were not able to use linecap at all.
74 // These two tests verify, that round linecaps in the xlsx file are saved in ods.
75 void Chart2GeometryTest::testTdf135184RoundLineCap()
77 // It tests chart area, data series line and regression-curve line.
78 loadFromURL(u"xlsx/tdf135184RoundLineCap.xlsx");
79 save("calc8");
80 xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
81 CPPUNIT_ASSERT(pXmlDoc);
83 const OString sStyleStart("/office:document-content/office:automatic-styles");
84 const OString sCap("/style:graphic-properties[@svg:stroke-linecap='round']");
85 const OString sChartStart("/office:document-content/office:body/office:chart/chart:chart");
86 OString sPredicate;
87 // chart area
88 const OUString sOUAreaStyleName = getXPathContent(pXmlDoc, sChartStart + "/@chart:style-name");
89 sPredicate = "[@style:name='" + OU2O(sOUAreaStyleName) + "']";
90 assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
91 // data series line
92 const OString sSeries(sChartStart + "/chart:plot-area/chart:series");
93 const OUString sOUSeriesStyleName = getXPathContent(pXmlDoc, sSeries + "/@chart:style-name");
94 sPredicate = "[@style:name='" + OU2O(sOUSeriesStyleName) + "']";
95 assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
96 // regression-curve (trend line)
97 const OString sTrend(sChartStart + "/chart:plot-area/chart:series/chart:regression-curve");
98 const OUString sOUTrendStyleName = getXPathContent(pXmlDoc, sTrend + "/@chart:style-name");
99 sPredicate = "[@style:name='" + OU2O(sOUTrendStyleName) + "']";
100 assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
103 void Chart2GeometryTest::testTdf135184RoundLineCap2()
105 // It tests legend, data series sector and title.
106 loadFromURL(u"xlsx/tdf135184RoundLineCap2.xlsx");
107 save("calc8");
108 xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
109 CPPUNIT_ASSERT(pXmlDoc);
111 const OString sStyleStart("/office:document-content/office:automatic-styles");
112 const OString sCap("/style:graphic-properties[@svg:stroke-linecap='round']");
113 const OString sChartStart("/office:document-content/office:body/office:chart/chart:chart");
114 OString sPredicate;
115 // legend
116 const OString sLegend(sChartStart + "/chart:legend");
117 const OUString sOULegendStyleName = getXPathContent(pXmlDoc, sLegend + "/@chart:style-name");
118 sPredicate = "[@style:name='" + OU2O(sOULegendStyleName) + "']";
119 assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
120 // title
121 const OString sTitle(sChartStart + "/chart:title");
122 const OUString sOUTitleStyleName = getXPathContent(pXmlDoc, sTitle + "/@chart:style-name");
123 sPredicate = "[@style:name='" + OU2O(sOUTitleStyleName) + "']";
124 assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
125 // sector
126 const OString sSector(sChartStart + "/chart:plot-area/chart:series/chart:data-point[3]");
127 const OUString sOUSectorStyleName = getXPathContent(pXmlDoc, sSector + "/@chart:style-name");
128 sPredicate = "[@style:name='" + OU2O(sOUSectorStyleName) + "']";
129 assertXPath(pXmlDoc, sStyleStart + "/style:style" + sPredicate + sCap);
132 // These two tests verify the round-trip of preset dash styles in the xlsx file.
133 void Chart2GeometryTest::testTdf135184RoundLineCap3()
135 // It tests chart area, data series line and regression-curve line.
136 loadFromURL(u"xlsx/tdf135184RoundLineCap.xlsx");
137 save("Calc Office Open XML");
138 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
139 CPPUNIT_ASSERT(pXmlDoc);
141 const OString sDash("/c:spPr/a:ln/a:prstDash");
142 // chart area
143 assertXPath(pXmlDoc, "/c:chartSpace" + sDash, "val", "dashDot");
144 // data series line
145 const OString sStart("/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser");
146 assertXPath(pXmlDoc, sStart + sDash, "val", "dash");
147 // regression-curve (trendline)
148 assertXPath(pXmlDoc, sStart + "/c:trendline" + sDash, "val", "sysDot");
151 void Chart2GeometryTest::testTdf135184RoundLineCap4()
153 // It tests legend, data series sector and title.
154 loadFromURL(u"xlsx/tdf135184RoundLineCap2.xlsx");
155 save("Calc Office Open XML");
156 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
157 CPPUNIT_ASSERT(pXmlDoc);
159 const OString sChartStart("/c:chartSpace/c:chart");
160 const OString sDash("/c:spPr/a:ln/a:prstDash");
161 assertXPath(pXmlDoc, sChartStart + "/c:legend" + sDash, "val", "sysDot");
162 const OString sSeries(sChartStart + "/c:plotArea/c:pieChart/c:ser/c:dPt[3]");
163 assertXPath(pXmlDoc, sSeries + sDash, "val", "dash");
164 assertXPath(pXmlDoc, sChartStart + "/c:title" + sDash, "val", "dashDot");
167 void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_export()
169 // chart area with color gradient and solid transparency
170 // Without the patch the transparency was lost in saved pptx file.
171 loadFromURL(u"odp/tdf128345_ChartArea_CG_TS.odp");
173 // MCGR: Similar to testTdf128345Legend_CS_TG_axial_export:
174 // Checked that it works with the existing import file,
175 // but will change with ODF MCGR im/export again.
176 // Adapting for now, but need to re-check values after
177 // ODF im/export for MCGR is integrated
179 // Make sure the chart area has a transparency in gradient stops in saved pptx file.
180 save("Impress MS PowerPoint 2007 XML");
181 xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart1.xml");
182 CPPUNIT_ASSERT(pXmlDoc);
184 OString sPathStart("//c:chartSpace/c:spPr/a:gradFill");
185 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 2);
186 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "30000");
187 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "30000");
190 void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_import()
192 // This works on the file, which was exported from file tdf128345_ChartArea_CG_TS.odp to pptx.
193 // It has gradient stops with identical transparency values.
194 // Make sure chart area has transparency when pptx document is opened and resaved as odp.
195 // As of Aug 2020, the import generates a transparency gradient. When import is changed to
196 // generate solid transparency, the test needs to be adapted.
198 // MCGR: Similar to testTdf128345Legend_CS_TG_axial_export:
199 // Checked that it works with the existing import file,
200 // but will change with ODF MCGR im/export again. We will need to
201 // update the *.odp input file. Disable unclear values for now and
202 // adapt when ODF im/export for MCGR is integrated
203 loadFromURL(u"pptx/tdf128345_ChartArea_CG_TS.pptx");
205 // Find transparency gradient name
206 save("impress8");
207 xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
208 CPPUNIT_ASSERT(pXmlDoc);
209 const OUString sOUChartStyleName = getXPathContent(
210 pXmlDoc,
211 "//office:document-content/office:body/office:chart/chart:chart/@chart:style-name");
212 const OString sStylePath(
213 "//office:document-content/office:automatic-styles/style:style[@style:name='"
214 + OU2O(sOUChartStyleName) + "']");
215 assertXPath(pXmlDoc, sStylePath, 1);
216 assertXPath(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name", 1);
217 const OUString sOUOpacityName
218 = getXPathContent(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name");
220 // Verify the content of the opacity definition
221 save("impress8");
222 xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml");
223 CPPUNIT_ASSERT(pXmlDoc2);
224 const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
225 const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
226 assertXPath(pXmlDoc2, sStart + "]", 1);
227 assertXPath(pXmlDoc2, sStart + " and @draw:style='linear']");
228 assertXPath(pXmlDoc2, sStart + " and @draw:start='30%']");
229 assertXPath(pXmlDoc2, sStart + " and @draw:end='30%']");
230 assertXPath(pXmlDoc2, sStart + " and @draw:angle='30deg']");
231 assertXPath(pXmlDoc2, sStart + " and @draw:border='0%']"); // MCGR: no border anymore 20% -> 0%
234 void Chart2GeometryTest::testTdf128345ChartWall_CS_TG_export()
236 // chart wall with solid color and transparency gradient
237 // Without the patch the transparency was lost.
238 loadFromURL(u"odp/tdf128345_ChartWall_CS_TG.odp");
240 // Make sure the chart has a gradient with transparency in gradient stops in saved pptx file.
241 save("Impress MS PowerPoint 2007 XML");
242 xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart1.xml");
243 CPPUNIT_ASSERT(pXmlDoc);
245 OString sPathStart("//c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill");
246 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 2); //linear
247 // MS Office has opacity, so 100% transparency is val="0"
248 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "0");
249 // no element for 0% transparent
250 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", 0);
253 void Chart2GeometryTest::testTdf128345ChartWall_CS_TG_import()
255 // This works on the file, which was exported from file tdf128345_ChartWall_CS_TG.odp to pptx.
256 // Make sure chart wall has transparency when pptx document is resaved as odp.
257 loadFromURL(u"pptx/tdf128345_ChartWall_CS_TG.pptx");
259 // Find transparency gradient name
260 save("impress8");
261 xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
262 CPPUNIT_ASSERT(pXmlDoc);
263 const OUString sOUChartStyleName
264 = getXPathContent(pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/"
265 "chart:plot-area/chart:wall/@chart:style-name");
266 const OString sStylePath(
267 "//office:document-content/office:automatic-styles/style:style[@style:name='"
268 + OU2O(sOUChartStyleName) + "']");
269 assertXPath(pXmlDoc, sStylePath, 1);
270 assertXPath(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name", 1);
271 const OUString sOUOpacityName
272 = getXPathContent(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name");
274 // Verify content of the opacity definition
275 save("impress8");
276 xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml");
277 CPPUNIT_ASSERT(pXmlDoc2);
278 const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
279 const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
280 assertXPath(pXmlDoc2, sStart + "]", 1);
281 assertXPath(pXmlDoc2, sStart + " and @draw:style='linear']");
282 assertXPath(pXmlDoc2, sStart + " and @draw:start='0%']");
283 assertXPath(pXmlDoc2, sStart + " and @draw:end='100%']");
286 void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_export()
288 // legend with solid color and transparency gradient
289 // Without the patch the transparency was lost.
290 loadFromURL(u"odp/tdf128345_Legend_CS_TG_axial.odp");
292 // Make sure the chart has a gradient with transparency in gradient stops in saved pptx file.
293 save("Impress MS PowerPoint 2007 XML");
294 xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart1.xml");
295 CPPUNIT_ASSERT(pXmlDoc);
297 OString sPathStart("//c:chartSpace/c:chart/c:legend/c:spPr/a:gradFill");
299 // MCGR: three entries due to axial being mirrored+expanded to linear
300 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 3);
302 // MCGR: start entry, no transparence, pos zero
303 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", 0);
304 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]", "pos", "0");
306 // MCGR: middle entry, 100% transparence, pos 0.5
307 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "0");
308 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]", "pos", "50000");
310 // MCGR: end entry, no transparence, pos 1.0
311 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[3]/a:srgbClr/a:alpha", 0);
312 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[3]", "pos", "100000");
315 void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_import()
317 // This works on the file, which was exported from file tdf128345_Legend_CS_TG_axial.odp to pptx.
318 // Error was, that in case of axial not the middle value was taken but start and end value.
319 loadFromURL(u"pptx/tdf128345_Legend_CS_TG_axial.pptx");
321 // Find transparency gradient name
322 save("impress8");
323 xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
324 CPPUNIT_ASSERT(pXmlDoc);
325 const OUString sOUChartStyleName
326 = getXPathContent(pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/"
327 "chart:legend/@chart:style-name");
328 const OString sStylePath(
329 "//office:document-content/office:automatic-styles/style:style[@style:name='"
330 + OU2O(sOUChartStyleName) + "']");
331 assertXPath(pXmlDoc, sStylePath, 1);
332 assertXPath(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name", 1);
333 const OUString sOUOpacityName
334 = getXPathContent(pXmlDoc, sStylePath + "/style:graphic-properties/@draw:opacity-name");
336 // Verify content of the opacity definition
337 save("impress8");
338 xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml");
339 CPPUNIT_ASSERT(pXmlDoc2);
340 const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
341 const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
342 assertXPath(pXmlDoc2, sStart + "]", 1);
343 assertXPath(pXmlDoc2, sStart + " and @draw:style='axial']");
344 assertXPath(pXmlDoc2, sStart + " and @draw:start='0%']");
345 assertXPath(pXmlDoc2, sStart + " and @draw:end='100%']");
348 void Chart2GeometryTest::testTdf135366LabelOnSeries()
350 // Error was, that the fill and line properties of a <chart:data-label> were not
351 // imported at all. Here they should be at the series.
352 loadFromURL(u"ods/tdf135366_data_label_series.ods");
353 uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
354 CPPUNIT_ASSERT(xChartDoc.is());
355 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
356 CPPUNIT_ASSERT(xDataSeries.is());
357 Reference<beans::XPropertySet> xPropSet(xDataSeries, UNO_QUERY_THROW);
358 uno::Any aAny;
360 aAny = xPropSet->getPropertyValue("LabelBorderStyle");
361 drawing::LineStyle eLineStyle;
362 CPPUNIT_ASSERT_MESSAGE("No LabelBorderStyle set.", aAny >>= eLineStyle);
363 CPPUNIT_ASSERT_EQUAL_MESSAGE("solid line expected", drawing::LineStyle_SOLID, eLineStyle);
365 sal_Int32 nBorderWidth;
366 sal_Int32 nExpectedWidth = 95;
367 xPropSet->getPropertyValue("LabelBorderWidth") >>= nBorderWidth;
368 CPPUNIT_ASSERT_EQUAL_MESSAGE("LabelBorderWidth", nExpectedWidth, nBorderWidth);
370 sal_Int32 nLineColor;
371 sal_Int32 nExpectedLineColor = 255;
372 xPropSet->getPropertyValue("LabelBorderColor") >>= nLineColor;
373 CPPUNIT_ASSERT_EQUAL_MESSAGE("line color blue, 255=#0000FF", nExpectedLineColor, nLineColor);
375 aAny = xPropSet->getPropertyValue("LabelFillStyle");
376 drawing::FillStyle eFillStyle;
377 CPPUNIT_ASSERT_MESSAGE("No LabelFillStyle set", aAny >>= eFillStyle);
378 CPPUNIT_ASSERT_EQUAL_MESSAGE("solid fill expected", drawing::FillStyle_SOLID, eFillStyle);
380 sal_Int32 nFillColor;
381 sal_Int32 nExpectedFillColor = 65280;
382 xPropSet->getPropertyValue("LabelFillColor") >>= nFillColor;
383 CPPUNIT_ASSERT_EQUAL_MESSAGE("fill color green, 65280=#00FF00", nExpectedFillColor, nFillColor);
386 void Chart2GeometryTest::testTdf135366LabelOnPoint()
388 // Error was, that the fill and line properties of a <chart:data-label> were not
389 // imported at all. Here they should be at point 2.
390 loadFromURL(u"odt/tdf135366_data_label_point.odt");
391 uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
392 CPPUNIT_ASSERT(xChartDoc.is());
393 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
394 CPPUNIT_ASSERT(xDataSeries.is());
395 Reference<beans::XPropertySet> xPropSet(xDataSeries->getDataPointByIndex(2),
396 uno::UNO_SET_THROW);
397 uno::Any aAny;
399 aAny = xPropSet->getPropertyValue("LabelBorderStyle");
400 drawing::LineStyle eLineStyle;
401 CPPUNIT_ASSERT_MESSAGE("No LabelBorderStyle set.", aAny >>= eLineStyle);
402 CPPUNIT_ASSERT_EQUAL_MESSAGE("solid line expected", drawing::LineStyle_SOLID, eLineStyle);
404 sal_Int32 nBorderWidth;
405 sal_Int32 nExpectedWidth = 381;
406 xPropSet->getPropertyValue("LabelBorderWidth") >>= nBorderWidth;
407 CPPUNIT_ASSERT_EQUAL_MESSAGE("LabelBorderWidth", nExpectedWidth, nBorderWidth);
409 sal_Int32 nLineTransparency;
410 sal_Int32 nExpectedTransparency = 30;
411 xPropSet->getPropertyValue("LabelBorderTransparency") >>= nLineTransparency;
412 CPPUNIT_ASSERT_EQUAL_MESSAGE("line transparency", nExpectedTransparency, nLineTransparency);
414 sal_Int32 nLineColor;
415 sal_Int32 nExpectedLineColor = 10206041;
416 xPropSet->getPropertyValue("LabelBorderColor") >>= nLineColor;
417 CPPUNIT_ASSERT_EQUAL_MESSAGE("line color greenish, 10206041=#9BBB59", nExpectedLineColor,
418 nLineColor);
420 aAny = xPropSet->getPropertyValue("LabelFillStyle");
421 drawing::FillStyle eFillStyle;
422 CPPUNIT_ASSERT_MESSAGE("No LabelFillStyle set", aAny >>= eFillStyle);
423 CPPUNIT_ASSERT_EQUAL_MESSAGE("solid fill expected", drawing::FillStyle_SOLID, eFillStyle);
425 sal_Int32 nFillColor;
426 sal_Int32 nExpectedFillColor = 14277081;
427 xPropSet->getPropertyValue("LabelFillColor") >>= nFillColor;
428 CPPUNIT_ASSERT_EQUAL_MESSAGE("fill color gray, 14277081=#d9d9d9", nExpectedFillColor,
429 nFillColor);
432 void Chart2GeometryTest::testTdf135366LabelExport()
434 // Error was, that line and fill properties were not exported as
435 // graphic-properties of a <chart:data-label> element, but only
436 // as loext chart-properties of the <chart:data-point> element.
437 loadFromURL(u"odt/tdf135366_data_label_export.odt");
439 // FIXME: Error: unexpected attribute "loext:label-stroke-color"
440 skipValidation();
442 save("writer8");
443 xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
444 CPPUNIT_ASSERT(pXmlDoc);
446 // Find label style
447 const OUString sOULabelStyleName = getXPathContent(
448 pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/chart:plot-area"
449 "/chart:series/chart:data-point[1]/chart:data-label/@chart:style-name");
451 // Verify content of graphic properties of label style
452 const OString sStylePath(
453 "//office:document-content/office:automatic-styles/style:style[@style:name='"
454 + OU2O(sOULabelStyleName) + "']/style:graphic-properties");
455 assertXPath(pXmlDoc, sStylePath, 1);
456 assertXPath(pXmlDoc, sStylePath + "[@draw:fill='solid']");
457 assertXPath(pXmlDoc, sStylePath + "[@draw:fill-color='#5050a0']");
458 assertXPath(pXmlDoc, sStylePath + "[@draw:stroke='solid']");
459 assertXPath(pXmlDoc, sStylePath + "[@svg:stroke-width='0.254cm']");
460 assertXPath(pXmlDoc, sStylePath + "[@svg:stroke-color='#00ffff']");
463 void Chart2GeometryTest::testTdf135366_CustomLabelText()
465 // Error was, that custom text in a data label was only exported in ODF extended,
466 // although the used <chart:data-label> element exists since ODF 1.2.
467 const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion());
468 SetODFDefaultVersion(SvtSaveOptions::ODFVER_012);
469 loadFromURL(u"pptx/tdf135366_CustomLabelText.pptx");
470 save("impress8");
471 xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml");
472 CPPUNIT_ASSERT(pXmlDoc);
474 // Find custom text. As of version 7.0 it is in a <text:span> element.
475 const OString sCustomTextPath(
476 "//office:document-content/office:body/office:chart/chart:chart/chart:plot-area"
477 "/chart:series/chart:data-point[2]/chart:data-label/text:p/text:span");
478 assertXPath(pXmlDoc, sCustomTextPath, 1);
480 // Verify text content
481 const OUString sOUTextContent = getXPathContent(pXmlDoc, sCustomTextPath);
482 CPPUNIT_ASSERT_EQUAL(OUString("Custom"), sOUTextContent);
484 SetODFDefaultVersion(nCurrentODFVersion);
487 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2GeometryTest);
489 CPPUNIT_PLUGIN_IMPLEMENT();
491 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */