Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / qa / extras / chart2import.cxx
blob7c24ff6110ba90b8cbdabd46b1add807f79d08dc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "charttest.hxx"
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>
32 #include <iterator>
34 #include <com/sun/star/util/Color.hpp>
35 #include <com/sun/star/awt/Gradient2.hpp>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <basegfx/utils/gradienttools.hxx>
38 #include <docmodel/uno/UnoGradientTools.hxx>
40 class Chart2ImportTest : public ChartTest
42 public:
43 Chart2ImportTest() : ChartTest("/chart2/qa/extras/data/") {}
45 protected:
46 void testTransparentBackground(std::u16string_view filename);
49 // error bar import
50 // split method up into smaller chunks for more detailed tests
51 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testFdo60083)
53 loadFromFile(u"ods/fdo60083.ods");
54 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
55 CPPUNIT_ASSERT(xChartDoc.is());
57 Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
58 CPPUNIT_ASSERT( xDataSeries.is() );
60 Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
62 // test that y error bars are there
63 Reference< beans::XPropertySet > xErrorBarYProps;
64 xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarYProps;
65 CPPUNIT_ASSERT(xErrorBarYProps.is());
67 sal_Int32 nErrorBarStyle;
68 CPPUNIT_ASSERT(
69 xErrorBarYProps->getPropertyValue("ErrorBarStyle")
70 >>= nErrorBarStyle);
71 CPPUNIT_ASSERT_EQUAL(
72 chart::ErrorBarStyle::RELATIVE,
73 nErrorBarStyle);
75 double nVal = 0.0;
76 CPPUNIT_ASSERT(
77 xErrorBarYProps->getPropertyValue("PositiveError") >>= nVal);
78 CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, nVal, 1e-8);
80 CPPUNIT_ASSERT(
81 xErrorBarYProps->getPropertyValue("NegativeError") >>= nVal);
82 CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, nVal, 1e-8);
84 bool bVal;
85 CPPUNIT_ASSERT(
86 xErrorBarYProps->getPropertyValue("ShowPositiveError") >>= bVal);
87 CPPUNIT_ASSERT_EQUAL(true, bVal);
89 CPPUNIT_ASSERT(
90 xErrorBarYProps->getPropertyValue("ShowNegativeError") >>= bVal);
91 CPPUNIT_ASSERT_EQUAL(true, bVal);
94 // test that x error bars are not imported
95 Reference< beans::XPropertySet > xErrorBarXProps;
96 xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_X) >>= xErrorBarXProps;
97 CPPUNIT_ASSERT(!xErrorBarXProps.is());
100 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testErrorBarRange)
102 loadFromFile(u"ods/error_bar_range.ods");
103 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
104 CPPUNIT_ASSERT(xChartDoc.is());
106 Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
107 CPPUNIT_ASSERT( xDataSeries.is() );
109 Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
111 // test that y error bars are there
112 Reference< beans::XPropertySet > xErrorBarYProps;
113 xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarYProps;
114 CPPUNIT_ASSERT(xErrorBarYProps.is());
116 sal_Int32 nErrorBarStyle;
117 CPPUNIT_ASSERT(
118 xErrorBarYProps->getPropertyValue("ErrorBarStyle")
119 >>= nErrorBarStyle);
120 CPPUNIT_ASSERT_EQUAL(
121 chart::ErrorBarStyle::FROM_DATA,
122 nErrorBarStyle);
124 OUString aRangePos;
125 CPPUNIT_ASSERT(xErrorBarYProps->getPropertyValue("ErrorBarRangePositive") >>= aRangePos);
126 CPPUNIT_ASSERT_EQUAL(OUString("$Sheet1.$C$2:$C$4"), aRangePos);
129 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testErrorBarFormatting)
131 loadFromFile(u"ods/error_bar_properties.ods");
132 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
133 CPPUNIT_ASSERT(xChartDoc.is());
135 Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
136 CPPUNIT_ASSERT( xDataSeries.is() );
138 Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
140 // test that y error bars are there
141 Reference< beans::XPropertySet > xErrorBarYProps;
142 xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarYProps;
143 CPPUNIT_ASSERT(xErrorBarYProps.is());
145 util::Color aColor(0);
146 xErrorBarYProps->getPropertyValue("LineColor") >>= aColor;
147 sal_uInt32 nColorValue = aColor;
148 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xff3333), nColorValue);
151 // stepped line interpolation
152 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testSteppedLines)
154 const sal_Int32 MAXSHEET = 14;
155 chart2::CurveStyle const curveStyle[] = {
156 chart2::CurveStyle_LINES,
157 chart2::CurveStyle_CUBIC_SPLINES,
158 chart2::CurveStyle_B_SPLINES,
159 chart2::CurveStyle_STEP_START,
160 chart2::CurveStyle_STEP_END,
161 chart2::CurveStyle_STEP_CENTER_X,
162 chart2::CurveStyle_STEP_CENTER_Y,
163 chart2::CurveStyle_LINES,
164 chart2::CurveStyle_CUBIC_SPLINES,
165 chart2::CurveStyle_B_SPLINES,
166 chart2::CurveStyle_STEP_START,
167 chart2::CurveStyle_STEP_END,
168 chart2::CurveStyle_STEP_CENTER_X,
169 chart2::CurveStyle_STEP_CENTER_Y
172 loadFromFile(u"ods/stepped_lines.ods");
173 for(sal_Int32 nSheet = 0; nSheet < MAXSHEET; ++nSheet)
175 uno::Reference< chart2::XChartDocument > xChart2Doc = getChartDocFromSheet( nSheet, mxComponent );
176 CPPUNIT_ASSERT(xChart2Doc.is());
178 Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChart2Doc, 0 );
179 CPPUNIT_ASSERT(xChartType.is());
181 Reference< beans::XPropertySet > xPropSet( xChartType, UNO_QUERY );
182 CPPUNIT_ASSERT(xPropSet.is());
184 chart2::CurveStyle eCurveStyle;
185 xPropSet->getPropertyValue("CurveStyle") >>= eCurveStyle;
186 CPPUNIT_ASSERT_EQUAL(eCurveStyle, curveStyle[nSheet]);
190 static uno::Sequence < OUString > getChartColumnDescriptions( uno::Reference< chart::XChartDocument > const & xChart1Doc)
192 CPPUNIT_ASSERT(xChart1Doc.is());
193 uno::Reference< chart::XChartDataArray > xChartData ( xChart1Doc->getData(), UNO_QUERY_THROW);
194 uno::Sequence < OUString > seriesList = xChartData->getColumnDescriptions();
195 return seriesList;
198 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testODSChartSeries)
200 loadFromFile(u"ods/chart.ods");
201 uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW);
202 uno::Sequence < OUString > seriesList = getChartColumnDescriptions( xChart1Doc);
203 CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList[0]);
204 CPPUNIT_ASSERT_EQUAL(OUString("Col2"), seriesList[1]);
205 CPPUNIT_ASSERT_EQUAL(OUString("Col 33"), seriesList[2]);
209 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testXLSXChartSeries)
211 loadFromFile(u"xlsx/chart.xlsx");
212 uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW);
213 uno::Sequence < OUString > seriesList = getChartColumnDescriptions(xChart1Doc );
214 CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList[0]);
215 CPPUNIT_ASSERT_EQUAL(OUString("Col2"), seriesList[1]);
216 CPPUNIT_ASSERT_EQUAL(OUString("Col 33"), seriesList[2]);
220 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testXLSChartSeries)
222 loadFromFile(u"xls/chart.xls");
223 uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW);
224 uno::Sequence < OUString > seriesList = getChartColumnDescriptions(xChart1Doc );
225 CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList[0]);
226 CPPUNIT_ASSERT_EQUAL(OUString("Col 2"), seriesList[1]);
227 CPPUNIT_ASSERT_EQUAL(OUString("Col 3"), seriesList[2]);
231 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testODTChartSeries)
233 loadFromFile(u"odt/chart.odt");
234 uno::Sequence< OUString > seriesList = getWriterChartColumnDescriptions(mxComponent);
235 CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
236 CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
237 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
241 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testDOCChartSeries)
243 loadFromFile(u"doc/chart.doc");
244 uno::Sequence< OUString > seriesList = getWriterChartColumnDescriptions(mxComponent);
245 CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
246 CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
247 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
250 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testDOCXChartSeries)
252 loadFromFile(u"docx/chart.docx");
253 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
254 CPPUNIT_ASSERT(xChartDoc.is());
256 Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
257 CPPUNIT_ASSERT(xCT.is());
259 std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
260 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
261 CPPUNIT_ASSERT_EQUAL(OUString("Series 1"), aLabels[0][0].get<OUString>());
262 CPPUNIT_ASSERT_EQUAL(OUString("Series 2"), aLabels[1][0].get<OUString>());
263 CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), aLabels[2][0].get<OUString>());
266 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testDOCXChartEmptySeries)
268 loadFromFile(u"docx/tdf125337.docx");
269 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
270 CPPUNIT_ASSERT(xChartDoc.is());
272 Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
273 CPPUNIT_ASSERT(xCT.is());
275 std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
276 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
277 CPPUNIT_ASSERT_EQUAL(OUString("1. dataseries"), aLabels[0][0].get<OUString>());
278 CPPUNIT_ASSERT_EQUAL(OUString("2. dataseries"), aLabels[1][0].get<OUString>());
279 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), aLabels[2][0].get<OUString>());
281 //test chart series sparse data for docx
282 std::vector<std::vector<double> > aValues = getDataSeriesYValuesFromChartType(xCT);
283 CPPUNIT_ASSERT_EQUAL(size_t(3), aValues.size());
284 //test the second series values
285 CPPUNIT_ASSERT_EQUAL(2.4, aValues[1][0]);
286 CPPUNIT_ASSERT_EQUAL(4.4, aValues[1][1]);
287 //test the third series (empty) values
288 CPPUNIT_ASSERT(std::isnan(aValues[2][0]));
289 CPPUNIT_ASSERT(std::isnan(aValues[2][1]));
292 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf81396)
294 loadFromFile(u"xlsx/tdf81396.xlsx");
295 Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent),
296 UNO_QUERY_THROW);
298 Reference<chart2::XChartDocument> xChartDoc2(xChartDoc, UNO_QUERY_THROW);
299 Reference<chart2::XChartType> xChartType(getChartTypeFromDoc(xChartDoc2, 0), UNO_SET_THROW);
300 std::vector aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType);
301 CPPUNIT_ASSERT_EQUAL(size_t(1), aDataSeriesYValues.size());
303 // Without the fix in place, this test would have failed with
304 // - Expected: 105.210801910481
305 // - Actual : nan
306 CPPUNIT_ASSERT_EQUAL(105.210801910481, aDataSeriesYValues[0][0]);
309 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPPTXChartErrorBars)
311 loadFromFile(u"pptx/tdf127720.pptx");
312 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
313 CPPUNIT_ASSERT(xChartDoc.is());
315 uno::Reference< chart::XChartDataArray > xDataArray(xChartDoc->getDataProvider(), UNO_QUERY_THROW);
316 Sequence<OUString> aColumnDesc = xDataArray->getColumnDescriptions();
317 // Number of columns = 4 (Y-values, X-values and positive/negative error bars).
318 // Without the fix there would only be 2 columns (no error range).
319 CPPUNIT_ASSERT_EQUAL_MESSAGE("There must be 4 columns and descriptions", static_cast<sal_Int32>(4), aColumnDesc.getLength());
322 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testDOCXChartValuesSize)
324 loadFromFile(u"docx/bubblechart.docx" );
325 Reference<chart2::XChartDocument> xChartDoc( getChartDocFromWriter(0), uno::UNO_QUERY );
326 CPPUNIT_ASSERT( xChartDoc.is() );
328 uno::Reference< chart::XChartDataArray > xDataArray( xChartDoc->getDataProvider(), UNO_QUERY_THROW );
329 Sequence<OUString> aColumnDesc = xDataArray->getColumnDescriptions();
330 // Number of columns = 3 (Y-values, X-values and bubble sizes).
331 // Without the fix there would only be 2 columns (no bubble sizes).
332 CPPUNIT_ASSERT_EQUAL_MESSAGE( "There must be 3 columns and descriptions", static_cast<sal_Int32>(3), aColumnDesc.getLength() );
333 Sequence<Sequence<double>> aData = xDataArray->getData();
334 CPPUNIT_ASSERT_EQUAL_MESSAGE( "There must be exactly 3 data points", static_cast<sal_Int32>(3), aData.getLength() );
336 std::vector<std::vector<double>> aExpected = { { 2.7, 0.7, 10.0 }, { 3.2, 1.8, 4.0 }, { 0.8, 2.6, 8.0 } };
338 for ( sal_Int32 nRowIdx = 0; nRowIdx < 3; ++nRowIdx )
339 for( sal_Int32 nColIdx = 0; nColIdx < 3; ++nColIdx )
340 CPPUNIT_ASSERT_DOUBLES_EQUAL( aExpected[nRowIdx][nColIdx], aData[nRowIdx][nColIdx], 1e-1 );
343 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPPTChartSeries)
345 //test chart series names for ppt
346 loadFromFile(u"ppt/chart.ppt");
347 uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions(0, 0);
349 CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
350 CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
351 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
355 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPPTXChartSeries)
357 //test chart series names for pptx
358 loadFromFile(u"pptx/chart.pptx");
359 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
360 CPPUNIT_ASSERT(xChartDoc.is());
362 Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
363 CPPUNIT_ASSERT(xCT.is());
365 std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
366 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
367 CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), aLabels[0][0].get<OUString>());
368 CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), aLabels[1][0].get<OUString>());
369 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), aLabels[2][0].get<OUString>());
372 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPPTXSparseChartSeries)
374 //test chart series sparse data for pptx
375 loadFromFile(u"pptx/sparse-chart.pptx");
376 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
377 CPPUNIT_ASSERT(xChartDoc.is());
379 Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
380 CPPUNIT_ASSERT(xCT.is());
382 std::vector<std::vector<double> > aValues = getDataSeriesYValuesFromChartType(xCT);
383 CPPUNIT_ASSERT_EQUAL(size_t(2), aValues.size());
384 CPPUNIT_ASSERT( std::isnan( aValues[0][0] ) );
385 CPPUNIT_ASSERT_EQUAL(2.5, aValues[0][1]);
386 CPPUNIT_ASSERT_EQUAL(3.5, aValues[0][2]);
387 CPPUNIT_ASSERT( std::isnan( aValues[0][3] ) );
388 CPPUNIT_ASSERT_EQUAL(-2.4, aValues[1][0]);
389 CPPUNIT_ASSERT( std::isnan( aValues[1][1] ) );
390 CPPUNIT_ASSERT( std::isnan( aValues[1][2] ) );
391 CPPUNIT_ASSERT_EQUAL(-2.8, aValues[1][3]);
394 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPPTXHiddenDataSeries)
397 * Original data contains 3 series but 2 of them are hidden. For now, we
398 * detect and skip those hidden series on import (since we don't support
399 * hidden columns for internal data table yet).
401 loadFromFile(u"pptx/stacked-bar-chart-hidden-series.pptx");
402 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
403 CPPUNIT_ASSERT(xChartDoc.is());
405 // "Automatic" chart background fill in pptx should be loaded as no fill.
406 Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
407 CPPUNIT_ASSERT(xPropSet.is());
408 drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
409 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in pptx should be loaded as no fill (transparent).",
410 drawing::FillStyle_NONE, eStyle);
412 Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
413 CPPUNIT_ASSERT(xCT.is());
415 // There should be only one data series present.
416 std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
417 CPPUNIT_ASSERT_EQUAL(size_t(1), aLabels.size());
418 CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), aLabels[0][0].get<OUString>());
420 // Test the internal data.
421 CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider());
423 Reference<chart2::XInternalDataProvider> xInternalProvider(xChartDoc->getDataProvider(), uno::UNO_QUERY);
424 CPPUNIT_ASSERT(xInternalProvider.is());
426 Reference<chart::XComplexDescriptionAccess> xDescAccess(xInternalProvider, uno::UNO_QUERY);
427 CPPUNIT_ASSERT(xDescAccess.is());
429 // Get the category labels.
430 Sequence<Sequence<OUString> > aCategories = xDescAccess->getComplexRowDescriptions();
431 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aCategories.getLength());
432 CPPUNIT_ASSERT_EQUAL(OUString("Category 1"), aCategories[0][0]);
433 CPPUNIT_ASSERT_EQUAL(OUString("Category 2"), aCategories[1][0]);
434 CPPUNIT_ASSERT_EQUAL(OUString("Category 3"), aCategories[2][0]);
435 CPPUNIT_ASSERT_EQUAL(OUString("Category 4"), aCategories[3][0]);
438 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPPTXPercentageNumberFormats)
440 loadFromFile(u"pptx/percentage-number-formats.pptx");
442 // 1st chart
443 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
444 CPPUNIT_ASSERT(xChartDoc.is());
446 uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
447 CPPUNIT_ASSERT(xDataSeries.is());
448 uno::Reference<beans::XPropertySet> xPropertySet;
449 chart2::DataPointLabel aLabel;
450 sal_Int32 nNumberFormat;
451 const sal_Int32 nPercentFormatSimple = getNumberFormat(xChartDoc, "0%");
452 const sal_Int32 nPercentFormatDecimal = getNumberFormat(xChartDoc, "0.00%");
454 xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
455 xPropertySet->getPropertyValue("Label") >>= aLabel;
456 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
457 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
458 xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
459 CPPUNIT_ASSERT_EQUAL(nPercentFormatSimple, nNumberFormat);
461 xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW);
462 xPropertySet->getPropertyValue("Label") >>= aLabel;
463 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
464 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
465 xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
466 CPPUNIT_ASSERT_EQUAL(nPercentFormatDecimal, nNumberFormat);
468 xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW);
469 xPropertySet->getPropertyValue("Label") >>= aLabel;
470 CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumber);
471 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
472 xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
473 CPPUNIT_ASSERT_EQUAL(nPercentFormatSimple, nNumberFormat);
475 xPropertySet.set(xDataSeries->getDataPointByIndex(3), uno::UNO_SET_THROW);
476 xPropertySet->getPropertyValue("Label") >>= aLabel;
477 CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumber);
478 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
479 xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
480 CPPUNIT_ASSERT_EQUAL(nPercentFormatDecimal, nNumberFormat);
482 // 2nd chart
483 xChartDoc.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY);
484 CPPUNIT_ASSERT(xChartDoc.is());
486 Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
487 CPPUNIT_ASSERT(xYAxis.is());
489 Reference<beans::XPropertySet> xPS(xYAxis, uno::UNO_QUERY_THROW);
490 bool bLinkNumberFormatToSource = true;
491 bool bSuccess = xPS->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
492 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", bSuccess);
493 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource);
495 // FIXME: This should be in fact "0.00%".
496 // see TODO in oox/source/drawingml/chart/modelbase.cxx
497 const sal_Int32 nPercentFormatDecimalShort = getNumberFormat(xChartDoc, "0.0%");
498 nNumberFormat = getNumberFormatFromAxis(xYAxis);
499 CPPUNIT_ASSERT_EQUAL(nPercentFormatDecimalShort, nNumberFormat);
500 sal_Int16 nType = getNumberFormatType(xChartDoc, nNumberFormat);
501 CPPUNIT_ASSERT_MESSAGE("Y axis should be a percent format.", (nType & util::NumberFormat::PERCENT));
504 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPieChartLabelsNumFormat)
506 loadFromFile(u"xlsx/tdfPieNumFormat.xlsx");
507 uno::Reference< chart::XChartDocument > xChartDoc(getChartCompFromSheet(0, 0, mxComponent), UNO_QUERY_THROW);
508 CPPUNIT_ASSERT(xChartDoc.is());
509 // test data point labels format
510 Reference<beans::XPropertySet> xDataPointPropSet(xChartDoc->getDiagram()->getDataPointProperties(0, 0), uno::UNO_SET_THROW);
511 chart2::DataPointLabel aLabel;
512 xDataPointPropSet->getPropertyValue("Label") >>= aLabel;
513 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
516 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPPTXStackedNonStackedYAxis)
518 loadFromFile(u"pptx/stacked-non-stacked-mix-y-axis.pptx");
520 // 1st chart is a normal stacked column.
521 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
522 CPPUNIT_ASSERT(xChartDoc.is());
524 Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
525 OUString aTitle = getTitleString(xTitled);
526 CPPUNIT_ASSERT_EQUAL(OUString("Stacked"), aTitle);
528 // Get the Y-axis.
529 Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
530 CPPUNIT_ASSERT(xYAxis.is());
532 sal_Int32 nNumberFormat = getNumberFormatFromAxis(xYAxis);
533 sal_Int16 nType = getNumberFormatType(xChartDoc, nNumberFormat);
534 CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType & util::NumberFormat::NUMBER));
535 CPPUNIT_ASSERT_MESSAGE("Y axis should NOT be a percent format.", !(nType & util::NumberFormat::PERCENT));
537 // 2nd chart is a percent-stacked column.
538 xChartDoc.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY);
539 CPPUNIT_ASSERT(xChartDoc.is());
541 xTitled.set(xChartDoc, uno::UNO_QUERY_THROW);
542 aTitle = getTitleString(xTitled);
543 CPPUNIT_ASSERT_EQUAL(OUString("100% Stacked"), aTitle);
545 // Get the Y-axis.
546 xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
547 CPPUNIT_ASSERT(xYAxis.is());
549 // Get the number format of the Y-axis.
550 nNumberFormat = getNumberFormatFromAxis(xYAxis);
551 nType = getNumberFormatType(xChartDoc, nNumberFormat);
552 CPPUNIT_ASSERT_MESSAGE("Y axis should be a percent format.", (nType & util::NumberFormat::PERCENT));
554 // 3rd chart is a mixture of normal-stacked column with a percent-stacked
555 // area chart series. Excel in this case sets the Y-axis to be
556 // non-percent axis and we should do the same for interoperability.
557 xChartDoc.set(getChartDocFromDrawImpress(2, 0), uno::UNO_QUERY);
558 CPPUNIT_ASSERT(xChartDoc.is());
560 xTitled.set(xChartDoc, uno::UNO_QUERY_THROW);
561 aTitle = getTitleString(xTitled);
562 CPPUNIT_ASSERT_EQUAL(OUString("Stacked column mixed with 100% stacked area"), aTitle);
564 // Get the Y-axis.
565 xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
566 CPPUNIT_ASSERT(xYAxis.is());
568 // Get the number format of the Y-axis.
569 nNumberFormat = getNumberFormatFromAxis(xYAxis);
570 nType = getNumberFormatType(xChartDoc, nNumberFormat);
571 CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType & util::NumberFormat::NUMBER));
572 CPPUNIT_ASSERT_MESSAGE("Y axis should NOT be a percent format.", !(nType & util::NumberFormat::PERCENT));
575 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testODPChartSeries)
577 //test chart series names for odp
578 loadFromFile(u"odp/chart.odp");
579 uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions(0, 0);
580 CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
581 CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
582 CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
586 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testBnc864396)
588 loadFromFile(u"pptx/bnc864396.pptx");
589 uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0,0), uno::UNO_QUERY_THROW);
590 CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider());
592 uno::Reference< chart2::XInternalDataProvider > xDataProvider( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
593 uno::Reference< chart::XChartDataArray > xChartDataArray(xDataProvider, uno::UNO_QUERY_THROW);
594 uno::Sequence< OUString > aRowLabels = xChartDataArray->getRowDescriptions();
595 for(sal_Int32 i = 0; i < aRowLabels.getLength(); ++i)
597 OUString aExpected = "cat" + OUString::number(i+1);
598 CPPUNIT_ASSERT_EQUAL(aExpected, aRowLabels[i]);
602 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testBnc889755)
604 loadFromFile(u"pptx/bnc889755.pptx");
605 uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 5), uno::UNO_QUERY_THROW);
606 CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider());
608 constexpr sal_Int32 nNumCategories = 16;
609 Sequence<OUString> aDateSeq = getFormattedDateCategories(xChartDoc);
611 CPPUNIT_ASSERT_EQUAL(nNumCategories, aDateSeq.getLength());
613 const OUString aExpectedDateCategories[nNumCategories] = {
614 "Oct-12", "Nov-12", "Dec-12", "Jan-13",
615 "Feb-13", "Mar-13", "Apr-13", "May-13",
616 "Jun-13", "Jul-13", "Aug-13", "Sep-13",
617 "Oct-13", "Nov-13", "Dec-13", "Jan-14",
620 for (size_t nIdx = 0; nIdx < nNumCategories; ++nIdx)
621 CPPUNIT_ASSERT_EQUAL(aExpectedDateCategories[nIdx], aDateSeq[nIdx]);
623 //tdf#139940 - the title's gradient was lost and was filled with solid blue, instead of a "blue underline".
624 uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW);
625 uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
627 // Shape "Title 3"
628 // MCGR: Use the whole completely imported transparency gradient to check for correctness
629 uno::Reference<beans::XPropertySet> xShapeProps(xPage->getByIndex(4), uno::UNO_QUERY_THROW);
630 awt::Gradient2 aTransparence;
631 xShapeProps->getPropertyValue("FillTransparenceGradient") >>= aTransparence;
632 const basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aTransparence.ColorStops);
634 CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
635 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
636 CPPUNIT_ASSERT_EQUAL(Color(0x404040), Color(aColorStops[0].getStopColor()));
637 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.070000000000000007));
638 CPPUNIT_ASSERT_EQUAL(Color(0x404040), Color(aColorStops[1].getStopColor()));
639 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 0.080000000000000002));
640 CPPUNIT_ASSERT_EQUAL(Color(0xffffff), Color(aColorStops[2].getStopColor()));
643 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testBnc882383)
645 loadFromFile(u"pptx/bnc882383.pptx");
646 uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY_THROW);
647 uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
648 CPPUNIT_ASSERT(xDataSeries.is());
650 uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
651 OUString sGradientName;
652 xPropertySet->getPropertyValue("GradientName") >>= sGradientName;
653 CPPUNIT_ASSERT(!sGradientName.isEmpty());
656 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTransparencyGradientValue)
658 loadFromFile(u"xlsx/tdf128732.xlsx");
659 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent);
660 CPPUNIT_ASSERT(xChartDoc.is());
661 uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
662 CPPUNIT_ASSERT(xDataSeries.is());
664 uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
665 OUString sTranspGradientName;
666 xPropertySet->getPropertyValue("FillTransparenceGradientName") >>= sTranspGradientName;
667 CPPUNIT_ASSERT(!sTranspGradientName.isEmpty());
669 awt::Gradient2 aTransparenceGradient;
670 uno::Reference< lang::XMultiServiceFactory > xFact(xChartDoc, uno::UNO_QUERY);
671 CPPUNIT_ASSERT(xFact.is());
672 uno::Reference< container::XNameAccess > xTransparenceGradient(xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY);
673 uno::Any rTransparenceValue = xTransparenceGradient->getByName(sTranspGradientName);
674 CPPUNIT_ASSERT(rTransparenceValue >>= aTransparenceGradient);
675 const basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aTransparenceGradient.ColorStops);
677 // MCGR: Use the whole completely imported transparency gradient to check for correctness
678 CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
679 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
680 CPPUNIT_ASSERT_EQUAL(Color(0x4d4d4d), Color(aColorStops[0].getStopColor()));
681 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
682 CPPUNIT_ASSERT_EQUAL(Color(0x333333), Color(aColorStops[1].getStopColor()));
685 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testSimpleStrictXLSX)
687 loadFromFile(u"xlsx/strict_chart.xlsx");
688 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
689 CPPUNIT_ASSERT(xChartDoc.is());
691 Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
692 CPPUNIT_ASSERT(xDataSeries.is());
696 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testDelayedCellImport)
698 // chart range referencing content on later sheets
699 loadFromFile(u"xlsx/fdo70609.xlsx");
700 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
701 Reference< chart2::data::XDataSequence > xDataSeq =
702 getDataSequenceFromDocByRole(xChartDoc, u"values-x");
704 OUString aRange = xDataSeq->getSourceRangeRepresentation();
705 CPPUNIT_ASSERT_EQUAL(OUString("$Sheet2.$C$5:$C$9"), aRange);
708 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testFlatODSStackedColumnChart)
710 loadFromFile(u"fods/stacked-column-chart.fods");
711 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
712 CPPUNIT_ASSERT(xChartDoc.is());
714 Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc, 0);
715 CPPUNIT_ASSERT(xChartType.is());
717 Reference<chart2::XDataSeriesContainer> xDSCont(xChartType, UNO_QUERY);
718 CPPUNIT_ASSERT(xDSCont.is());
719 Sequence<Reference<chart2::XDataSeries> > aSeriesSeq = xDSCont->getDataSeries();
721 // The stacked column chart should consist of 5 data series.
722 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aSeriesSeq.getLength());
725 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testFdo78080)
727 loadFromFile(u"xlsx/fdo78080.xlsx");
728 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
729 CPPUNIT_ASSERT(xChartDoc.is());
731 Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
732 Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
733 CPPUNIT_ASSERT(!xTitle.is());
736 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf127811)
738 loadFromFile(u"pptx/tdf127811.pptx");
739 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
740 CPPUNIT_ASSERT(xChartDoc.is());
742 Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
743 CPPUNIT_ASSERT(xCT.is());
745 std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
746 CPPUNIT_ASSERT_EQUAL(size_t(2), aLabels.size());
748 // Without the fix in place, this test would have failed with
749 // - Expected: 1. first
750 // - Actual : 2. second
751 CPPUNIT_ASSERT_EQUAL(OUString("1. first"), aLabels[0][0].get<OUString>());
752 CPPUNIT_ASSERT_EQUAL(OUString("2. second"), aLabels[1][0].get<OUString>());
755 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf86624)
757 // manually placed legends
758 loadFromFile(u"ods/tdf86624.ods");
759 uno::Reference< chart2::XChartDocument > xChart2Doc = getChartDocFromSheet(0, mxComponent);
760 uno::Reference< chart::XChartDocument > xChartDoc (xChart2Doc, uno::UNO_QUERY);
761 uno::Reference<drawing::XShape> xLegend = xChartDoc->getLegend();
762 awt::Point aPos = xLegend->getPosition();
763 CPPUNIT_ASSERT(aPos.X > 5000); // real value for me is above 8000 but before bug fix is below 1000
764 CPPUNIT_ASSERT(aPos.Y > 4000); // real value for ms is above 7000
767 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf105517)
769 loadFromFile(u"pptx/tdf105517.pptx");
770 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
771 CPPUNIT_ASSERT(xChartDoc.is());
773 Reference<chart2::XCoordinateSystemContainer> xCoordContainer(xChartDoc->getFirstDiagram(), uno::UNO_QUERY);
774 CPPUNIT_ASSERT(xCoordContainer.is());
775 Reference<chart2::XChartTypeContainer> xChartTypeContainer(xCoordContainer->getCoordinateSystems()[0], uno::UNO_QUERY);
776 CPPUNIT_ASSERT(xChartTypeContainer.is());
777 Reference<chart2::XDataSeriesContainer> xDSContainer(xChartTypeContainer->getChartTypes()[0], uno::UNO_QUERY);
778 CPPUNIT_ASSERT(xDSContainer.is());
779 Reference<beans::XPropertySet> xPropSet1(xDSContainer->getDataSeries()[0], uno::UNO_QUERY);
780 CPPUNIT_ASSERT(xPropSet1.is());
782 tools::Long lineColor;
783 xPropSet1->getPropertyValue("Color") >>= lineColor;
784 // incorrect line color was 0x4a7ebb due to not handling themeOverride
785 CPPUNIT_ASSERT_EQUAL(tools::Long(0xeaa700), lineColor);
787 Reference<beans::XPropertySet> xPropSet2(xDSContainer->getDataSeries()[1], uno::UNO_QUERY);
788 CPPUNIT_ASSERT(xPropSet2.is());
790 xPropSet2->getPropertyValue("Color") >>= lineColor;
791 // incorrect line color was 0x98b855
792 CPPUNIT_ASSERT_EQUAL(tools::Long(0x1e69a8), lineColor);
795 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf106217)
797 loadFromFile(u"pptx/tdf106217.pptx");
798 uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromDrawImpress(0, 0);
799 CPPUNIT_ASSERT(xChartDoc.is());
801 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY);
802 uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
803 uno::Reference<drawing::XShape> xCircle(xDrawPage->getByIndex(1), uno::UNO_QUERY);
804 CPPUNIT_ASSERT(xCircle.is());
806 uno::Reference<container::XNamed> xNamedShape(xCircle, uno::UNO_QUERY);
807 CPPUNIT_ASSERT_EQUAL(OUString("Oval 1"), xNamedShape->getName());
809 awt::Point aPosition = xCircle->getPosition();
810 CPPUNIT_ASSERT_EQUAL(sal_Int32(6870), aPosition.X);
811 CPPUNIT_ASSERT_EQUAL(sal_Int32(7261), aPosition.Y);
812 awt::Size aSize = xCircle->getSize();
813 CPPUNIT_ASSERT_EQUAL(sal_Int32(2701), aSize.Width);
814 CPPUNIT_ASSERT_EQUAL(sal_Int32(2700), aSize.Height);
817 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf108021)
819 // Tdf108021 : To check TextBreak value is true.
820 loadFromFile(u"ods/tdf108021.ods");
821 uno::Reference< chart::XDiagram > mxDiagram;
822 uno::Reference< beans::XPropertySet > xAxisProp;
823 bool bTextBreak = false;
824 uno::Reference< chart::XChartDocument > xChartDoc ( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW);
825 mxDiagram.set(xChartDoc->getDiagram());
826 CPPUNIT_ASSERT(mxDiagram.is());
827 uno::Reference< chart::XAxisXSupplier > xAxisXSupp( mxDiagram, uno::UNO_QUERY );
828 CPPUNIT_ASSERT(xAxisXSupp.is());
829 xAxisProp = xAxisXSupp->getXAxis();
830 xAxisProp->getPropertyValue("TextBreak") >>= bTextBreak;
831 // Expected value of 'TextBreak' is true
832 CPPUNIT_ASSERT(bTextBreak);
835 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf100084)
837 // The test file was created with IBM Cognos, make sure there is a diagram.
838 loadFromFile(u"xlsx/tdf100084.xlsx");
839 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
840 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
841 Reference<beans::XPropertySet> xDiagram(xChartDoc->getFirstDiagram(), UNO_QUERY);
842 CPPUNIT_ASSERT_MESSAGE("There should be a Diagram.", xDiagram.is());
845 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf124817)
847 loadFromFile(u"xlsx/tdf124817.xlsx");
848 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
849 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
851 uno::Reference<chart2::XDataSeries> xDataSeries;
852 chart2::Symbol aSymblProp;
854 // Check the symbol of data series 1 (marker style none)
855 xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
856 CPPUNIT_ASSERT(xDataSeries.is());
857 uno::Reference<beans::XPropertySet> xPropSet_0(xDataSeries, uno::UNO_QUERY_THROW);
858 CPPUNIT_ASSERT((xPropSet_0->getPropertyValue("Symbol") >>= aSymblProp));
859 CPPUNIT_ASSERT_EQUAL(chart2::SymbolStyle_NONE, aSymblProp.Style);
861 // Check the symbol of data series 2 (marker style square)
862 xDataSeries = getDataSeriesFromDoc(xChartDoc, 1);
863 CPPUNIT_ASSERT(xDataSeries.is());
864 uno::Reference<beans::XPropertySet> xPropSet_1(xDataSeries, uno::UNO_QUERY_THROW);
865 CPPUNIT_ASSERT((xPropSet_1->getPropertyValue("Symbol") >>= aSymblProp));
866 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xED7D31), aSymblProp.FillColor);
868 // Check the symbol of data series 3 (marker style diagonal cross)
869 xDataSeries = getDataSeriesFromDoc(xChartDoc, 2);
870 CPPUNIT_ASSERT(xDataSeries.is());
871 uno::Reference<beans::XPropertySet> xPropSet_2(xDataSeries, uno::UNO_QUERY_THROW);
872 CPPUNIT_ASSERT((xPropSet_2->getPropertyValue("Symbol") >>= aSymblProp));
873 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xFF0000), aSymblProp.BorderColor);
876 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf126033)
878 loadFromFile(u"xlsx/tdf126033.xlsx");
879 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
880 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
882 // Check symbol style and size of data points
883 chart2::Symbol aSymblProp;
884 uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
885 CPPUNIT_ASSERT(xDataSeries.is());
886 uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
887 CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Symbol") >>= aSymblProp);
888 CPPUNIT_ASSERT_EQUAL(chart2::SymbolStyle_NONE, aSymblProp.Style);
889 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(176), aSymblProp.Size.Width);
890 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(176), aSymblProp.Size.Height);
893 void Chart2ImportTest::testTransparentBackground(std::u16string_view filename)
895 loadFromFile(filename);
896 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent);
897 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
899 uno::Reference< chart::XChartDocument > xChart2Doc (xChartDoc, uno::UNO_QUERY);
900 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChart2Doc.is());
902 Reference< beans::XPropertySet > xPropSet = xChart2Doc->getArea();
903 CPPUNIT_ASSERT_MESSAGE("failed to get Area", xPropSet.is());
905 css::drawing::FillStyle aStyle;
906 xPropSet -> getPropertyValue("FillStyle") >>= aStyle;
908 CPPUNIT_ASSERT_EQUAL_MESSAGE("Background needs to be with solid fill style", css::drawing::FillStyle_SOLID, aStyle);
911 // 2 test methods here so that tearDown() can dispose the document
912 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testFdo54361)
914 testTransparentBackground(u"xlsx/fdo54361.xlsx");
916 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testFdo54361_1)
918 testTransparentBackground(u"xlsx/fdo54361-1.xlsx");
921 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testAutoBackgroundXLSX)
923 loadFromFile(u"xlsx/chart-auto-background.xlsx");
924 uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
925 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
927 // "Automatic" chart background fill in xlsx should be loaded as solid white.
928 Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
929 CPPUNIT_ASSERT(xPropSet.is());
930 drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
931 sal_Int32 nColor = xPropSet->getPropertyValue("FillColor").get<sal_Int32>();
932 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid fill.",
933 drawing::FillStyle_SOLID, eStyle);
934 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid white.",
935 sal_Int32(0x00FFFFFF), sal_Int32(nColor & 0x00FFFFFF)); // highest 2 bytes are transparency which we ignore here.
938 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testAutoChartAreaBorderPropXLSX)
940 loadFromFile(u"xlsx/chart-area-style-border.xlsx");
941 uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
942 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
944 // Test "Automatic" chartarea border style/color/width.
945 Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
946 CPPUNIT_ASSERT(xPropSet.is());
947 drawing::LineStyle eStyle = xPropSet->getPropertyValue("LineStyle").get<drawing::LineStyle>();
948 sal_Int32 nColor = xPropSet->getPropertyValue("LineColor").get<sal_Int32>();
949 sal_Int32 nWidth = xPropSet->getPropertyValue("LineWidth").get<sal_Int32>();
950 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border should be loaded as solid style.",
951 drawing::LineStyle_SOLID, eStyle);
952 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border color should be loaded as light gray.",
953 sal_Int32(0xD9D9D9), nColor);
954 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border width should be loaded as 0.75 pt (~0.026 cm)",
955 sal_Int32(26), nWidth);
958 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testAutoChartAreaBorderPropPPTX)
960 loadFromFile(u"pptx/tdf150176.pptx");
961 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
962 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
964 // Test "Automatic" chartarea border style/color/width.
965 Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
966 CPPUNIT_ASSERT(xPropSet.is());
967 drawing::LineStyle eStyle = xPropSet->getPropertyValue("LineStyle").get<drawing::LineStyle>();
968 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border should be loaded as none style for pptx.",
969 drawing::LineStyle_NONE, eStyle);
972 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testChartAreaStyleBackgroundXLSX)
974 loadFromFile(u"xlsx/chart-area-style-background.xlsx");
975 uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
976 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
978 // "Automatic" chart background fill in xlsx should be loaded as solid white.
979 Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
980 CPPUNIT_ASSERT(xPropSet.is());
981 drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
982 sal_Int32 nColor = xPropSet->getPropertyValue("FillColor").get<sal_Int32>();
983 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid fill.",
984 drawing::FillStyle_SOLID, eStyle);
985 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid white.",
986 sal_Int32(0), nColor);
989 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testChartHatchFillXLSX)
991 loadFromFile(u"xlsx/chart-hatch-fill.xlsx");
992 uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
993 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
995 // Check the chart background FillStyle is HATCH
996 Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
997 CPPUNIT_ASSERT(xPropSet.is());
998 drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
1000 CPPUNIT_ASSERT_EQUAL_MESSAGE("Chart background fill in this xlsx should be loaded as hatch fill.",
1001 drawing::FillStyle_HATCH, eStyle);
1003 // Check the FillBackground of chart background
1004 bool bBackgroundFill = false;
1005 xPropSet->getPropertyValue("FillBackground") >>= bBackgroundFill;
1006 CPPUNIT_ASSERT(bBackgroundFill);
1008 Color nBackgroundColor;
1009 xPropSet->getPropertyValue("FillColor") >>= nBackgroundColor;
1010 CPPUNIT_ASSERT_EQUAL(COL_WHITE, nBackgroundColor);
1012 // Check the datapoint has HatchName value
1013 uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
1014 CPPUNIT_ASSERT(xDataSeries.is());
1016 uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW);
1017 OUString sHatchName;
1018 xPropertySet->getPropertyValue("HatchName") >>= sHatchName;
1019 CPPUNIT_ASSERT(!sHatchName.isEmpty());
1021 // Check the FillBackground of datapoint
1022 bool bBackgroundFillofDatapoint = false;
1023 xPropertySet->getPropertyValue("FillBackground") >>= bBackgroundFillofDatapoint;
1024 CPPUNIT_ASSERT(bBackgroundFillofDatapoint);
1026 sal_Int32 nBackgroundColorofDatapoint;
1027 xPropertySet->getPropertyValue("FillColor") >>= nBackgroundColorofDatapoint;
1028 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x00B050), nBackgroundColorofDatapoint);
1031 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testAxisTextRotationXLSX)
1033 loadFromFile(u"xlsx/axis-label-rotation.xlsx");
1034 uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1035 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1037 Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
1038 CPPUNIT_ASSERT(xYAxis.is());
1040 Reference<beans::XPropertySet> xPS(xYAxis, uno::UNO_QUERY_THROW);
1041 double nRotation = 0;
1042 bool bSuccess = xPS->getPropertyValue("TextRotation") >>= nRotation;
1044 CPPUNIT_ASSERT(bSuccess);
1045 CPPUNIT_ASSERT_DOUBLES_EQUAL(90, nRotation, 1e-10);
1048 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTextCanOverlapXLSX)
1050 // fdo#84647 : To check textoverlap value is imported correctly.
1051 loadFromFile(u"xlsx/chart-text-can-overlap.xlsx");
1052 uno::Reference< chart::XDiagram > mxDiagram;
1053 uno::Reference< beans::XPropertySet > xAxisProp;
1054 bool bTextCanOverlap = false;
1055 uno::Reference< chart::XChartDocument > xChartDoc ( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW);
1056 mxDiagram.set(xChartDoc->getDiagram());
1057 CPPUNIT_ASSERT(mxDiagram.is());
1058 uno::Reference< chart::XAxisXSupplier > xAxisXSupp( mxDiagram, uno::UNO_QUERY );
1059 CPPUNIT_ASSERT(xAxisXSupp.is());
1060 xAxisProp = xAxisXSupp->getXAxis();
1061 xAxisProp->getPropertyValue("TextCanOverlap") >>= bTextCanOverlap;
1062 CPPUNIT_ASSERT(!bTextCanOverlap);
1065 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTextBreakXLSX)
1067 // tdf#122091: To check textbreak value is true in case of 0° degree of Axis label rotation.
1068 loadFromFile(u"xlsx/chart_label_text_break.xlsx");
1069 uno::Reference< chart::XDiagram > mxDiagram;
1070 uno::Reference< beans::XPropertySet > xAxisProp;
1071 bool textBreak = false;
1072 uno::Reference< chart::XChartDocument > xChartDoc ( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW);
1073 CPPUNIT_ASSERT(xChartDoc.is());
1074 mxDiagram.set(xChartDoc->getDiagram());
1075 CPPUNIT_ASSERT(mxDiagram.is());
1076 uno::Reference< chart::XAxisXSupplier > xAxisXSupp( mxDiagram, uno::UNO_QUERY );
1077 CPPUNIT_ASSERT(xAxisXSupp.is());
1078 xAxisProp = xAxisXSupp->getXAxis();
1079 xAxisProp->getPropertyValue("TextBreak") >>= textBreak;
1080 // Expected value of 'TextBreak' is true
1081 CPPUNIT_ASSERT(textBreak);
1084 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testNumberFormatsXLSX)
1086 loadFromFile(u"xlsx/number-formats.xlsx");
1087 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1088 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1090 uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
1091 CPPUNIT_ASSERT(xDataSeries.is());
1092 uno::Reference<beans::XPropertySet> xPropertySet;
1093 chart2::DataPointLabel aLabel;
1094 sal_Int32 nNumberFormat;
1095 bool bLinkNumberFormatToSource = false;
1096 const sal_Int32 nChartDataNumberFormat = getNumberFormat(
1097 xChartDoc, "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"??_);_(@_)");
1099 xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
1100 xPropertySet->getPropertyValue("Label") >>= aLabel;
1101 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
1102 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
1103 xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
1104 CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
1105 bool bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
1106 CPPUNIT_ASSERT_EQUAL(false, bSuccess);
1107 bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
1108 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess);
1109 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource);
1111 xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW);
1112 xPropertySet->getPropertyValue("Label") >>= aLabel;
1113 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
1114 CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumberInPercent);
1115 xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
1116 CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
1117 bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
1118 CPPUNIT_ASSERT_EQUAL(false, bSuccess);
1119 bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
1120 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess);
1121 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource);
1123 xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW);
1124 xPropertySet->getPropertyValue("Label") >>= aLabel;
1125 CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumber);
1126 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
1127 xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
1128 CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
1129 bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
1130 CPPUNIT_ASSERT_EQUAL(false, bSuccess);
1131 bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
1132 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess);
1133 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource);
1136 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testNumberFormatsDOCX)
1138 loadFromFile(u"docx/tdf132174.docx");
1140 uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
1141 CPPUNIT_ASSERT(xChartDoc.is());
1143 css::uno::Reference<chart2::XDiagram> xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW);
1144 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
1145 uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries, uno::UNO_QUERY_THROW);
1146 CPPUNIT_ASSERT(xPropertySet.is());
1148 sal_Int32 nNumberFormat;
1149 bool bLinkNumberFormatToSource = true;
1150 const sal_Int32 nChartDataNumberFormat = getNumberFormat(xChartDoc, "0%");
1151 xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
1152 CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
1153 xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
1154 // LinkNumberFormatToSource should be set to false even if the original OOXML contain a true value,
1155 // because the inner data table of charts have no own number format!
1156 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource);
1159 loadFromFile(u"docx/tdf136650.docx");
1161 uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
1162 CPPUNIT_ASSERT(xChartDoc.is());
1164 css::uno::Reference<chart2::XDiagram> xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW);
1165 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
1166 CPPUNIT_ASSERT(xDataSeries.is());
1167 Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW);
1169 sal_Int32 nNumberFormat;
1170 bool bLinkNumberFormatToSource = true;
1171 const sal_Int32 nChartDataNumberFormat = getNumberFormat(xChartDoc, "0%");
1172 xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
1173 CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
1174 xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
1175 // LinkNumberFormatToSource should be set to false even if the original OOXML file contain a true value,
1176 // because the inner data table of charts have no own number format!
1177 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource);
1181 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPercentageNumberFormatsDOCX)
1183 loadFromFile(u"docx/tdf133632.docx");
1184 uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
1185 CPPUNIT_ASSERT(xChartDoc.is());
1187 css::uno::Reference<chart2::XDiagram> xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW);
1188 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
1189 uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries, uno::UNO_QUERY_THROW);
1190 CPPUNIT_ASSERT(xPropertySet.is());
1192 bool bLinkNumberFormatToSource = false;
1193 chart2::DataPointLabel aLabel;
1194 xPropertySet->getPropertyValue("Label") >>= aLabel;
1195 CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumber);
1196 CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
1197 bool bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
1198 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess);
1199 CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource);
1202 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testAutoTitleDelDefaultValue2007XLSX)
1204 // below are OOXML default value tests for cases
1205 // where we fixed the handling of MSO 2007 vs OOXML
1206 loadFromFile(u"xlsx/autotitledel_2007.xlsx");
1207 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1208 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1210 Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
1211 OUString aTitle = getTitleString(xTitled);
1212 CPPUNIT_ASSERT_MESSAGE("autoTitleDel default value is false in MSO 2007 documents",
1213 !aTitle.isEmpty());
1216 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testAutoTitleDelDefaultValue2013XLSX)
1218 loadFromFile(u"xlsx/autotitledel_2013.xlsx");
1219 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1220 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1222 Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
1223 uno::Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
1224 CPPUNIT_ASSERT_MESSAGE("autoTitleDel default value is true in the OOXML spec",
1225 !xTitle.is());
1228 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testDispBlanksAsDefaultValue2007XLSX)
1230 loadFromFile(u"xlsx/dispBlanksAs_2007.xlsx");
1231 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1232 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1234 Reference<beans::XPropertySet> xDiagram(xChartDoc->getFirstDiagram(), UNO_QUERY);
1235 CPPUNIT_ASSERT(xDiagram.is());
1236 uno::Any aAny = xDiagram->getPropertyValue("MissingValueTreatment");
1237 sal_Int32 nMissingValueTreatment = -2;
1238 CPPUNIT_ASSERT(aAny >>= nMissingValueTreatment);
1239 CPPUNIT_ASSERT_EQUAL(chart::MissingValueTreatment::LEAVE_GAP, nMissingValueTreatment);
1242 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testDispBlanksAsDefaultValue2013XLSX)
1244 loadFromFile(u"xlsx/dispBlanksAs_2013.xlsx");
1245 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1246 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1248 Reference<beans::XPropertySet> xDiagram(xChartDoc->getFirstDiagram(), UNO_QUERY);
1249 CPPUNIT_ASSERT(xDiagram.is());
1250 uno::Any aAny = xDiagram->getPropertyValue("MissingValueTreatment");
1251 sal_Int32 nMissingValueTreatment = -2;
1252 CPPUNIT_ASSERT(aAny >>= nMissingValueTreatment);
1253 CPPUNIT_ASSERT_EQUAL(chart::MissingValueTreatment::USE_ZERO, nMissingValueTreatment);
1256 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testSmoothDefaultValue2007XLSX)
1258 loadFromFile(u"xlsx/smoothed_series2007.xlsx");
1259 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1260 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1261 CPPUNIT_ASSERT(xChartDoc.is());
1263 Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 );
1264 CPPUNIT_ASSERT(xChartType.is());
1266 Reference< beans::XPropertySet > xPropSet( xChartType, UNO_QUERY );
1267 CPPUNIT_ASSERT(xPropSet.is());
1269 chart2::CurveStyle eCurveStyle;
1270 xPropSet->getPropertyValue("CurveStyle") >>= eCurveStyle;
1271 CPPUNIT_ASSERT_EQUAL(chart2::CurveStyle_LINES, eCurveStyle);
1274 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testSmoothDefaultValue2013XLSX)
1276 loadFromFile(u"xlsx/smoothed_series.xlsx");
1277 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1278 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1279 CPPUNIT_ASSERT(xChartDoc.is());
1281 Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 );
1282 CPPUNIT_ASSERT(xChartType.is());
1284 Reference< beans::XPropertySet > xPropSet( xChartType, UNO_QUERY );
1285 CPPUNIT_ASSERT(xPropSet.is());
1287 chart2::CurveStyle eCurveStyle;
1288 xPropSet->getPropertyValue("CurveStyle") >>= eCurveStyle;
1289 CPPUNIT_ASSERT(eCurveStyle != chart2::CurveStyle_LINES);
1292 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTrendlineDefaultValue2007XLSX)
1294 loadFromFile(u"xlsx/trendline2007.xlsx");
1295 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1296 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1297 CPPUNIT_ASSERT(xChartDoc.is());
1298 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
1299 CPPUNIT_ASSERT(xDataSeries.is());
1300 Reference<chart2::XRegressionCurveContainer> xRegressionCurveContainer(xDataSeries, UNO_QUERY_THROW);
1301 Sequence< Reference<chart2::XRegressionCurve> > xRegressionCurveSequence = xRegressionCurveContainer->getRegressionCurves();
1302 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xRegressionCurveSequence.getLength());
1304 Reference<chart2::XRegressionCurve> xCurve = xRegressionCurveSequence[0];
1306 Reference<beans::XPropertySet> xPropSet(xCurve->getEquationProperties(), uno::UNO_SET_THROW);
1307 uno::Any aAny = xPropSet->getPropertyValue("ShowEquation");
1308 bool bShowEquation = true;
1309 CPPUNIT_ASSERT(aAny >>= bShowEquation);
1310 CPPUNIT_ASSERT(!bShowEquation);
1312 aAny = xPropSet->getPropertyValue("ShowCorrelationCoefficient");
1313 bool bShowCorrelation = true;
1314 CPPUNIT_ASSERT(aAny >>= bShowCorrelation);
1315 CPPUNIT_ASSERT(!bShowCorrelation);
1318 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTrendlineDefaultValue2013XLSX)
1320 loadFromFile(u"xlsx/trendline.xlsx");
1321 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1322 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1323 CPPUNIT_ASSERT(xChartDoc.is());
1324 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
1325 CPPUNIT_ASSERT(xDataSeries.is());
1326 Reference<chart2::XRegressionCurveContainer> xRegressionCurveContainer(xDataSeries, UNO_QUERY_THROW);
1327 Sequence< Reference<chart2::XRegressionCurve> > xRegressionCurveSequence = xRegressionCurveContainer->getRegressionCurves();
1328 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xRegressionCurveSequence.getLength());
1330 Reference<chart2::XRegressionCurve> xCurve = xRegressionCurveSequence[0];
1332 Reference<beans::XPropertySet> xPropSet(xCurve->getEquationProperties(), uno::UNO_SET_THROW);
1333 uno::Any aAny = xPropSet->getPropertyValue("ShowEquation");
1334 bool bShowEquation = false;
1335 CPPUNIT_ASSERT(aAny >>= bShowEquation);
1336 CPPUNIT_ASSERT(bShowEquation);
1338 aAny = xPropSet->getPropertyValue("ShowCorrelationCoefficient");
1339 bool bShowCorrelation = false;
1340 CPPUNIT_ASSERT(aAny >>= bShowCorrelation);
1341 CPPUNIT_ASSERT(bShowCorrelation);
1344 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testVaryColorDefaultValues2007XLSX)
1346 loadFromFile(u"xlsx/vary_color2007.xlsx");
1347 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1348 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1349 CPPUNIT_ASSERT(xChartDoc.is());
1350 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
1351 CPPUNIT_ASSERT(xDataSeries.is());
1352 Reference<beans::XPropertySet> xPropSet(xDataSeries, uno::UNO_QUERY_THROW);
1353 uno::Any aAny = xPropSet->getPropertyValue("VaryColorsByPoint");
1354 bool bVaryColor = true;
1355 CPPUNIT_ASSERT(aAny >>= bVaryColor);
1356 CPPUNIT_ASSERT(!bVaryColor);
1359 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testVaryColorDefaultValues2013XLSX)
1361 loadFromFile(u"xlsx/vary_color.xlsx");
1362 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1363 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1364 CPPUNIT_ASSERT(xChartDoc.is());
1365 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
1366 CPPUNIT_ASSERT(xDataSeries.is());
1367 Reference<beans::XPropertySet> xPropSet(xDataSeries, uno::UNO_QUERY_THROW);
1368 uno::Any aAny = xPropSet->getPropertyValue("VaryColorsByPoint");
1369 bool bVaryColor = false;
1370 CPPUNIT_ASSERT(aAny >>= bVaryColor);
1371 CPPUNIT_ASSERT(!bVaryColor);
1374 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPlotVisOnlyDefaultValue2013XLSX)
1376 loadFromFile(u"xlsx/plotVisOnly.xlsx");
1377 uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW);
1378 Reference<beans::XPropertySet> xPropSet(xChart1Doc->getDiagram(), uno::UNO_QUERY_THROW);
1379 uno::Any aAny = xPropSet->getPropertyValue("IncludeHiddenCells");
1380 CPPUNIT_ASSERT(aAny.hasValue());
1381 bool bShowHiddenValues = true;
1382 CPPUNIT_ASSERT(aAny >>= bShowHiddenValues);
1383 CPPUNIT_ASSERT(!bShowHiddenValues);
1386 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testRAngAxDefaultValue2013XLSX)
1388 loadFromFile(u"xlsx/rAngAx.xlsx");
1389 uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW);
1390 Reference<beans::XPropertySet> xPropSet(xChart1Doc->getDiagram(), uno::UNO_QUERY_THROW);
1391 uno::Any aAny = xPropSet->getPropertyValue("RightAngledAxes");
1392 CPPUNIT_ASSERT(aAny.hasValue());
1393 bool bRightAngleAxes = false;
1394 CPPUNIT_ASSERT(aAny >>= bRightAngleAxes);
1395 CPPUNIT_ASSERT(bRightAngleAxes);
1398 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testMajorTickMarksDefaultValue2013XLSX)
1400 loadFromFile(u"xlsx/majorTickMark.xlsx");
1401 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1402 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1403 Reference<chart2::XAxis> xXAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
1404 CPPUNIT_ASSERT(xXAxis.is());
1405 Reference<beans::XPropertySet> xPropSet(xXAxis, uno::UNO_QUERY_THROW);
1406 uno::Any aAny = xPropSet->getPropertyValue("MajorTickmarks");
1407 sal_Int32 nMajorTickmarks = chart2::TickmarkStyle::NONE;
1408 CPPUNIT_ASSERT(aAny.hasValue());
1409 CPPUNIT_ASSERT(aAny >>= nMajorTickmarks);
1410 CPPUNIT_ASSERT_EQUAL(chart2::TickmarkStyle::INNER | chart2::TickmarkStyle::OUTER, nMajorTickmarks);
1413 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testMinorTickMarksDefaultValue2013XLSX)
1415 loadFromFile(u"xlsx/minorTickMark.xlsx");
1416 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1417 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1418 Reference<chart2::XAxis> xXAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
1419 CPPUNIT_ASSERT(xXAxis.is());
1420 Reference<beans::XPropertySet> xPropSet(xXAxis, uno::UNO_QUERY_THROW);
1421 uno::Any aAny = xPropSet->getPropertyValue("MinorTickmarks");
1422 sal_Int32 nMajorTickmarks = chart2::TickmarkStyle::NONE;
1423 CPPUNIT_ASSERT(aAny.hasValue());
1424 CPPUNIT_ASSERT(aAny >>= nMajorTickmarks);
1425 CPPUNIT_ASSERT_EQUAL(chart2::TickmarkStyle::INNER | chart2::TickmarkStyle::OUTER, nMajorTickmarks);
1428 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testAxisTitleDefaultRotationXLSX)
1430 loadFromFile(u"xlsx/axis_title_default_rotation.xlsx");
1431 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1432 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1433 Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
1434 CPPUNIT_ASSERT(xYAxis.is());
1435 Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW);
1436 Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
1437 CPPUNIT_ASSERT(xTitle.is());
1438 Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW);
1439 uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
1440 double nRotation = 0;
1441 CPPUNIT_ASSERT(aAny >>= nRotation);
1442 CPPUNIT_ASSERT_EQUAL(90.0, nRotation);
1445 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testSecondaryAxisTitleDefaultRotationXLSX)
1447 loadFromFile(u"xlsx/secondary_axis_title_default_rotation.xlsx");
1448 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1449 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1450 Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 1);
1451 CPPUNIT_ASSERT(xYAxis.is());
1452 Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW);
1453 Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
1454 CPPUNIT_ASSERT(xTitle.is());
1455 Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW);
1456 uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
1457 double nRotation = 0;
1458 CPPUNIT_ASSERT(aAny >>= nRotation);
1459 CPPUNIT_ASSERT_EQUAL(90.0, nRotation);
1462 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testAxisTitleRotationXLSX)
1464 loadFromFile(u"xlsx/axis_title_rotated.xlsx");
1465 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1466 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1468 Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
1469 CPPUNIT_ASSERT(xYAxis.is());
1470 Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW);
1471 Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
1472 CPPUNIT_ASSERT(xTitle.is());
1473 Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW);
1474 uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
1475 double nRotation = 0;
1476 CPPUNIT_ASSERT(aAny >>= nRotation);
1477 CPPUNIT_ASSERT_EQUAL(340.0, nRotation);
1480 Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 1);
1481 CPPUNIT_ASSERT(xYAxis.is());
1482 Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW);
1483 Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
1484 CPPUNIT_ASSERT(xTitle.is());
1485 Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW);
1486 uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
1487 double nRotation = 0;
1488 CPPUNIT_ASSERT(aAny >>= nRotation);
1489 CPPUNIT_ASSERT_EQUAL(270.0, nRotation);
1494 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testAxisTitlePositionDOCX)
1496 loadFromFile(u"docx/testAxisTitlePosition.docx");
1497 uno::Reference< chart::XDiagram > mxDiagram;
1498 uno::Reference< drawing::XShape > xAxisTitle;
1499 uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromWriter(0);
1500 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1501 mxDiagram.set(xChartDoc->getDiagram());
1502 CPPUNIT_ASSERT(mxDiagram.is());
1503 // test X Axis title position
1504 uno::Reference< chart::XAxisXSupplier > xAxisXSupp(mxDiagram, uno::UNO_QUERY);
1505 CPPUNIT_ASSERT(xAxisXSupp.is());
1507 xAxisTitle = xAxisXSupp->getXAxisTitle();
1508 CPPUNIT_ASSERT(xAxisTitle.is());
1510 awt::Point aPos = xAxisTitle->getPosition();
1511 CPPUNIT_ASSERT_DOUBLES_EQUAL(10640, aPos.X, 2);
1512 CPPUNIT_ASSERT_DOUBLES_EQUAL(7157, aPos.Y, 2);
1514 // test Y Axis title position
1515 uno::Reference< chart::XAxisYSupplier > xAxisYSupp(mxDiagram, uno::UNO_QUERY);
1516 CPPUNIT_ASSERT(xAxisYSupp.is());
1518 xAxisTitle = xAxisYSupp->getYAxisTitle();
1519 CPPUNIT_ASSERT(xAxisTitle.is());
1521 aPos = xAxisTitle->getPosition();
1522 CPPUNIT_ASSERT_DOUBLES_EQUAL(387, aPos.X, 2);
1523 CPPUNIT_ASSERT_DOUBLES_EQUAL(6378, aPos.Y, 300);
1526 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testCombinedChartAttachedAxisXLSX)
1528 loadFromFile(u"xlsx/testCombinedChartAxis.xlsx");
1529 Reference< chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1530 // First series
1531 Reference<chart2::XDataSeries> xSeries = getDataSeriesFromDoc(xChartDoc, 0);
1532 CPPUNIT_ASSERT(xSeries.is());
1534 Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY_THROW);
1535 sal_Int32 nAxisIndex = -1;
1536 // First series (column chart) should be attached to secondary axis!
1537 uno::Any aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
1538 CPPUNIT_ASSERT(aAny >>= nAxisIndex);
1539 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nAxisIndex);
1541 // Second series
1542 xSeries = getDataSeriesFromDoc(xChartDoc, 0, 1);
1543 CPPUNIT_ASSERT(xSeries.is());
1545 xPropSet.set(xSeries, uno::UNO_QUERY_THROW);
1546 // Second series (line chart) should be attached to primary axis!
1547 aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
1548 CPPUNIT_ASSERT(aAny >>= nAxisIndex);
1549 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex);
1552 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf140489MultiSeriesChartAxisXLSX)
1554 loadFromFile(u"xlsx/tdf140489.xlsx");
1555 Reference< chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
1556 // First series
1557 Reference<chart2::XDataSeries> xSeries = getDataSeriesFromDoc(xChartDoc, 0);
1558 CPPUNIT_ASSERT(xSeries.is());
1560 Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY_THROW);
1561 sal_Int32 nAxisIndex = -1;
1562 uno::Any aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
1563 CPPUNIT_ASSERT(aAny >>= nAxisIndex);
1564 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex);
1566 // Second series
1567 xSeries = getDataSeriesFromDoc(xChartDoc, 0, 1);
1568 CPPUNIT_ASSERT(xSeries.is());
1570 xPropSet.set(xSeries, uno::UNO_QUERY_THROW);
1571 aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
1572 CPPUNIT_ASSERT(aAny >>= nAxisIndex);
1573 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex);
1575 // Third series
1576 xSeries = getDataSeriesFromDoc(xChartDoc, 0, 2);
1577 CPPUNIT_ASSERT(xSeries.is());
1579 xPropSet.set(xSeries, uno::UNO_QUERY_THROW);
1580 aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
1581 CPPUNIT_ASSERT(aAny >>= nAxisIndex);
1582 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nAxisIndex);
1585 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testInternalDataProvider)
1587 loadFromFile(u"odp/chart.odp");
1588 uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0,0), uno::UNO_QUERY_THROW);
1589 const uno::Reference< chart2::data::XDataProvider >& rxDataProvider = xChartDoc->getDataProvider();
1591 // Parse 42 array
1592 Reference<chart2::data::XDataSequence> xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;42;42;42}", "");
1593 Sequence<Any> xSequence = xDataSeq->getData();
1594 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
1595 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[1]);
1596 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[2]);
1597 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[3]);
1599 // Parse empty first and last
1600 xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{\"\";42;42;\"\"}", "");
1601 xSequence = xDataSeq->getData();
1602 CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence[0].getValue())));
1603 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[1]);
1604 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[2]);
1605 CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence[3].getValue())));
1607 // Parse empty middle
1608 xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"\";\"\";42}", "");
1609 xSequence = xDataSeq->getData();
1610 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
1611 CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence[1].getValue())) );
1612 CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence[2].getValue())) );
1613 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[3]);
1615 // Parse mixed types, numeric only role
1616 xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"hello\";0;\"world\"}", "");
1617 xSequence = xDataSeq->getData();
1618 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
1619 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[1]);
1620 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[2]);
1621 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[3]);
1623 // Parse mixed types, mixed role
1624 xDataSeq = rxDataProvider->createDataSequenceByValueArray("categories", "{42;\"hello\";0;\"world\"}", "");
1625 xSequence = xDataSeq->getData();
1626 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 1 42")), xSequence[0]);
1627 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 2 hello")), xSequence[1]);
1628 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 3 0")), xSequence[2]);
1629 CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 4 world")), xSequence[3]);
1632 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf90510)
1634 // Pie chart label placement settings(XLS)
1635 loadFromFile(u"xls/piechart_outside.xls");
1636 uno::Reference< chart::XChartDocument > xChart1Doc( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW );
1637 Reference<beans::XPropertySet> xPropSet( xChart1Doc->getDiagram()->getDataPointProperties( 0, 0 ), uno::UNO_SET_THROW );
1638 uno::Any aAny = xPropSet->getPropertyValue( "LabelPlacement" );
1639 CPPUNIT_ASSERT( aAny.hasValue() );
1640 sal_Int32 nLabelPlacement = 0;
1641 CPPUNIT_ASSERT( aAny >>= nLabelPlacement );
1642 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data labels should be placed outside", chart::DataLabelPlacement::OUTSIDE, nLabelPlacement );
1645 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf109858)
1647 // Pie chart label placement settings(XLSX)
1648 loadFromFile(u"xlsx/piechart_outside.xlsx");
1649 uno::Reference< chart::XChartDocument > xChart1Doc( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW );
1651 // test data point labels position
1652 Reference<beans::XPropertySet> xDataPointPropSet( xChart1Doc->getDiagram()->getDataPointProperties( 0, 0 ), uno::UNO_SET_THROW );
1653 uno::Any aAny = xDataPointPropSet->getPropertyValue( "LabelPlacement" );
1654 CPPUNIT_ASSERT( aAny.hasValue() );
1655 sal_Int32 nLabelPlacement = 0;
1656 CPPUNIT_ASSERT( aAny >>= nLabelPlacement );
1657 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data point label should be placed bestfit", chart::DataLabelPlacement::CUSTOM, nLabelPlacement );
1659 // test data series label position
1660 Reference<beans::XPropertySet> xSeriesPropSet(xChart1Doc->getDiagram()->getDataRowProperties(0), uno::UNO_SET_THROW);
1661 aAny = xSeriesPropSet->getPropertyValue( "LabelPlacement" );
1662 CPPUNIT_ASSERT( aAny >>= nLabelPlacement );
1663 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data series labels should be placed outside", chart::DataLabelPlacement::OUTSIDE, nLabelPlacement );
1666 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf130105)
1668 loadFromFile(u"xlsx/barchart_outend.xlsx");
1669 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent);
1670 CPPUNIT_ASSERT(xChartDoc.is());
1671 uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
1672 CPPUNIT_ASSERT(xDataSeries.is());
1674 uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
1675 uno::Any aAny = xPropertySet->getPropertyValue("LabelPlacement");
1676 CPPUNIT_ASSERT(aAny.hasValue());
1677 sal_Int32 nLabelPlacement = 0;
1678 CPPUNIT_ASSERT(aAny >>= nLabelPlacement);
1679 CPPUNIT_ASSERT_EQUAL_MESSAGE("Data label should be placed outend", chart::DataLabelPlacement::OUTSIDE, nLabelPlacement);
1682 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf111173)
1684 loadFromFile(u"xlsx/tdf111173.xlsx");
1685 uno::Reference< chart::XChartDocument > xChart1Doc( getChartCompFromSheet( 0, 0, mxComponent ), UNO_QUERY_THROW );
1688 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf122226)
1690 loadFromFile(u"docx/testTdf122226.docx" );
1691 uno::Reference< chart2::XChartDocument > xChartDoc ( getChartDocFromWriter(0), uno::UNO_QUERY);
1692 CPPUNIT_ASSERT( xChartDoc.is() );
1694 css::uno::Reference<chart2::XDiagram> xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW);
1695 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
1696 uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
1697 CPPUNIT_ASSERT(xPropertySet.is());
1699 uno::Any aAny = xPropertySet->getPropertyValue( "LabelSeparator" );
1700 CPPUNIT_ASSERT( aAny.hasValue() );
1701 OUString nLabelSeparator;
1702 CPPUNIT_ASSERT( aAny >>= nLabelSeparator );
1703 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data labels should be separated into new lines", OUString("\n"), nLabelSeparator );
1706 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf115107)
1708 // import complex data point labels
1709 loadFromFile(u"pptx/tdf115107.pptx");
1711 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
1712 CPPUNIT_ASSERT(xChartDoc.is());
1714 uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
1715 CPPUNIT_ASSERT(xDataSeries.is());
1716 float nFontSize;
1717 sal_Int64 nFontColor;
1718 sal_Int32 nCharUnderline;
1719 uno::Reference<beans::XPropertySet> xPropertySet;
1720 uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aFields;
1722 // 1
1723 xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
1724 xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
1725 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), aFields.getLength());
1727 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[0]->getFieldType());
1728 CPPUNIT_ASSERT_EQUAL(OUString("90.0 = "), aFields[0]->getString());
1729 aFields[0]->getPropertyValue("CharHeight") >>= nFontSize;
1730 aFields[0]->getPropertyValue("CharColor") >>= nFontColor;
1731 CPPUNIT_ASSERT_EQUAL(static_cast<float>(18), nFontSize);
1732 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xed7d31), nFontColor);
1734 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, aFields[1]->getFieldType());
1735 CPPUNIT_ASSERT_EQUAL(OUString("90"), aFields[1]->getString());
1737 // 2
1738 xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW);
1739 xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
1740 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(8), aFields.getLength());
1742 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[0]->getFieldType());
1743 CPPUNIT_ASSERT_EQUAL(OUString("Text"), aFields[0]->getString());
1745 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType());
1746 CPPUNIT_ASSERT_EQUAL(OUString(" : "), aFields[1]->getString());
1748 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CATEGORYNAME, aFields[2]->getFieldType());
1749 CPPUNIT_ASSERT_EQUAL(OUString("B"), aFields[2]->getString());
1750 aFields[2]->getPropertyValue("CharHeight") >>= nFontSize;
1751 aFields[2]->getPropertyValue("CharColor") >>= nFontColor;
1752 CPPUNIT_ASSERT_EQUAL(static_cast<float>(16), nFontSize);
1753 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xed7d31), nFontColor);
1755 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE, aFields[3]->getFieldType());
1757 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[4]->getFieldType());
1758 CPPUNIT_ASSERT_EQUAL(OUString("Multi"), aFields[4]->getString());
1760 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[5]->getFieldType());
1761 CPPUNIT_ASSERT_EQUAL(OUString("line"), aFields[5]->getString());
1762 aFields[5]->getPropertyValue("CharHeight") >>= nFontSize;
1763 aFields[5]->getPropertyValue("CharColor") >>= nFontColor;
1764 CPPUNIT_ASSERT_EQUAL(static_cast<float>(11.97), nFontSize);
1765 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xbf9000), nFontColor);
1767 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE, aFields[6]->getFieldType());
1769 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[7]->getFieldType());
1770 CPPUNIT_ASSERT_EQUAL(OUString("Abc"), aFields[7]->getString());
1771 aFields[7]->getPropertyValue("CharHeight") >>= nFontSize;
1772 aFields[7]->getPropertyValue("CharColor") >>= nFontColor;
1773 aFields[7]->getPropertyValue("CharUnderline") >>= nCharUnderline;
1774 CPPUNIT_ASSERT_EQUAL(static_cast<float>(12), nFontSize);
1775 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xa9d18e), nFontColor);
1776 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nCharUnderline);
1778 // 3
1779 xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW);
1780 xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
1781 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aFields.getLength());
1783 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, aFields[0]->getFieldType());
1784 CPPUNIT_ASSERT_EQUAL(OUString("DATA"), aFields[0]->getString());
1786 // 4
1787 xPropertySet.set(xDataSeries->getDataPointByIndex(3), uno::UNO_SET_THROW);
1788 xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
1789 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), aFields.getLength());
1791 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CELLREF, aFields[0]->getFieldType());
1792 //CPPUNIT_ASSERT_EQUAL(OUString("70"), aFields[0]->getString()); TODO: Not implemented yet
1794 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType());
1795 CPPUNIT_ASSERT_EQUAL(OUString(" <CELLREF"), aFields[1]->getString());
1798 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf115107_2)
1800 // import complex data point labels in cobo charts with multiple data series
1801 loadFromFile(u"pptx/tdf115107-2.pptx");
1803 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
1804 CPPUNIT_ASSERT(xChartDoc.is());
1806 uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
1807 CPPUNIT_ASSERT(xDataSeries.is());
1808 float nFontSize;
1809 sal_Int64 nFontColor;
1810 uno::Reference<beans::XPropertySet> xPropertySet;
1811 uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aFields;
1813 // First series
1814 xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
1815 xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
1816 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), aFields.getLength());
1818 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, aFields[0]->getFieldType());
1819 CPPUNIT_ASSERT_EQUAL(OUString("4.3"), aFields[0]->getString());
1820 aFields[0]->getPropertyValue("CharHeight") >>= nFontSize;
1821 aFields[0]->getPropertyValue("CharColor") >>= nFontColor;
1822 CPPUNIT_ASSERT_EQUAL(static_cast<float>(18), nFontSize);
1823 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xc00000), nFontColor);
1825 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType());
1826 CPPUNIT_ASSERT_EQUAL(OUString(" "), aFields[1]->getString());
1828 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, aFields[2]->getFieldType());
1829 CPPUNIT_ASSERT_EQUAL(OUString("Bars"), aFields[2]->getString());
1831 // Second series
1832 xDataSeries = getDataSeriesFromDoc(xChartDoc, 0, 1);
1833 CPPUNIT_ASSERT(xDataSeries.is());
1835 xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
1836 xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields;
1837 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), aFields.getLength());
1839 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, aFields[0]->getFieldType());
1840 CPPUNIT_ASSERT_EQUAL(OUString("2"), aFields[0]->getString());
1841 aFields[0]->getPropertyValue("CharHeight") >>= nFontSize;
1842 aFields[0]->getPropertyValue("CharColor") >>= nFontColor;
1843 CPPUNIT_ASSERT_EQUAL(static_cast<float>(18), nFontSize);
1844 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(0xffd966), nFontColor);
1846 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType());
1847 CPPUNIT_ASSERT_EQUAL(OUString(" "), aFields[1]->getString());
1849 CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, aFields[2]->getFieldType());
1850 CPPUNIT_ASSERT_EQUAL(OUString("Line"), aFields[2]->getString());
1854 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf116163)
1856 loadFromFile(u"pptx/tdf116163.pptx");
1858 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
1859 CPPUNIT_ASSERT(xChartDoc.is());
1861 Reference<chart2::XAxis> xHAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
1862 CPPUNIT_ASSERT(xHAxis.is());
1864 chart2::ScaleData aScaleData = xHAxis->getScaleData();
1865 CPPUNIT_ASSERT(aScaleData.Categories.is());
1867 Reference<chart2::data::XLabeledDataSequence> xLabeledDataSequence = aScaleData.Categories;
1868 CPPUNIT_ASSERT(xLabeledDataSequence.is());
1870 Reference<chart2::data::XDataSequence> xDataSequence = xLabeledDataSequence->getValues();
1871 CPPUNIT_ASSERT(xDataSequence.is());
1873 Reference<chart2::data::XTextualDataSequence> xTextualDataSequence(xDataSequence, uno::UNO_QUERY);
1874 CPPUNIT_ASSERT(xTextualDataSequence.is());
1876 std::vector<OUString> aCategories;
1877 const Sequence<OUString> aTextData(xTextualDataSequence->getTextualData());
1878 ::std::copy(aTextData.begin(), aTextData.end(),
1879 ::std::back_inserter(aCategories));
1881 CPPUNIT_ASSERT_EQUAL(OUString("Aaaa"), aCategories[0]);
1882 CPPUNIT_ASSERT_EQUAL(OUString("Bbbbbbb"), aCategories[1]);
1883 CPPUNIT_ASSERT_EQUAL(OUString("Ccc"), aCategories[2]);
1884 CPPUNIT_ASSERT_EQUAL(OUString("Ddddddddddddd"), aCategories[3]);
1886 // Check visible text
1888 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY);
1889 uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
1890 uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY);
1891 CPPUNIT_ASSERT(xShapes.is());
1893 uno::Reference<drawing::XShape> xXAxis = getShapeByName(xShapes, "CID/D=0:CS=0:Axis=0,0",
1894 // Axis occurs twice in chart xshape representation so need to get the one related to labels
1895 [](const uno::Reference<drawing::XShape>& rXShape) -> bool
1897 uno::Reference<drawing::XShapes> xAxisShapes(rXShape, uno::UNO_QUERY);
1898 CPPUNIT_ASSERT(xAxisShapes.is());
1899 uno::Reference<drawing::XShape> xChildShape(xAxisShapes->getByIndex(0), uno::UNO_QUERY);
1900 uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xChildShape, uno::UNO_QUERY_THROW);
1901 return (xShapeDescriptor->getShapeType() == "com.sun.star.drawing.TextShape");
1903 CPPUNIT_ASSERT(xXAxis.is());
1905 uno::Reference<container::XIndexAccess> xIndexAccess(xXAxis, UNO_QUERY_THROW);
1907 // Check text
1908 uno::Reference<text::XTextRange> xLabel0(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
1909 CPPUNIT_ASSERT_EQUAL(OUString("Aaaa"), xLabel0->getString());
1910 uno::Reference<text::XTextRange> xLabel1(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
1911 // If there is space for 3 chars only then don't show "..."
1912 CPPUNIT_ASSERT_EQUAL(OUString("Bbb"), xLabel1->getString());
1913 uno::Reference<text::XTextRange> xLabel2(xIndexAccess->getByIndex(2), uno::UNO_QUERY);
1914 CPPUNIT_ASSERT_EQUAL(OUString("Ccc"), xLabel2->getString());
1915 uno::Reference<text::XTextRange> xLabel3(xIndexAccess->getByIndex(3), uno::UNO_QUERY);
1916 CPPUNIT_ASSERT_EQUAL(OUString("Dddd..."), xLabel3->getString());
1919 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf48041)
1921 loadFromFile(u"pptx/tdf48041.pptx");
1923 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
1924 CPPUNIT_ASSERT(xChartDoc.is());
1926 Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
1927 CPPUNIT_ASSERT(xYAxis.is());
1929 chart2::ScaleData aScaleData = xYAxis->getScaleData();
1930 CPPUNIT_ASSERT(aScaleData.Scaling.is());
1932 // Check visible text
1933 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY);
1934 uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
1935 uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY);
1936 CPPUNIT_ASSERT(xShapes.is());
1938 uno::Reference<drawing::XShape> xYAxisShape = getShapeByName(xShapes, "CID/D=0:CS=0:Axis=1,0", // Y Axis
1939 // Axis occurs twice in chart xshape representation so need to get the one related to labels
1940 [](const uno::Reference<drawing::XShape>& rXShape) -> bool
1942 uno::Reference<drawing::XShapes> xAxisShapes(rXShape, uno::UNO_QUERY);
1943 CPPUNIT_ASSERT(xAxisShapes.is());
1944 uno::Reference<drawing::XShape> xChildShape(xAxisShapes->getByIndex(0), uno::UNO_QUERY);
1945 uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xChildShape, uno::UNO_QUERY_THROW);
1946 return (xShapeDescriptor->getShapeType() == "com.sun.star.drawing.TextShape");
1948 CPPUNIT_ASSERT(xYAxisShape.is());
1950 // Check label count
1951 uno::Reference<container::XIndexAccess> xIndexAccess(xYAxisShape, UNO_QUERY_THROW);
1952 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6), xIndexAccess->getCount());
1954 // Check text
1955 uno::Reference<text::XTextRange> xLabel0(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
1956 CPPUNIT_ASSERT_EQUAL(OUString("0"), xLabel0->getString());
1957 uno::Reference<text::XTextRange> xLabel1(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
1958 CPPUNIT_ASSERT_EQUAL(OUString("1"), xLabel1->getString());
1959 uno::Reference<text::XTextRange> xLabel2(xIndexAccess->getByIndex(2), uno::UNO_QUERY);
1960 CPPUNIT_ASSERT_EQUAL(OUString("2"), xLabel2->getString());
1961 uno::Reference<text::XTextRange> xLabel3(xIndexAccess->getByIndex(3), uno::UNO_QUERY);
1962 CPPUNIT_ASSERT_EQUAL(OUString("3"), xLabel3->getString());
1963 uno::Reference<text::XTextRange> xLabel4(xIndexAccess->getByIndex(4), uno::UNO_QUERY);
1964 CPPUNIT_ASSERT_EQUAL(OUString("4"), xLabel4->getString());
1965 uno::Reference<text::XTextRange> xLabel5(xIndexAccess->getByIndex(5), uno::UNO_QUERY);
1966 CPPUNIT_ASSERT_EQUAL(OUString("5"), xLabel5->getString());
1969 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf121205)
1971 loadFromFile(u"pptx/tdf121205.pptx");
1972 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
1974 uno::Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
1975 CPPUNIT_ASSERT_MESSAGE("chart doc does not have title", xTitled.is());
1976 OUString aTitle = getTitleString(xTitled);
1978 // We expect title split in 3 lines
1979 CPPUNIT_ASSERT_EQUAL(OUString("Firstline\nSecondline\nThirdline"), aTitle);
1982 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf146487)
1984 loadFromFile(u"pptx/tdf146487.pptx");
1985 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
1986 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
1988 Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
1989 uno::Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
1990 CPPUNIT_ASSERT_MESSAGE("chart doc should not have a title", !xTitle.is());
1993 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testFixedSizeBarChartVeryLongLabel)
1995 // Bar chart area size is fixed (not automatic) so we can't resize
1996 // the chart area to let the label break into multiple lines. In this
1997 // case the best course of action is to just crop the label text. This
1998 // test checks that the rendered text is actually cropped.
2000 loadFromFile(u"odp/BarChartVeryLongLabel.odp");
2002 // Select shape 0 which has fixed size chart
2003 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
2004 CPPUNIT_ASSERT(xChartDoc.is());
2006 Reference<chart2::XAxis> xHAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
2007 CPPUNIT_ASSERT(xHAxis.is());
2009 chart2::ScaleData aScaleData = xHAxis->getScaleData();
2010 CPPUNIT_ASSERT(aScaleData.Categories.is());
2012 Reference<chart2::data::XLabeledDataSequence> xLabeledDataSequence = aScaleData.Categories;
2013 CPPUNIT_ASSERT(xLabeledDataSequence.is());
2015 Reference<chart2::data::XDataSequence> xDataSequence = xLabeledDataSequence->getValues();
2016 CPPUNIT_ASSERT(xDataSequence.is());
2018 Reference<chart2::data::XTextualDataSequence> xTextualDataSequence(xDataSequence, uno::UNO_QUERY);
2019 CPPUNIT_ASSERT(xTextualDataSequence.is());
2021 std::vector<OUString> aCategories;
2022 const Sequence<OUString> aTextData(xTextualDataSequence->getTextualData());
2023 ::std::copy(aTextData.begin(), aTextData.end(),
2024 ::std::back_inserter(aCategories));
2026 // Check that we have a very very long label text
2027 CPPUNIT_ASSERT_EQUAL(OUString("Very very very very very very very very very very very loooooooooooong label"), aCategories[0]);
2029 // Check visible text
2030 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY);
2031 uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
2032 uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY);
2033 CPPUNIT_ASSERT(xShapes.is());
2035 uno::Reference<drawing::XShape> xXAxis = getShapeByName(xShapes, "CID/D=0:CS=0:Axis=0,0",
2036 // Axis occurs twice in chart xshape representation so need to get the one related to labels
2037 [](const uno::Reference<drawing::XShape>& rXShape) -> bool
2039 uno::Reference<drawing::XShapes> xAxisShapes(rXShape, uno::UNO_QUERY);
2040 CPPUNIT_ASSERT(xAxisShapes.is());
2041 uno::Reference<drawing::XShape> xChildShape(xAxisShapes->getByIndex(0), uno::UNO_QUERY);
2042 uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xChildShape, uno::UNO_QUERY_THROW);
2043 return (xShapeDescriptor->getShapeType() == "com.sun.star.drawing.TextShape");
2045 CPPUNIT_ASSERT(xXAxis.is());
2047 uno::Reference<container::XIndexAccess> xIndexAccess(xXAxis, UNO_QUERY_THROW);
2049 // Check text is actually cropped. Depending on DPI,
2050 // it may be "Very very very very very very..." or "Very very very very very ver..."
2051 uno::Reference<text::XTextRange> xLabel(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
2052 const OUString aLabelString = xLabel->getString();
2053 CPPUNIT_ASSERT_LESSEQUAL(sal_Int32(32), aLabelString.getLength());
2054 CPPUNIT_ASSERT(aLabelString.endsWith(u"..."));
2056 uno::Reference<drawing::XShape> xChartWall = getShapeByName(xShapes, "CID/DiagramWall=");
2057 CPPUNIT_ASSERT(xChartWall.is());
2059 // The text shape width should be smaller than the chart wall
2060 CPPUNIT_ASSERT_LESS(xChartWall->getSize().Width, xXAxis->getSize().Width);
2062 CPPUNIT_ASSERT_DOUBLES_EQUAL(7113, xChartWall->getSize().Height, 100);
2063 CPPUNIT_ASSERT_DOUBLES_EQUAL(398, xXAxis->getSize().Height, 100);
2066 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testAutomaticSizeBarChartVeryLongLabel)
2068 // Bar chart area size is automatic so we expect the label to be broken
2069 // into multiple lines.
2071 loadFromFile(u"odp/BarChartVeryLongLabel.odp");
2073 // Select shape 1, which has an automatic sized chart
2074 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 1), uno::UNO_QUERY);
2075 CPPUNIT_ASSERT(xChartDoc.is());
2077 Reference<chart2::XAxis> xHAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
2078 CPPUNIT_ASSERT(xHAxis.is());
2080 chart2::ScaleData aScaleData = xHAxis->getScaleData();
2081 CPPUNIT_ASSERT(aScaleData.Categories.is());
2083 Reference<chart2::data::XLabeledDataSequence> xLabeledDataSequence = aScaleData.Categories;
2084 CPPUNIT_ASSERT(xLabeledDataSequence.is());
2086 Reference<chart2::data::XDataSequence> xDataSequence = xLabeledDataSequence->getValues();
2087 CPPUNIT_ASSERT(xDataSequence.is());
2089 Reference<chart2::data::XTextualDataSequence> xTextualDataSequence(xDataSequence, uno::UNO_QUERY);
2090 CPPUNIT_ASSERT(xTextualDataSequence.is());
2092 std::vector<OUString> aCategories;
2093 const Sequence<OUString> aTextData(xTextualDataSequence->getTextualData());
2094 ::std::copy(aTextData.begin(), aTextData.end(),
2095 ::std::back_inserter(aCategories));
2097 // Check that we have a very very long label text
2098 CPPUNIT_ASSERT_EQUAL(OUString("Very very very very very very very very very very very loooooooooooong label"), aCategories[0]);
2100 // Check visible text
2101 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY);
2102 uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
2103 uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY);
2104 CPPUNIT_ASSERT(xShapes.is());
2106 uno::Reference<drawing::XShape> xXAxis = getShapeByName(xShapes, "CID/D=0:CS=0:Axis=0,0",
2107 // Axis occurs twice in chart xshape representation so need to get the one related to labels
2108 [](const uno::Reference<drawing::XShape>& rXShape) -> bool
2110 uno::Reference<drawing::XShapes> xAxisShapes(rXShape, uno::UNO_QUERY);
2111 CPPUNIT_ASSERT(xAxisShapes.is());
2112 uno::Reference<drawing::XShape> xChildShape(xAxisShapes->getByIndex(0), uno::UNO_QUERY);
2113 uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xChildShape, uno::UNO_QUERY_THROW);
2114 return (xShapeDescriptor->getShapeType() == "com.sun.star.drawing.TextShape");
2116 CPPUNIT_ASSERT(xXAxis.is());
2118 uno::Reference<container::XIndexAccess> xIndexAccess(xXAxis, UNO_QUERY_THROW);
2120 // Check text is unmodified
2121 uno::Reference<text::XTextRange> xLabel(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
2122 CPPUNIT_ASSERT_EQUAL(OUString("Very very very very very very very very very very very loooooooooooong label"), xLabel->getString());
2124 uno::Reference<drawing::XShape> xChartWall = getShapeByName(xShapes, "CID/DiagramWall=");
2125 CPPUNIT_ASSERT(xChartWall.is());
2127 // The text shape width should be smaller than the chart wall
2128 CPPUNIT_ASSERT_LESS(xChartWall->getSize().Width, xXAxis->getSize().Width);
2130 CPPUNIT_ASSERT_DOUBLES_EQUAL(7200, xChartWall->getSize().Height, 100);
2131 CPPUNIT_ASSERT_DOUBLES_EQUAL(1192, xXAxis->getSize().Height, 100);
2134 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTotalsRowIgnored)
2136 loadFromFile(u"xlsx/barchart_totalsrow.xlsx");
2138 uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
2139 CPPUNIT_ASSERT(xChartDoc.is());
2141 Reference<chart2::data::XDataSequence> xDataSeq =
2142 getDataSequenceFromDocByRole(xChartDoc, u"values-y");
2143 CPPUNIT_ASSERT(xDataSeq.is());
2145 // Table data range is D2:D9 (8 rows) but because last row is totals row it is ignored
2146 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(7u), xDataSeq->getData().size());
2149 uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(1, mxComponent);
2150 CPPUNIT_ASSERT(xChartDoc.is());
2152 Reference<chart2::data::XDataSequence> xDataSeq =
2153 getDataSequenceFromDocByRole(xChartDoc, u"values-y");
2154 CPPUNIT_ASSERT(xDataSeq.is());
2156 // Table data range is D2:D10 (9 rows) and totals row isn't the last row so it's not ignored
2157 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(9u), xDataSeq->getData().size());
2161 CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPieChartPlotAreaMarginWithAutomaticLayout)
2163 // tdf#91265
2164 // Checks the margin and calculation of the plot area for the pie chart inside the chart area.
2166 loadFromFile(u"pptx/PieChartWithAutomaticLayout_SizeAndPosition.pptx");
2168 OUString aCheckShapeName = "CID/D=0:CS=0:CT=0:Series=0";
2169 // Chart Wuse case Width == Height
2171 // Load chart Chart_2_2 - 2cm x 2cm -
2172 auto xDocument = getChartDocFromDrawImpressNamed(0, u"Chart_2_2");
2173 CPPUNIT_ASSERT(xDocument.is());
2175 uno::Reference<chart2::XChartDocument>xChartDocument(xDocument, uno::UNO_QUERY);
2176 CPPUNIT_ASSERT(xChartDocument.is());
2178 // Get the shape of the diagram / chart
2179 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDocument, uno::UNO_QUERY);
2180 CPPUNIT_ASSERT(xDrawPageSupplier.is());
2181 uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
2182 uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY);
2183 CPPUNIT_ASSERT(xShapes.is());
2185 uno::Reference<drawing::XShape> xChartDiagramShape = getShapeByName(xShapes, aCheckShapeName);
2186 CPPUNIT_ASSERT(xChartDiagramShape.is());
2188 // Size
2189 CPPUNIT_ASSERT_DOUBLES_EQUAL(1300, xChartDiagramShape->getSize().Width, 5); // calculated chart area size - 2 * margin
2190 CPPUNIT_ASSERT_DOUBLES_EQUAL(1300, xChartDiagramShape->getSize().Height, 5); // calculated chart area size - 2 * margin
2191 // Position
2192 CPPUNIT_ASSERT_DOUBLES_EQUAL(350, xChartDiagramShape->getPosition().X, 5); // margin
2193 CPPUNIT_ASSERT_DOUBLES_EQUAL(350, xChartDiagramShape->getPosition().Y, 5); // margin
2196 // Chart use case - Width < Height
2198 // Load chart Chart_3_4 - 3cm x 4cm
2199 auto xDocument = getChartDocFromDrawImpressNamed(0, u"Chart_3_4");
2200 CPPUNIT_ASSERT(xDocument.is());
2202 uno::Reference<chart2::XChartDocument>xChartDocument(xDocument, uno::UNO_QUERY);
2203 CPPUNIT_ASSERT(xChartDocument.is());
2205 // Get the shape of the diagram / chart
2206 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDocument, uno::UNO_QUERY);
2207 CPPUNIT_ASSERT(xDrawPageSupplier.is());
2208 uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
2209 uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY);
2210 CPPUNIT_ASSERT(xShapes.is());
2212 uno::Reference<drawing::XShape> xChartDiagramShape = getShapeByName(xShapes, aCheckShapeName);
2213 CPPUNIT_ASSERT(xChartDiagramShape.is());
2215 // Size
2216 CPPUNIT_ASSERT_DOUBLES_EQUAL(2300, xChartDiagramShape->getSize().Width, 5); // calculated chart area size - 2 * margin
2217 CPPUNIT_ASSERT_DOUBLES_EQUAL(2300, xChartDiagramShape->getSize().Height, 5); // calculated chart area size - 2 * margin
2218 // Position
2219 CPPUNIT_ASSERT_DOUBLES_EQUAL(350, xChartDiagramShape->getPosition().X, 5); // margin
2220 CPPUNIT_ASSERT_DOUBLES_EQUAL(850, xChartDiagramShape->getPosition().Y, 5); // margin + calculated centering
2223 // Chart use case - Width > Height
2225 // Load chart Chart_3_2 - 3cm x 2cm
2226 auto xDocument = getChartDocFromDrawImpressNamed(0, u"Chart_3_2");
2227 CPPUNIT_ASSERT(xDocument.is());
2229 uno::Reference<chart2::XChartDocument>xChartDocument(xDocument, uno::UNO_QUERY);
2230 CPPUNIT_ASSERT(xChartDocument.is());
2232 // Get the shape of the diagram / chart
2233 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDocument, uno::UNO_QUERY);
2234 CPPUNIT_ASSERT(xDrawPageSupplier.is());
2235 uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
2236 uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY);
2237 CPPUNIT_ASSERT(xShapes.is());
2239 uno::Reference<drawing::XShape> xChartDiagramShape = getShapeByName(xShapes, aCheckShapeName);
2240 CPPUNIT_ASSERT(xChartDiagramShape.is());
2242 // Size
2243 CPPUNIT_ASSERT_DOUBLES_EQUAL(1300, xChartDiagramShape->getSize().Width, 5); // calculated chart area size - 2 * margin
2244 CPPUNIT_ASSERT_DOUBLES_EQUAL(1300, xChartDiagramShape->getSize().Height, 5); // calculated chart area size - 2 * margin
2245 // Position
2246 CPPUNIT_ASSERT_DOUBLES_EQUAL(850, xChartDiagramShape->getPosition().X, 5); // margin + calculated centering
2247 CPPUNIT_ASSERT_DOUBLES_EQUAL(350, xChartDiagramShape->getPosition().Y, 5); // margin
2251 CPPUNIT_PLUGIN_IMPLEMENT();
2253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */