1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include "charttest.hxx"
12 #include <com/sun/star/chart2/DataPointLabel.hpp>
13 #include <com/sun/star/awt/FontWeight.hpp>
14 #include <com/sun/star/awt/FontSlant.hpp>
15 #include <com/sun/star/awt/FontUnderline.hpp>
18 using beans::XPropertySet
;
20 class Chart2ExportTest3
: public ChartTest
23 Chart2ExportTest3() : ChartTest(u
"/chart2/qa/extras/data/"_ustr
) {}
26 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testTdf108107
)
28 loadFromFile(u
"xlsx/tdf108107.xlsx");
30 // FIXME: validation error in OOXML export: Errors: 1
33 save(u
"Calc Office Open XML"_ustr
);
34 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
35 CPPUNIT_ASSERT(pXmlDoc
);
36 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:idx", "val", u
"1");
37 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:txPr/a:p/a:pPr/a:defRPr", "b", u
"1");
38 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:txPr/a:p/a:pPr/a:defRPr", "sz", u
"2000");
41 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testTdf114139
)
43 loadFromFile(u
"xlsx/tdf114139.xlsx");
44 save(u
"Calc Office Open XML"_ustr
);
45 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
46 CPPUNIT_ASSERT(pXmlDoc
);
48 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:pie3DChart", 1);
50 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:spPr", 0);
51 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:solidFill", 0);
54 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testTdf64224
)
56 loadFromFile(u
"ods/tdf64224.ods");
57 save(u
"Calc Office Open XML"_ustr
);
58 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
59 CPPUNIT_ASSERT(pXmlDoc
);
62 assertXPath(pXmlDoc
, "/c:chartSpace/c:spPr/a:noFill", 1);
63 assertXPath(pXmlDoc
, "/c:chartSpace/c:spPr/a:solidFill", 0);
66 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testChartTitlePropertiesColorFillDOCX
)
68 loadFromFile(u
"docx/testChartTitlePropertiesColorFill.docx");
69 save(u
"Office Open XML Text"_ustr
);
70 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/charts/chart1.xml"_ustr
);
71 CPPUNIT_ASSERT(pXmlDoc
);
72 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", u
"ff0000");
73 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
76 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testChartTitlePropertiesGradientFillDOCX
)
78 loadFromFile(u
"docx/testChartTitlePropertiesGradientFill.docx");
79 save(u
"Office Open XML Text"_ustr
);
80 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/charts/chart1.xml"_ustr
);
81 CPPUNIT_ASSERT(pXmlDoc
);
82 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", u
"cccccc");
83 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", u
"666666");
84 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
87 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testChartTitlePropertiesBitmapFillDOCX
)
89 loadFromFile(u
"docx/testChartTitlePropertiesBitmapFill.docx");
90 save(u
"Office Open XML Text"_ustr
);
91 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/charts/chart1.xml"_ustr
);
92 CPPUNIT_ASSERT(pXmlDoc
);
93 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip", "embed", u
"rId1");
94 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
98 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testColorGradientWithTransparencyDOCX
)
100 // Test color gradient (two color) with gradient transparency
101 loadFromFile(u
"docx/testColorGradientWithTransparency.docx");
102 save(u
"Office Open XML Text"_ustr
);
103 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/charts/chart1.xml"_ustr
);
104 CPPUNIT_ASSERT(pXmlDoc
);
105 // Test the transparency of the first color
106 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", u
"60000");
107 // Test the transparency of the second color
108 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", u
"90000");
111 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testColorGradientWithTransparencyODS
)
113 // Test color gradient (two color) with simple transparency
114 loadFromFile(u
"ods/testColorGradientWithTransparency.ods");
115 save(u
"Calc Office Open XML"_ustr
);
116 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
117 CPPUNIT_ASSERT(pXmlDoc
);
118 // Test the transparency of the first color
119 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", u
"60000");
120 // Test the transparency of the second color
121 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", u
"60000");
124 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testColorGradientStopXLSX
)
126 // Test color gradient (two color) stop of the first color
127 loadFromFile(u
"xlsx/tdf128619.xlsx");
128 save(u
"Calc Office Open XML"_ustr
);
129 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
130 CPPUNIT_ASSERT(pXmlDoc
);
131 // Test the position of the first color
132 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[1]", "pos", u
"45000");
133 // Test the position of the second color
134 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[2]", "pos", u
"100000");
137 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testRadialColorGradientDOCX
)
139 loadFromFile(u
"docx/tdf128794.docx");
140 save(u
"Office Open XML Text"_ustr
);
141 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/charts/chart1.xml"_ustr
);
142 CPPUNIT_ASSERT(pXmlDoc
);
143 // Test the gradient style (if there is no 'a:path' attribute, it is a linear gradient)
144 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path", 0);
145 // Test the linear gradient angle
146 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:lin", "ang", u
"13500000");
149 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testBarChartDataPointPropDOCX
)
151 loadFromFile(u
"docx/testBarChartDataPointPropDOCX.docx");
152 save(u
"Office Open XML Text"_ustr
);
153 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/charts/chart1.xml"_ustr
);
154 CPPUNIT_ASSERT(pXmlDoc
);
156 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", u
"0");
158 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:idx", "val", u
"1");
159 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", u
"f6f8fc");
160 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", u
"c7d5ed");
161 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:ln/a:solidFill/a:srgbClr", "val", u
"70ad47");
163 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:idx", "val", u
"2");
164 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:solidFill/a:srgbClr", "val", u
"ff0000");
165 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:ln/a:solidFill/a:srgbClr", "val", u
"000000");
168 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testFdo83058dlblPos
)
170 loadFromFile(u
"docx/fdo83058_dlblPos.docx");
172 // FIXME: validation error in OOXML export: Errors: 1
175 save(u
"Office Open XML Text"_ustr
);
176 xmlDocUniquePtr pXmlDoc
= parseExport(u
"word/charts/chart1.xml"_ustr
);
177 CPPUNIT_ASSERT(pXmlDoc
);
178 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[2]/c:dLblPos", "val", u
"outEnd");
179 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[3]/c:dLblPos", "val", u
"outEnd");
180 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[4]/c:dLblPos", "val", u
"outEnd");
181 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[5]/c:dLblPos", "val", u
"outEnd");
184 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testAutoTitleDelXLSX
)
186 loadFromFile(u
"xlsx/autotitledel_2007.xlsx");
187 save(u
"Calc Office Open XML"_ustr
);
188 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
189 CPPUNIT_ASSERT(pXmlDoc
);
190 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:autoTitleDeleted", "val", u
"0");
193 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testDispBlanksAsXLSX
)
195 loadFromFile(u
"xlsx/dispBlanksAs_2007.xlsx");
196 save(u
"Calc Office Open XML"_ustr
);
197 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
198 CPPUNIT_ASSERT(pXmlDoc
);
199 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", u
"gap");
202 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testMarkerColorXLSX
)
204 loadFromFile(u
"xlsx/markerColor.xlsx");
205 save(u
"Calc Office Open XML"_ustr
);
206 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
207 CPPUNIT_ASSERT(pXmlDoc
);
208 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:marker/c:spPr/a:solidFill/a:srgbClr", "val", u
"92d050");
211 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testRoundedCornersXLSX
)
213 loadFromFile(u
"xlsx/markerColor.xlsx");
214 save(u
"Calc Office Open XML"_ustr
);
215 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
216 CPPUNIT_ASSERT(pXmlDoc
);
217 assertXPath(pXmlDoc
, "/c:chartSpace/c:roundedCorners", "val", u
"0");
220 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testAxisNumberFormatXLSX
)
222 loadFromFile(u
"ods/axis_number_format.ods");
223 save(u
"Calc Office Open XML"_ustr
);
224 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
225 CPPUNIT_ASSERT(pXmlDoc
);
226 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx", 2);
227 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:numFmt", "formatCode", u
"0.00E+000");
228 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:numFmt", "sourceLinked", u
"0");
230 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:numFmt", "formatCode", u
"[$$-409]#,##0;\\-[$$-409]#,##0");
231 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:numFmt", "sourceLinked", u
"1");
234 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testDataPointLabelNumberFormatXLSX
)
236 // FIXME: validation error in OOXML export: Errors: 1
239 loadFromFile(u
"ods/tdf123774.ods");
241 save(u
"Calc Office Open XML"_ustr
);
242 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
243 CPPUNIT_ASSERT(pXmlDoc
);
244 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt", "formatCode", u
"[$-40E]0.00%");
245 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt", "sourceLinked", u
"0");
247 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:numFmt", "formatCode", u
"[$-40E]0.00%");
248 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:numFmt", "sourceLinked", u
"0");
251 loadFromFile(u
"xlsx/tdf130986.xlsx");
253 save(u
"Calc Office Open XML"_ustr
);
254 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
255 CPPUNIT_ASSERT(pXmlDoc
);
256 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:idx", "val", u
"1");
257 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:numFmt", "formatCode", u
"0.00E+00");
258 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:numFmt", "sourceLinked", u
"0");
262 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testDataLabelDefaultValuesXLSX
)
264 loadFromFile(u
"xlsx/data_label.xlsx");
265 Reference
< chart2::XChartDocument
> xDoc
= getChartDocFromSheet(0);
266 Reference
<chart2::XDataSeries
> xSeries
= getDataSeriesFromDoc(xDoc
, 0);
267 Reference
<beans::XPropertySet
> xPropSet(xSeries
, uno::UNO_QUERY_THROW
);
268 uno::Any aAny
= xPropSet
->getPropertyValue(u
"Label"_ustr
);
269 chart2::DataPointLabel aLabel
;
270 CPPUNIT_ASSERT(aAny
>>= aLabel
);
271 CPPUNIT_ASSERT(aLabel
.ShowNumber
);
273 save(u
"Calc Office Open XML"_ustr
);
274 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
275 CPPUNIT_ASSERT(pXmlDoc
);
276 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:showVal", "val", u
"1");
277 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLblPos", "val", u
"outEnd");
280 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testDataLabelFillColor
)
282 loadFromFile(u
"xlsx/data_labels_fill_color.xlsx");
283 Reference
< chart2::XChartDocument
> xDoc
= getChartDocFromSheet(0);
284 Reference
<chart2::XDataSeries
> xSeries
= getDataSeriesFromDoc(xDoc
, 0);
285 Reference
<beans::XPropertySet
> xPropSet(xSeries
, uno::UNO_QUERY_THROW
);
286 uno::Any aAny
= xPropSet
->getPropertyValue(u
"LabelFillColor"_ustr
);
287 sal_Int32 nLabelFillColor
;
288 CPPUNIT_ASSERT(aAny
>>= nLabelFillColor
);
290 save(u
"Calc Office Open XML"_ustr
);
291 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
292 CPPUNIT_ASSERT(pXmlDoc
);
293 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:spPr/a:solidFill/a:srgbClr", "val", u
"F79646");
296 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testTitleOverlayXLSX
)
298 loadFromFile(u
"xlsx/chart_title.xlsx");
299 save(u
"Calc Office Open XML"_ustr
);
300 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
301 CPPUNIT_ASSERT(pXmlDoc
);
302 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:overlay", "val", u
"0");
305 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testInvertIfNegativeXLSX
)
307 loadFromFile(u
"xlsx/bar_chart_simple.xlsx");
308 save(u
"Calc Office Open XML"_ustr
);
309 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
310 CPPUNIT_ASSERT(pXmlDoc
);
311 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:invertIfNegative", "val", u
"0");
314 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testBubble3DXLSX
)
316 loadFromFile(u
"xlsx/bubble_chart_simple.xlsx");
317 save(u
"Calc Office Open XML"_ustr
);
318 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
319 CPPUNIT_ASSERT(pXmlDoc
);
320 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:bubbleChart/c:ser[1]/c:bubble3D", "val", u
"0");
321 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:bubbleChart/c:ser[2]/c:bubble3D", "val", u
"0");
322 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:bubbleChart/c:ser[3]/c:bubble3D", "val", u
"0");
325 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testNoMarkerXLSX
)
327 loadFromFile(u
"xlsx/no_marker.xlsx");
328 save(u
"Calc Office Open XML"_ustr
);
329 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
330 CPPUNIT_ASSERT(pXmlDoc
);
331 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:marker/c:symbol", "val", u
"none");
332 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:marker/c:symbol", "val", u
"none");
333 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:marker", "val", u
"0");
336 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testTitleManualLayoutXLSX
)
338 loadFromFile(u
"xlsx/title_manual_layout.xlsx");
339 save(u
"Calc Office Open XML"_ustr
);
340 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
341 CPPUNIT_ASSERT(pXmlDoc
);
342 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:layoutTarget", 0);
343 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:xMode", "val", u
"edge");
344 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:yMode", "val", u
"edge");
346 OUString aXVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:x", "val");
347 double nX
= aXVal
.toDouble();
348 CPPUNIT_ASSERT(nX
> 0);
349 CPPUNIT_ASSERT(nX
< 1);
351 OUString aYVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:y", "val");
352 double nY
= aYVal
.toDouble();
353 CPPUNIT_ASSERT(nY
> 0);
354 CPPUNIT_ASSERT(nY
< 1);
355 CPPUNIT_ASSERT(nX
!= nY
);
357 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:bodyPr", "rot", u
"1200000");
360 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testPlotAreaManualLayoutXLSX
)
362 loadFromFile(u
"xlsx/plot_area_manual_layout.xlsx");
363 save(u
"Calc Office Open XML"_ustr
);
364 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
365 CPPUNIT_ASSERT(pXmlDoc
);
367 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:layoutTarget", "val", u
"inner");
368 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:xMode", "val", u
"edge");
369 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:yMode", "val", u
"edge");
371 OUString aXVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:x", "val");
372 double nX
= aXVal
.toDouble();
373 CPPUNIT_ASSERT(nX
> 0);
374 CPPUNIT_ASSERT(nX
< 1);
376 OUString aYVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:y", "val");
377 double nY
= aYVal
.toDouble();
378 CPPUNIT_ASSERT(nY
> 0);
379 CPPUNIT_ASSERT(nY
< 1);
380 CPPUNIT_ASSERT(nX
!= nY
);
382 OUString aWVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:w", "val");
383 double nW
= aWVal
.toDouble();
384 CPPUNIT_ASSERT(nW
> 0);
385 CPPUNIT_ASSERT(nW
< 1);
387 OUString aHVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:h", "val");
388 double nH
= aHVal
.toDouble();
389 CPPUNIT_ASSERT(nH
> 0);
390 CPPUNIT_ASSERT(nH
< 1);
391 CPPUNIT_ASSERT(nH
!= nW
);
394 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testLegendManualLayoutXLSX
)
396 loadFromFile(u
"xlsx/legend_manual_layout.xlsx");
397 save(u
"Calc Office Open XML"_ustr
);
398 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
399 CPPUNIT_ASSERT(pXmlDoc
);
401 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:layoutTarget", 0);
402 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:xMode", "val", u
"edge");
403 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:yMode", "val", u
"edge");
405 OUString aXVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:x", "val");
406 double nX
= aXVal
.toDouble();
407 CPPUNIT_ASSERT(nX
> 0);
408 CPPUNIT_ASSERT(nX
< 1);
410 OUString aYVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:y", "val");
411 double nY
= aYVal
.toDouble();
412 CPPUNIT_ASSERT(nY
> 0);
413 CPPUNIT_ASSERT(nY
< 1);
414 CPPUNIT_ASSERT(nX
!= nY
);
416 OUString aWVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:w", "val");
417 double nW
= aWVal
.toDouble();
418 CPPUNIT_ASSERT(nW
> 0);
419 CPPUNIT_ASSERT(nW
< 1);
421 OUString aHVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:h", "val");
422 double nH
= aHVal
.toDouble();
423 CPPUNIT_ASSERT(nH
> 0);
424 CPPUNIT_ASSERT(nH
< 1);
425 CPPUNIT_ASSERT(nH
!= nW
);
427 // Make sure that default text font size is preserved after export
428 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:txPr/a:p/a:pPr/a:defRPr", "sz", u
"900");
431 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testChartSubTitle
)
433 loadFromFile(u
"ods/testChartSubTitle.ods");
434 save(u
"Calc Office Open XML"_ustr
);
435 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
436 CPPUNIT_ASSERT(pXmlDoc
);
437 // test properties of subtitle
439 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "sz", u
"1100");
440 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "b", u
"1");
442 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr", "sz", u
"1100");
443 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr", "b", u
"1");
444 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr/a:solidFill/a:srgbClr", "val", u
"00a933");
445 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr/a:latin", "typeface", u
"Times New Roman");
447 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:t", u
"It is a Subtitle");
449 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", u
"b2b2b2");
452 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testChartMainWithSubTitle
)
454 loadFromFile(u
"ods/testChartMainWithSubTitle.ods");
455 save(u
"Calc Office Open XML"_ustr
);
456 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
457 CPPUNIT_ASSERT(pXmlDoc
);
458 // test properties of title
460 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:pPr/a:defRPr", "sz", u
"1300");
461 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:pPr/a:defRPr", "b", u
"0");
463 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r/a:rPr", "sz", u
"1300");
464 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r/a:rPr", "b", u
"0");
465 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r/a:rPr", "i", u
"1");
466 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r/a:rPr/a:solidFill/a:srgbClr", "val", u
"f10d0c");
467 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r/a:rPr/a:latin", "typeface", u
"Arial");
469 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r/a:t", u
"It is a Maintitle");
470 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r/a:t", u
"It is a Subtitle");
472 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", u
"81d41a");
475 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testAutoTitleDeleted
)
477 loadFromFile(u
"xlsx/testAutoTitleDeleted.xlsx");
478 save(u
"Calc Office Open XML"_ustr
);
479 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
480 CPPUNIT_ASSERT(pXmlDoc
);
481 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:autoTitleDeleted", "val", u
"1");
484 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testChartTitlePropertiesColorFillXLSX
)
486 loadFromFile(u
"xlsx/testChartTitlePropertiesColorFill.xlsx");
487 save(u
"Calc Office Open XML"_ustr
);
488 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
489 CPPUNIT_ASSERT(pXmlDoc
);
490 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", u
"ff0000");
491 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
494 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testChartTitlePropertiesGradientFillXLSX
)
496 loadFromFile(u
"xlsx/testChartTitlePropertiesGradientFill.xlsx");
497 save(u
"Calc Office Open XML"_ustr
);
498 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
499 CPPUNIT_ASSERT(pXmlDoc
);
500 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", u
"cccccc");
501 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", u
"666666");
502 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
505 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testChartTitlePropertiesBitmapFillXLSX
)
507 loadFromFile(u
"xlsx/testChartTitlePropertiesBitmapFill.xlsx");
508 save(u
"Calc Office Open XML"_ustr
);
509 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
510 CPPUNIT_ASSERT(pXmlDoc
);
511 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip", "embed", u
"rId1");
512 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
515 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testBarChartDataPointPropXLSX
)
517 loadFromFile(u
"xlsx/testBarChartDataPointPropXLSX.xlsx");
518 save(u
"Calc Office Open XML"_ustr
);
519 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
520 CPPUNIT_ASSERT(pXmlDoc
);
522 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", u
"0");
524 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:idx", "val", u
"1");
525 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:solidFill/a:srgbClr", "val", u
"ff0000");
526 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:ln/a:solidFill/a:srgbClr", "val", u
"000000");
528 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:idx", "val", u
"2");
529 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", u
"f6f8fc");
530 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", u
"c7d5ed");
531 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:ln/a:solidFill/a:srgbClr", "val", u
"70ad47");
534 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testAxisCharacterPropertiesXLSX
)
536 loadFromFile(u
"xlsx/axis_character_properties.xlsx");
537 save(u
"Calc Office Open XML"_ustr
);
538 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
539 CPPUNIT_ASSERT(pXmlDoc
);
541 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "sz", u
"1000");
542 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "b", u
"1");
543 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "i", u
"1");
544 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "u", u
"sng");
546 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr", "sz", u
"900");
547 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr", "b", u
"1");
548 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr", "strike", u
"sngStrike");
549 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr", "val", u
"ff0000");
552 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testTitleCharacterPropertiesXLSX
)
554 loadFromFile(u
"xlsx/title_character_properties.xlsx");
555 save(u
"Calc Office Open XML"_ustr
);
556 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
557 CPPUNIT_ASSERT(pXmlDoc
);
559 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "sz", u
"1300");
560 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "b", u
"0");
562 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr", "sz", u
"2400");
563 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr", "b", u
"1");
566 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testPlotVisOnlyXLSX
)
568 loadFromFile(u
"xlsx/hidden_cells.xlsx");
569 save(u
"Calc Office Open XML"_ustr
);
570 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
571 CPPUNIT_ASSERT(pXmlDoc
);
573 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotVisOnly", "val", u
"0");
576 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testBarChartVaryColorsXLSX
)
578 loadFromFile(u
"xlsx/tdf90876.xlsx");
579 save(u
"Calc Office Open XML"_ustr
);
580 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
581 CPPUNIT_ASSERT(pXmlDoc
);
583 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", u
"0");
586 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testTdf96161
)
588 loadFromFile(u
"ods/tdf96161.ods");
589 save(u
"Calc Office Open XML"_ustr
);
590 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
591 CPPUNIT_ASSERT(pXmlDoc
);
593 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:varyColors", "val", u
"0");
596 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testTableOnPage3
)
598 loadFromFile(u
"docx/TableOnPage3.docx");
600 // FIXME: validation error in OOXML export: Errors: 2
603 saveAndReload(u
"Office Open XML Text"_ustr
);
605 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
606 CPPUNIT_ASSERT(xChartDoc
.is());
607 uno::Reference
< chart::XChartDataArray
> xDataArray(xChartDoc
->getDataProvider(), UNO_QUERY_THROW
);
608 Sequence
<OUString
> aColumnDesc
= xDataArray
->getColumnDescriptions();
609 CPPUNIT_ASSERT_EQUAL_MESSAGE("There must be 4 columns and descriptions", static_cast<sal_Int32
>(4), aColumnDesc
.getLength());
610 CPPUNIT_ASSERT_EQUAL(u
"If oversubscription relative to allowance increases at the same average rate B15-B17"_ustr
, aColumnDesc
[0]);
611 CPPUNIT_ASSERT_EQUAL(u
"Known requirements"_ustr
, aColumnDesc
[1]);
612 CPPUNIT_ASSERT_EQUAL(u
"Allowance"_ustr
, aColumnDesc
[2]);
613 CPPUNIT_ASSERT_EQUAL(u
"If oversubscription relative to allowance holds steady at average oversubscription level B15-B17"_ustr
, aColumnDesc
[3]);
616 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, tdf137691
)
618 // given a doc where the banana negative data formats as ($123) and the pineapple data as $(123)
619 loadFromFile(u
"pptx/tdf137691_dataTable.pptx");
620 saveAndReload(u
"Impress MS PowerPoint 2007 XML"_ustr
);
622 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
624 Reference
< chart2::data::XDataSequence
> xDataSeq
;
625 xDataSeq
.set(getDataSequenceFromDocByRole(xChartDoc
, u
"values-y", 0));
626 const sal_Int32 nKey_bananas
= xDataSeq
->getNumberFormatKeyByIndex(-1);
627 // This should not be General format (0), but a defined format (129)
628 CPPUNIT_ASSERT(nKey_bananas
);
630 xDataSeq
.set(getDataSequenceFromDocByRole(xChartDoc
, u
"values-y", 1));
631 const sal_Int32 nKey_pineapples
= xDataSeq
->getNumberFormatKeyByIndex(-1);
632 // This should not be General format (0), but a defined format (130)
633 CPPUNIT_ASSERT(nKey_pineapples
);
634 CPPUNIT_ASSERT(nKey_pineapples
!= nKey_bananas
);
637 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testMultipleAxisXLSX
)
639 loadFromFile(u
"ods/multiple_axis.ods");
640 save(u
"Calc Office Open XML"_ustr
);
641 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
642 CPPUNIT_ASSERT(pXmlDoc
);
644 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart", 2);
645 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart[1]/c:ser", 1);
646 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart[2]/c:ser", 1);
647 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx", 4);
648 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:delete[@val='1']", 1);
649 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:axPos[@val='l']", 1);
650 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:axPos[@val='r']", 1);
653 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testSecondaryAxisXLSX
)
655 loadFromFile(u
"ods/secondary_axis.ods");
656 save(u
"Calc Office Open XML"_ustr
);
657 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
658 CPPUNIT_ASSERT(pXmlDoc
);
660 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart", 2);
661 // test there is just those series in the first <lineChart> tag which are attached to the primary axis
662 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[1]/c:ser", 2);
663 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[1]/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v", u
"b");
664 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[1]/c:ser[2]/c:tx/c:strRef/c:strCache/c:pt/c:v", u
"c");
665 // test there is just those series in the second <lineChart> tag which are attached to the secondary axis
666 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[2]/c:ser", 1);
667 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[2]/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v", u
"a");
670 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testBarChartSecondaryAxisXLSX
)
672 loadFromFile(u
"xlsx/testSecondaryAxis.xlsx");
673 save(u
"Calc Office Open XML"_ustr
);
674 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
675 CPPUNIT_ASSERT(pXmlDoc
);
676 // Collect barchart axID on primary Axis
677 OUString XValueIdOf1Barchart
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart[1]/c:axId[1]", "val");
678 OUString YValueIdOf1Barchart
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart[1]/c:axId[2]", "val");
679 // Collect barchart axID on secondary Axis
680 OUString XValueIdOf2Barchart
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart[2]/c:axId[1]", "val");
681 OUString YValueIdOf2Barchart
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart[2]/c:axId[2]", "val");
682 // Check which c:catAx and c:valAx contain the AxisId of barcharts
683 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx[1]/c:axId", "val", XValueIdOf1Barchart
);
684 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:axId", "val", YValueIdOf1Barchart
);
685 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx[2]/c:axId", "val", XValueIdOf2Barchart
);
686 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:axId", "val", YValueIdOf2Barchart
);
689 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testTdf148142
)
691 // The document contains a line chart with "Between tick marks" X axis position.
692 loadFromFile(u
"ods/tdf148142.ods");
693 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0);
694 CPPUNIT_ASSERT(xChartDoc
.is());
695 Reference
<chart2::XAxis
> xAxis
= getAxisFromDoc(xChartDoc
, 0, 0, 0);
696 CPPUNIT_ASSERT(xAxis
.is());
697 chart2::ScaleData aScaleData
= xAxis
->getScaleData();
698 CPPUNIT_ASSERT(aScaleData
.ShiftedCategoryPosition
);
700 // Set the X axis position to "On tick marks".
701 aScaleData
.ShiftedCategoryPosition
= false;
702 xAxis
->setScaleData(aScaleData
);
704 // Check the X axis position after export.
705 saveAndReload(u
"calc8"_ustr
);
706 Reference
<chart2::XChartDocument
> xChartDoc2
= getChartDocFromSheet(0);
707 CPPUNIT_ASSERT(xChartDoc2
.is());
708 Reference
<chart2::XAxis
> xAxis2
= getAxisFromDoc(xChartDoc2
, 0, 0, 0);
709 CPPUNIT_ASSERT(xAxis2
.is());
710 chart2::ScaleData aScaleData2
= xAxis2
->getScaleData();
711 CPPUNIT_ASSERT(!aScaleData2
.ShiftedCategoryPosition
);
714 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testFormattedChartTitles
)
716 loadFromFile(u
"xlsx/tdf39052.xlsx");
717 save(u
"Calc Office Open XML"_ustr
);
718 xmlDocUniquePtr pXmlDoc
= parseExport(u
"xl/charts/chart1.xml"_ustr
);
719 CPPUNIT_ASSERT(pXmlDoc
);
721 // Check run level properties [1] - first paragraph
722 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[1]/a:rPr", "b", u
"1");
723 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[1]/a:rPr", "sz", u
"1400");
724 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[1]/a:rPr/a:solidFill/a:srgbClr", "val", u
"ff0000");
725 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[1]/a:rPr/a:latin", "typeface", u
"Aptos Narrow");
726 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[1]/a:t", u
"This");
727 // Check run level properties [2]
728 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[2]/a:rPr", "b", u
"0");
729 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[2]/a:rPr", "sz", u
"1400");
730 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[2]/a:rPr/a:solidFill/a:srgbClr", "val", u
"595959");
731 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[2]/a:t", u
" is");
732 // Check run level properties [3]
733 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[3]/a:rPr", "b", u
"0");
734 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[3]/a:rPr", "sz", u
"1400");
735 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[3]/a:rPr", "baseline", u
"30000");
736 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[3]/a:t", u
"3");
737 // Check run level properties [4]
738 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[4]/a:rPr", "b", u
"0");
739 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[4]/a:rPr", "sz", u
"1400");
740 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[4]/a:t", u
" a ");
741 // Check run level properties [5]
742 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[5]/a:rPr", "b", u
"0");
743 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[5]/a:rPr", "i", u
"1");
744 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[5]/a:rPr", "sz", u
"2000");
745 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[5]/a:rPr", "u", u
"sng");
746 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[5]/a:rPr/a:solidFill/a:srgbClr", "val", u
"4ea72e");
747 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[5]/a:rPr/a:uFillTx", 1);
748 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[5]/a:t", u
"custom");
749 // Check run level properties [6]
750 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[6]/a:rPr", "b", u
"0");
751 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[6]/a:rPr", "sz", u
"1400");
752 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[1]/a:r[6]/a:t", u
" erte1");
753 // Check run level properties [1] - second paragraph
754 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[1]/a:rPr", "b", u
"0");
755 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[1]/a:rPr", "sz", u
"1400");
756 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[1]/a:rPr/a:solidFill/a:srgbClr", "val", u
"595959");
757 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[1]/a:rPr/a:latin", "typeface", u
"Aptos Narrow");
758 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[1]/a:t", u
"2dfgd ch");
759 // Check run level properties [2]
760 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[2]/a:rPr", "b", u
"1");
761 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[2]/a:t", u
"ar");
762 // Check run level properties [3]
763 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[3]/a:rPr", "b", u
"0");;
764 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[3]/a:t", u
"t ");
765 // Check run level properties [4]
766 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[4]/a:rPr", "b", u
"0");
767 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[4]/a:rPr", "strike", u
"sngStrike");
768 assertXPathContent(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p[2]/a:r[4]/a:t", u
"title");
773 void checkCharacterProps(Reference
<beans::XPropertySet
> const & xTitleProp
)
775 Sequence
< uno::Reference
< chart2::XFormattedString
> > xFormattedSubTitle
;
776 CPPUNIT_ASSERT(xTitleProp
->getPropertyValue(u
"FormattedStrings"_ustr
) >>= xFormattedSubTitle
);
777 CPPUNIT_ASSERT_EQUAL(sal_Int32(10), xFormattedSubTitle
.getLength());
779 std::vector
<OUString
> aValues
= { u
"This"_ustr
, u
" is"_ustr
, u
"3"_ustr
, u
" a "_ustr
, u
"custom"_ustr
, u
" erte1\n"_ustr
, u
"2dfgd ch"_ustr
, u
"ar"_ustr
, u
"t "_ustr
, u
"title"_ustr
};
780 for (sal_Int32 i
= 0; i
< xFormattedSubTitle
.getLength(); i
++)
782 const OUString aText
= xFormattedSubTitle
[i
]->getString();
783 CPPUNIT_ASSERT_EQUAL(aValues
[i
], aText
);
784 Reference
< beans::XPropertySet
> xRunPropSet(xFormattedSubTitle
[i
], uno::UNO_QUERY
);
786 uno::Any aAny
= xRunPropSet
->getPropertyValue(u
"CharFontName"_ustr
);
787 CPPUNIT_ASSERT_EQUAL(uno::Any(u
"Aptos Narrow"_ustr
), aAny
);
789 if (aText
== aValues
[0])
791 aAny
= xRunPropSet
->getPropertyValue(u
"CharWeight"_ustr
);
792 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontWeight::BOLD
), aAny
);
793 aAny
= xRunPropSet
->getPropertyValue(u
"CharHeight"_ustr
);
794 CPPUNIT_ASSERT_EQUAL(uno::Any(14.0f
), aAny
);
795 aAny
= xRunPropSet
->getPropertyValue(u
"CharColor"_ustr
);
796 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(0xff0000)), aAny
);
797 aAny
= xRunPropSet
->getPropertyValue(u
"CharEscapement"_ustr
);
798 CPPUNIT_ASSERT_EQUAL(uno::Any(short(0)), aAny
);
799 aAny
= xRunPropSet
->getPropertyValue(u
"CharEscapementHeight"_ustr
);
800 CPPUNIT_ASSERT_EQUAL(uno::Any(short(100)), aAny
);
802 else if (aText
== aValues
[1] || aText
== aValues
[3] || aText
== aValues
[5] ||
803 aText
== aValues
[6] || aText
== aValues
[8])
805 aAny
= xRunPropSet
->getPropertyValue(u
"CharWeight"_ustr
);
806 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontWeight::NORMAL
), aAny
);
807 aAny
= xRunPropSet
->getPropertyValue(u
"CharHeight"_ustr
);
808 CPPUNIT_ASSERT_EQUAL(uno::Any(14.0f
), aAny
);
809 aAny
= xRunPropSet
->getPropertyValue(u
"CharColor"_ustr
);
810 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(0x595959)), aAny
);
812 else if (aText
== aValues
[2])
814 aAny
= xRunPropSet
->getPropertyValue(u
"CharWeight"_ustr
);
815 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontWeight::NORMAL
), aAny
);
816 aAny
= xRunPropSet
->getPropertyValue(u
"CharHeight"_ustr
);
817 CPPUNIT_ASSERT_EQUAL(uno::Any(14.0f
), aAny
);
818 aAny
= xRunPropSet
->getPropertyValue(u
"CharColor"_ustr
);
819 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(0x595959)), aAny
);
820 aAny
= xRunPropSet
->getPropertyValue(u
"CharEscapement"_ustr
);
821 CPPUNIT_ASSERT_EQUAL(uno::Any(short(30)), aAny
);
822 aAny
= xRunPropSet
->getPropertyValue(u
"CharEscapementHeight"_ustr
);
823 CPPUNIT_ASSERT_EQUAL(uno::Any(short(58)), aAny
);
825 else if (aText
== aValues
[4])
827 aAny
= xRunPropSet
->getPropertyValue(u
"CharWeight"_ustr
);
828 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontWeight::NORMAL
), aAny
);
829 aAny
= xRunPropSet
->getPropertyValue(u
"CharHeight"_ustr
);
830 CPPUNIT_ASSERT_EQUAL(uno::Any(20.0f
), aAny
);
831 aAny
= xRunPropSet
->getPropertyValue(u
"CharColor"_ustr
);
832 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(0x4ea72e)), aAny
);
833 aAny
= xRunPropSet
->getPropertyValue(u
"CharPosture"_ustr
);
834 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontSlant_ITALIC
), aAny
);
835 aAny
= xRunPropSet
->getPropertyValue(u
"CharUnderline"_ustr
);
836 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontUnderline::SINGLE
), aAny
);
838 else if (aText
== aValues
[7])
840 aAny
= xRunPropSet
->getPropertyValue(u
"CharWeight"_ustr
);
841 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontWeight::BOLD
), aAny
);
842 aAny
= xRunPropSet
->getPropertyValue(u
"CharHeight"_ustr
);
843 CPPUNIT_ASSERT_EQUAL(uno::Any(14.0f
), aAny
);
844 aAny
= xRunPropSet
->getPropertyValue(u
"CharColor"_ustr
);
845 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(0x595959)), aAny
);
846 aAny
= xRunPropSet
->getPropertyValue(u
"CharPosture"_ustr
);
847 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontSlant_NONE
), aAny
);
849 else // aText == aValues[9]
851 aAny
= xRunPropSet
->getPropertyValue(u
"CharWeight"_ustr
);
852 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontWeight::NORMAL
), aAny
);
853 aAny
= xRunPropSet
->getPropertyValue(u
"CharHeight"_ustr
);
854 CPPUNIT_ASSERT_EQUAL(uno::Any(14.0f
), aAny
);
855 aAny
= xRunPropSet
->getPropertyValue(u
"CharColor"_ustr
);
856 CPPUNIT_ASSERT_EQUAL(uno::Any(Color(0x595959)), aAny
);
857 aAny
= xRunPropSet
->getPropertyValue(u
"CharPosture"_ustr
);
858 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontSlant_ITALIC
), aAny
);
859 aAny
= xRunPropSet
->getPropertyValue(u
"CharOverline"_ustr
);
860 CPPUNIT_ASSERT_EQUAL(uno::Any(awt::FontUnderline::NONE
), aAny
);
867 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3
, testODSFormattedChartTitles
)
869 // The document contains a line chart with "Between tick marks" X axis position.
870 loadFromFile(u
"ods/tdf39052.ods");
871 // Check formatted strings after export.
872 saveAndReload(u
"calc8"_ustr
);
874 Reference
<chart2::XChartDocument
> xChart2Doc
= getChartDocFromSheet(0);
875 CPPUNIT_ASSERT(xChart2Doc
.is());
876 Reference
< chart::XChartDocument
> xChartDoc(xChart2Doc
, uno::UNO_QUERY
);
877 CPPUNIT_ASSERT(xChartDoc
.is());
878 uno::Reference
< beans::XPropertySet
> xTitleProp(xChartDoc
->getTitle(), uno::UNO_QUERY
);
879 CPPUNIT_ASSERT(xTitleProp
.is());
881 checkCharacterProps(xTitleProp
);
884 CPPUNIT_PLUGIN_IMPLEMENT();
886 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */