Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / qa / extras / chart2export3.cxx
blob838da77191b7e9e95e512487ebf9fe1232bad69b
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 <com/sun/star/chart/ErrorBarStyle.hpp>
13 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
14 #include <com/sun/star/chart2/MovingAverageType.hpp>
15 #include <com/sun/star/lang/XServiceName.hpp>
16 #include <com/sun/star/text/XTextDocument.hpp>
17 #include <com/sun/star/drawing/LineStyle.hpp>
18 #include <com/sun/star/drawing/FillStyle.hpp>
19 #include <com/sun/star/chart2/DataPointLabel.hpp>
20 #include <com/sun/star/chart/DataLabelPlacement.hpp>
22 using uno::Reference;
23 using beans::XPropertySet;
25 class Chart2ExportTest3 : public ChartTest
27 public:
28 Chart2ExportTest3() : ChartTest("/chart2/qa/extras/data/") {}
31 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testTdf108107)
33 loadFromFile(u"xlsx/tdf108107.xlsx");
35 // FIXME: validation error in OOXML export: Errors: 1
36 skipValidation();
38 save("Calc Office Open XML");
39 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
40 CPPUNIT_ASSERT(pXmlDoc);
41 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:idx"_ostr, "val"_ostr, "1");
42 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"_ostr, "b"_ostr, "1");
43 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"_ostr, "sz"_ostr, "2000");
46 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testTdf114139)
48 loadFromFile(u"xlsx/tdf114139.xlsx");
49 save("Calc Office Open XML");
50 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
51 CPPUNIT_ASSERT(pXmlDoc);
53 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pie3DChart"_ostr, 1);
54 //no fill
55 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr"_ostr, 0);
56 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:solidFill"_ostr, 0);
59 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testTdf64224)
61 loadFromFile(u"ods/tdf64224.ods");
62 save("Calc Office Open XML");
63 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
64 CPPUNIT_ASSERT(pXmlDoc);
66 //no fill
67 assertXPath(pXmlDoc, "/c:chartSpace/c:spPr/a:noFill"_ostr, 1);
68 assertXPath(pXmlDoc, "/c:chartSpace/c:spPr/a:solidFill"_ostr, 0);
71 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testChartTitlePropertiesColorFillDOCX)
73 loadFromFile(u"docx/testChartTitlePropertiesColorFill.docx");
74 save("Office Open XML Text");
75 xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1.xml");
76 CPPUNIT_ASSERT(pXmlDoc);
77 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "ff0000");
78 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill"_ostr, 1);
81 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testChartTitlePropertiesGradientFillDOCX)
83 loadFromFile(u"docx/testChartTitlePropertiesGradientFill.docx");
84 save("Office Open XML Text");
85 xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1.xml");
86 CPPUNIT_ASSERT(pXmlDoc);
87 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr"_ostr, "val"_ostr, "cccccc");
88 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr"_ostr, "val"_ostr, "666666");
89 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill"_ostr, 1);
92 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testChartTitlePropertiesBitmapFillDOCX)
94 loadFromFile(u"docx/testChartTitlePropertiesBitmapFill.docx");
95 save("Office Open XML Text");
96 xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1.xml");
97 CPPUNIT_ASSERT(pXmlDoc);
98 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip"_ostr, "embed"_ostr, "rId1");
99 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill"_ostr, 1);
103 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testColorGradientWithTransparencyDOCX)
105 // Test color gradient (two color) with gradient transparency
106 loadFromFile(u"docx/testColorGradientWithTransparency.docx");
107 save("Office Open XML Text");
108 xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1.xml");
109 CPPUNIT_ASSERT(pXmlDoc);
110 // Test the transparency of the first color
111 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"_ostr, "val"_ostr, "60000");
112 // Test the transparency of the second color
113 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"_ostr, "val"_ostr, "90000");
116 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testColorGradientWithTransparencyODS)
118 // Test color gradient (two color) with simple transparency
119 loadFromFile(u"ods/testColorGradientWithTransparency.ods");
120 save("Calc Office Open XML");
121 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
122 CPPUNIT_ASSERT(pXmlDoc);
123 // Test the transparency of the first color
124 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"_ostr, "val"_ostr, "60000");
125 // Test the transparency of the second color
126 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"_ostr, "val"_ostr, "60000");
129 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testColorGradientStopXLSX)
131 // Test color gradient (two color) stop of the first color
132 loadFromFile(u"xlsx/tdf128619.xlsx");
133 save("Calc Office Open XML");
134 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
135 CPPUNIT_ASSERT(pXmlDoc);
136 // Test the position of the first color
137 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[1]"_ostr, "pos"_ostr, "45000");
138 // Test the position of the second color
139 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[2]"_ostr, "pos"_ostr, "100000");
142 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testRadialColorGradientDOCX)
144 loadFromFile(u"docx/tdf128794.docx");
145 save("Office Open XML Text");
146 xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1.xml");
147 CPPUNIT_ASSERT(pXmlDoc);
148 // Test the gradient style (if there is no 'a:path' attribute, it is a linear gradient)
149 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path"_ostr, 0);
150 // Test the linear gradient angle
151 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:lin"_ostr, "ang"_ostr, "13500000");
154 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testBarChartDataPointPropDOCX)
156 loadFromFile(u"docx/testBarChartDataPointPropDOCX.docx");
157 save("Office Open XML Text");
158 xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1.xml");
159 CPPUNIT_ASSERT(pXmlDoc);
161 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors"_ostr, "val"_ostr, "0");
163 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:idx"_ostr, "val"_ostr, "1");
164 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"_ostr, "val"_ostr, "f6f8fc");
165 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"_ostr, "val"_ostr, "c7d5ed");
166 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:ln/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "70ad47");
168 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:idx"_ostr, "val"_ostr, "2");
169 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "ff0000");
170 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:ln/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "000000");
173 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testFdo83058dlblPos)
175 loadFromFile(u"docx/fdo83058_dlblPos.docx");
177 // FIXME: validation error in OOXML export: Errors: 1
178 skipValidation();
180 save("Office Open XML Text");
181 xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1.xml");
182 CPPUNIT_ASSERT(pXmlDoc);
183 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[2]/c:dLblPos"_ostr, "val"_ostr, "outEnd");
184 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[3]/c:dLblPos"_ostr, "val"_ostr, "outEnd");
185 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[4]/c:dLblPos"_ostr, "val"_ostr, "outEnd");
186 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[5]/c:dLblPos"_ostr, "val"_ostr, "outEnd");
189 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testAutoTitleDelXLSX)
191 loadFromFile(u"xlsx/autotitledel_2007.xlsx");
192 save("Calc Office Open XML");
193 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
194 CPPUNIT_ASSERT(pXmlDoc);
195 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:autoTitleDeleted"_ostr, "val"_ostr, "0");
198 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testDispBlanksAsXLSX)
200 loadFromFile(u"xlsx/dispBlanksAs_2007.xlsx");
201 save("Calc Office Open XML");
202 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
203 CPPUNIT_ASSERT(pXmlDoc);
204 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs"_ostr, "val"_ostr, "gap");
207 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testMarkerColorXLSX)
209 loadFromFile(u"xlsx/markerColor.xlsx");
210 save("Calc Office Open XML");
211 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
212 CPPUNIT_ASSERT(pXmlDoc);
213 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:marker/c:spPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "92d050");
216 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testRoundedCornersXLSX)
218 loadFromFile(u"xlsx/markerColor.xlsx");
219 save("Calc Office Open XML");
220 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
221 CPPUNIT_ASSERT(pXmlDoc);
222 assertXPath(pXmlDoc, "/c:chartSpace/c:roundedCorners"_ostr, "val"_ostr, "0");
225 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testAxisNumberFormatXLSX)
227 loadFromFile(u"ods/axis_number_format.ods");
228 save("Calc Office Open XML");
229 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
230 CPPUNIT_ASSERT(pXmlDoc);
231 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx"_ostr, 2);
232 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:numFmt"_ostr, "formatCode"_ostr, "0.00E+000");
233 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:numFmt"_ostr, "sourceLinked"_ostr, "0");
235 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:numFmt"_ostr, "formatCode"_ostr, "[$$-409]#,##0;\\-[$$-409]#,##0");
236 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:numFmt"_ostr, "sourceLinked"_ostr, "1");
239 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testDataPointLabelNumberFormatXLSX)
241 // FIXME: validation error in OOXML export: Errors: 1
242 skipValidation();
244 loadFromFile(u"ods/tdf123774.ods");
246 save("Calc Office Open XML");
247 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
248 CPPUNIT_ASSERT(pXmlDoc);
249 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt"_ostr, "formatCode"_ostr, "[$-40E]0.00%");
250 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt"_ostr, "sourceLinked"_ostr, "0");
252 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:numFmt"_ostr, "formatCode"_ostr, "[$-40E]0.00%");
253 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:numFmt"_ostr, "sourceLinked"_ostr, "0");
256 loadFromFile(u"xlsx/tdf130986.xlsx");
258 save("Calc Office Open XML");
259 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
260 CPPUNIT_ASSERT(pXmlDoc);
261 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:idx"_ostr, "val"_ostr, "1");
262 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:numFmt"_ostr, "formatCode"_ostr, "0.00E+00");
263 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:numFmt"_ostr, "sourceLinked"_ostr, "0");
267 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testDataLabelDefaultValuesXLSX)
269 loadFromFile(u"xlsx/data_label.xlsx");
270 Reference< chart2::XChartDocument> xDoc = getChartDocFromSheet(0, mxComponent);
271 Reference<chart2::XDataSeries> xSeries = getDataSeriesFromDoc(xDoc, 0);
272 Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY_THROW);
273 uno::Any aAny = xPropSet->getPropertyValue("Label");
274 chart2::DataPointLabel aLabel;
275 CPPUNIT_ASSERT(aAny >>= aLabel);
276 CPPUNIT_ASSERT(aLabel.ShowNumber);
278 save("Calc Office Open XML");
279 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
280 CPPUNIT_ASSERT(pXmlDoc);
281 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:showVal"_ostr, "val"_ostr, "1");
282 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLblPos"_ostr, "val"_ostr, "outEnd");
285 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testDataLabelFillColor)
287 loadFromFile(u"xlsx/data_labels_fill_color.xlsx");
288 Reference< chart2::XChartDocument> xDoc = getChartDocFromSheet(0, mxComponent);
289 Reference<chart2::XDataSeries> xSeries = getDataSeriesFromDoc(xDoc, 0);
290 Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY_THROW);
291 uno::Any aAny = xPropSet->getPropertyValue("LabelFillColor");
292 sal_Int32 nLabelFillColor;
293 CPPUNIT_ASSERT(aAny >>= nLabelFillColor);
295 save("Calc Office Open XML");
296 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
297 CPPUNIT_ASSERT(pXmlDoc);
298 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:spPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "F79646");
301 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testTitleOverlayXLSX)
303 loadFromFile(u"xlsx/chart_title.xlsx");
304 save("Calc Office Open XML");
305 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
306 CPPUNIT_ASSERT(pXmlDoc);
307 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:overlay"_ostr, "val"_ostr, "0");
310 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testInvertIfNegativeXLSX)
312 loadFromFile(u"xlsx/bar_chart_simple.xlsx");
313 save("Calc Office Open XML");
314 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
315 CPPUNIT_ASSERT(pXmlDoc);
316 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:invertIfNegative"_ostr, "val"_ostr, "0");
319 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testBubble3DXLSX)
321 loadFromFile(u"xlsx/bubble_chart_simple.xlsx");
322 save("Calc Office Open XML");
323 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
324 CPPUNIT_ASSERT(pXmlDoc);
325 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:bubbleChart/c:ser[1]/c:bubble3D"_ostr, "val"_ostr, "0");
326 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:bubbleChart/c:ser[2]/c:bubble3D"_ostr, "val"_ostr, "0");
327 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:bubbleChart/c:ser[3]/c:bubble3D"_ostr, "val"_ostr, "0");
330 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testNoMarkerXLSX)
332 loadFromFile(u"xlsx/no_marker.xlsx");
333 save("Calc Office Open XML");
334 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
335 CPPUNIT_ASSERT(pXmlDoc);
336 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:marker/c:symbol"_ostr, "val"_ostr, "none");
337 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:marker/c:symbol"_ostr, "val"_ostr, "none");
338 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:marker"_ostr, "val"_ostr, "0");
341 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testTitleManualLayoutXLSX)
343 loadFromFile(u"xlsx/title_manual_layout.xlsx");
344 save("Calc Office Open XML");
345 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
346 CPPUNIT_ASSERT(pXmlDoc);
347 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:layoutTarget"_ostr, 0);
348 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:xMode"_ostr, "val"_ostr, "edge");
349 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:yMode"_ostr, "val"_ostr, "edge");
351 OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:x"_ostr, "val"_ostr);
352 double nX = aXVal.toDouble();
353 CPPUNIT_ASSERT(nX > 0);
354 CPPUNIT_ASSERT(nX < 1);
356 OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:y"_ostr, "val"_ostr);
357 double nY = aYVal.toDouble();
358 CPPUNIT_ASSERT(nY > 0);
359 CPPUNIT_ASSERT(nY < 1);
360 CPPUNIT_ASSERT(nX != nY);
362 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:bodyPr"_ostr, "rot"_ostr, "1200000");
365 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testPlotAreaManualLayoutXLSX)
367 loadFromFile(u"xlsx/plot_area_manual_layout.xlsx");
368 save("Calc Office Open XML");
369 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
370 CPPUNIT_ASSERT(pXmlDoc);
372 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:layoutTarget"_ostr, "val"_ostr, "inner");
373 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:xMode"_ostr, "val"_ostr, "edge");
374 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:yMode"_ostr, "val"_ostr, "edge");
376 OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:x"_ostr, "val"_ostr);
377 double nX = aXVal.toDouble();
378 CPPUNIT_ASSERT(nX > 0);
379 CPPUNIT_ASSERT(nX < 1);
381 OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:y"_ostr, "val"_ostr);
382 double nY = aYVal.toDouble();
383 CPPUNIT_ASSERT(nY > 0);
384 CPPUNIT_ASSERT(nY < 1);
385 CPPUNIT_ASSERT(nX != nY);
387 OUString aWVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:w"_ostr, "val"_ostr);
388 double nW = aWVal.toDouble();
389 CPPUNIT_ASSERT(nW > 0);
390 CPPUNIT_ASSERT(nW < 1);
392 OUString aHVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:h"_ostr, "val"_ostr);
393 double nH = aHVal.toDouble();
394 CPPUNIT_ASSERT(nH > 0);
395 CPPUNIT_ASSERT(nH < 1);
396 CPPUNIT_ASSERT(nH != nW);
399 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testLegendManualLayoutXLSX)
401 loadFromFile(u"xlsx/legend_manual_layout.xlsx");
402 save("Calc Office Open XML");
403 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
404 CPPUNIT_ASSERT(pXmlDoc);
406 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:layoutTarget"_ostr, 0);
407 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:xMode"_ostr, "val"_ostr, "edge");
408 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:yMode"_ostr, "val"_ostr, "edge");
410 OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:x"_ostr, "val"_ostr);
411 double nX = aXVal.toDouble();
412 CPPUNIT_ASSERT(nX > 0);
413 CPPUNIT_ASSERT(nX < 1);
415 OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:y"_ostr, "val"_ostr);
416 double nY = aYVal.toDouble();
417 CPPUNIT_ASSERT(nY > 0);
418 CPPUNIT_ASSERT(nY < 1);
419 CPPUNIT_ASSERT(nX != nY);
421 OUString aWVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:w"_ostr, "val"_ostr);
422 double nW = aWVal.toDouble();
423 CPPUNIT_ASSERT(nW > 0);
424 CPPUNIT_ASSERT(nW < 1);
426 OUString aHVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:h"_ostr, "val"_ostr);
427 double nH = aHVal.toDouble();
428 CPPUNIT_ASSERT(nH > 0);
429 CPPUNIT_ASSERT(nH < 1);
430 CPPUNIT_ASSERT(nH != nW);
432 // Make sure that default text font size is preserved after export
433 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:txPr/a:p/a:pPr/a:defRPr"_ostr, "sz"_ostr, "900");
436 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testChartSubTitle)
438 loadFromFile(u"ods/testChartSubTitle.ods");
439 save("Calc Office Open XML");
440 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
441 CPPUNIT_ASSERT(pXmlDoc);
442 // test properties of subtitle
443 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr"_ostr, "sz"_ostr, "1100");
444 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr"_ostr, "b"_ostr, "1");
445 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "00a933");
446 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr/a:latin"_ostr, "typeface"_ostr, "Times New Roman");
447 assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:t"_ostr, "It is a Subtitle");
448 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "b2b2b2");
451 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testChartMainWithSubTitle)
453 loadFromFile(u"ods/testChartMainWithSubTitle.ods");
454 save("Calc Office Open XML");
455 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
456 CPPUNIT_ASSERT(pXmlDoc);
457 // test properties of title
458 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr"_ostr, "sz"_ostr, "1300");
459 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr"_ostr, "b"_ostr, "0");
460 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr"_ostr, "i"_ostr, "1");
461 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "f10d0c");
462 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr/a:latin"_ostr, "typeface"_ostr, "Arial");
463 assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:t"_ostr, "It is a Maintitle\nIt is a Subtitle");
464 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "81d41a");
467 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testAutoTitleDeleted)
469 loadFromFile(u"xlsx/testAutoTitleDeleted.xlsx");
470 save("Calc Office Open XML");
471 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
472 CPPUNIT_ASSERT(pXmlDoc);
473 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:autoTitleDeleted"_ostr, "val"_ostr, "1");
476 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testChartTitlePropertiesColorFillXLSX)
478 loadFromFile(u"xlsx/testChartTitlePropertiesColorFill.xlsx");
479 save("Calc Office Open XML");
480 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
481 CPPUNIT_ASSERT(pXmlDoc);
482 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "ff0000");
483 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill"_ostr, 1);
486 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testChartTitlePropertiesGradientFillXLSX)
488 loadFromFile(u"xlsx/testChartTitlePropertiesGradientFill.xlsx");
489 save("Calc Office Open XML");
490 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
491 CPPUNIT_ASSERT(pXmlDoc);
492 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr"_ostr, "val"_ostr, "cccccc");
493 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr"_ostr, "val"_ostr, "666666");
494 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill"_ostr, 1);
497 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testChartTitlePropertiesBitmapFillXLSX)
499 loadFromFile(u"xlsx/testChartTitlePropertiesBitmapFill.xlsx");
500 save("Calc Office Open XML");
501 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
502 CPPUNIT_ASSERT(pXmlDoc);
503 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip"_ostr, "embed"_ostr, "rId1");
504 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill"_ostr, 1);
507 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testBarChartDataPointPropXLSX)
509 loadFromFile(u"xlsx/testBarChartDataPointPropXLSX.xlsx");
510 save("Calc Office Open XML");
511 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
512 CPPUNIT_ASSERT(pXmlDoc);
514 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors"_ostr, "val"_ostr, "0");
516 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:idx"_ostr, "val"_ostr, "1");
517 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "ff0000");
518 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:ln/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "000000");
520 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:idx"_ostr, "val"_ostr, "2");
521 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"_ostr, "val"_ostr, "f6f8fc");
522 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"_ostr, "val"_ostr, "c7d5ed");
523 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:ln/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "70ad47");
526 namespace {
528 void checkGapWidth(Reference<beans::XPropertySet> const & xPropSet, sal_Int32 nValue)
530 uno::Any aAny = xPropSet->getPropertyValue("GapwidthSequence");
531 CPPUNIT_ASSERT(aAny.hasValue());
532 uno::Sequence< sal_Int32 > aSequence;
533 aAny >>= aSequence;
534 CPPUNIT_ASSERT(aSequence.hasElements());
535 CPPUNIT_ASSERT_EQUAL(nValue, aSequence[0]);
538 void checkOverlap(Reference<beans::XPropertySet> const & xPropSet, sal_Int32 nValue)
540 uno::Any aAny = xPropSet->getPropertyValue("OverlapSequence");
541 CPPUNIT_ASSERT(aAny.hasValue());
542 uno::Sequence< sal_Int32 > aSequence;
543 aAny >>= aSequence;
544 CPPUNIT_ASSERT(aSequence.hasElements());
545 CPPUNIT_ASSERT_EQUAL(nValue, aSequence[0]);
548 void checkSheetForGapWidthAndOverlap(uno::Reference< chart2::XChartDocument > const & xChartDoc,
549 sal_Int32 nExpectedGapWidth, sal_Int32 nExpectedOverlap)
551 CPPUNIT_ASSERT(xChartDoc.is());
553 Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 );
554 CPPUNIT_ASSERT(xChartType.is());
556 Reference< beans::XPropertySet > xPropSet( xChartType, uno::UNO_QUERY_THROW );
557 checkGapWidth(xPropSet, nExpectedGapWidth);
558 checkOverlap(xPropSet, nExpectedOverlap);
564 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testDataseriesOverlapStackedChartXLSX)
566 loadFromFile(u"xlsx/testDataseriesOverlapStackedChart.xlsx");
568 // test the overlap value of a simple Stacked Column Chart
569 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
570 checkSheetForGapWidthAndOverlap(xChartDoc, 100, 0);
572 // test the overlap value of a Percent Stacked Bar Chart
573 xChartDoc = getChartDocFromSheet( 1, mxComponent );
574 checkSheetForGapWidthAndOverlap(xChartDoc, 100, 35);
576 saveAndReload("Calc Office Open XML");
578 xChartDoc = getChartDocFromSheet( 0, mxComponent );
579 checkSheetForGapWidthAndOverlap(xChartDoc, 100, 100);
581 xChartDoc = getChartDocFromSheet( 1, mxComponent );
582 checkSheetForGapWidthAndOverlap(xChartDoc, 100, 100);
585 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testAxisCharacterPropertiesXLSX)
587 loadFromFile(u"xlsx/axis_character_properties.xlsx");
588 save("Calc Office Open XML");
589 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
590 CPPUNIT_ASSERT(pXmlDoc);
592 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr"_ostr, "sz"_ostr, "1000");
593 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr"_ostr, "b"_ostr, "1");
594 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr"_ostr, "i"_ostr, "1");
595 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr"_ostr, "u"_ostr, "sng");
597 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr"_ostr, "sz"_ostr, "900");
598 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr"_ostr, "b"_ostr, "1");
599 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr"_ostr, "strike"_ostr, "sngStrike");
600 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr"_ostr, "val"_ostr, "ff0000");
603 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testTitleCharacterPropertiesXLSX)
605 loadFromFile(u"xlsx/title_character_properties.xlsx");
606 save("Calc Office Open XML");
607 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
608 CPPUNIT_ASSERT(pXmlDoc);
610 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr"_ostr, "sz"_ostr, "2400");
611 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr"_ostr, "b"_ostr, "1");
613 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr"_ostr, "sz"_ostr, "2400");
614 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr"_ostr, "b"_ostr, "1");
617 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testPlotVisOnlyXLSX)
619 loadFromFile(u"xlsx/hidden_cells.xlsx");
620 save("Calc Office Open XML");
621 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
622 CPPUNIT_ASSERT(pXmlDoc);
624 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotVisOnly"_ostr, "val"_ostr, "0");
627 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testBarChartVaryColorsXLSX)
629 loadFromFile(u"xlsx/tdf90876.xlsx");
630 save("Calc Office Open XML");
631 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
632 CPPUNIT_ASSERT(pXmlDoc);
634 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors"_ostr, "val"_ostr, "0");
637 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testTdf96161)
639 loadFromFile(u"ods/tdf96161.ods");
640 save("Calc Office Open XML");
641 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
642 CPPUNIT_ASSERT(pXmlDoc);
644 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:varyColors"_ostr, "val"_ostr, "0");
647 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testTableOnPage3)
649 loadFromFile(u"docx/TableOnPage3.docx");
651 // FIXME: validation error in OOXML export: Errors: 2
652 skipValidation();
654 saveAndReload("Office Open XML Text");
656 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
657 CPPUNIT_ASSERT(xChartDoc.is());
658 uno::Reference< chart::XChartDataArray > xDataArray(xChartDoc->getDataProvider(), UNO_QUERY_THROW);
659 Sequence<OUString> aColumnDesc = xDataArray->getColumnDescriptions();
660 CPPUNIT_ASSERT_EQUAL_MESSAGE("There must be 4 columns and descriptions", static_cast<sal_Int32>(4), aColumnDesc.getLength());
661 CPPUNIT_ASSERT_EQUAL(OUString("If oversubscription relative to allowance increases at the same average rate B15-B17"), aColumnDesc[0]);
662 CPPUNIT_ASSERT_EQUAL(OUString("Known requirements"), aColumnDesc[1]);
663 CPPUNIT_ASSERT_EQUAL(OUString("Allowance"), aColumnDesc[2]);
664 CPPUNIT_ASSERT_EQUAL(OUString("If oversubscription relative to allowance holds steady at average oversubscription level B15-B17"), aColumnDesc[3]);
667 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, tdf137691)
669 // given a doc where the banana negative data formats as ($123) and the pineapple data as $(123)
670 loadFromFile(u"pptx/tdf137691_dataTable.pptx");
671 saveAndReload("Impress MS PowerPoint 2007 XML");
673 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
675 Reference< chart2::data::XDataSequence > xDataSeq;
676 xDataSeq.set(getDataSequenceFromDocByRole(xChartDoc, u"values-y", 0));
677 const sal_Int32 nKey_bananas = xDataSeq->getNumberFormatKeyByIndex(-1);
678 // This should not be General format (0), but a defined format (129)
679 CPPUNIT_ASSERT(nKey_bananas);
681 xDataSeq.set(getDataSequenceFromDocByRole(xChartDoc, u"values-y", 1));
682 const sal_Int32 nKey_pineapples = xDataSeq->getNumberFormatKeyByIndex(-1);
683 // This should not be General format (0), but a defined format (130)
684 CPPUNIT_ASSERT(nKey_pineapples);
685 CPPUNIT_ASSERT(nKey_pineapples != nKey_bananas);
688 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testMultipleAxisXLSX)
690 loadFromFile(u"ods/multiple_axis.ods");
691 save("Calc Office Open XML");
692 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
693 CPPUNIT_ASSERT(pXmlDoc);
695 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart"_ostr, 2);
696 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart[1]/c:ser"_ostr, 1);
697 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart[2]/c:ser"_ostr, 1);
698 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx"_ostr, 4);
699 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:delete[@val='1']"_ostr, 1);
700 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:axPos[@val='l']"_ostr, 1);
701 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:axPos[@val='r']"_ostr, 1);
704 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testSecondaryAxisXLSX)
706 loadFromFile(u"ods/secondary_axis.ods");
707 save("Calc Office Open XML");
708 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
709 CPPUNIT_ASSERT(pXmlDoc);
711 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart"_ostr, 2);
712 // test there is just those series in the first <lineChart> tag which are attached to the primary axis
713 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[1]/c:ser"_ostr, 2);
714 assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[1]/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v"_ostr, "b");
715 assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[1]/c:ser[2]/c:tx/c:strRef/c:strCache/c:pt/c:v"_ostr, "c");
716 // test there is just those series in the second <lineChart> tag which are attached to the secondary axis
717 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[2]/c:ser"_ostr, 1);
718 assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[2]/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v"_ostr, "a");
721 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testBarChartSecondaryAxisXLSX)
723 loadFromFile(u"xlsx/testSecondaryAxis.xlsx");
724 save("Calc Office Open XML");
725 xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
726 CPPUNIT_ASSERT(pXmlDoc);
727 // Collect barchart axID on primary Axis
728 OUString XValueIdOf1Barchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart[1]/c:axId[1]"_ostr, "val"_ostr);
729 OUString YValueIdOf1Barchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart[1]/c:axId[2]"_ostr, "val"_ostr);
730 // Collect barchart axID on secondary Axis
731 OUString XValueIdOf2Barchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart[2]/c:axId[1]"_ostr, "val"_ostr);
732 OUString YValueIdOf2Barchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart[2]/c:axId[2]"_ostr, "val"_ostr);
733 // Check which c:catAx and c:valAx contain the AxisId of barcharts
734 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[1]/c:axId"_ostr, "val"_ostr, XValueIdOf1Barchart);
735 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:axId"_ostr, "val"_ostr, YValueIdOf1Barchart);
736 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[2]/c:axId"_ostr, "val"_ostr, XValueIdOf2Barchart);
737 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:axId"_ostr, "val"_ostr, YValueIdOf2Barchart);
740 CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, testTdf148142)
742 // The document contains a line chart with "Between tick marks" X axis position.
743 loadFromFile(u"ods/tdf148142.ods");
744 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
745 CPPUNIT_ASSERT(xChartDoc.is());
746 Reference<chart2::XAxis> xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
747 CPPUNIT_ASSERT(xAxis.is());
748 chart2::ScaleData aScaleData = xAxis->getScaleData();
749 CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition);
751 // Set the X axis position to "On tick marks".
752 aScaleData.ShiftedCategoryPosition = false;
753 xAxis->setScaleData(aScaleData);
755 // Check the X axis position after export.
756 saveAndReload("calc8");
757 Reference<chart2::XChartDocument> xChartDoc2 = getChartDocFromSheet(0, mxComponent);
758 CPPUNIT_ASSERT(xChartDoc2.is());
759 Reference<chart2::XAxis> xAxis2 = getAxisFromDoc(xChartDoc2, 0, 0, 0);
760 CPPUNIT_ASSERT(xAxis2.is());
761 chart2::ScaleData aScaleData2 = xAxis2->getScaleData();
762 CPPUNIT_ASSERT(!aScaleData2.ShiftedCategoryPosition);
765 CPPUNIT_PLUGIN_IMPLEMENT();
767 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */