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"
11 #include <com/sun/star/chart2/CurveStyle.hpp>
12 #include <com/sun/star/chart2/DataPointLabel.hpp>
13 #include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
14 #include <com/sun/star/chart2/DataPointCustomLabelFieldType.hpp>
15 #include <com/sun/star/chart/ErrorBarStyle.hpp>
16 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
17 #include <com/sun/star/chart2/XChartDocument.hpp>
18 #include <com/sun/star/chart/XChartDocument.hpp>
19 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
20 #include <com/sun/star/chart/XChartDataArray.hpp>
21 #include <com/sun/star/drawing/FillStyle.hpp>
22 #include <com/sun/star/drawing/LineStyle.hpp>
23 #include <com/sun/star/chart/XAxisXSupplier.hpp>
24 #include <com/sun/star/chart/XAxisYSupplier.hpp>
25 #include <com/sun/star/chart/MissingValueTreatment.hpp>
26 #include <com/sun/star/chart2/TickmarkStyle.hpp>
27 #include <com/sun/star/chart2/SymbolStyle.hpp>
28 #include <com/sun/star/chart2/Symbol.hpp>
29 #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
30 #include <com/sun/star/chart/DataLabelPlacement.hpp>
31 #include <com/sun/star/text/XTextRange.hpp>
34 #include <com/sun/star/util/Color.hpp>
35 #include <com/sun/star/awt/Gradient.hpp>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 class Chart2ImportTest
: public ChartTest
41 Chart2ImportTest() : ChartTest("/chart2/qa/extras/data/") {}
44 void testSteppedLines();
45 void testErrorBarRange();
46 void testErrorBarFormatting();
47 void testODSChartSeries();
48 void testXLSXChartSeries();
49 void testXLSChartSeries();
50 void testODTChartSeries();
51 void testDOCChartSeries();
52 void testDOCXChartSeries();
53 void testDOCXChartEmptySeries();
55 void testPPTXChartErrorBars();
56 void testDOCXChartValuesSize();
57 void testPPTXChartSeries();
58 void testPPTXSparseChartSeries();
60 * Original data contains 3 series but 2 of them are hidden. For now, we
61 * detect and skip those hidden series on import (since we don't support
62 * hidden columns for internal data table yet).
64 void testPPTXHiddenDataSeries();
65 void testPPTXPercentageNumberFormats();
66 void testPieChartLabelsNumFormat();
67 void testPPTXStackedNonStackedYAxis();
68 void testPPTChartSeries();
69 void testODPChartSeries();
72 void testTransparencyGradientValue();
74 void testSimpleStrictXLSX();
75 void testDelayedCellImport(); // chart range referencing content on later sheets
76 void testFlatODSStackedColumnChart();
79 void testFdo54361_1();
81 void testTdf86624(); // manually placed legends
88 void testAutoBackgroundXLSX();
89 void testAutoChartAreaBorderPropXLSX();
90 void testAutoChartAreaBorderPropPPTX();
91 void testChartAreaStyleBackgroundXLSX();
92 void testChartHatchFillXLSX();
93 void testAxisTextRotationXLSX();
94 // void testTextCanOverlapXLSX(); // TODO : temporarily disabled.
95 void testTextBreakXLSX();
96 void testNumberFormatsXLSX();
97 void testNumberFormatsDOCX();
98 void testPercentageNumberFormatsDOCX();
100 void testTransparentBackground(std::u16string_view filename
);
102 // below are OOXML default value tests for cases
103 // where we fixed the handling of MSO 2007 vs OOXML
104 void testAutoTitleDelDefaultValue2007XLSX();
105 void testAutoTitleDelDefaultValue2013XLSX();
106 void testDispBlanksAsDefaultValue2007XLSX();
107 void testDispBlanksAsDefaultValue2013XLSX();
109 void testSmoothDefaultValue2007XLSX();
110 void testSmoothDefaultValue2013XLSX();
111 void testTrendlineDefaultValue2007XLSX();
112 void testTrendlineDefaultValue2013XLSX();
113 void testVaryColorDefaultValues2007XLSX();
114 void testVaryColorDefaultValues2013XLSX();
115 void testPlotVisOnlyDefaultValue2013XLSX();
116 void testRAngAxDefaultValue2013XLSX();
117 void testMajorTickMarksDefaultValue2013XLSX();
118 void testMinorTickMarksDefaultValue2013XLSX();
120 void testAxisTitleDefaultRotationXLSX();
121 void testSecondaryAxisTitleDefaultRotationXLSX();
122 void testAxisTitleRotationXLSX();
123 void testAxisTitlePositionDOCX();
124 void testCombinedChartAttachedAxisXLSX();
125 void testTdf140489MultiSeriesChartAxisXLSX();
127 void testTdf90510(); // Pie chart label placement settings(XLS)
128 void testTdf109858(); // Pie chart label placement settings(XLSX)
129 void testTdf130105();
130 void testTdf111173();
131 void testTdf122226();
132 void testInternalDataProvider();
133 void testTdf115107(); // import complex data point labels
134 void testTdf115107_2(); // import complex data point labels in cobo charts with multiple data series
135 void testTdf116163();
137 void testTdf121205();
138 void testFixedSizeBarChartVeryLongLabel();
139 void testAutomaticSizeBarChartVeryLongLabel();
140 void testTotalsRowIgnored();
142 CPPUNIT_TEST_SUITE(Chart2ImportTest
);
143 CPPUNIT_TEST(Fdo60083
);
144 CPPUNIT_TEST(testSteppedLines
);
145 CPPUNIT_TEST(testErrorBarRange
);
146 CPPUNIT_TEST(testErrorBarFormatting
);
147 CPPUNIT_TEST(testODSChartSeries
);
148 CPPUNIT_TEST(testXLSXChartSeries
);
149 CPPUNIT_TEST(testXLSChartSeries
);
150 CPPUNIT_TEST(testODTChartSeries
);
151 CPPUNIT_TEST(testDOCChartSeries
);
152 CPPUNIT_TEST(testDOCXChartSeries
);
153 CPPUNIT_TEST(testDOCXChartEmptySeries
);
154 CPPUNIT_TEST(testTdf81396
);
155 CPPUNIT_TEST(testPPTXChartErrorBars
);
156 CPPUNIT_TEST(testDOCXChartValuesSize
);
157 CPPUNIT_TEST(testPPTChartSeries
);
158 CPPUNIT_TEST(testPPTXChartSeries
);
159 CPPUNIT_TEST(testPPTXSparseChartSeries
);
160 CPPUNIT_TEST(testPPTXHiddenDataSeries
);
161 CPPUNIT_TEST(testPPTXPercentageNumberFormats
);
162 CPPUNIT_TEST(testPieChartLabelsNumFormat
);
163 CPPUNIT_TEST(testPPTXStackedNonStackedYAxis
);
164 CPPUNIT_TEST(testODPChartSeries
);
165 CPPUNIT_TEST(testBnc864396
);
166 CPPUNIT_TEST(testBnc882383
);
167 CPPUNIT_TEST(testTransparencyGradientValue
);
168 CPPUNIT_TEST(testBnc889755
);
169 CPPUNIT_TEST(testSimpleStrictXLSX
);
170 CPPUNIT_TEST(testDelayedCellImport
);
171 CPPUNIT_TEST(testFlatODSStackedColumnChart
);
172 CPPUNIT_TEST(testFdo78080
);
173 CPPUNIT_TEST(testFdo54361
);
174 CPPUNIT_TEST(testFdo54361_1
);
175 CPPUNIT_TEST(testTdf127811
);
176 CPPUNIT_TEST(testTdf86624
);
177 CPPUNIT_TEST(testTdf105517
);
178 CPPUNIT_TEST(testTdf106217
);
179 CPPUNIT_TEST(testTdf108021
);
180 CPPUNIT_TEST(testTdf100084
);
181 CPPUNIT_TEST(testTdf124817
);
182 CPPUNIT_TEST(testTdf126033
);
183 CPPUNIT_TEST(testAutoBackgroundXLSX
);
184 CPPUNIT_TEST(testAutoChartAreaBorderPropXLSX
);
185 CPPUNIT_TEST(testAutoChartAreaBorderPropPPTX
);
186 CPPUNIT_TEST(testChartAreaStyleBackgroundXLSX
);
187 CPPUNIT_TEST(testChartHatchFillXLSX
);
188 CPPUNIT_TEST(testAxisTextRotationXLSX
);
189 // CPPUNIT_TEST(testTextCanOverlapXLSX); // TODO : temporarily disabled.
190 CPPUNIT_TEST(testTextBreakXLSX
);
191 CPPUNIT_TEST(testNumberFormatsXLSX
);
192 CPPUNIT_TEST(testNumberFormatsDOCX
);
193 CPPUNIT_TEST(testPercentageNumberFormatsDOCX
);
194 CPPUNIT_TEST(testAutoTitleDelDefaultValue2007XLSX
);
195 CPPUNIT_TEST(testAutoTitleDelDefaultValue2013XLSX
);
196 CPPUNIT_TEST(testDispBlanksAsDefaultValue2007XLSX
);
197 CPPUNIT_TEST(testDispBlanksAsDefaultValue2013XLSX
);
198 CPPUNIT_TEST(testSmoothDefaultValue2007XLSX
);
199 CPPUNIT_TEST(testSmoothDefaultValue2013XLSX
);
200 CPPUNIT_TEST(testTrendlineDefaultValue2007XLSX
);
201 CPPUNIT_TEST(testTrendlineDefaultValue2013XLSX
);
202 CPPUNIT_TEST(testVaryColorDefaultValues2007XLSX
);
203 CPPUNIT_TEST(testVaryColorDefaultValues2013XLSX
);
204 CPPUNIT_TEST(testPlotVisOnlyDefaultValue2013XLSX
);
205 CPPUNIT_TEST(testRAngAxDefaultValue2013XLSX
);
206 CPPUNIT_TEST(testMajorTickMarksDefaultValue2013XLSX
);
207 CPPUNIT_TEST(testMinorTickMarksDefaultValue2013XLSX
);
208 CPPUNIT_TEST(testAxisTitleDefaultRotationXLSX
);
209 CPPUNIT_TEST(testSecondaryAxisTitleDefaultRotationXLSX
);
210 CPPUNIT_TEST(testAxisTitleRotationXLSX
);
211 CPPUNIT_TEST(testAxisTitlePositionDOCX
);
212 CPPUNIT_TEST(testCombinedChartAttachedAxisXLSX
);
213 CPPUNIT_TEST(testTdf140489MultiSeriesChartAxisXLSX
);
214 CPPUNIT_TEST(testTdf90510
);
215 CPPUNIT_TEST(testTdf109858
);
216 CPPUNIT_TEST(testTdf130105
);
217 CPPUNIT_TEST(testTdf111173
);
218 CPPUNIT_TEST(testTdf122226
);
219 CPPUNIT_TEST(testInternalDataProvider
);
220 CPPUNIT_TEST(testTdf115107
);
221 CPPUNIT_TEST(testTdf115107_2
);
222 CPPUNIT_TEST(testTdf116163
);
223 CPPUNIT_TEST(testTdf48041
);
224 CPPUNIT_TEST(testTdf121205
);
225 CPPUNIT_TEST(testFixedSizeBarChartVeryLongLabel
);
226 CPPUNIT_TEST(testAutomaticSizeBarChartVeryLongLabel
);
227 CPPUNIT_TEST(testTotalsRowIgnored
);
229 CPPUNIT_TEST_SUITE_END();
233 // split method up into smaller chunks for more detailed tests
234 void Chart2ImportTest::Fdo60083()
236 loadFromURL(u
"ods/fdo60083.ods");
237 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
238 CPPUNIT_ASSERT(xChartDoc
.is());
240 Reference
< chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc( xChartDoc
, 0 );
241 CPPUNIT_ASSERT( xDataSeries
.is() );
243 Reference
< beans::XPropertySet
> xPropSet( xDataSeries
, UNO_QUERY_THROW
);
245 // test that y error bars are there
246 Reference
< beans::XPropertySet
> xErrorBarYProps
;
247 xPropSet
->getPropertyValue(CHART_UNONAME_ERRORBAR_Y
) >>= xErrorBarYProps
;
248 CPPUNIT_ASSERT(xErrorBarYProps
.is());
250 sal_Int32 nErrorBarStyle
;
252 xErrorBarYProps
->getPropertyValue("ErrorBarStyle")
254 CPPUNIT_ASSERT_EQUAL(
255 chart::ErrorBarStyle::RELATIVE
,
260 xErrorBarYProps
->getPropertyValue("PositiveError") >>= nVal
);
261 CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, nVal
, 1e-8);
264 xErrorBarYProps
->getPropertyValue("NegativeError") >>= nVal
);
265 CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, nVal
, 1e-8);
269 xErrorBarYProps
->getPropertyValue("ShowPositiveError") >>= bVal
);
270 CPPUNIT_ASSERT_EQUAL(true, bVal
);
273 xErrorBarYProps
->getPropertyValue("ShowNegativeError") >>= bVal
);
274 CPPUNIT_ASSERT_EQUAL(true, bVal
);
277 // test that x error bars are not imported
278 Reference
< beans::XPropertySet
> xErrorBarXProps
;
279 xPropSet
->getPropertyValue(CHART_UNONAME_ERRORBAR_X
) >>= xErrorBarXProps
;
280 CPPUNIT_ASSERT(!xErrorBarXProps
.is());
283 void Chart2ImportTest::testErrorBarRange()
285 loadFromURL(u
"ods/error_bar_range.ods");
286 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
287 CPPUNIT_ASSERT(xChartDoc
.is());
289 Reference
< chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc( xChartDoc
, 0 );
290 CPPUNIT_ASSERT( xDataSeries
.is() );
292 Reference
< beans::XPropertySet
> xPropSet( xDataSeries
, UNO_QUERY_THROW
);
294 // test that y error bars are there
295 Reference
< beans::XPropertySet
> xErrorBarYProps
;
296 xPropSet
->getPropertyValue(CHART_UNONAME_ERRORBAR_Y
) >>= xErrorBarYProps
;
297 CPPUNIT_ASSERT(xErrorBarYProps
.is());
299 sal_Int32 nErrorBarStyle
;
301 xErrorBarYProps
->getPropertyValue("ErrorBarStyle")
303 CPPUNIT_ASSERT_EQUAL(
304 chart::ErrorBarStyle::FROM_DATA
,
308 CPPUNIT_ASSERT(xErrorBarYProps
->getPropertyValue("ErrorBarRangePositive") >>= aRangePos
);
309 CPPUNIT_ASSERT_EQUAL(OUString("$Sheet1.$C$2:$C$4"), aRangePos
);
312 void Chart2ImportTest::testErrorBarFormatting()
314 loadFromURL(u
"ods/error_bar_properties.ods");
315 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
316 CPPUNIT_ASSERT(xChartDoc
.is());
318 Reference
< chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc( xChartDoc
, 0 );
319 CPPUNIT_ASSERT( xDataSeries
.is() );
321 Reference
< beans::XPropertySet
> xPropSet( xDataSeries
, UNO_QUERY_THROW
);
323 // test that y error bars are there
324 Reference
< beans::XPropertySet
> xErrorBarYProps
;
325 xPropSet
->getPropertyValue(CHART_UNONAME_ERRORBAR_Y
) >>= xErrorBarYProps
;
326 CPPUNIT_ASSERT(xErrorBarYProps
.is());
328 util::Color
aColor(0);
329 xErrorBarYProps
->getPropertyValue("LineColor") >>= aColor
;
330 sal_uInt32 nColorValue
= aColor
;
331 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xff3333), nColorValue
);
334 // stepped line interpolation
335 void Chart2ImportTest::testSteppedLines()
337 const sal_Int32 MAXSHEET
= 14;
338 chart2::CurveStyle
const curveStyle
[] = {
339 chart2::CurveStyle_LINES
,
340 chart2::CurveStyle_CUBIC_SPLINES
,
341 chart2::CurveStyle_B_SPLINES
,
342 chart2::CurveStyle_STEP_START
,
343 chart2::CurveStyle_STEP_END
,
344 chart2::CurveStyle_STEP_CENTER_X
,
345 chart2::CurveStyle_STEP_CENTER_Y
,
346 chart2::CurveStyle_LINES
,
347 chart2::CurveStyle_CUBIC_SPLINES
,
348 chart2::CurveStyle_B_SPLINES
,
349 chart2::CurveStyle_STEP_START
,
350 chart2::CurveStyle_STEP_END
,
351 chart2::CurveStyle_STEP_CENTER_X
,
352 chart2::CurveStyle_STEP_CENTER_Y
355 loadFromURL(u
"ods/stepped_lines.ods");
356 for(sal_Int32 nSheet
= 0; nSheet
< MAXSHEET
; ++nSheet
)
358 uno::Reference
< chart2::XChartDocument
> xChart2Doc
= getChartDocFromSheet( nSheet
, mxComponent
);
359 CPPUNIT_ASSERT(xChart2Doc
.is());
361 Reference
< chart2::XChartType
> xChartType
= getChartTypeFromDoc( xChart2Doc
, 0 );
362 CPPUNIT_ASSERT(xChartType
.is());
364 Reference
< beans::XPropertySet
> xPropSet( xChartType
, UNO_QUERY
);
365 CPPUNIT_ASSERT(xPropSet
.is());
367 chart2::CurveStyle eCurveStyle
;
368 xPropSet
->getPropertyValue("CurveStyle") >>= eCurveStyle
;
369 CPPUNIT_ASSERT_EQUAL(eCurveStyle
, curveStyle
[nSheet
]);
373 static uno::Sequence
< OUString
> getChartColumnDescriptions( uno::Reference
< chart::XChartDocument
> const & xChart1Doc
)
375 CPPUNIT_ASSERT(xChart1Doc
.is());
376 uno::Reference
< chart::XChartDataArray
> xChartData ( xChart1Doc
->getData(), UNO_QUERY_THROW
);
377 uno::Sequence
< OUString
> seriesList
= xChartData
->getColumnDescriptions();
381 void Chart2ImportTest::testODSChartSeries()
383 loadFromURL(u
"ods/chart.ods");
384 uno::Reference
< chart::XChartDocument
> xChart1Doc ( getChartCompFromSheet( 0, 0, mxComponent
), UNO_QUERY_THROW
);
385 uno::Sequence
< OUString
> seriesList
= getChartColumnDescriptions( xChart1Doc
);
386 CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList
[0]);
387 CPPUNIT_ASSERT_EQUAL(OUString("Col2"), seriesList
[1]);
388 CPPUNIT_ASSERT_EQUAL(OUString("Col 33"), seriesList
[2]);
392 void Chart2ImportTest::testXLSXChartSeries()
394 loadFromURL(u
"xlsx/chart.xlsx");
395 uno::Reference
< chart::XChartDocument
> xChart1Doc ( getChartCompFromSheet( 0, 0, mxComponent
), UNO_QUERY_THROW
);
396 uno::Sequence
< OUString
> seriesList
= getChartColumnDescriptions(xChart1Doc
);
397 CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList
[0]);
398 CPPUNIT_ASSERT_EQUAL(OUString("Col2"), seriesList
[1]);
399 CPPUNIT_ASSERT_EQUAL(OUString("Col 33"), seriesList
[2]);
403 void Chart2ImportTest::testXLSChartSeries()
405 loadFromURL(u
"xls/chart.xls");
406 uno::Reference
< chart::XChartDocument
> xChart1Doc ( getChartCompFromSheet( 0, 0, mxComponent
), UNO_QUERY_THROW
);
407 uno::Sequence
< OUString
> seriesList
= getChartColumnDescriptions(xChart1Doc
);
408 CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList
[0]);
409 CPPUNIT_ASSERT_EQUAL(OUString("Col 2"), seriesList
[1]);
410 CPPUNIT_ASSERT_EQUAL(OUString("Col 3"), seriesList
[2]);
414 void Chart2ImportTest::testODTChartSeries()
416 loadFromURL(u
"odt/chart.odt");
417 uno::Sequence
< OUString
> seriesList
= getWriterChartColumnDescriptions(mxComponent
);
418 CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList
[0]);
419 CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList
[1]);
420 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList
[2]);
424 void Chart2ImportTest::testDOCChartSeries()
426 loadFromURL(u
"doc/chart.doc");
427 uno::Sequence
< OUString
> seriesList
= getWriterChartColumnDescriptions(mxComponent
);
428 CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList
[0]);
429 CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList
[1]);
430 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList
[2]);
433 void Chart2ImportTest::testDOCXChartSeries()
435 loadFromURL(u
"docx/chart.docx");
436 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
437 CPPUNIT_ASSERT(xChartDoc
.is());
439 Reference
<chart2::XChartType
> xCT
= getChartTypeFromDoc(xChartDoc
, 0);
440 CPPUNIT_ASSERT(xCT
.is());
442 std::vector
<uno::Sequence
<uno::Any
> > aLabels
= getDataSeriesLabelsFromChartType(xCT
);
443 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels
.size());
444 CPPUNIT_ASSERT_EQUAL(OUString("Series 1"), aLabels
[0][0].get
<OUString
>());
445 CPPUNIT_ASSERT_EQUAL(OUString("Series 2"), aLabels
[1][0].get
<OUString
>());
446 CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), aLabels
[2][0].get
<OUString
>());
449 void Chart2ImportTest::testDOCXChartEmptySeries()
451 loadFromURL(u
"docx/tdf125337.docx");
452 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
453 CPPUNIT_ASSERT(xChartDoc
.is());
455 Reference
<chart2::XChartType
> xCT
= getChartTypeFromDoc(xChartDoc
, 0);
456 CPPUNIT_ASSERT(xCT
.is());
458 std::vector
<uno::Sequence
<uno::Any
> > aLabels
= getDataSeriesLabelsFromChartType(xCT
);
459 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels
.size());
460 CPPUNIT_ASSERT_EQUAL(OUString("1. dataseries"), aLabels
[0][0].get
<OUString
>());
461 CPPUNIT_ASSERT_EQUAL(OUString("2. dataseries"), aLabels
[1][0].get
<OUString
>());
462 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), aLabels
[2][0].get
<OUString
>());
464 //test chart series sparse data for docx
465 std::vector
<std::vector
<double> > aValues
= getDataSeriesYValuesFromChartType(xCT
);
466 CPPUNIT_ASSERT_EQUAL(size_t(3), aValues
.size());
467 //test the second series values
468 CPPUNIT_ASSERT_EQUAL(2.4, aValues
[1][0]);
469 CPPUNIT_ASSERT_EQUAL(4.4, aValues
[1][1]);
470 //test the third series (empty) values
471 CPPUNIT_ASSERT(std::isnan(aValues
[2][0]));
472 CPPUNIT_ASSERT(std::isnan(aValues
[2][1]));
475 void Chart2ImportTest::testTdf81396()
477 loadFromURL(u
"xlsx/tdf81396.xlsx");
478 Reference
<chart::XChartDocument
> xChartDoc(getChartDocFromSheet(0, mxComponent
),
481 Reference
<chart2::XChartDocument
> xChartDoc2(xChartDoc
, UNO_QUERY_THROW
);
482 Reference
<chart2::XChartType
> xChartType(getChartTypeFromDoc(xChartDoc2
, 0), UNO_SET_THROW
);
483 std::vector aDataSeriesYValues
= getDataSeriesYValuesFromChartType(xChartType
);
484 CPPUNIT_ASSERT_EQUAL(size_t(1), aDataSeriesYValues
.size());
486 // Without the fix in place, this test would have failed with
487 // - Expected: 105.210801910481
489 CPPUNIT_ASSERT_EQUAL(105.210801910481, aDataSeriesYValues
[0][0]);
492 void Chart2ImportTest::testPPTXChartErrorBars()
494 loadFromURL(u
"pptx/tdf127720.pptx");
495 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
496 CPPUNIT_ASSERT(xChartDoc
.is());
498 uno::Reference
< chart::XChartDataArray
> xDataArray(xChartDoc
->getDataProvider(), UNO_QUERY_THROW
);
499 Sequence
<OUString
> aColumnDesc
= xDataArray
->getColumnDescriptions();
500 // Number of columns = 4 (Y-values, X-values and positive/negative error bars).
501 // Without the fix there would only be 2 columns (no error range).
502 CPPUNIT_ASSERT_EQUAL_MESSAGE("There must be 4 columns and descriptions", static_cast<sal_Int32
>(4), aColumnDesc
.getLength());
505 void Chart2ImportTest::testDOCXChartValuesSize()
507 loadFromURL(u
"docx/bubblechart.docx" );
508 Reference
<chart2::XChartDocument
> xChartDoc( getChartDocFromWriter(0), uno::UNO_QUERY
);
509 CPPUNIT_ASSERT( xChartDoc
.is() );
511 uno::Reference
< chart::XChartDataArray
> xDataArray( xChartDoc
->getDataProvider(), UNO_QUERY_THROW
);
512 Sequence
<OUString
> aColumnDesc
= xDataArray
->getColumnDescriptions();
513 // Number of columns = 3 (Y-values, X-values and bubble sizes).
514 // Without the fix there would only be 2 columns (no bubble sizes).
515 CPPUNIT_ASSERT_EQUAL_MESSAGE( "There must be 3 columns and descriptions", static_cast<sal_Int32
>(3), aColumnDesc
.getLength() );
516 Sequence
<Sequence
<double>> aData
= xDataArray
->getData();
517 CPPUNIT_ASSERT_EQUAL_MESSAGE( "There must be exactly 3 data points", static_cast<sal_Int32
>(3), aData
.getLength() );
519 std::vector
<std::vector
<double>> aExpected
= { { 2.7, 0.7, 10.0 }, { 3.2, 1.8, 4.0 }, { 0.8, 2.6, 8.0 } };
521 for ( sal_Int32 nRowIdx
= 0; nRowIdx
< 3; ++nRowIdx
)
522 for( sal_Int32 nColIdx
= 0; nColIdx
< 3; ++nColIdx
)
523 CPPUNIT_ASSERT_DOUBLES_EQUAL( aExpected
[nRowIdx
][nColIdx
], aData
[nRowIdx
][nColIdx
], 1e-1 );
526 void Chart2ImportTest::testPPTChartSeries()
528 //test chart series names for ppt
529 uno::Sequence
< OUString
> seriesList
= getImpressChartColumnDescriptions(u
"/chart2/qa/extras/data/ppt/", "chart.ppt");
531 CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList
[0]);
532 CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList
[1]);
533 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList
[2]);
537 void Chart2ImportTest::testPPTXChartSeries()
539 //test chart series names for pptx
540 loadFromURL(u
"pptx/chart.pptx");
541 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
542 CPPUNIT_ASSERT(xChartDoc
.is());
544 Reference
<chart2::XChartType
> xCT
= getChartTypeFromDoc(xChartDoc
, 0);
545 CPPUNIT_ASSERT(xCT
.is());
547 std::vector
<uno::Sequence
<uno::Any
> > aLabels
= getDataSeriesLabelsFromChartType(xCT
);
548 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels
.size());
549 CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), aLabels
[0][0].get
<OUString
>());
550 CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), aLabels
[1][0].get
<OUString
>());
551 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), aLabels
[2][0].get
<OUString
>());
554 void Chart2ImportTest::testPPTXSparseChartSeries()
556 //test chart series sparse data for pptx
557 loadFromURL(u
"pptx/sparse-chart.pptx");
558 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
559 CPPUNIT_ASSERT(xChartDoc
.is());
561 Reference
<chart2::XChartType
> xCT
= getChartTypeFromDoc(xChartDoc
, 0);
562 CPPUNIT_ASSERT(xCT
.is());
564 std::vector
<std::vector
<double> > aValues
= getDataSeriesYValuesFromChartType(xCT
);
565 CPPUNIT_ASSERT_EQUAL(size_t(2), aValues
.size());
566 CPPUNIT_ASSERT( std::isnan( aValues
[0][0] ) );
567 CPPUNIT_ASSERT_EQUAL(2.5, aValues
[0][1]);
568 CPPUNIT_ASSERT_EQUAL(3.5, aValues
[0][2]);
569 CPPUNIT_ASSERT( std::isnan( aValues
[0][3] ) );
570 CPPUNIT_ASSERT_EQUAL(-2.4, aValues
[1][0]);
571 CPPUNIT_ASSERT( std::isnan( aValues
[1][1] ) );
572 CPPUNIT_ASSERT( std::isnan( aValues
[1][2] ) );
573 CPPUNIT_ASSERT_EQUAL(-2.8, aValues
[1][3]);
576 void Chart2ImportTest::testPPTXHiddenDataSeries()
578 loadFromURL(u
"pptx/stacked-bar-chart-hidden-series.pptx");
579 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
580 CPPUNIT_ASSERT(xChartDoc
.is());
582 // "Automatic" chart background fill in pptx should be loaded as no fill.
583 Reference
<beans::XPropertySet
> xPropSet
= xChartDoc
->getPageBackground();
584 CPPUNIT_ASSERT(xPropSet
.is());
585 drawing::FillStyle eStyle
= xPropSet
->getPropertyValue("FillStyle").get
<drawing::FillStyle
>();
586 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in pptx should be loaded as no fill (transparent).",
587 drawing::FillStyle_NONE
, eStyle
);
589 Reference
<chart2::XChartType
> xCT
= getChartTypeFromDoc(xChartDoc
, 0);
590 CPPUNIT_ASSERT(xCT
.is());
592 // There should be only one data series present.
593 std::vector
<uno::Sequence
<uno::Any
> > aLabels
= getDataSeriesLabelsFromChartType(xCT
);
594 CPPUNIT_ASSERT_EQUAL(size_t(1), aLabels
.size());
595 CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), aLabels
[0][0].get
<OUString
>());
597 // Test the internal data.
598 CPPUNIT_ASSERT(xChartDoc
->hasInternalDataProvider());
600 Reference
<chart2::XInternalDataProvider
> xInternalProvider(xChartDoc
->getDataProvider(), uno::UNO_QUERY
);
601 CPPUNIT_ASSERT(xInternalProvider
.is());
603 Reference
<chart::XComplexDescriptionAccess
> xDescAccess(xInternalProvider
, uno::UNO_QUERY
);
604 CPPUNIT_ASSERT(xDescAccess
.is());
606 // Get the category labels.
607 Sequence
<Sequence
<OUString
> > aCategories
= xDescAccess
->getComplexRowDescriptions();
608 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aCategories
.getLength());
609 CPPUNIT_ASSERT_EQUAL(OUString("Category 1"), aCategories
[0][0]);
610 CPPUNIT_ASSERT_EQUAL(OUString("Category 2"), aCategories
[1][0]);
611 CPPUNIT_ASSERT_EQUAL(OUString("Category 3"), aCategories
[2][0]);
612 CPPUNIT_ASSERT_EQUAL(OUString("Category 4"), aCategories
[3][0]);
615 void Chart2ImportTest::testPPTXPercentageNumberFormats()
617 loadFromURL(u
"pptx/percentage-number-formats.pptx");
620 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
621 CPPUNIT_ASSERT(xChartDoc
.is());
623 uno::Reference
<chart2::XDataSeries
> xDataSeries(getDataSeriesFromDoc(xChartDoc
, 0));
624 CPPUNIT_ASSERT(xDataSeries
.is());
625 uno::Reference
<beans::XPropertySet
> xPropertySet
;
626 chart2::DataPointLabel aLabel
;
627 sal_Int32 nNumberFormat
;
628 const sal_Int32 nPercentFormatSimple
= getNumberFormat(xChartDoc
, "0%");
629 const sal_Int32 nPercentFormatDecimal
= getNumberFormat(xChartDoc
, "0.00%");
631 xPropertySet
.set(xDataSeries
->getDataPointByIndex(0), uno::UNO_SET_THROW
);
632 xPropertySet
->getPropertyValue("Label") >>= aLabel
;
633 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumber
);
634 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumberInPercent
);
635 xPropertySet
->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat
;
636 CPPUNIT_ASSERT_EQUAL(nPercentFormatSimple
, nNumberFormat
);
638 xPropertySet
.set(xDataSeries
->getDataPointByIndex(1), uno::UNO_SET_THROW
);
639 xPropertySet
->getPropertyValue("Label") >>= aLabel
;
640 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumber
);
641 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumberInPercent
);
642 xPropertySet
->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat
;
643 CPPUNIT_ASSERT_EQUAL(nPercentFormatDecimal
, nNumberFormat
);
645 xPropertySet
.set(xDataSeries
->getDataPointByIndex(2), uno::UNO_SET_THROW
);
646 xPropertySet
->getPropertyValue("Label") >>= aLabel
;
647 CPPUNIT_ASSERT_EQUAL(sal_False
, aLabel
.ShowNumber
);
648 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumberInPercent
);
649 xPropertySet
->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat
;
650 CPPUNIT_ASSERT_EQUAL(nPercentFormatSimple
, nNumberFormat
);
652 xPropertySet
.set(xDataSeries
->getDataPointByIndex(3), uno::UNO_SET_THROW
);
653 xPropertySet
->getPropertyValue("Label") >>= aLabel
;
654 CPPUNIT_ASSERT_EQUAL(sal_False
, aLabel
.ShowNumber
);
655 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumberInPercent
);
656 xPropertySet
->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat
;
657 CPPUNIT_ASSERT_EQUAL(nPercentFormatDecimal
, nNumberFormat
);
660 xChartDoc
.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY
);
661 CPPUNIT_ASSERT(xChartDoc
.is());
663 Reference
<chart2::XAxis
> xYAxis
= getAxisFromDoc(xChartDoc
, 0, 1, 0);
664 CPPUNIT_ASSERT(xYAxis
.is());
666 Reference
<beans::XPropertySet
> xPS(xYAxis
, uno::UNO_QUERY_THROW
);
667 bool bLinkNumberFormatToSource
= true;
668 bool bSuccess
= xPS
->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT
) >>= bLinkNumberFormatToSource
;
669 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", bSuccess
);
670 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource
);
672 // FIXME: This should be in fact "0.00%".
673 // see TODO in oox/source/drawingml/chart/modelbase.cxx
674 const sal_Int32 nPercentFormatDecimalShort
= getNumberFormat(xChartDoc
, "0.0%");
675 nNumberFormat
= getNumberFormatFromAxis(xYAxis
);
676 CPPUNIT_ASSERT_EQUAL(nPercentFormatDecimalShort
, nNumberFormat
);
677 sal_Int16 nType
= getNumberFormatType(xChartDoc
, nNumberFormat
);
678 CPPUNIT_ASSERT_MESSAGE("Y axis should be a percent format.", (nType
& util::NumberFormat::PERCENT
));
681 void Chart2ImportTest::testPieChartLabelsNumFormat()
683 loadFromURL(u
"xlsx/tdfPieNumFormat.xlsx");
684 uno::Reference
< chart::XChartDocument
> xChartDoc(getChartCompFromSheet(0, 0, mxComponent
), UNO_QUERY_THROW
);
685 CPPUNIT_ASSERT(xChartDoc
.is());
686 // test data point labels format
687 Reference
<beans::XPropertySet
> xDataPointPropSet(xChartDoc
->getDiagram()->getDataPointProperties(0, 0), uno::UNO_SET_THROW
);
688 chart2::DataPointLabel aLabel
;
689 xDataPointPropSet
->getPropertyValue("Label") >>= aLabel
;
690 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumber
);
693 void Chart2ImportTest::testPPTXStackedNonStackedYAxis()
695 loadFromURL(u
"pptx/stacked-non-stacked-mix-y-axis.pptx");
697 // 1st chart is a normal stacked column.
698 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
699 CPPUNIT_ASSERT(xChartDoc
.is());
701 Reference
<chart2::XTitled
> xTitled(xChartDoc
, uno::UNO_QUERY_THROW
);
702 OUString aTitle
= getTitleString(xTitled
);
703 CPPUNIT_ASSERT_EQUAL(OUString("Stacked"), aTitle
);
706 Reference
<chart2::XAxis
> xYAxis
= getAxisFromDoc(xChartDoc
, 0, 1, 0);
707 CPPUNIT_ASSERT(xYAxis
.is());
709 sal_Int32 nNumberFormat
= getNumberFormatFromAxis(xYAxis
);
710 sal_Int16 nType
= getNumberFormatType(xChartDoc
, nNumberFormat
);
711 CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType
& util::NumberFormat::NUMBER
));
712 CPPUNIT_ASSERT_MESSAGE("Y axis should NOT be a percent format.", !(nType
& util::NumberFormat::PERCENT
));
714 // 2nd chart is a percent-stacked column.
715 xChartDoc
.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY
);
716 CPPUNIT_ASSERT(xChartDoc
.is());
718 xTitled
.set(xChartDoc
, uno::UNO_QUERY_THROW
);
719 aTitle
= getTitleString(xTitled
);
720 CPPUNIT_ASSERT_EQUAL(OUString("100% Stacked"), aTitle
);
723 xYAxis
= getAxisFromDoc(xChartDoc
, 0, 1, 0);
724 CPPUNIT_ASSERT(xYAxis
.is());
726 // Get the number format of the Y-axis.
727 nNumberFormat
= getNumberFormatFromAxis(xYAxis
);
728 nType
= getNumberFormatType(xChartDoc
, nNumberFormat
);
729 CPPUNIT_ASSERT_MESSAGE("Y axis should be a percent format.", (nType
& util::NumberFormat::PERCENT
));
731 // 3rd chart is a mixture of normal-stacked column with a percent-stacked
732 // area chart series. Excel in this case sets the Y-axis to be
733 // non-percent axis and we should do the same for interoperability.
734 xChartDoc
.set(getChartDocFromDrawImpress(2, 0), uno::UNO_QUERY
);
735 CPPUNIT_ASSERT(xChartDoc
.is());
737 xTitled
.set(xChartDoc
, uno::UNO_QUERY_THROW
);
738 aTitle
= getTitleString(xTitled
);
739 CPPUNIT_ASSERT_EQUAL(OUString("Stacked column mixed with 100% stacked area"), aTitle
);
742 xYAxis
= getAxisFromDoc(xChartDoc
, 0, 1, 0);
743 CPPUNIT_ASSERT(xYAxis
.is());
745 // Get the number format of the Y-axis.
746 nNumberFormat
= getNumberFormatFromAxis(xYAxis
);
747 nType
= getNumberFormatType(xChartDoc
, nNumberFormat
);
748 CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType
& util::NumberFormat::NUMBER
));
749 CPPUNIT_ASSERT_MESSAGE("Y axis should NOT be a percent format.", !(nType
& util::NumberFormat::PERCENT
));
752 void Chart2ImportTest::testODPChartSeries()
754 //test chart series names for odp
755 uno::Sequence
< OUString
> seriesList
= getImpressChartColumnDescriptions(u
"/chart2/qa/extras/data/odp/", "chart.odp");
756 CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList
[0]);
757 CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList
[1]);
758 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList
[2]);
762 void Chart2ImportTest::testBnc864396()
764 uno::Reference
< chart2::XChartDocument
> xChartDoc(getChartDocFromImpress(u
"/chart2/qa/extras/data/pptx/", "bnc864396.pptx"), uno::UNO_QUERY_THROW
);
765 CPPUNIT_ASSERT(xChartDoc
->hasInternalDataProvider());
767 uno::Reference
< chart2::XInternalDataProvider
> xDataProvider( xChartDoc
->getDataProvider(), uno::UNO_QUERY_THROW
);
768 uno::Reference
< chart::XChartDataArray
> xChartDataArray(xDataProvider
, uno::UNO_QUERY_THROW
);
769 uno::Sequence
< OUString
> aRowLabels
= xChartDataArray
->getRowDescriptions();
770 for(sal_Int32 i
= 0; i
< aRowLabels
.getLength(); ++i
)
772 OUString aExpected
= "cat" + OUString::number(i
+1);
773 CPPUNIT_ASSERT_EQUAL(aExpected
, aRowLabels
[i
]);
777 void Chart2ImportTest::testBnc889755()
779 loadFromURL(u
"pptx/bnc889755.pptx");
780 uno::Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 5), uno::UNO_QUERY_THROW
);
781 CPPUNIT_ASSERT(xChartDoc
->hasInternalDataProvider());
783 constexpr sal_Int32 nNumCategories
= 16;
784 Sequence
<OUString
> aDateSeq
= getFormattedDateCategories(xChartDoc
);
786 CPPUNIT_ASSERT_EQUAL(nNumCategories
, aDateSeq
.getLength());
788 const OUString aExpectedDateCategories
[nNumCategories
] = {
789 "Oct-12", "Nov-12", "Dec-12", "Jan-13",
790 "Feb-13", "Mar-13", "Apr-13", "May-13",
791 "Jun-13", "Jul-13", "Aug-13", "Sep-13",
792 "Oct-13", "Nov-13", "Dec-13", "Jan-14",
795 for (size_t nIdx
= 0; nIdx
< nNumCategories
; ++nIdx
)
796 CPPUNIT_ASSERT_EQUAL(aExpectedDateCategories
[nIdx
], aDateSeq
[nIdx
]);
798 //tdf#139940 - the title's gradient was lost and was filled with solid blue, instead of a "blue underline".
799 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
800 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
802 uno::Reference
<beans::XPropertySet
> xShapeProps(xPage
->getByIndex(4), uno::UNO_QUERY_THROW
);
803 awt::Gradient aTransparence
;
804 xShapeProps
->getPropertyValue("FillTransparenceGradient") >>= aTransparence
;
805 CPPUNIT_ASSERT(aTransparence
.StartColor
!= aTransparence
.EndColor
);
806 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, Color(ColorTransparency
, aTransparence
.StartColor
));
809 void Chart2ImportTest::testBnc882383()
811 loadFromURL(u
"pptx/bnc882383.pptx");
812 uno::Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY_THROW
);
813 uno::Reference
<chart2::XDataSeries
> xDataSeries(getDataSeriesFromDoc(xChartDoc
, 0));
814 CPPUNIT_ASSERT(xDataSeries
.is());
816 uno::Reference
<beans::XPropertySet
> xPropertySet(xDataSeries
->getDataPointByIndex(0), uno::UNO_SET_THROW
);
817 OUString sGradientName
;
818 xPropertySet
->getPropertyValue("GradientName") >>= sGradientName
;
819 CPPUNIT_ASSERT(!sGradientName
.isEmpty());
822 void Chart2ImportTest::testTransparencyGradientValue()
824 loadFromURL(u
"xlsx/tdf128732.xlsx");
825 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
826 CPPUNIT_ASSERT(xChartDoc
.is());
827 uno::Reference
<chart2::XDataSeries
> xDataSeries(getDataSeriesFromDoc(xChartDoc
, 0));
828 CPPUNIT_ASSERT(xDataSeries
.is());
830 uno::Reference
<beans::XPropertySet
> xPropertySet(xDataSeries
->getDataPointByIndex(0), uno::UNO_SET_THROW
);
831 OUString sTranspGradientName
;
832 xPropertySet
->getPropertyValue("FillTransparenceGradientName") >>= sTranspGradientName
;
833 CPPUNIT_ASSERT(!sTranspGradientName
.isEmpty());
835 awt::Gradient aTransparenceGradient
;
836 uno::Reference
< lang::XMultiServiceFactory
> xFact(xChartDoc
, uno::UNO_QUERY
);
837 CPPUNIT_ASSERT(xFact
.is());
838 uno::Reference
< container::XNameAccess
> xTransparenceGradient(xFact
->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY
);
839 uno::Any rTransparenceValue
= xTransparenceGradient
->getByName(sTranspGradientName
);
840 CPPUNIT_ASSERT(rTransparenceValue
>>= aTransparenceGradient
);
841 CPPUNIT_ASSERT_EQUAL(sal_Int32(3355443), aTransparenceGradient
.EndColor
);
842 CPPUNIT_ASSERT_EQUAL(sal_Int32(5000268), aTransparenceGradient
.StartColor
);
845 void Chart2ImportTest::testSimpleStrictXLSX()
847 loadFromURL(u
"xlsx/strict_chart.xlsx");
848 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
849 CPPUNIT_ASSERT(xChartDoc
.is());
851 Reference
< chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc( xChartDoc
, 0 );
852 CPPUNIT_ASSERT(xDataSeries
.is());
856 void Chart2ImportTest::testDelayedCellImport()
858 loadFromURL(u
"xlsx/fdo70609.xlsx");
859 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
860 Reference
< chart2::data::XDataSequence
> xDataSeq
=
861 getDataSequenceFromDocByRole(xChartDoc
, u
"values-x");
863 OUString aRange
= xDataSeq
->getSourceRangeRepresentation();
864 CPPUNIT_ASSERT_EQUAL(OUString("$Sheet2.$C$5:$C$9"), aRange
);
867 void Chart2ImportTest::testFlatODSStackedColumnChart()
869 loadFromURL(u
"fods/stacked-column-chart.fods");
870 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
871 CPPUNIT_ASSERT(xChartDoc
.is());
873 Reference
<chart2::XChartType
> xChartType
= getChartTypeFromDoc(xChartDoc
, 0);
874 CPPUNIT_ASSERT(xChartType
.is());
876 Reference
<chart2::XDataSeriesContainer
> xDSCont(xChartType
, UNO_QUERY
);
877 CPPUNIT_ASSERT(xDSCont
.is());
878 Sequence
<Reference
<chart2::XDataSeries
> > aSeriesSeq
= xDSCont
->getDataSeries();
880 // The stacked column chart should consist of 5 data series.
881 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aSeriesSeq
.getLength());
884 void Chart2ImportTest::testFdo78080()
886 loadFromURL(u
"xlsx/fdo78080.xlsx");
887 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
888 CPPUNIT_ASSERT(xChartDoc
.is());
890 Reference
<chart2::XTitled
> xTitled(xChartDoc
, uno::UNO_QUERY_THROW
);
891 Reference
<chart2::XTitle
> xTitle
= xTitled
->getTitleObject();
892 CPPUNIT_ASSERT(!xTitle
.is());
895 void Chart2ImportTest::testTdf127811()
897 loadFromURL(u
"pptx/tdf127811.pptx");
898 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
899 CPPUNIT_ASSERT(xChartDoc
.is());
901 Reference
<chart2::XChartType
> xCT
= getChartTypeFromDoc(xChartDoc
, 0);
902 CPPUNIT_ASSERT(xCT
.is());
904 std::vector
<uno::Sequence
<uno::Any
> > aLabels
= getDataSeriesLabelsFromChartType(xCT
);
905 CPPUNIT_ASSERT_EQUAL(size_t(2), aLabels
.size());
907 // Without the fix in place, this test would have failed with
908 // - Expected: 1. first
909 // - Actual : 2. second
910 CPPUNIT_ASSERT_EQUAL(OUString("1. first"), aLabels
[0][0].get
<OUString
>());
911 CPPUNIT_ASSERT_EQUAL(OUString("2. second"), aLabels
[1][0].get
<OUString
>());
914 void Chart2ImportTest::testTdf86624()
916 loadFromURL(u
"ods/tdf86624.ods");
917 uno::Reference
< chart2::XChartDocument
> xChart2Doc
= getChartDocFromSheet(0, mxComponent
);
918 uno::Reference
< chart::XChartDocument
> xChartDoc (xChart2Doc
, uno::UNO_QUERY
);
919 uno::Reference
<drawing::XShape
> xLegend
= xChartDoc
->getLegend();
920 awt::Point aPos
= xLegend
->getPosition();
921 CPPUNIT_ASSERT(aPos
.X
> 5000); // real value for me is above 8000 but before bug fix is below 1000
922 CPPUNIT_ASSERT(aPos
.Y
> 4000); // real value for ms is above 7000
925 void Chart2ImportTest::testTdf105517()
927 loadFromURL(u
"pptx/tdf105517.pptx");
928 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
929 CPPUNIT_ASSERT(xChartDoc
.is());
931 Reference
<chart2::XCoordinateSystemContainer
> xCoordContainer(xChartDoc
->getFirstDiagram(), uno::UNO_QUERY
);
932 CPPUNIT_ASSERT(xCoordContainer
.is());
933 Reference
<chart2::XChartTypeContainer
> xChartTypeContainer(xCoordContainer
->getCoordinateSystems()[0], uno::UNO_QUERY
);
934 CPPUNIT_ASSERT(xChartTypeContainer
.is());
935 Reference
<chart2::XDataSeriesContainer
> xDSContainer(xChartTypeContainer
->getChartTypes()[0], uno::UNO_QUERY
);
936 CPPUNIT_ASSERT(xDSContainer
.is());
937 Reference
<beans::XPropertySet
> xPropSet1(xDSContainer
->getDataSeries()[0], uno::UNO_QUERY
);
938 CPPUNIT_ASSERT(xPropSet1
.is());
940 tools::Long lineColor
;
941 xPropSet1
->getPropertyValue("Color") >>= lineColor
;
942 // incorrect line color was 0x4a7ebb due to not handling themeOverride
943 CPPUNIT_ASSERT_EQUAL(tools::Long(0xeaa700), lineColor
);
945 Reference
<beans::XPropertySet
> xPropSet2(xDSContainer
->getDataSeries()[1], uno::UNO_QUERY
);
946 CPPUNIT_ASSERT(xPropSet2
.is());
948 xPropSet2
->getPropertyValue("Color") >>= lineColor
;
949 // incorrect line color was 0x98b855
950 CPPUNIT_ASSERT_EQUAL(tools::Long(0x1e69a8), lineColor
);
953 void Chart2ImportTest::testTdf106217()
955 loadFromURL(u
"pptx/tdf106217.pptx");
956 uno::Reference
< chart::XChartDocument
> xChartDoc
= getChartDocFromDrawImpress(0, 0);
957 CPPUNIT_ASSERT(xChartDoc
.is());
959 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(xChartDoc
, uno::UNO_QUERY
);
960 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
961 uno::Reference
<drawing::XShape
> xCircle(xDrawPage
->getByIndex(1), uno::UNO_QUERY
);
962 CPPUNIT_ASSERT(xCircle
.is());
964 uno::Reference
<container::XNamed
> xNamedShape(xCircle
, uno::UNO_QUERY
);
965 CPPUNIT_ASSERT_EQUAL(OUString("Oval 1"), xNamedShape
->getName());
967 awt::Point aPosition
= xCircle
->getPosition();
968 CPPUNIT_ASSERT_EQUAL(sal_Int32(6870), aPosition
.X
);
969 CPPUNIT_ASSERT_EQUAL(sal_Int32(7261), aPosition
.Y
);
970 awt::Size aSize
= xCircle
->getSize();
971 CPPUNIT_ASSERT_EQUAL(sal_Int32(2701), aSize
.Width
);
972 CPPUNIT_ASSERT_EQUAL(sal_Int32(2700), aSize
.Height
);
975 void Chart2ImportTest::testTdf108021()
977 // Tdf108021 : To check TextBreak value is true.
978 loadFromURL(u
"ods/tdf108021.ods");
979 uno::Reference
< chart::XDiagram
> mxDiagram
;
980 uno::Reference
< beans::XPropertySet
> xAxisProp
;
981 bool bTextBreak
= false;
982 uno::Reference
< chart::XChartDocument
> xChartDoc ( getChartCompFromSheet( 0, 0, mxComponent
), UNO_QUERY_THROW
);
983 mxDiagram
.set(xChartDoc
->getDiagram());
984 CPPUNIT_ASSERT(mxDiagram
.is());
985 uno::Reference
< chart::XAxisXSupplier
> xAxisXSupp( mxDiagram
, uno::UNO_QUERY
);
986 CPPUNIT_ASSERT(xAxisXSupp
.is());
987 xAxisProp
= xAxisXSupp
->getXAxis();
988 xAxisProp
->getPropertyValue("TextBreak") >>= bTextBreak
;
989 // Expected value of 'TextBreak' is true
990 CPPUNIT_ASSERT(bTextBreak
);
993 void Chart2ImportTest::testTdf100084()
995 // The test file was created with IBM Cognos, make sure there is a diagram.
996 loadFromURL(u
"xlsx/tdf100084.xlsx");
997 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
998 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
999 Reference
<beans::XPropertySet
> xDiagram(xChartDoc
->getFirstDiagram(), UNO_QUERY
);
1000 CPPUNIT_ASSERT_MESSAGE("There should be a Diagram.", xDiagram
.is());
1003 void Chart2ImportTest::testTdf124817()
1005 loadFromURL(u
"xlsx/tdf124817.xlsx");
1006 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1007 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1009 uno::Reference
<chart2::XDataSeries
> xDataSeries
;
1010 chart2::Symbol aSymblProp
;
1012 // Check the symbol of data series 1 (marker style none)
1013 xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1014 CPPUNIT_ASSERT(xDataSeries
.is());
1015 uno::Reference
<beans::XPropertySet
> xPropSet_0(xDataSeries
, uno::UNO_QUERY_THROW
);
1016 CPPUNIT_ASSERT((xPropSet_0
->getPropertyValue("Symbol") >>= aSymblProp
));
1017 CPPUNIT_ASSERT_EQUAL(chart2::SymbolStyle_NONE
, aSymblProp
.Style
);
1019 // Check the symbol of data series 2 (marker style square)
1020 xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 1);
1021 CPPUNIT_ASSERT(xDataSeries
.is());
1022 uno::Reference
<beans::XPropertySet
> xPropSet_1(xDataSeries
, uno::UNO_QUERY_THROW
);
1023 CPPUNIT_ASSERT((xPropSet_1
->getPropertyValue("Symbol") >>= aSymblProp
));
1024 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0xED7D31), aSymblProp
.FillColor
);
1026 // Check the symbol of data series 3 (marker style diagonal cross)
1027 xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 2);
1028 CPPUNIT_ASSERT(xDataSeries
.is());
1029 uno::Reference
<beans::XPropertySet
> xPropSet_2(xDataSeries
, uno::UNO_QUERY_THROW
);
1030 CPPUNIT_ASSERT((xPropSet_2
->getPropertyValue("Symbol") >>= aSymblProp
));
1031 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0xFF0000), aSymblProp
.BorderColor
);
1034 void Chart2ImportTest::testTdf126033()
1036 loadFromURL(u
"xlsx/tdf126033.xlsx");
1037 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1038 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1040 // Check symbol style and size of data points
1041 chart2::Symbol aSymblProp
;
1042 uno::Reference
<chart2::XDataSeries
> xDataSeries(getDataSeriesFromDoc(xChartDoc
, 0));
1043 CPPUNIT_ASSERT(xDataSeries
.is());
1044 uno::Reference
<beans::XPropertySet
> xPropertySet(xDataSeries
->getDataPointByIndex(0), uno::UNO_SET_THROW
);
1045 CPPUNIT_ASSERT(xPropertySet
->getPropertyValue("Symbol") >>= aSymblProp
);
1046 CPPUNIT_ASSERT_EQUAL(chart2::SymbolStyle_NONE
, aSymblProp
.Style
);
1047 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(176), aSymblProp
.Size
.Width
);
1048 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(176), aSymblProp
.Size
.Height
);
1051 void Chart2ImportTest::testTransparentBackground(std::u16string_view filename
)
1053 loadFromURL(filename
);
1054 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1055 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1057 uno::Reference
< chart::XChartDocument
> xChart2Doc (xChartDoc
, uno::UNO_QUERY
);
1058 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChart2Doc
.is());
1060 Reference
< beans::XPropertySet
> xPropSet
= xChart2Doc
->getArea();
1061 CPPUNIT_ASSERT_MESSAGE("failed to get Area", xPropSet
.is());
1063 css::drawing::FillStyle aStyle
;
1064 xPropSet
-> getPropertyValue("FillStyle") >>= aStyle
;
1066 CPPUNIT_ASSERT_EQUAL_MESSAGE("Background needs to be with solid fill style", css::drawing::FillStyle_SOLID
, aStyle
);
1068 // 2 test methods here so that tearDown() can dispose the document
1069 void Chart2ImportTest::testFdo54361()
1071 testTransparentBackground(u
"xlsx/fdo54361.xlsx");
1073 void Chart2ImportTest::testFdo54361_1()
1075 testTransparentBackground(u
"xlsx/fdo54361-1.xlsx");
1078 void Chart2ImportTest::testAutoBackgroundXLSX()
1080 loadFromURL(u
"xlsx/chart-auto-background.xlsx");
1081 uno::Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1082 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1084 // "Automatic" chart background fill in xlsx should be loaded as solid white.
1085 Reference
<beans::XPropertySet
> xPropSet
= xChartDoc
->getPageBackground();
1086 CPPUNIT_ASSERT(xPropSet
.is());
1087 drawing::FillStyle eStyle
= xPropSet
->getPropertyValue("FillStyle").get
<drawing::FillStyle
>();
1088 sal_Int32 nColor
= xPropSet
->getPropertyValue("FillColor").get
<sal_Int32
>();
1089 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid fill.",
1090 drawing::FillStyle_SOLID
, eStyle
);
1091 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid white.",
1092 sal_Int32(0x00FFFFFF), sal_Int32(nColor
& 0x00FFFFFF)); // highest 2 bytes are transparency which we ignore here.
1095 void Chart2ImportTest::testAutoChartAreaBorderPropXLSX()
1097 loadFromURL(u
"xlsx/chart-area-style-border.xlsx");
1098 uno::Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1099 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1101 // Test "Automatic" chartarea border style/color/width.
1102 Reference
<beans::XPropertySet
> xPropSet
= xChartDoc
->getPageBackground();
1103 CPPUNIT_ASSERT(xPropSet
.is());
1104 drawing::LineStyle eStyle
= xPropSet
->getPropertyValue("LineStyle").get
<drawing::LineStyle
>();
1105 sal_Int32 nColor
= xPropSet
->getPropertyValue("LineColor").get
<sal_Int32
>();
1106 sal_Int32 nWidth
= xPropSet
->getPropertyValue("LineWidth").get
<sal_Int32
>();
1107 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border should be loaded as solid style.",
1108 drawing::LineStyle_SOLID
, eStyle
);
1109 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border color should be loaded as light gray.",
1110 sal_Int32(0xD9D9D9), nColor
);
1111 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border width should be loaded as 0.75 pt (~0.026 cm)",
1112 sal_Int32(26), nWidth
);
1115 void Chart2ImportTest::testAutoChartAreaBorderPropPPTX()
1117 loadFromURL(u
"pptx/tdf150176.pptx");
1118 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
1119 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1121 // Test "Automatic" chartarea border style/color/width.
1122 Reference
<beans::XPropertySet
> xPropSet
= xChartDoc
->getPageBackground();
1123 CPPUNIT_ASSERT(xPropSet
.is());
1124 drawing::LineStyle eStyle
= xPropSet
->getPropertyValue("LineStyle").get
<drawing::LineStyle
>();
1125 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border should be loaded as none style for pptx.",
1126 drawing::LineStyle_NONE
, eStyle
);
1129 void Chart2ImportTest::testChartAreaStyleBackgroundXLSX()
1131 loadFromURL(u
"xlsx/chart-area-style-background.xlsx");
1132 uno::Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1133 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1135 // "Automatic" chart background fill in xlsx should be loaded as solid white.
1136 Reference
<beans::XPropertySet
> xPropSet
= xChartDoc
->getPageBackground();
1137 CPPUNIT_ASSERT(xPropSet
.is());
1138 drawing::FillStyle eStyle
= xPropSet
->getPropertyValue("FillStyle").get
<drawing::FillStyle
>();
1139 sal_Int32 nColor
= xPropSet
->getPropertyValue("FillColor").get
<sal_Int32
>();
1140 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid fill.",
1141 drawing::FillStyle_SOLID
, eStyle
);
1142 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid white.",
1143 sal_Int32(0), nColor
);
1146 void Chart2ImportTest::testChartHatchFillXLSX()
1148 loadFromURL(u
"xlsx/chart-hatch-fill.xlsx");
1149 uno::Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1150 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1152 // Check the chart background FillStyle is HATCH
1153 Reference
<beans::XPropertySet
> xPropSet
= xChartDoc
->getPageBackground();
1154 CPPUNIT_ASSERT(xPropSet
.is());
1155 drawing::FillStyle eStyle
= xPropSet
->getPropertyValue("FillStyle").get
<drawing::FillStyle
>();
1157 CPPUNIT_ASSERT_EQUAL_MESSAGE("Chart background fill in this xlsx should be loaded as hatch fill.",
1158 drawing::FillStyle_HATCH
, eStyle
);
1160 // Check the FillBackground of chart background
1161 bool bBackgroundFill
= false;
1162 xPropSet
->getPropertyValue("FillBackground") >>= bBackgroundFill
;
1163 CPPUNIT_ASSERT(bBackgroundFill
);
1165 Color nBackgroundColor
;
1166 xPropSet
->getPropertyValue("FillColor") >>= nBackgroundColor
;
1167 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nBackgroundColor
);
1169 // Check the datapoint has HatchName value
1170 uno::Reference
<chart2::XDataSeries
> xDataSeries(getDataSeriesFromDoc(xChartDoc
, 0));
1171 CPPUNIT_ASSERT(xDataSeries
.is());
1173 uno::Reference
<beans::XPropertySet
> xPropertySet(xDataSeries
->getDataPointByIndex(1), uno::UNO_SET_THROW
);
1174 OUString sHatchName
;
1175 xPropertySet
->getPropertyValue("HatchName") >>= sHatchName
;
1176 CPPUNIT_ASSERT(!sHatchName
.isEmpty());
1178 // Check the FillBackground of datapoint
1179 bool bBackgroundFillofDatapoint
= false;
1180 xPropertySet
->getPropertyValue("FillBackground") >>= bBackgroundFillofDatapoint
;
1181 CPPUNIT_ASSERT(bBackgroundFillofDatapoint
);
1183 sal_Int32 nBackgroundColorofDatapoint
;
1184 xPropertySet
->getPropertyValue("FillColor") >>= nBackgroundColorofDatapoint
;
1185 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0x00B050), nBackgroundColorofDatapoint
);
1188 void Chart2ImportTest::testAxisTextRotationXLSX()
1190 loadFromURL(u
"xlsx/axis-label-rotation.xlsx");
1191 uno::Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1192 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1194 Reference
<chart2::XAxis
> xYAxis
= getAxisFromDoc(xChartDoc
, 0, 0, 0);
1195 CPPUNIT_ASSERT(xYAxis
.is());
1197 Reference
<beans::XPropertySet
> xPS(xYAxis
, uno::UNO_QUERY_THROW
);
1198 double nRotation
= 0;
1199 bool bSuccess
= xPS
->getPropertyValue("TextRotation") >>= nRotation
;
1201 CPPUNIT_ASSERT(bSuccess
);
1202 CPPUNIT_ASSERT_DOUBLES_EQUAL(90, nRotation
, 1e-10);
1205 /* TODO : temporarily disabled.
1206 void Chart2ImportTest::testTextCanOverlapXLSX()
1208 // fdo#84647 : To check textoverlap value is imported correctly.
1209 load("/chart2/qa/extras/data/xlsx/", "chart-text-can-overlap.xlsx");
1210 uno::Reference< chart::XDiagram > mxDiagram;
1211 uno::Reference< beans::XPropertySet > xAxisProp;
1212 bool bTextCanOverlap = false;
1213 uno::Reference< chart::XChartDocument > xChartDoc ( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW);
1214 mxDiagram.set(xChartDoc->getDiagram());
1215 CPPUNIT_ASSERT(mxDiagram.is());
1216 uno::Reference< chart::XAxisXSupplier > xAxisXSupp( mxDiagram, uno::UNO_QUERY );
1217 CPPUNIT_ASSERT(xAxisXSupp.is());
1218 xAxisProp = xAxisXSupp->getXAxis();
1219 xAxisProp->getPropertyValue("TextCanOverlap") >>= bTextCanOverlap;
1220 // Expected value of 'TextCanOverlap' is true
1221 CPPUNIT_ASSERT(bTextCanOverlap);
1225 void Chart2ImportTest::testTextBreakXLSX()
1227 // tdf#122091: To check textbreak value is true in case of 0° degree of Axis label rotation.
1228 loadFromURL(u
"xlsx/chart_label_text_break.xlsx");
1229 uno::Reference
< chart::XDiagram
> mxDiagram
;
1230 uno::Reference
< beans::XPropertySet
> xAxisProp
;
1231 bool textBreak
= false;
1232 uno::Reference
< chart::XChartDocument
> xChartDoc ( getChartCompFromSheet( 0, 0, mxComponent
), UNO_QUERY_THROW
);
1233 CPPUNIT_ASSERT(xChartDoc
.is());
1234 mxDiagram
.set(xChartDoc
->getDiagram());
1235 CPPUNIT_ASSERT(mxDiagram
.is());
1236 uno::Reference
< chart::XAxisXSupplier
> xAxisXSupp( mxDiagram
, uno::UNO_QUERY
);
1237 CPPUNIT_ASSERT(xAxisXSupp
.is());
1238 xAxisProp
= xAxisXSupp
->getXAxis();
1239 xAxisProp
->getPropertyValue("TextBreak") >>= textBreak
;
1240 // Expected value of 'TextBreak' is true
1241 CPPUNIT_ASSERT(textBreak
);
1244 void Chart2ImportTest::testNumberFormatsXLSX()
1246 loadFromURL(u
"xlsx/number-formats.xlsx");
1247 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1248 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1250 uno::Reference
<chart2::XDataSeries
> xDataSeries(getDataSeriesFromDoc(xChartDoc
, 0));
1251 CPPUNIT_ASSERT(xDataSeries
.is());
1252 uno::Reference
<beans::XPropertySet
> xPropertySet
;
1253 chart2::DataPointLabel aLabel
;
1254 sal_Int32 nNumberFormat
;
1255 bool bLinkNumberFormatToSource
= false;
1256 const sal_Int32 nChartDataNumberFormat
= getNumberFormat(
1257 xChartDoc
, "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"??_);_(@_)");
1259 xPropertySet
.set(xDataSeries
->getDataPointByIndex(0), uno::UNO_SET_THROW
);
1260 xPropertySet
->getPropertyValue("Label") >>= aLabel
;
1261 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumber
);
1262 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumberInPercent
);
1263 xPropertySet
->getPropertyValue(CHART_UNONAME_NUMFMT
) >>= nNumberFormat
;
1264 CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat
, nNumberFormat
);
1265 bool bSuccess
= xPropertySet
->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat
;
1266 CPPUNIT_ASSERT_EQUAL(false, bSuccess
);
1267 bSuccess
= xPropertySet
->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT
) >>= bLinkNumberFormatToSource
;
1268 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess
);
1269 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource
);
1271 xPropertySet
.set(xDataSeries
->getDataPointByIndex(1), uno::UNO_SET_THROW
);
1272 xPropertySet
->getPropertyValue("Label") >>= aLabel
;
1273 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumber
);
1274 CPPUNIT_ASSERT_EQUAL(sal_False
, aLabel
.ShowNumberInPercent
);
1275 xPropertySet
->getPropertyValue(CHART_UNONAME_NUMFMT
) >>= nNumberFormat
;
1276 CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat
, nNumberFormat
);
1277 bSuccess
= xPropertySet
->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat
;
1278 CPPUNIT_ASSERT_EQUAL(false, bSuccess
);
1279 bSuccess
= xPropertySet
->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT
) >>= bLinkNumberFormatToSource
;
1280 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess
);
1281 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource
);
1283 xPropertySet
.set(xDataSeries
->getDataPointByIndex(2), uno::UNO_SET_THROW
);
1284 xPropertySet
->getPropertyValue("Label") >>= aLabel
;
1285 CPPUNIT_ASSERT_EQUAL(sal_False
, aLabel
.ShowNumber
);
1286 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumberInPercent
);
1287 xPropertySet
->getPropertyValue(CHART_UNONAME_NUMFMT
) >>= nNumberFormat
;
1288 CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat
, nNumberFormat
);
1289 bSuccess
= xPropertySet
->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat
;
1290 CPPUNIT_ASSERT_EQUAL(false, bSuccess
);
1291 bSuccess
= xPropertySet
->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT
) >>= bLinkNumberFormatToSource
;
1292 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess
);
1293 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource
);
1296 void Chart2ImportTest::testNumberFormatsDOCX()
1298 loadFromURL(u
"docx/tdf132174.docx");
1300 uno::Reference
< chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
1301 CPPUNIT_ASSERT(xChartDoc
.is());
1303 css::uno::Reference
<chart2::XDiagram
> xDiagram(xChartDoc
->getFirstDiagram(), UNO_SET_THROW
);
1304 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1305 uno::Reference
<beans::XPropertySet
> xPropertySet(xDataSeries
, uno::UNO_QUERY_THROW
);
1306 CPPUNIT_ASSERT(xPropertySet
.is());
1308 sal_Int32 nNumberFormat
;
1309 bool bLinkNumberFormatToSource
= true;
1310 const sal_Int32 nChartDataNumberFormat
= getNumberFormat(xChartDoc
, "0%");
1311 xPropertySet
->getPropertyValue(CHART_UNONAME_NUMFMT
) >>= nNumberFormat
;
1312 CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat
, nNumberFormat
);
1313 xPropertySet
->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT
) >>= bLinkNumberFormatToSource
;
1314 // LinkNumberFormatToSource should be set to false even if the original OOXML contain a true value,
1315 // because the inner data table of charts have no own number format!
1316 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource
);
1319 loadFromURL(u
"docx/tdf136650.docx");
1321 uno::Reference
< chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
1322 CPPUNIT_ASSERT(xChartDoc
.is());
1324 css::uno::Reference
<chart2::XDiagram
> xDiagram(xChartDoc
->getFirstDiagram(), UNO_SET_THROW
);
1325 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1326 CPPUNIT_ASSERT(xDataSeries
.is());
1327 Reference
<beans::XPropertySet
> xPropertySet(xDataSeries
->getDataPointByIndex(1), uno::UNO_SET_THROW
);
1329 sal_Int32 nNumberFormat
;
1330 bool bLinkNumberFormatToSource
= true;
1331 const sal_Int32 nChartDataNumberFormat
= getNumberFormat(xChartDoc
, "0%");
1332 xPropertySet
->getPropertyValue(CHART_UNONAME_NUMFMT
) >>= nNumberFormat
;
1333 CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat
, nNumberFormat
);
1334 xPropertySet
->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT
) >>= bLinkNumberFormatToSource
;
1335 // LinkNumberFormatToSource should be set to false even if the original OOXML file contain a true value,
1336 // because the inner data table of charts have no own number format!
1337 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource
);
1341 void Chart2ImportTest::testPercentageNumberFormatsDOCX()
1343 loadFromURL(u
"docx/tdf133632.docx");
1344 uno::Reference
< chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
1345 CPPUNIT_ASSERT(xChartDoc
.is());
1347 css::uno::Reference
<chart2::XDiagram
> xDiagram(xChartDoc
->getFirstDiagram(), UNO_SET_THROW
);
1348 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1349 uno::Reference
<beans::XPropertySet
> xPropertySet(xDataSeries
, uno::UNO_QUERY_THROW
);
1350 CPPUNIT_ASSERT(xPropertySet
.is());
1352 bool bLinkNumberFormatToSource
= false;
1353 chart2::DataPointLabel aLabel
;
1354 xPropertySet
->getPropertyValue("Label") >>= aLabel
;
1355 CPPUNIT_ASSERT_EQUAL(sal_False
, aLabel
.ShowNumber
);
1356 CPPUNIT_ASSERT_EQUAL(sal_True
, aLabel
.ShowNumberInPercent
);
1357 bool bSuccess
= xPropertySet
->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT
) >>= bLinkNumberFormatToSource
;
1358 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess
);
1359 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource
);
1362 void Chart2ImportTest::testAutoTitleDelDefaultValue2007XLSX()
1364 loadFromURL(u
"xlsx/autotitledel_2007.xlsx");
1365 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1366 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1368 Reference
<chart2::XTitled
> xTitled(xChartDoc
, uno::UNO_QUERY_THROW
);
1369 OUString aTitle
= getTitleString(xTitled
);
1370 CPPUNIT_ASSERT_MESSAGE("autoTitleDel default value is false in MSO 2007 documents",
1374 void Chart2ImportTest::testAutoTitleDelDefaultValue2013XLSX()
1376 loadFromURL(u
"xlsx/autotitledel_2013.xlsx");
1377 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1378 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1380 Reference
<chart2::XTitled
> xTitled(xChartDoc
, uno::UNO_QUERY_THROW
);
1381 uno::Reference
<chart2::XTitle
> xTitle
= xTitled
->getTitleObject();
1382 CPPUNIT_ASSERT_MESSAGE("autoTitleDel default value is true in the OOXML spec",
1386 void Chart2ImportTest::testDispBlanksAsDefaultValue2007XLSX()
1388 loadFromURL(u
"xlsx/dispBlanksAs_2007.xlsx");
1389 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1390 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1392 Reference
<beans::XPropertySet
> xDiagram(xChartDoc
->getFirstDiagram(), UNO_QUERY
);
1393 CPPUNIT_ASSERT(xDiagram
.is());
1394 uno::Any aAny
= xDiagram
->getPropertyValue("MissingValueTreatment");
1395 sal_Int32 nMissingValueTreatment
= -2;
1396 CPPUNIT_ASSERT(aAny
>>= nMissingValueTreatment
);
1397 CPPUNIT_ASSERT_EQUAL(chart::MissingValueTreatment::LEAVE_GAP
, nMissingValueTreatment
);
1400 void Chart2ImportTest::testDispBlanksAsDefaultValue2013XLSX()
1402 loadFromURL(u
"xlsx/dispBlanksAs_2013.xlsx");
1403 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1404 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1406 Reference
<beans::XPropertySet
> xDiagram(xChartDoc
->getFirstDiagram(), UNO_QUERY
);
1407 CPPUNIT_ASSERT(xDiagram
.is());
1408 uno::Any aAny
= xDiagram
->getPropertyValue("MissingValueTreatment");
1409 sal_Int32 nMissingValueTreatment
= -2;
1410 CPPUNIT_ASSERT(aAny
>>= nMissingValueTreatment
);
1411 CPPUNIT_ASSERT_EQUAL(chart::MissingValueTreatment::USE_ZERO
, nMissingValueTreatment
);
1414 void Chart2ImportTest::testSmoothDefaultValue2007XLSX()
1416 loadFromURL(u
"xlsx/smoothed_series2007.xlsx");
1417 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1418 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1419 CPPUNIT_ASSERT(xChartDoc
.is());
1421 Reference
< chart2::XChartType
> xChartType
= getChartTypeFromDoc( xChartDoc
, 0 );
1422 CPPUNIT_ASSERT(xChartType
.is());
1424 Reference
< beans::XPropertySet
> xPropSet( xChartType
, UNO_QUERY
);
1425 CPPUNIT_ASSERT(xPropSet
.is());
1427 chart2::CurveStyle eCurveStyle
;
1428 xPropSet
->getPropertyValue("CurveStyle") >>= eCurveStyle
;
1429 CPPUNIT_ASSERT_EQUAL(chart2::CurveStyle_LINES
, eCurveStyle
);
1432 void Chart2ImportTest::testSmoothDefaultValue2013XLSX()
1434 loadFromURL(u
"xlsx/smoothed_series.xlsx");
1435 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1436 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1437 CPPUNIT_ASSERT(xChartDoc
.is());
1439 Reference
< chart2::XChartType
> xChartType
= getChartTypeFromDoc( xChartDoc
, 0 );
1440 CPPUNIT_ASSERT(xChartType
.is());
1442 Reference
< beans::XPropertySet
> xPropSet( xChartType
, UNO_QUERY
);
1443 CPPUNIT_ASSERT(xPropSet
.is());
1445 chart2::CurveStyle eCurveStyle
;
1446 xPropSet
->getPropertyValue("CurveStyle") >>= eCurveStyle
;
1447 CPPUNIT_ASSERT(eCurveStyle
!= chart2::CurveStyle_LINES
);
1450 void Chart2ImportTest::testTrendlineDefaultValue2007XLSX()
1452 loadFromURL(u
"xlsx/trendline2007.xlsx");
1453 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1454 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1455 CPPUNIT_ASSERT(xChartDoc
.is());
1456 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1457 CPPUNIT_ASSERT(xDataSeries
.is());
1458 Reference
<chart2::XRegressionCurveContainer
> xRegressionCurveContainer(xDataSeries
, UNO_QUERY_THROW
);
1459 Sequence
< Reference
<chart2::XRegressionCurve
> > xRegressionCurveSequence
= xRegressionCurveContainer
->getRegressionCurves();
1460 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xRegressionCurveSequence
.getLength());
1462 Reference
<chart2::XRegressionCurve
> xCurve
= xRegressionCurveSequence
[0];
1464 Reference
<beans::XPropertySet
> xPropSet(xCurve
->getEquationProperties(), uno::UNO_SET_THROW
);
1465 uno::Any aAny
= xPropSet
->getPropertyValue("ShowEquation");
1466 bool bShowEquation
= true;
1467 CPPUNIT_ASSERT(aAny
>>= bShowEquation
);
1468 CPPUNIT_ASSERT(!bShowEquation
);
1470 aAny
= xPropSet
->getPropertyValue("ShowCorrelationCoefficient");
1471 bool bShowCorrelation
= true;
1472 CPPUNIT_ASSERT(aAny
>>= bShowCorrelation
);
1473 CPPUNIT_ASSERT(!bShowCorrelation
);
1476 void Chart2ImportTest::testTrendlineDefaultValue2013XLSX()
1478 loadFromURL(u
"xlsx/trendline.xlsx");
1479 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1480 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1481 CPPUNIT_ASSERT(xChartDoc
.is());
1482 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1483 CPPUNIT_ASSERT(xDataSeries
.is());
1484 Reference
<chart2::XRegressionCurveContainer
> xRegressionCurveContainer(xDataSeries
, UNO_QUERY_THROW
);
1485 Sequence
< Reference
<chart2::XRegressionCurve
> > xRegressionCurveSequence
= xRegressionCurveContainer
->getRegressionCurves();
1486 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xRegressionCurveSequence
.getLength());
1488 Reference
<chart2::XRegressionCurve
> xCurve
= xRegressionCurveSequence
[0];
1490 Reference
<beans::XPropertySet
> xPropSet(xCurve
->getEquationProperties(), uno::UNO_SET_THROW
);
1491 uno::Any aAny
= xPropSet
->getPropertyValue("ShowEquation");
1492 bool bShowEquation
= false;
1493 CPPUNIT_ASSERT(aAny
>>= bShowEquation
);
1494 CPPUNIT_ASSERT(bShowEquation
);
1496 aAny
= xPropSet
->getPropertyValue("ShowCorrelationCoefficient");
1497 bool bShowCorrelation
= false;
1498 CPPUNIT_ASSERT(aAny
>>= bShowCorrelation
);
1499 CPPUNIT_ASSERT(bShowCorrelation
);
1502 void Chart2ImportTest::testVaryColorDefaultValues2007XLSX()
1504 loadFromURL(u
"xlsx/vary_color2007.xlsx");
1505 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1506 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1507 CPPUNIT_ASSERT(xChartDoc
.is());
1508 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1509 CPPUNIT_ASSERT(xDataSeries
.is());
1510 Reference
<beans::XPropertySet
> xPropSet(xDataSeries
, uno::UNO_QUERY_THROW
);
1511 uno::Any aAny
= xPropSet
->getPropertyValue("VaryColorsByPoint");
1512 bool bVaryColor
= true;
1513 CPPUNIT_ASSERT(aAny
>>= bVaryColor
);
1514 CPPUNIT_ASSERT(!bVaryColor
);
1517 void Chart2ImportTest::testVaryColorDefaultValues2013XLSX()
1519 loadFromURL(u
"xlsx/vary_color.xlsx");
1520 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1521 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1522 CPPUNIT_ASSERT(xChartDoc
.is());
1523 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1524 CPPUNIT_ASSERT(xDataSeries
.is());
1525 Reference
<beans::XPropertySet
> xPropSet(xDataSeries
, uno::UNO_QUERY_THROW
);
1526 uno::Any aAny
= xPropSet
->getPropertyValue("VaryColorsByPoint");
1527 bool bVaryColor
= false;
1528 CPPUNIT_ASSERT(aAny
>>= bVaryColor
);
1529 CPPUNIT_ASSERT(!bVaryColor
);
1532 void Chart2ImportTest::testPlotVisOnlyDefaultValue2013XLSX()
1534 loadFromURL(u
"xlsx/plotVisOnly.xlsx");
1535 uno::Reference
< chart::XChartDocument
> xChart1Doc ( getChartCompFromSheet( 0, 0, mxComponent
), UNO_QUERY_THROW
);
1536 Reference
<beans::XPropertySet
> xPropSet(xChart1Doc
->getDiagram(), uno::UNO_QUERY_THROW
);
1537 uno::Any aAny
= xPropSet
->getPropertyValue("IncludeHiddenCells");
1538 CPPUNIT_ASSERT(aAny
.hasValue());
1539 bool bShowHiddenValues
= true;
1540 CPPUNIT_ASSERT(aAny
>>= bShowHiddenValues
);
1541 CPPUNIT_ASSERT(!bShowHiddenValues
);
1544 void Chart2ImportTest::testRAngAxDefaultValue2013XLSX()
1546 loadFromURL(u
"xlsx/rAngAx.xlsx");
1547 uno::Reference
< chart::XChartDocument
> xChart1Doc ( getChartCompFromSheet( 0, 0, mxComponent
), UNO_QUERY_THROW
);
1548 Reference
<beans::XPropertySet
> xPropSet(xChart1Doc
->getDiagram(), uno::UNO_QUERY_THROW
);
1549 uno::Any aAny
= xPropSet
->getPropertyValue("RightAngledAxes");
1550 CPPUNIT_ASSERT(aAny
.hasValue());
1551 bool bRightAngleAxes
= false;
1552 CPPUNIT_ASSERT(aAny
>>= bRightAngleAxes
);
1553 CPPUNIT_ASSERT(bRightAngleAxes
);
1556 void Chart2ImportTest::testMajorTickMarksDefaultValue2013XLSX()
1558 loadFromURL(u
"xlsx/majorTickMark.xlsx");
1559 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1560 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1561 Reference
<chart2::XAxis
> xXAxis
= getAxisFromDoc(xChartDoc
, 0, 0, 0);
1562 CPPUNIT_ASSERT(xXAxis
.is());
1563 Reference
<beans::XPropertySet
> xPropSet(xXAxis
, uno::UNO_QUERY_THROW
);
1564 uno::Any aAny
= xPropSet
->getPropertyValue("MajorTickmarks");
1565 sal_Int32 nMajorTickmarks
= chart2::TickmarkStyle::NONE
;
1566 CPPUNIT_ASSERT(aAny
.hasValue());
1567 CPPUNIT_ASSERT(aAny
>>= nMajorTickmarks
);
1568 CPPUNIT_ASSERT_EQUAL(chart2::TickmarkStyle::INNER
| chart2::TickmarkStyle::OUTER
, nMajorTickmarks
);
1571 void Chart2ImportTest::testMinorTickMarksDefaultValue2013XLSX()
1573 loadFromURL(u
"xlsx/minorTickMark.xlsx");
1574 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1575 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1576 Reference
<chart2::XAxis
> xXAxis
= getAxisFromDoc(xChartDoc
, 0, 0, 0);
1577 CPPUNIT_ASSERT(xXAxis
.is());
1578 Reference
<beans::XPropertySet
> xPropSet(xXAxis
, uno::UNO_QUERY_THROW
);
1579 uno::Any aAny
= xPropSet
->getPropertyValue("MinorTickmarks");
1580 sal_Int32 nMajorTickmarks
= chart2::TickmarkStyle::NONE
;
1581 CPPUNIT_ASSERT(aAny
.hasValue());
1582 CPPUNIT_ASSERT(aAny
>>= nMajorTickmarks
);
1583 CPPUNIT_ASSERT_EQUAL(chart2::TickmarkStyle::INNER
| chart2::TickmarkStyle::OUTER
, nMajorTickmarks
);
1586 void Chart2ImportTest::testAxisTitleDefaultRotationXLSX()
1588 loadFromURL(u
"xlsx/axis_title_default_rotation.xlsx");
1589 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1590 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1591 Reference
<chart2::XAxis
> xYAxis
= getAxisFromDoc(xChartDoc
, 0, 1, 0);
1592 CPPUNIT_ASSERT(xYAxis
.is());
1593 Reference
<chart2::XTitled
> xTitled(xYAxis
, uno::UNO_QUERY_THROW
);
1594 Reference
<chart2::XTitle
> xTitle
= xTitled
->getTitleObject();
1595 CPPUNIT_ASSERT(xTitle
.is());
1596 Reference
<beans::XPropertySet
> xPropSet(xTitle
, uno::UNO_QUERY_THROW
);
1597 uno::Any aAny
= xPropSet
->getPropertyValue("TextRotation");
1598 double nRotation
= 0;
1599 CPPUNIT_ASSERT(aAny
>>= nRotation
);
1600 CPPUNIT_ASSERT_EQUAL(90.0, nRotation
);
1603 void Chart2ImportTest::testSecondaryAxisTitleDefaultRotationXLSX()
1605 loadFromURL(u
"xlsx/secondary_axis_title_default_rotation.xlsx");
1606 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1607 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1608 Reference
<chart2::XAxis
> xYAxis
= getAxisFromDoc(xChartDoc
, 0, 1, 1);
1609 CPPUNIT_ASSERT(xYAxis
.is());
1610 Reference
<chart2::XTitled
> xTitled(xYAxis
, uno::UNO_QUERY_THROW
);
1611 Reference
<chart2::XTitle
> xTitle
= xTitled
->getTitleObject();
1612 CPPUNIT_ASSERT(xTitle
.is());
1613 Reference
<beans::XPropertySet
> xPropSet(xTitle
, uno::UNO_QUERY_THROW
);
1614 uno::Any aAny
= xPropSet
->getPropertyValue("TextRotation");
1615 double nRotation
= 0;
1616 CPPUNIT_ASSERT(aAny
>>= nRotation
);
1617 CPPUNIT_ASSERT_EQUAL(90.0, nRotation
);
1620 void Chart2ImportTest::testAxisTitleRotationXLSX()
1622 loadFromURL(u
"xlsx/axis_title_rotated.xlsx");
1623 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1624 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1626 Reference
<chart2::XAxis
> xYAxis
= getAxisFromDoc(xChartDoc
, 0, 1, 0);
1627 CPPUNIT_ASSERT(xYAxis
.is());
1628 Reference
<chart2::XTitled
> xTitled(xYAxis
, uno::UNO_QUERY_THROW
);
1629 Reference
<chart2::XTitle
> xTitle
= xTitled
->getTitleObject();
1630 CPPUNIT_ASSERT(xTitle
.is());
1631 Reference
<beans::XPropertySet
> xPropSet(xTitle
, uno::UNO_QUERY_THROW
);
1632 uno::Any aAny
= xPropSet
->getPropertyValue("TextRotation");
1633 double nRotation
= 0;
1634 CPPUNIT_ASSERT(aAny
>>= nRotation
);
1635 CPPUNIT_ASSERT_EQUAL(340.0, nRotation
);
1638 Reference
<chart2::XAxis
> xYAxis
= getAxisFromDoc(xChartDoc
, 0, 1, 1);
1639 CPPUNIT_ASSERT(xYAxis
.is());
1640 Reference
<chart2::XTitled
> xTitled(xYAxis
, uno::UNO_QUERY_THROW
);
1641 Reference
<chart2::XTitle
> xTitle
= xTitled
->getTitleObject();
1642 CPPUNIT_ASSERT(xTitle
.is());
1643 Reference
<beans::XPropertySet
> xPropSet(xTitle
, uno::UNO_QUERY_THROW
);
1644 uno::Any aAny
= xPropSet
->getPropertyValue("TextRotation");
1645 double nRotation
= 0;
1646 CPPUNIT_ASSERT(aAny
>>= nRotation
);
1647 CPPUNIT_ASSERT_EQUAL(270.0, nRotation
);
1652 void Chart2ImportTest::testAxisTitlePositionDOCX()
1654 loadFromURL(u
"docx/testAxisTitlePosition.docx");
1655 uno::Reference
< chart::XDiagram
> mxDiagram
;
1656 uno::Reference
< drawing::XShape
> xAxisTitle
;
1657 uno::Reference
< chart::XChartDocument
> xChartDoc
= getChartDocFromWriter(0);
1658 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1659 mxDiagram
.set(xChartDoc
->getDiagram());
1660 CPPUNIT_ASSERT(mxDiagram
.is());
1661 // test X Axis title position
1662 uno::Reference
< chart::XAxisXSupplier
> xAxisXSupp(mxDiagram
, uno::UNO_QUERY
);
1663 CPPUNIT_ASSERT(xAxisXSupp
.is());
1665 xAxisTitle
= xAxisXSupp
->getXAxisTitle();
1666 CPPUNIT_ASSERT(xAxisTitle
.is());
1668 awt::Point aPos
= xAxisTitle
->getPosition();
1669 CPPUNIT_ASSERT_DOUBLES_EQUAL(10640, aPos
.X
, 2);
1670 CPPUNIT_ASSERT_DOUBLES_EQUAL(7157, aPos
.Y
, 2);
1672 // test Y Axis title position
1673 uno::Reference
< chart::XAxisYSupplier
> xAxisYSupp(mxDiagram
, uno::UNO_QUERY
);
1674 CPPUNIT_ASSERT(xAxisYSupp
.is());
1676 xAxisTitle
= xAxisYSupp
->getYAxisTitle();
1677 CPPUNIT_ASSERT(xAxisTitle
.is());
1679 aPos
= xAxisTitle
->getPosition();
1680 CPPUNIT_ASSERT_DOUBLES_EQUAL(387, aPos
.X
, 2);
1681 CPPUNIT_ASSERT_DOUBLES_EQUAL(6378, aPos
.Y
, 300);
1684 void Chart2ImportTest::testCombinedChartAttachedAxisXLSX()
1686 loadFromURL(u
"xlsx/testCombinedChartAxis.xlsx");
1687 Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1689 Reference
<chart2::XDataSeries
> xSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1690 CPPUNIT_ASSERT(xSeries
.is());
1692 Reference
<beans::XPropertySet
> xPropSet(xSeries
, uno::UNO_QUERY_THROW
);
1693 sal_Int32 nAxisIndex
= -1;
1694 // First series (column chart) should be attached to secondary axis!
1695 uno::Any aAny
= xPropSet
->getPropertyValue("AttachedAxisIndex");
1696 CPPUNIT_ASSERT(aAny
>>= nAxisIndex
);
1697 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nAxisIndex
);
1700 xSeries
= getDataSeriesFromDoc(xChartDoc
, 0, 1);
1701 CPPUNIT_ASSERT(xSeries
.is());
1703 xPropSet
.set(xSeries
, uno::UNO_QUERY_THROW
);
1704 // Second series (line chart) should be attached to primary axis!
1705 aAny
= xPropSet
->getPropertyValue("AttachedAxisIndex");
1706 CPPUNIT_ASSERT(aAny
>>= nAxisIndex
);
1707 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex
);
1710 void Chart2ImportTest::testTdf140489MultiSeriesChartAxisXLSX()
1712 loadFromURL(u
"xlsx/tdf140489.xlsx");
1713 Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1715 Reference
<chart2::XDataSeries
> xSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1716 CPPUNIT_ASSERT(xSeries
.is());
1718 Reference
<beans::XPropertySet
> xPropSet(xSeries
, uno::UNO_QUERY_THROW
);
1719 sal_Int32 nAxisIndex
= -1;
1720 uno::Any aAny
= xPropSet
->getPropertyValue("AttachedAxisIndex");
1721 CPPUNIT_ASSERT(aAny
>>= nAxisIndex
);
1722 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex
);
1725 xSeries
= getDataSeriesFromDoc(xChartDoc
, 0, 1);
1726 CPPUNIT_ASSERT(xSeries
.is());
1728 xPropSet
.set(xSeries
, uno::UNO_QUERY_THROW
);
1729 aAny
= xPropSet
->getPropertyValue("AttachedAxisIndex");
1730 CPPUNIT_ASSERT(aAny
>>= nAxisIndex
);
1731 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex
);
1734 xSeries
= getDataSeriesFromDoc(xChartDoc
, 0, 2);
1735 CPPUNIT_ASSERT(xSeries
.is());
1737 xPropSet
.set(xSeries
, uno::UNO_QUERY_THROW
);
1738 aAny
= xPropSet
->getPropertyValue("AttachedAxisIndex");
1739 CPPUNIT_ASSERT(aAny
>>= nAxisIndex
);
1740 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nAxisIndex
);
1743 void Chart2ImportTest::testInternalDataProvider() {
1744 uno::Reference
< chart2::XChartDocument
> xChartDoc(getChartDocFromImpress(u
"/chart2/qa/extras/data/odp/", "chart.odp"), uno::UNO_QUERY_THROW
);
1745 const uno::Reference
< chart2::data::XDataProvider
>& rxDataProvider
= xChartDoc
->getDataProvider();
1748 Reference
<chart2::data::XDataSequence
> xDataSeq
= rxDataProvider
->createDataSequenceByValueArray("values-y", "{42;42;42;42}", "");
1749 Sequence
<Any
> xSequence
= xDataSeq
->getData();
1750 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence
[0]);
1751 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence
[1]);
1752 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence
[2]);
1753 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence
[3]);
1755 // Parse empty first and last
1756 xDataSeq
= rxDataProvider
->createDataSequenceByValueArray("values-y", "{\"\";42;42;\"\"}", "");
1757 xSequence
= xDataSeq
->getData();
1758 CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence
[0].getValue())));
1759 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence
[1]);
1760 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence
[2]);
1761 CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence
[3].getValue())));
1763 // Parse empty middle
1764 xDataSeq
= rxDataProvider
->createDataSequenceByValueArray("values-y", "{42;\"\";\"\";42}", "");
1765 xSequence
= xDataSeq
->getData();
1766 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence
[0]);
1767 CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence
[1].getValue())) );
1768 CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence
[2].getValue())) );
1769 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence
[3]);
1771 // Parse mixed types, numeric only role
1772 xDataSeq
= rxDataProvider
->createDataSequenceByValueArray("values-y", "{42;\"hello\";0;\"world\"}", "");
1773 xSequence
= xDataSeq
->getData();
1774 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence
[0]);
1775 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence
[1]);
1776 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence
[2]);
1777 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence
[3]);
1779 // Parse mixed types, mixed role
1780 xDataSeq
= rxDataProvider
->createDataSequenceByValueArray("categories", "{42;\"hello\";0;\"world\"}", "");
1781 xSequence
= xDataSeq
->getData();
1782 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 1 42")), xSequence
[0]);
1783 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 2 hello")), xSequence
[1]);
1784 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 3 0")), xSequence
[2]);
1785 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 4 world")), xSequence
[3]);
1788 void Chart2ImportTest::testTdf90510()
1790 loadFromURL(u
"xls/piechart_outside.xls");
1791 uno::Reference
< chart::XChartDocument
> xChart1Doc( getChartCompFromSheet( 0, 0, mxComponent
), UNO_QUERY_THROW
);
1792 Reference
<beans::XPropertySet
> xPropSet( xChart1Doc
->getDiagram()->getDataPointProperties( 0, 0 ), uno::UNO_SET_THROW
);
1793 uno::Any aAny
= xPropSet
->getPropertyValue( "LabelPlacement" );
1794 CPPUNIT_ASSERT( aAny
.hasValue() );
1795 sal_Int32 nLabelPlacement
= 0;
1796 CPPUNIT_ASSERT( aAny
>>= nLabelPlacement
);
1797 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data labels should be placed outside", chart::DataLabelPlacement::OUTSIDE
, nLabelPlacement
);
1800 void Chart2ImportTest::testTdf109858()
1802 loadFromURL(u
"xlsx/piechart_outside.xlsx");
1803 uno::Reference
< chart::XChartDocument
> xChart1Doc( getChartCompFromSheet( 0, 0, mxComponent
), UNO_QUERY_THROW
);
1805 // test data point labels position
1806 Reference
<beans::XPropertySet
> xDataPointPropSet( xChart1Doc
->getDiagram()->getDataPointProperties( 0, 0 ), uno::UNO_SET_THROW
);
1807 uno::Any aAny
= xDataPointPropSet
->getPropertyValue( "LabelPlacement" );
1808 CPPUNIT_ASSERT( aAny
.hasValue() );
1809 sal_Int32 nLabelPlacement
= 0;
1810 CPPUNIT_ASSERT( aAny
>>= nLabelPlacement
);
1811 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data point label should be placed bestfit", chart::DataLabelPlacement::CUSTOM
, nLabelPlacement
);
1813 // test data series label position
1814 Reference
<beans::XPropertySet
> xSeriesPropSet(xChart1Doc
->getDiagram()->getDataRowProperties(0), uno::UNO_SET_THROW
);
1815 aAny
= xSeriesPropSet
->getPropertyValue( "LabelPlacement" );
1816 CPPUNIT_ASSERT( aAny
>>= nLabelPlacement
);
1817 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data series labels should be placed outside", chart::DataLabelPlacement::OUTSIDE
, nLabelPlacement
);
1820 void Chart2ImportTest::testTdf130105()
1822 loadFromURL(u
"xlsx/barchart_outend.xlsx");
1823 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
1824 CPPUNIT_ASSERT(xChartDoc
.is());
1825 uno::Reference
<chart2::XDataSeries
> xDataSeries(getDataSeriesFromDoc(xChartDoc
, 0));
1826 CPPUNIT_ASSERT(xDataSeries
.is());
1828 uno::Reference
<beans::XPropertySet
> xPropertySet(xDataSeries
->getDataPointByIndex(0), uno::UNO_SET_THROW
);
1829 uno::Any aAny
= xPropertySet
->getPropertyValue("LabelPlacement");
1830 CPPUNIT_ASSERT(aAny
.hasValue());
1831 sal_Int32 nLabelPlacement
= 0;
1832 CPPUNIT_ASSERT(aAny
>>= nLabelPlacement
);
1833 CPPUNIT_ASSERT_EQUAL_MESSAGE("Data label should be placed outend", chart::DataLabelPlacement::OUTSIDE
, nLabelPlacement
);
1836 void Chart2ImportTest::testTdf111173()
1838 loadFromURL(u
"xlsx/tdf111173.xlsx");
1839 uno::Reference
< chart::XChartDocument
> xChart1Doc( getChartCompFromSheet( 0, 0, mxComponent
), UNO_QUERY_THROW
);
1842 void Chart2ImportTest::testTdf122226()
1844 loadFromURL(u
"docx/testTdf122226.docx" );
1845 uno::Reference
< chart2::XChartDocument
> xChartDoc ( getChartDocFromWriter(0), uno::UNO_QUERY
);
1846 CPPUNIT_ASSERT( xChartDoc
.is() );
1848 css::uno::Reference
<chart2::XDiagram
> xDiagram(xChartDoc
->getFirstDiagram(), UNO_SET_THROW
);
1849 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
1850 uno::Reference
<beans::XPropertySet
> xPropertySet(xDataSeries
->getDataPointByIndex(0), uno::UNO_SET_THROW
);
1851 CPPUNIT_ASSERT(xPropertySet
.is());
1853 uno::Any aAny
= xPropertySet
->getPropertyValue( "LabelSeparator" );
1854 CPPUNIT_ASSERT( aAny
.hasValue() );
1855 OUString nLabelSeparator
;
1856 CPPUNIT_ASSERT( aAny
>>= nLabelSeparator
);
1857 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data labels should be separated into new lines", OUString("\n"), nLabelSeparator
);
1860 void Chart2ImportTest::testTdf115107()
1862 loadFromURL(u
"pptx/tdf115107.pptx");
1864 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
1865 CPPUNIT_ASSERT(xChartDoc
.is());
1867 uno::Reference
<chart2::XDataSeries
> xDataSeries(getDataSeriesFromDoc(xChartDoc
, 0));
1868 CPPUNIT_ASSERT(xDataSeries
.is());
1870 sal_Int64 nFontColor
;
1871 sal_Int32 nCharUnderline
;
1872 uno::Reference
<beans::XPropertySet
> xPropertySet
;
1873 uno::Sequence
<uno::Reference
<chart2::XDataPointCustomLabelField
>> aFields
;
1876 xPropertySet
.set(xDataSeries
->getDataPointByIndex(0), uno::UNO_SET_THROW
);
1877 xPropertySet
->getPropertyValue("CustomLabelFields") >>= aFields
;
1878 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), aFields
.getLength());
1880 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT
, aFields
[0]->getFieldType());
1881 CPPUNIT_ASSERT_EQUAL(OUString("90.0 = "), aFields
[0]->getString());
1882 aFields
[0]->getPropertyValue("CharHeight") >>= nFontSize
;
1883 aFields
[0]->getPropertyValue("CharColor") >>= nFontColor
;
1884 CPPUNIT_ASSERT_EQUAL(static_cast<float>(18), nFontSize
);
1885 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64
>(0xed7d31), nFontColor
);
1887 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE
, aFields
[1]->getFieldType());
1888 CPPUNIT_ASSERT_EQUAL(OUString("90"), aFields
[1]->getString());
1891 xPropertySet
.set(xDataSeries
->getDataPointByIndex(1), uno::UNO_SET_THROW
);
1892 xPropertySet
->getPropertyValue("CustomLabelFields") >>= aFields
;
1893 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(8), aFields
.getLength());
1895 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT
, aFields
[0]->getFieldType());
1896 CPPUNIT_ASSERT_EQUAL(OUString("Text"), aFields
[0]->getString());
1898 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT
, aFields
[1]->getFieldType());
1899 CPPUNIT_ASSERT_EQUAL(OUString(" : "), aFields
[1]->getString());
1901 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CATEGORYNAME
, aFields
[2]->getFieldType());
1902 CPPUNIT_ASSERT_EQUAL(OUString("B"), aFields
[2]->getString());
1903 aFields
[2]->getPropertyValue("CharHeight") >>= nFontSize
;
1904 aFields
[2]->getPropertyValue("CharColor") >>= nFontColor
;
1905 CPPUNIT_ASSERT_EQUAL(static_cast<float>(16), nFontSize
);
1906 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64
>(0xed7d31), nFontColor
);
1908 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE
, aFields
[3]->getFieldType());
1910 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT
, aFields
[4]->getFieldType());
1911 CPPUNIT_ASSERT_EQUAL(OUString("Multi"), aFields
[4]->getString());
1913 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT
, aFields
[5]->getFieldType());
1914 CPPUNIT_ASSERT_EQUAL(OUString("line"), aFields
[5]->getString());
1915 aFields
[5]->getPropertyValue("CharHeight") >>= nFontSize
;
1916 aFields
[5]->getPropertyValue("CharColor") >>= nFontColor
;
1917 CPPUNIT_ASSERT_EQUAL(static_cast<float>(11.97), nFontSize
);
1918 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64
>(0xbf9000), nFontColor
);
1920 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE
, aFields
[6]->getFieldType());
1922 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT
, aFields
[7]->getFieldType());
1923 CPPUNIT_ASSERT_EQUAL(OUString("Abc"), aFields
[7]->getString());
1924 aFields
[7]->getPropertyValue("CharHeight") >>= nFontSize
;
1925 aFields
[7]->getPropertyValue("CharColor") >>= nFontColor
;
1926 aFields
[7]->getPropertyValue("CharUnderline") >>= nCharUnderline
;
1927 CPPUNIT_ASSERT_EQUAL(static_cast<float>(12), nFontSize
);
1928 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64
>(0xa9d18e), nFontColor
);
1929 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), nCharUnderline
);
1932 xPropertySet
.set(xDataSeries
->getDataPointByIndex(2), uno::UNO_SET_THROW
);
1933 xPropertySet
->getPropertyValue("CustomLabelFields") >>= aFields
;
1934 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), aFields
.getLength());
1936 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME
, aFields
[0]->getFieldType());
1937 CPPUNIT_ASSERT_EQUAL(OUString("DATA"), aFields
[0]->getString());
1940 xPropertySet
.set(xDataSeries
->getDataPointByIndex(3), uno::UNO_SET_THROW
);
1941 xPropertySet
->getPropertyValue("CustomLabelFields") >>= aFields
;
1942 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), aFields
.getLength());
1944 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CELLREF
, aFields
[0]->getFieldType());
1945 //CPPUNIT_ASSERT_EQUAL(OUString("70"), aFields[0]->getString()); TODO: Not implemented yet
1947 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT
, aFields
[1]->getFieldType());
1948 CPPUNIT_ASSERT_EQUAL(OUString(" <CELLREF"), aFields
[1]->getString());
1951 void Chart2ImportTest::testTdf115107_2()
1953 loadFromURL(u
"pptx/tdf115107-2.pptx");
1955 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
1956 CPPUNIT_ASSERT(xChartDoc
.is());
1958 uno::Reference
<chart2::XDataSeries
> xDataSeries(getDataSeriesFromDoc(xChartDoc
, 0));
1959 CPPUNIT_ASSERT(xDataSeries
.is());
1961 sal_Int64 nFontColor
;
1962 uno::Reference
<beans::XPropertySet
> xPropertySet
;
1963 uno::Sequence
<uno::Reference
<chart2::XDataPointCustomLabelField
>> aFields
;
1966 xPropertySet
.set(xDataSeries
->getDataPointByIndex(0), uno::UNO_SET_THROW
);
1967 xPropertySet
->getPropertyValue("CustomLabelFields") >>= aFields
;
1968 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), aFields
.getLength());
1970 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE
, aFields
[0]->getFieldType());
1971 CPPUNIT_ASSERT_EQUAL(OUString("4.3"), aFields
[0]->getString());
1972 aFields
[0]->getPropertyValue("CharHeight") >>= nFontSize
;
1973 aFields
[0]->getPropertyValue("CharColor") >>= nFontColor
;
1974 CPPUNIT_ASSERT_EQUAL(static_cast<float>(18), nFontSize
);
1975 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64
>(0xc00000), nFontColor
);
1977 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT
, aFields
[1]->getFieldType());
1978 CPPUNIT_ASSERT_EQUAL(OUString(" "), aFields
[1]->getString());
1980 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME
, aFields
[2]->getFieldType());
1981 CPPUNIT_ASSERT_EQUAL(OUString("Bars"), aFields
[2]->getString());
1984 xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0, 1);
1985 CPPUNIT_ASSERT(xDataSeries
.is());
1987 xPropertySet
.set(xDataSeries
->getDataPointByIndex(0), uno::UNO_SET_THROW
);
1988 xPropertySet
->getPropertyValue("CustomLabelFields") >>= aFields
;
1989 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), aFields
.getLength());
1991 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE
, aFields
[0]->getFieldType());
1992 CPPUNIT_ASSERT_EQUAL(OUString("2"), aFields
[0]->getString());
1993 aFields
[0]->getPropertyValue("CharHeight") >>= nFontSize
;
1994 aFields
[0]->getPropertyValue("CharColor") >>= nFontColor
;
1995 CPPUNIT_ASSERT_EQUAL(static_cast<float>(18), nFontSize
);
1996 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64
>(0xffd966), nFontColor
);
1998 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT
, aFields
[1]->getFieldType());
1999 CPPUNIT_ASSERT_EQUAL(OUString(" "), aFields
[1]->getString());
2001 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME
, aFields
[2]->getFieldType());
2002 CPPUNIT_ASSERT_EQUAL(OUString("Line"), aFields
[2]->getString());
2006 void Chart2ImportTest::testTdf116163()
2008 loadFromURL(u
"pptx/tdf116163.pptx");
2010 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
2011 CPPUNIT_ASSERT(xChartDoc
.is());
2013 Reference
<chart2::XAxis
> xHAxis
= getAxisFromDoc(xChartDoc
, 0, 0, 0);
2014 CPPUNIT_ASSERT(xHAxis
.is());
2016 chart2::ScaleData aScaleData
= xHAxis
->getScaleData();
2017 CPPUNIT_ASSERT(aScaleData
.Categories
.is());
2019 Reference
<chart2::data::XLabeledDataSequence
> xLabeledDataSequence
= aScaleData
.Categories
;
2020 CPPUNIT_ASSERT(xLabeledDataSequence
.is());
2022 Reference
<chart2::data::XDataSequence
> xDataSequence
= xLabeledDataSequence
->getValues();
2023 CPPUNIT_ASSERT(xDataSequence
.is());
2025 Reference
<chart2::data::XTextualDataSequence
> xTextualDataSequence(xDataSequence
, uno::UNO_QUERY
);
2026 CPPUNIT_ASSERT(xTextualDataSequence
.is());
2028 std::vector
<OUString
> aCategories
;
2029 const Sequence
<OUString
> aTextData(xTextualDataSequence
->getTextualData());
2030 ::std::copy(aTextData
.begin(), aTextData
.end(),
2031 ::std::back_inserter(aCategories
));
2033 CPPUNIT_ASSERT_EQUAL(OUString("Aaaa"), aCategories
[0]);
2034 CPPUNIT_ASSERT_EQUAL(OUString("Bbbbbbb"), aCategories
[1]);
2035 CPPUNIT_ASSERT_EQUAL(OUString("Ccc"), aCategories
[2]);
2036 CPPUNIT_ASSERT_EQUAL(OUString("Ddddddddddddd"), aCategories
[3]);
2038 // Check visible text
2040 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(xChartDoc
, uno::UNO_QUERY
);
2041 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
2042 uno::Reference
<drawing::XShapes
> xShapes(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
2043 CPPUNIT_ASSERT(xShapes
.is());
2045 uno::Reference
<drawing::XShape
> xXAxis
= getShapeByName(xShapes
, "CID/D=0:CS=0:Axis=0,0",
2046 // Axis occurs twice in chart xshape representation so need to get the one related to labels
2047 [](const uno::Reference
<drawing::XShape
>& rXShape
) -> bool
2049 uno::Reference
<drawing::XShapes
> xAxisShapes(rXShape
, uno::UNO_QUERY
);
2050 CPPUNIT_ASSERT(xAxisShapes
.is());
2051 uno::Reference
<drawing::XShape
> xChildShape(xAxisShapes
->getByIndex(0), uno::UNO_QUERY
);
2052 uno::Reference
< drawing::XShapeDescriptor
> xShapeDescriptor(xChildShape
, uno::UNO_QUERY_THROW
);
2053 return (xShapeDescriptor
->getShapeType() == "com.sun.star.drawing.TextShape");
2055 CPPUNIT_ASSERT(xXAxis
.is());
2057 uno::Reference
<container::XIndexAccess
> xIndexAccess(xXAxis
, UNO_QUERY_THROW
);
2060 uno::Reference
<text::XTextRange
> xLabel0(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
2061 CPPUNIT_ASSERT_EQUAL(OUString("Aaaa"), xLabel0
->getString());
2062 uno::Reference
<text::XTextRange
> xLabel1(xIndexAccess
->getByIndex(1), uno::UNO_QUERY
);
2063 // If there is space for 3 chars only then don't show "..."
2064 CPPUNIT_ASSERT_EQUAL(OUString("Bbb"), xLabel1
->getString());
2065 uno::Reference
<text::XTextRange
> xLabel2(xIndexAccess
->getByIndex(2), uno::UNO_QUERY
);
2066 CPPUNIT_ASSERT_EQUAL(OUString("Ccc"), xLabel2
->getString());
2067 uno::Reference
<text::XTextRange
> xLabel3(xIndexAccess
->getByIndex(3), uno::UNO_QUERY
);
2068 CPPUNIT_ASSERT_EQUAL(OUString("Dddd..."), xLabel3
->getString());
2071 void Chart2ImportTest::testTdf48041()
2073 loadFromURL(u
"pptx/tdf48041.pptx");
2075 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
2076 CPPUNIT_ASSERT(xChartDoc
.is());
2078 Reference
<chart2::XAxis
> xYAxis
= getAxisFromDoc(xChartDoc
, 0, 1, 0);
2079 CPPUNIT_ASSERT(xYAxis
.is());
2081 chart2::ScaleData aScaleData
= xYAxis
->getScaleData();
2082 CPPUNIT_ASSERT(aScaleData
.Scaling
.is());
2084 // Check visible text
2085 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(xChartDoc
, uno::UNO_QUERY
);
2086 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
2087 uno::Reference
<drawing::XShapes
> xShapes(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
2088 CPPUNIT_ASSERT(xShapes
.is());
2090 uno::Reference
<drawing::XShape
> xYAxisShape
= getShapeByName(xShapes
, "CID/D=0:CS=0:Axis=1,0", // Y Axis
2091 // Axis occurs twice in chart xshape representation so need to get the one related to labels
2092 [](const uno::Reference
<drawing::XShape
>& rXShape
) -> bool
2094 uno::Reference
<drawing::XShapes
> xAxisShapes(rXShape
, uno::UNO_QUERY
);
2095 CPPUNIT_ASSERT(xAxisShapes
.is());
2096 uno::Reference
<drawing::XShape
> xChildShape(xAxisShapes
->getByIndex(0), uno::UNO_QUERY
);
2097 uno::Reference
< drawing::XShapeDescriptor
> xShapeDescriptor(xChildShape
, uno::UNO_QUERY_THROW
);
2098 return (xShapeDescriptor
->getShapeType() == "com.sun.star.drawing.TextShape");
2100 CPPUNIT_ASSERT(xYAxisShape
.is());
2102 // Check label count
2103 uno::Reference
<container::XIndexAccess
> xIndexAccess(xYAxisShape
, UNO_QUERY_THROW
);
2104 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(6), xIndexAccess
->getCount());
2107 uno::Reference
<text::XTextRange
> xLabel0(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
2108 CPPUNIT_ASSERT_EQUAL(OUString("0"), xLabel0
->getString());
2109 uno::Reference
<text::XTextRange
> xLabel1(xIndexAccess
->getByIndex(1), uno::UNO_QUERY
);
2110 CPPUNIT_ASSERT_EQUAL(OUString("1"), xLabel1
->getString());
2111 uno::Reference
<text::XTextRange
> xLabel2(xIndexAccess
->getByIndex(2), uno::UNO_QUERY
);
2112 CPPUNIT_ASSERT_EQUAL(OUString("2"), xLabel2
->getString());
2113 uno::Reference
<text::XTextRange
> xLabel3(xIndexAccess
->getByIndex(3), uno::UNO_QUERY
);
2114 CPPUNIT_ASSERT_EQUAL(OUString("3"), xLabel3
->getString());
2115 uno::Reference
<text::XTextRange
> xLabel4(xIndexAccess
->getByIndex(4), uno::UNO_QUERY
);
2116 CPPUNIT_ASSERT_EQUAL(OUString("4"), xLabel4
->getString());
2117 uno::Reference
<text::XTextRange
> xLabel5(xIndexAccess
->getByIndex(5), uno::UNO_QUERY
);
2118 CPPUNIT_ASSERT_EQUAL(OUString("5"), xLabel5
->getString());
2121 void Chart2ImportTest::testTdf121205()
2123 loadFromURL(u
"pptx/tdf121205.pptx");
2124 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
2126 uno::Reference
<chart2::XTitled
> xTitled(xChartDoc
, uno::UNO_QUERY_THROW
);
2127 CPPUNIT_ASSERT_MESSAGE("chart doc does not have title", xTitled
.is());
2128 OUString aTitle
= getTitleString(xTitled
);
2130 // We expect title split in 3 lines
2131 CPPUNIT_ASSERT_EQUAL(OUString("Firstline\nSecondline\nThirdline"), aTitle
);
2134 void Chart2ImportTest::testFixedSizeBarChartVeryLongLabel()
2136 // Bar chart area size is fixed (not automatic) so we can't resize
2137 // the chart area to let the label break into multiple lines. In this
2138 // case the best course of action is to just crop the label text. This
2139 // test checks that the rendered text is actually cropped.
2141 loadFromURL(u
"odp/BarChartVeryLongLabel.odp");
2143 // Select shape 0 which has fixed size chart
2144 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY
);
2145 CPPUNIT_ASSERT(xChartDoc
.is());
2147 Reference
<chart2::XAxis
> xHAxis
= getAxisFromDoc(xChartDoc
, 0, 0, 0);
2148 CPPUNIT_ASSERT(xHAxis
.is());
2150 chart2::ScaleData aScaleData
= xHAxis
->getScaleData();
2151 CPPUNIT_ASSERT(aScaleData
.Categories
.is());
2153 Reference
<chart2::data::XLabeledDataSequence
> xLabeledDataSequence
= aScaleData
.Categories
;
2154 CPPUNIT_ASSERT(xLabeledDataSequence
.is());
2156 Reference
<chart2::data::XDataSequence
> xDataSequence
= xLabeledDataSequence
->getValues();
2157 CPPUNIT_ASSERT(xDataSequence
.is());
2159 Reference
<chart2::data::XTextualDataSequence
> xTextualDataSequence(xDataSequence
, uno::UNO_QUERY
);
2160 CPPUNIT_ASSERT(xTextualDataSequence
.is());
2162 std::vector
<OUString
> aCategories
;
2163 const Sequence
<OUString
> aTextData(xTextualDataSequence
->getTextualData());
2164 ::std::copy(aTextData
.begin(), aTextData
.end(),
2165 ::std::back_inserter(aCategories
));
2167 // Check that we have a very very long label text
2168 CPPUNIT_ASSERT_EQUAL(OUString("Very very very very very very very very very very very loooooooooooong label"), aCategories
[0]);
2170 // Check visible text
2171 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(xChartDoc
, uno::UNO_QUERY
);
2172 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
2173 uno::Reference
<drawing::XShapes
> xShapes(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
2174 CPPUNIT_ASSERT(xShapes
.is());
2176 uno::Reference
<drawing::XShape
> xXAxis
= getShapeByName(xShapes
, "CID/D=0:CS=0:Axis=0,0",
2177 // Axis occurs twice in chart xshape representation so need to get the one related to labels
2178 [](const uno::Reference
<drawing::XShape
>& rXShape
) -> bool
2180 uno::Reference
<drawing::XShapes
> xAxisShapes(rXShape
, uno::UNO_QUERY
);
2181 CPPUNIT_ASSERT(xAxisShapes
.is());
2182 uno::Reference
<drawing::XShape
> xChildShape(xAxisShapes
->getByIndex(0), uno::UNO_QUERY
);
2183 uno::Reference
< drawing::XShapeDescriptor
> xShapeDescriptor(xChildShape
, uno::UNO_QUERY_THROW
);
2184 return (xShapeDescriptor
->getShapeType() == "com.sun.star.drawing.TextShape");
2186 CPPUNIT_ASSERT(xXAxis
.is());
2188 uno::Reference
<container::XIndexAccess
> xIndexAccess(xXAxis
, UNO_QUERY_THROW
);
2190 // Check text is actually cropped. Depending on DPI,
2191 // it may be "Very very very very very very..." or "Very very very very very ver..."
2192 uno::Reference
<text::XTextRange
> xLabel(xIndexAccess
->getByIndex(0), uno::UNO_QUERY_THROW
);
2193 const OUString aLabelString
= xLabel
->getString();
2194 CPPUNIT_ASSERT_LESSEQUAL(sal_Int32(32), aLabelString
.getLength());
2195 CPPUNIT_ASSERT(aLabelString
.endsWith(u
"..."));
2197 uno::Reference
<drawing::XShape
> xChartWall
= getShapeByName(xShapes
, "CID/DiagramWall=");
2198 CPPUNIT_ASSERT(xChartWall
.is());
2200 // The text shape width should be smaller than the chart wall
2201 // The specific numbers unfortunately vary depending on DPI - allow 1 mm
2202 CPPUNIT_ASSERT_DOUBLES_EQUAL(5085, xChartWall
->getSize().Width
, 100);
2203 CPPUNIT_ASSERT_DOUBLES_EQUAL(7113, xChartWall
->getSize().Height
, 100);
2205 CPPUNIT_ASSERT_DOUBLES_EQUAL(4800, xXAxis
->getSize().Width
, 100);
2206 CPPUNIT_ASSERT_DOUBLES_EQUAL(398, xXAxis
->getSize().Height
, 100);
2209 void Chart2ImportTest::testAutomaticSizeBarChartVeryLongLabel()
2211 // Bar chart area size is automatic so we expect the label to be broken
2212 // into multiple lines.
2214 loadFromURL(u
"odp/BarChartVeryLongLabel.odp");
2216 // Select shape 1, which has an automatic sized chart
2217 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromDrawImpress(0, 1), uno::UNO_QUERY
);
2218 CPPUNIT_ASSERT(xChartDoc
.is());
2220 Reference
<chart2::XAxis
> xHAxis
= getAxisFromDoc(xChartDoc
, 0, 0, 0);
2221 CPPUNIT_ASSERT(xHAxis
.is());
2223 chart2::ScaleData aScaleData
= xHAxis
->getScaleData();
2224 CPPUNIT_ASSERT(aScaleData
.Categories
.is());
2226 Reference
<chart2::data::XLabeledDataSequence
> xLabeledDataSequence
= aScaleData
.Categories
;
2227 CPPUNIT_ASSERT(xLabeledDataSequence
.is());
2229 Reference
<chart2::data::XDataSequence
> xDataSequence
= xLabeledDataSequence
->getValues();
2230 CPPUNIT_ASSERT(xDataSequence
.is());
2232 Reference
<chart2::data::XTextualDataSequence
> xTextualDataSequence(xDataSequence
, uno::UNO_QUERY
);
2233 CPPUNIT_ASSERT(xTextualDataSequence
.is());
2235 std::vector
<OUString
> aCategories
;
2236 const Sequence
<OUString
> aTextData(xTextualDataSequence
->getTextualData());
2237 ::std::copy(aTextData
.begin(), aTextData
.end(),
2238 ::std::back_inserter(aCategories
));
2240 // Check that we have a very very long label text
2241 CPPUNIT_ASSERT_EQUAL(OUString("Very very very very very very very very very very very loooooooooooong label"), aCategories
[0]);
2243 // Check visible text
2244 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(xChartDoc
, uno::UNO_QUERY
);
2245 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
2246 uno::Reference
<drawing::XShapes
> xShapes(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
2247 CPPUNIT_ASSERT(xShapes
.is());
2249 uno::Reference
<drawing::XShape
> xXAxis
= getShapeByName(xShapes
, "CID/D=0:CS=0:Axis=0,0",
2250 // Axis occurs twice in chart xshape representation so need to get the one related to labels
2251 [](const uno::Reference
<drawing::XShape
>& rXShape
) -> bool
2253 uno::Reference
<drawing::XShapes
> xAxisShapes(rXShape
, uno::UNO_QUERY
);
2254 CPPUNIT_ASSERT(xAxisShapes
.is());
2255 uno::Reference
<drawing::XShape
> xChildShape(xAxisShapes
->getByIndex(0), uno::UNO_QUERY
);
2256 uno::Reference
< drawing::XShapeDescriptor
> xShapeDescriptor(xChildShape
, uno::UNO_QUERY_THROW
);
2257 return (xShapeDescriptor
->getShapeType() == "com.sun.star.drawing.TextShape");
2259 CPPUNIT_ASSERT(xXAxis
.is());
2261 uno::Reference
<container::XIndexAccess
> xIndexAccess(xXAxis
, UNO_QUERY_THROW
);
2263 // Check text is unmodified
2264 uno::Reference
<text::XTextRange
> xLabel(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
2265 CPPUNIT_ASSERT_EQUAL(OUString("Very very very very very very very very very very very loooooooooooong label"), xLabel
->getString());
2267 uno::Reference
<drawing::XShape
> xChartWall
= getShapeByName(xShapes
, "CID/DiagramWall=");
2268 CPPUNIT_ASSERT(xChartWall
.is());
2270 // The text shape width should be smaller than the chart wall
2271 // The specific numbers unfortunately vary depending on DPI - allow 1 mm
2272 CPPUNIT_ASSERT_DOUBLES_EQUAL(5761, xChartWall
->getSize().Width
, 100);
2273 CPPUNIT_ASSERT_DOUBLES_EQUAL(7200, xChartWall
->getSize().Height
, 100);
2275 CPPUNIT_ASSERT_DOUBLES_EQUAL(5320, xXAxis
->getSize().Width
, 100);
2276 CPPUNIT_ASSERT_DOUBLES_EQUAL(1192, xXAxis
->getSize().Height
, 100);
2279 void Chart2ImportTest::testTotalsRowIgnored()
2281 loadFromURL(u
"xlsx/barchart_totalsrow.xlsx");
2283 uno::Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
2284 CPPUNIT_ASSERT(xChartDoc
.is());
2286 Reference
<chart2::data::XDataSequence
> xDataSeq
=
2287 getDataSequenceFromDocByRole(xChartDoc
, u
"values-y");
2288 CPPUNIT_ASSERT(xDataSeq
.is());
2290 // Table data range is D2:D9 (8 rows) but because last row is totals row it is ignored
2291 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32
>(7u), xDataSeq
->getData().size());
2294 uno::Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(1, mxComponent
);
2295 CPPUNIT_ASSERT(xChartDoc
.is());
2297 Reference
<chart2::data::XDataSequence
> xDataSeq
=
2298 getDataSequenceFromDocByRole(xChartDoc
, u
"values-y");
2299 CPPUNIT_ASSERT(xDataSeq
.is());
2301 // Table data range is D2:D10 (9 rows) and totals row isn't the last row so it's not ignored
2302 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32
>(9u), xDataSeq
->getData().size());
2306 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest
);
2308 CPPUNIT_PLUGIN_IMPLEMENT();
2310 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */