tdf#90352: set/handle LinkNumberFormatToSource property in xls...
[LibreOffice.git] / chart2 / qa / extras / chart2export.cxx
blob67aa996c89d56e1586a4de82653dc77e28d75568
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "charttest.hxx"
12 #include <test/xmltesttools.hxx>
14 #include <com/sun/star/chart/ErrorBarStyle.hpp>
15 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
16 #include <com/sun/star/lang/XServiceName.hpp>
17 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
18 #include <com/sun/star/text/XTextDocument.hpp>
19 #include <com/sun/star/text/XTextFramesSupplier.hpp>
20 #include <com/sun/star/drawing/LineStyle.hpp>
21 #include <com/sun/star/chart2/DataPointLabel.hpp>
23 #include <unotools/ucbstreamhelper.hxx>
24 #include <rtl/strbuf.hxx>
26 #include <libxml/xpathInternals.h>
27 #include <libxml/parserInternals.h>
29 #include <algorithm>
31 using uno::Reference;
32 using beans::XPropertySet;
34 class Chart2ExportTest : public ChartTest, public XmlTestTools
36 protected:
38 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override;
39 public:
40 Chart2ExportTest() : ChartTest() {}
41 void testErrorBarXLSX();
42 void testTrendline();
43 void testTrendlineOOXML();
44 void testTrendlineXLS();
45 void testStockChart();
46 void testBarChart();
47 void testCrosses();
48 void testScatterChartTextXValues();
49 void testChartDataTable();
50 void testChartExternalData();
51 void testEmbeddingsGrabBag();
52 void testAreaChartLoad();
53 void testUpDownBars();
54 void testDoughnutChart();
55 void testDisplayUnits();
56 // void testFdo74115WallGradientFill();
57 void testFdo74115WallBitmapFill();
58 void testBarChartRotation();
59 void testShapeFollowedByChart();
60 void testPieChartDataLabels();
61 void testSeriesIdxOrder();
62 void testScatterPlotLabels();
63 void testErrorBarDataRangeODS();
64 void testChartCrash();
65 void testPieChartRotation();
66 void testEmbeddingsOleObjectGrabBag();
67 void testGapWidthXLSX();
68 void testSmoothedLines();
69 void testLabelStringODS();
70 void testFdo78290LineChartMarkerX();
71 void testFdo78290ScatterChartMarkerX();
72 void testFdo78290CombinationChartMarkerX();
73 void testAxisNumberFormatODS();
74 void testAxisNumberFormatXLS();
75 void testDataLabelBordersDOCX();
76 void testDataLabel3DChartDOCX();
77 void testDataLabelBarChartDOCX();
78 void testDataLabelClusteredBarChartDOCX();
79 void testDataLabelRadarChartDOCX();
80 void testDataLabelDoughnutChartDOCX();
81 void testDataLabelAreaChartDOCX();
82 void testDataLabelDefaultLineChartDOCX();
83 void testFdo83058dlblPos();
84 void testAutoTitleDelXLSX();
85 void testDispBlanksAsXLSX();
86 void testMarkerColorXLSX();
87 void testRoundedCornersXLSX();
88 void testAxisNumberFormatXLSX();
89 void testDataLabelDefaultValuesXLSX();
90 void testTitleOverlayXLSX();
91 void testInvertIfNegativeXLSX();
92 void testBubble3DXLSX();
93 void testNoMarkerXLSX();
94 void testTitleManualLayoutXLSX();
95 void testPlotAreaManualLayoutXLSX();
96 void testLegendManualLayoutXLSX();
97 void testAxisCharacterPropertiesXLSX();
98 void testTitleCharacterPropertiesXLSX();
99 void testPlotVisOnlyXLSX();
100 void testBarChartVaryColorsXLSX();
101 void testMultipleAxisXLSX();
102 void testAxisTitleRotationXLSX();
103 void testAxisCrossBetweenXSLX();
105 CPPUNIT_TEST_SUITE(Chart2ExportTest);
106 CPPUNIT_TEST(testErrorBarXLSX);
107 CPPUNIT_TEST(testTrendline);
108 CPPUNIT_TEST(testTrendlineOOXML);
109 CPPUNIT_TEST(testTrendlineXLS);
110 CPPUNIT_TEST(testStockChart);
111 CPPUNIT_TEST(testBarChart);
112 CPPUNIT_TEST(testCrosses);
113 CPPUNIT_TEST(testScatterChartTextXValues);
114 CPPUNIT_TEST(testChartDataTable);
115 CPPUNIT_TEST(testChartExternalData);
116 CPPUNIT_TEST(testEmbeddingsGrabBag);
117 CPPUNIT_TEST(testAreaChartLoad);
118 CPPUNIT_TEST(testUpDownBars);
119 CPPUNIT_TEST(testDoughnutChart);
120 CPPUNIT_TEST(testDisplayUnits);
121 // CPPUNIT_TEST(testFdo74115WallGradientFill);
122 CPPUNIT_TEST(testFdo74115WallBitmapFill);
123 CPPUNIT_TEST(testBarChartRotation);
124 CPPUNIT_TEST(testShapeFollowedByChart);
125 CPPUNIT_TEST(testPieChartDataLabels);
126 CPPUNIT_TEST(testSeriesIdxOrder);
127 CPPUNIT_TEST(testScatterPlotLabels);
128 CPPUNIT_TEST(testErrorBarDataRangeODS);
129 CPPUNIT_TEST(testChartCrash);
130 CPPUNIT_TEST(testPieChartRotation);
131 CPPUNIT_TEST(testEmbeddingsOleObjectGrabBag);
132 CPPUNIT_TEST(testGapWidthXLSX);
133 CPPUNIT_TEST(testSmoothedLines);
134 CPPUNIT_TEST(testLabelStringODS);
135 CPPUNIT_TEST(testFdo78290LineChartMarkerX);
136 CPPUNIT_TEST(testFdo78290ScatterChartMarkerX);
137 CPPUNIT_TEST(testFdo78290CombinationChartMarkerX);
138 CPPUNIT_TEST(testAxisNumberFormatODS);
139 CPPUNIT_TEST(testAxisNumberFormatXLS);
140 CPPUNIT_TEST(testDataLabelBordersDOCX);
141 CPPUNIT_TEST(testDataLabel3DChartDOCX);
142 CPPUNIT_TEST(testDataLabelBarChartDOCX);
143 CPPUNIT_TEST(testDataLabelClusteredBarChartDOCX);
144 CPPUNIT_TEST(testDataLabelRadarChartDOCX);
145 CPPUNIT_TEST(testDataLabelDoughnutChartDOCX);
146 CPPUNIT_TEST(testDataLabelAreaChartDOCX);
147 CPPUNIT_TEST(testDataLabelDefaultLineChartDOCX);
148 CPPUNIT_TEST(testFdo83058dlblPos);
149 CPPUNIT_TEST(testAutoTitleDelXLSX);
150 CPPUNIT_TEST(testDispBlanksAsXLSX);
151 CPPUNIT_TEST(testMarkerColorXLSX);
152 CPPUNIT_TEST(testRoundedCornersXLSX);
153 CPPUNIT_TEST(testAxisNumberFormatXLSX);
154 CPPUNIT_TEST(testDataLabelDefaultValuesXLSX);
155 CPPUNIT_TEST(testTitleOverlayXLSX);
156 CPPUNIT_TEST(testInvertIfNegativeXLSX);
157 CPPUNIT_TEST(testBubble3DXLSX);
158 CPPUNIT_TEST(testNoMarkerXLSX);
159 CPPUNIT_TEST(testTitleManualLayoutXLSX);
160 CPPUNIT_TEST(testPlotAreaManualLayoutXLSX);
161 CPPUNIT_TEST(testLegendManualLayoutXLSX);
162 CPPUNIT_TEST(testAxisCharacterPropertiesXLSX);
163 CPPUNIT_TEST(testTitleCharacterPropertiesXLSX);
164 CPPUNIT_TEST(testPlotVisOnlyXLSX);
165 CPPUNIT_TEST(testBarChartVaryColorsXLSX);
166 CPPUNIT_TEST(testMultipleAxisXLSX);
167 CPPUNIT_TEST(testAxisTitleRotationXLSX);
168 CPPUNIT_TEST(testAxisCrossBetweenXSLX);
169 CPPUNIT_TEST_SUITE_END();
171 protected:
173 * Given that some problem doesn't affect the result in the importer, we
174 * test the resulting file directly, by opening the zip file, parsing an
175 * xml stream, and asserting an XPath expression. This method returns the
176 * xml stream, so that you can do the asserting.
178 xmlDocPtr parseExport(const OUString& rDir, const OUString& rFilterFormat);
182 namespace {
184 struct CheckForChartName
186 private:
187 OUString aDir;
189 public:
190 explicit CheckForChartName( const OUString& rDir ):
191 aDir(rDir) {}
193 bool operator()(const OUString& rName)
195 if(!rName.startsWith(aDir))
196 return false;
198 if(!rName.endsWith(".xml"))
199 return false;
201 return true;
205 OUString findChartFile(const OUString& rDir, uno::Reference< container::XNameAccess > const & xNames )
207 uno::Sequence<OUString> aNames = xNames->getElementNames();
208 OUString* pElement = std::find_if(aNames.begin(), aNames.end(), CheckForChartName(rDir));
210 CPPUNIT_ASSERT(pElement != aNames.end());
211 return *pElement;
216 xmlDocPtr Chart2ExportTest::parseExport(const OUString& rDir, const OUString& rFilterFormat)
218 std::shared_ptr<utl::TempFile> pTempFile = save(rFilterFormat);
220 // Read the XML stream we're interested in.
221 uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), pTempFile->GetURL());
222 uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(findChartFile(rDir, xNameAccess)), uno::UNO_QUERY);
223 CPPUNIT_ASSERT(xInputStream.is());
224 std::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
226 return parseXmlStream(pStream.get());
229 void Chart2ExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx)
231 struct { char const * pPrefix; char const * pURI; } aNamespaces[] =
233 { "w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main" },
234 { "v", "urn:schemas-microsoft-com:vml" },
235 { "c", "http://schemas.openxmlformats.org/drawingml/2006/chart" },
236 { "a", "http://schemas.openxmlformats.org/drawingml/2006/main" },
237 { "mc", "http://schemas.openxmlformats.org/markup-compatibility/2006" },
238 { "wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" },
239 { "wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" },
240 { "wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" },
241 { "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" },
242 { "table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0" },
243 { "text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0" },
244 { "xlink", "http://www.w3c.org/1999/xlink" }
246 for(size_t i = 0; i < SAL_N_ELEMENTS(aNamespaces); ++i)
248 xmlXPathRegisterNs(
249 pXmlXPathCtx,
250 reinterpret_cast<xmlChar const *>(aNamespaces[i].pPrefix),
251 reinterpret_cast<xmlChar const *>(aNamespaces[i].pURI));
255 namespace {
257 void testErrorBar( Reference< XPropertySet > const & xErrorBar )
259 sal_Int32 nErrorBarStyle;
260 CPPUNIT_ASSERT(
261 xErrorBar->getPropertyValue("ErrorBarStyle") >>= nErrorBarStyle);
262 CPPUNIT_ASSERT_EQUAL(nErrorBarStyle, chart::ErrorBarStyle::RELATIVE);
263 bool bShowPositive = bool(), bShowNegative = bool();
264 CPPUNIT_ASSERT(
265 xErrorBar->getPropertyValue("ShowPositiveError") >>= bShowPositive);
266 CPPUNIT_ASSERT(bShowPositive);
267 CPPUNIT_ASSERT(
268 xErrorBar->getPropertyValue("ShowNegativeError") >>= bShowNegative);
269 CPPUNIT_ASSERT(bShowNegative);
270 double nVal = 0.0;
271 CPPUNIT_ASSERT(xErrorBar->getPropertyValue("PositiveError") >>= nVal);
272 CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, nVal, 1e-10);
275 void checkCommonTrendline(
276 Reference<chart2::XRegressionCurve> const & xCurve,
277 double aExpectedExtrapolateForward, double aExpectedExtrapolateBackward,
278 bool aExpectedForceIntercept, double aExpectedInterceptValue,
279 bool aExpectedShowEquation, bool aExpectedR2)
281 Reference<XPropertySet> xProperties( xCurve , uno::UNO_QUERY );
282 CPPUNIT_ASSERT(xProperties.is());
284 double aExtrapolateForward = 0.0;
285 CPPUNIT_ASSERT(xProperties->getPropertyValue("ExtrapolateForward") >>= aExtrapolateForward);
286 CPPUNIT_ASSERT_EQUAL(aExpectedExtrapolateForward, aExtrapolateForward);
288 double aExtrapolateBackward = 0.0;
289 CPPUNIT_ASSERT(xProperties->getPropertyValue("ExtrapolateBackward") >>= aExtrapolateBackward);
290 CPPUNIT_ASSERT_EQUAL(aExpectedExtrapolateBackward, aExtrapolateBackward);
292 bool bForceIntercept = false;
293 CPPUNIT_ASSERT(xProperties->getPropertyValue("ForceIntercept") >>= bForceIntercept);
294 CPPUNIT_ASSERT_EQUAL(aExpectedForceIntercept, bForceIntercept);
296 if (bForceIntercept)
298 double aInterceptValue = 0.0;
299 CPPUNIT_ASSERT(xProperties->getPropertyValue("InterceptValue") >>= aInterceptValue);
300 CPPUNIT_ASSERT_EQUAL(aExpectedInterceptValue, aInterceptValue);
303 Reference< XPropertySet > xEquationProperties( xCurve->getEquationProperties() );
304 CPPUNIT_ASSERT(xEquationProperties.is());
306 bool bShowEquation = false;
307 CPPUNIT_ASSERT(xEquationProperties->getPropertyValue("ShowEquation") >>= bShowEquation);
308 CPPUNIT_ASSERT_EQUAL(aExpectedShowEquation, bShowEquation);
310 bool bShowCorrelationCoefficient = false;
311 CPPUNIT_ASSERT(xEquationProperties->getPropertyValue("ShowCorrelationCoefficient") >>= bShowCorrelationCoefficient);
312 CPPUNIT_ASSERT_EQUAL(aExpectedR2, bShowCorrelationCoefficient);
315 void checkNameAndType(Reference<XPropertySet> const & xProperties, const OUString& aExpectedName, const OUString& aExpectedServiceName)
317 Reference< lang::XServiceName > xServiceName( xProperties, UNO_QUERY );
318 CPPUNIT_ASSERT(xServiceName.is());
320 OUString aServiceName = xServiceName->getServiceName();
321 CPPUNIT_ASSERT_EQUAL(aExpectedServiceName, aServiceName);
323 OUString aCurveName;
324 CPPUNIT_ASSERT(xProperties->getPropertyValue("CurveName") >>= aCurveName);
325 CPPUNIT_ASSERT_EQUAL(aExpectedName, aCurveName);
328 void checkLinearTrendline(
329 Reference<chart2::XRegressionCurve> const & xCurve, const OUString& aExpectedName,
330 double aExpectedExtrapolateForward, double aExpectedExtrapolateBackward,
331 bool aExpectedForceIntercept, double aExpectedInterceptValue,
332 bool aExpectedShowEquation, bool aExpectedR2)
334 Reference<XPropertySet> xProperties( xCurve , uno::UNO_QUERY );
335 CPPUNIT_ASSERT(xProperties.is());
337 checkNameAndType(xProperties, aExpectedName, "com.sun.star.chart2.LinearRegressionCurve");
339 checkCommonTrendline(
340 xCurve,
341 aExpectedExtrapolateForward, aExpectedExtrapolateBackward,
342 aExpectedForceIntercept, aExpectedInterceptValue,
343 aExpectedShowEquation, aExpectedR2);
346 void checkPolynomialTrendline(
347 Reference<chart2::XRegressionCurve> const & xCurve, const OUString& aExpectedName,
348 sal_Int32 aExpectedDegree,
349 double aExpectedExtrapolateForward, double aExpectedExtrapolateBackward,
350 bool aExpectedForceIntercept, double aExpectedInterceptValue,
351 bool aExpectedShowEquation, bool aExpectedR2)
353 Reference<XPropertySet> xProperties( xCurve , uno::UNO_QUERY );
354 CPPUNIT_ASSERT(xProperties.is());
356 checkNameAndType(xProperties, aExpectedName, "com.sun.star.chart2.PolynomialRegressionCurve");
358 sal_Int32 aDegree = 2;
359 CPPUNIT_ASSERT(xProperties->getPropertyValue("PolynomialDegree") >>= aDegree);
360 CPPUNIT_ASSERT_EQUAL(aExpectedDegree, aDegree);
362 checkCommonTrendline(
363 xCurve,
364 aExpectedExtrapolateForward, aExpectedExtrapolateBackward,
365 aExpectedForceIntercept, aExpectedInterceptValue,
366 aExpectedShowEquation, aExpectedR2);
369 void checkMovingAverageTrendline(
370 Reference<chart2::XRegressionCurve> const & xCurve, const OUString& aExpectedName, sal_Int32 aExpectedPeriod)
372 Reference<XPropertySet> xProperties( xCurve , uno::UNO_QUERY );
373 CPPUNIT_ASSERT(xProperties.is());
375 checkNameAndType(xProperties, aExpectedName, "com.sun.star.chart2.MovingAverageRegressionCurve");
377 sal_Int32 aPeriod = 2;
378 CPPUNIT_ASSERT(xProperties->getPropertyValue("MovingAveragePeriod") >>= aPeriod);
379 CPPUNIT_ASSERT_EQUAL(aExpectedPeriod, aPeriod);
382 void checkTrendlinesInChart(uno::Reference< chart2::XChartDocument > const & xChartDoc)
384 CPPUNIT_ASSERT(xChartDoc.is());
386 Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
387 CPPUNIT_ASSERT( xDataSeries.is() );
389 Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xDataSeries, UNO_QUERY );
390 CPPUNIT_ASSERT( xRegressionCurveContainer.is() );
392 Sequence< Reference< chart2::XRegressionCurve > > xRegressionCurveSequence = xRegressionCurveContainer->getRegressionCurves();
393 CPPUNIT_ASSERT_EQUAL((sal_Int32) 3, xRegressionCurveSequence.getLength());
395 Reference<chart2::XRegressionCurve> xCurve;
397 xCurve = xRegressionCurveSequence[0];
398 CPPUNIT_ASSERT(xCurve.is());
399 checkPolynomialTrendline(xCurve, "col2_poly", 3, 0.1, -0.1, true, -1.0, true, true);
401 xCurve = xRegressionCurveSequence[1];
402 CPPUNIT_ASSERT(xCurve.is());
403 checkLinearTrendline(xCurve, "col2_linear", -0.5, -0.5, false, 0.0, true, false);
405 xCurve = xRegressionCurveSequence[2];
406 CPPUNIT_ASSERT(xCurve.is());
407 checkMovingAverageTrendline(xCurve, "col2_moving_avg", 3);
412 // improve the test
413 void Chart2ExportTest::testErrorBarXLSX()
415 load("/chart2/qa/extras/data/ods/", "error_bar.ods");
417 // make sure the ODS import was successful
418 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
419 CPPUNIT_ASSERT(xChartDoc.is());
421 Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
422 CPPUNIT_ASSERT( xDataSeries.is() );
424 Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
425 CPPUNIT_ASSERT( xPropSet.is() );
427 // test that y error bars are there
428 Reference< beans::XPropertySet > xErrorBarYProps;
429 xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarYProps;
430 testErrorBar(xErrorBarYProps);
433 reload("Calc Office Open XML");
435 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
436 CPPUNIT_ASSERT(xChartDoc.is());
438 Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
439 CPPUNIT_ASSERT( xDataSeries.is() );
441 Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
442 CPPUNIT_ASSERT( xPropSet.is() );
444 // test that y error bars are there
445 Reference< beans::XPropertySet > xErrorBarYProps;
446 xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarYProps;
447 testErrorBar(xErrorBarYProps);
451 // This method tests the preservation of properties for trendlines / regression curves
452 // in an export -> import cycle using different file formats - ODS, XLS and XLSX.
453 void Chart2ExportTest::testTrendline()
455 mbSkipValidation = true;
456 load("/chart2/qa/extras/data/ods/", "trendline.ods");
457 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent));
458 reload("calc8");
459 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent));
462 void Chart2ExportTest::testTrendlineOOXML()
464 load("/chart2/qa/extras/data/ods/", "trendline.ods");
465 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent));
466 reload("Calc Office Open XML");
467 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent));
470 void Chart2ExportTest::testTrendlineXLS()
472 mbSkipValidation = true;
473 load("/chart2/qa/extras/data/ods/", "trendline.ods");
474 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent));
475 reload("MS Excel 97");
476 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent));
479 void Chart2ExportTest::testStockChart()
481 /* For attached file Stock_Chart.docx, in chart1.xml,
482 * <c:stockChart>, there are four types of series as
483 * Open,Low,High and Close.
484 * For Open series, in <c:idx val="0" />
485 * an attribute val of index should start from 1 and not from 0.
486 * Which was problem area.
488 load("/chart2/qa/extras/data/docx/", "testStockChart.docx");
490 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
491 if (!pXmlDoc)
492 return;
494 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:stockChart/c:ser[1]/c:idx", "val", "1");
495 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:stockChart/c:ser[1]/c:order", "val", "1");
496 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:stockChart/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v", "Open");
499 void Chart2ExportTest::testBarChart()
501 load("/chart2/qa/extras/data/docx/", "testBarChart.docx");
502 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
503 if (!pXmlDoc)
504 return;
506 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:barDir", "val", "col");
509 void Chart2ExportTest::testCrosses()
511 load("/chart2/qa/extras/data/docx/", "Bar_horizontal_cone.docx");
512 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
514 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:crosses", "val", "autoZero");
517 void Chart2ExportTest::testScatterChartTextXValues()
519 load("/chart2/qa/extras/data/docx/", "scatter-chart-text-x-values.docx");
521 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
522 CPPUNIT_ASSERT(xChartDoc.is());
524 Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
525 CPPUNIT_ASSERT(xCT.is());
527 // Make sure we have exactly 3 data series.
528 std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
529 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
530 CPPUNIT_ASSERT_EQUAL(OUString("Series 1"), aLabels[0][0].get<OUString>());
531 CPPUNIT_ASSERT_EQUAL(OUString("Series 2"), aLabels[1][0].get<OUString>());
532 CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), aLabels[2][0].get<OUString>());
534 std::vector<std::vector<double> > aYValues = getDataSeriesYValuesFromChartType(xCT);
535 CPPUNIT_ASSERT_EQUAL(size_t(3), aYValues.size());
537 // Check the Y values of "Series 1".
538 CPPUNIT_ASSERT_EQUAL(size_t(4), aYValues[0].size());
539 CPPUNIT_ASSERT_EQUAL(4.3, aYValues[0][0]);
540 CPPUNIT_ASSERT_EQUAL(2.5, aYValues[0][1]);
541 CPPUNIT_ASSERT_EQUAL(3.5, aYValues[0][2]);
542 CPPUNIT_ASSERT_EQUAL(4.5, aYValues[0][3]);
544 // And "Series 2".
545 CPPUNIT_ASSERT_EQUAL(size_t(4), aYValues[1].size());
546 CPPUNIT_ASSERT_EQUAL(2.4, aYValues[1][0]);
547 CPPUNIT_ASSERT_EQUAL(4.4, aYValues[1][1]);
548 CPPUNIT_ASSERT_EQUAL(1.8, aYValues[1][2]);
549 CPPUNIT_ASSERT_EQUAL(2.8, aYValues[1][3]);
551 // And "Series 3".
552 CPPUNIT_ASSERT_EQUAL(size_t(4), aYValues[2].size());
553 CPPUNIT_ASSERT_EQUAL(2.0, aYValues[2][0]);
554 CPPUNIT_ASSERT_EQUAL(2.0, aYValues[2][1]);
555 CPPUNIT_ASSERT_EQUAL(3.0, aYValues[2][2]);
556 CPPUNIT_ASSERT_EQUAL(5.0, aYValues[2][3]);
558 // Test the export.
559 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
560 if (!pXmlDoc)
561 return;
563 assertXPathContent(pXmlDoc, "//c:scatterChart/c:ser[1]/c:xVal[1]/c:numRef[1]/c:numCache[1]/c:pt[1]/c:v[1]", "1");
566 void Chart2ExportTest::testChartDataTable()
568 load("/chart2/qa/extras/data/docx/", "testChartDataTable.docx");
570 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
571 CPPUNIT_ASSERT(pXmlDoc);
572 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dTable/c:showHorzBorder", "val", "1");
573 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dTable/c:showVertBorder", "val", "1");
574 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dTable/c:showOutline", "val", "1");
577 void Chart2ExportTest::testChartExternalData()
579 load("/chart2/qa/extras/data/docx/", "testMultipleChart.docx");
581 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
582 CPPUNIT_ASSERT(pXmlDoc);
583 xmlXPathObjectPtr pXmlPathObj = getXPathNode(pXmlDoc, "/c:chartSpace/c:externalData");
584 xmlNodeSetPtr pXmlNodes = pXmlPathObj->nodesetval;
585 CPPUNIT_ASSERT(pXmlNodes);
588 void Chart2ExportTest::testEmbeddingsGrabBag()
590 // The problem was that .xlsx files were missing from docx file from embeddings folder
591 // after saving file.
592 // This test case tests whether embeddings files grabbagged properly in correct object.
594 load("/chart2/qa/extras/data/docx/", "testMultiplechartembeddings.docx" );
595 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
596 uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
597 uno::Sequence<beans::PropertyValue> aGrabBag(0);
598 xTextDocumentPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
599 CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty
600 bool bEmbeddings = false;
601 const char* const testEmbeddedFileNames[] {"word/embeddings/Microsoft_Excel_Worksheet3.xlsx",
602 "word/embeddings/Microsoft_Excel_Worksheet2.xlsx",
603 "word/embeddings/Microsoft_Excel_Worksheet1.xlsx"};
604 for(int i = 0; i < aGrabBag.getLength(); ++i)
606 if (aGrabBag[i].Name == "OOXEmbeddings")
608 bEmbeddings = true;
609 uno::Sequence<beans::PropertyValue> aEmbeddingsList(0);
610 uno::Reference<io::XInputStream> aEmbeddingXlsxStream;
611 OUString aEmbeddedfileName;
612 CPPUNIT_ASSERT(aGrabBag[i].Value >>= aEmbeddingsList); // PropertyValue of proper type
613 sal_Int32 length = aEmbeddingsList.getLength();
614 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), length);
615 for(int j = 0; j < length; ++j)
617 aEmbeddingsList[j].Value >>= aEmbeddingXlsxStream;
618 aEmbeddedfileName = aEmbeddingsList[j].Name;
619 CPPUNIT_ASSERT(aEmbeddingXlsxStream.get()); // Reference not empty
620 CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(testEmbeddedFileNames[j]),aEmbeddedfileName);
624 CPPUNIT_ASSERT(bEmbeddings); // Grab Bag has all the expected elements
627 void Chart2ExportTest::testAreaChartLoad()
629 load ("/chart2/qa/extras/data/docx/", "testAreaChartLoad.docx");
630 xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
631 CPPUNIT_ASSERT(pXmlDoc);
632 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:showVal", "val", "1");
633 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:dLbl", 0);
636 void Chart2ExportTest::testUpDownBars()
639 load("/chart2/qa/extras/data/docx/", "UpDownBars.docx");
640 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
641 CPPUNIT_ASSERT(pXmlDoc);
642 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:upDownBars");
646 void Chart2ExportTest::testDoughnutChart()
648 load("/chart2/qa/extras/data/docx/", "doughnutChart.docx");
649 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
650 CPPUNIT_ASSERT(pXmlDoc);
652 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart", "1");
655 void Chart2ExportTest::testDisplayUnits()
657 load("/chart2/qa/extras/data/docx/", "DisplayUnits.docx");
658 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
659 CPPUNIT_ASSERT(pXmlDoc);
661 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:dispUnits/c:builtInUnit", "val", "billions");
664 // void Chart2ExportTest::testFdo74115WallGradientFill()
665 // {
666 // load("/chart2/qa/extras/data/docx/", "fdo74115_WallGradientFill.docx");
667 // xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
668 // CPPUNIT_ASSERT(pXmlDoc);
670 // assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill");
671 // }
673 void Chart2ExportTest::testFdo74115WallBitmapFill()
675 load("/chart2/qa/extras/data/docx/", "fdo74115_WallBitmapFill.docx");
676 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
677 CPPUNIT_ASSERT(pXmlDoc);
678 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:blipFill");
681 //The below test case tests the built in marker 'x' for Office 2010 in Line charts
683 void Chart2ExportTest::testFdo78290LineChartMarkerX()
685 load("/chart2/qa/extras/data/docx/", "fdo78290_Line_Chart_Marker_x.docx");
686 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
687 CPPUNIT_ASSERT(pXmlDoc);
688 assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:symbol[1]","val","x");
689 assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:size[1]","val","7");
692 // We can also use the built in marker 'x' in scatter chart, hence writing the test case for the same.
694 void Chart2ExportTest::testFdo78290ScatterChartMarkerX()
696 load("/chart2/qa/extras/data/docx/", "fdo78290_Scatter_Chart_Marker_x.docx");
697 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
698 CPPUNIT_ASSERT(pXmlDoc);
699 assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:scatterChart[1]/c:ser[1]/c:marker[1]/c:symbol[1]","val","x");
700 assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:scatterChart[1]/c:ser[1]/c:marker[1]/c:size[1]","val","7");
703 // Also in a combination of charts like a column chart and line chart, we can use the built in marker 'x'
704 // for the line chart too. hence put a test case for the combination chart also.
706 void Chart2ExportTest::testFdo78290CombinationChartMarkerX()
708 load("/chart2/qa/extras/data/docx/", "fdo78290_Combination_Chart_Marker_x.docx");
709 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
710 CPPUNIT_ASSERT(pXmlDoc);
711 assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:symbol[1]","val","x");
712 assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:size[1]","val","7");
715 void Chart2ExportTest::testAxisNumberFormatODS()
717 struct
719 void check( const Reference<chart2::XChartDocument>& xChartDoc )
721 Reference<chart2::XAxis> xAxisX = getAxisFromDoc(xChartDoc, 0, 0, 0);
722 Reference<chart2::XTitled> xTitle(xAxisX, UNO_QUERY_THROW);
723 OUString aTitleText = getTitleString(xTitle);
724 CPPUNIT_ASSERT_EQUAL(OUString("Linked To Source"), aTitleText);
726 sal_Int32 nNumFmt = getNumberFormatFromAxis(xAxisX);
727 sal_Int16 nType = getNumberFormatType(xChartDoc, nNumFmt);
728 CPPUNIT_ASSERT_MESSAGE("X axis should be percentage format.", (nType & util::NumberFormat::PERCENT));
730 bool bNumFmtLinked = false;
731 Reference<beans::XPropertySet> xPS(xAxisX, uno::UNO_QUERY_THROW);
732 xPS->getPropertyValue("LinkNumberFormatToSource") >>= bNumFmtLinked;
733 CPPUNIT_ASSERT_MESSAGE("X axis should have its number format linked to source.", bNumFmtLinked);
735 Reference<chart2::XAxis> xAxisY = getAxisFromDoc(xChartDoc, 0, 1, 0);
736 xTitle.set(xAxisY, UNO_QUERY_THROW);
737 aTitleText = getTitleString(xTitle);
738 CPPUNIT_ASSERT_EQUAL(OUString("Not Linked"), aTitleText);
740 nNumFmt = getNumberFormatFromAxis(xAxisY);
741 nType = getNumberFormatType(xChartDoc, nNumFmt);
742 CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType & util::NumberFormat::NUMBER));
744 bNumFmtLinked = true;
745 xPS.set(xAxisY, uno::UNO_QUERY_THROW);
746 xPS->getPropertyValue("LinkNumberFormatToSource") >>= bNumFmtLinked;
747 CPPUNIT_ASSERT_MESSAGE("Y axis should not have its number format linked to source.", !bNumFmtLinked);
750 } aTest;
752 load("/chart2/qa/extras/data/ods/", "axis-numformats-linked.ods");
754 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
755 aTest.check(xChartDoc);
757 // Reload the document and make sure everything remains intact.
758 reload("calc8");
759 xChartDoc = getChartDocFromSheet(0, mxComponent);
760 aTest.check(xChartDoc);
763 void Chart2ExportTest::testAxisNumberFormatXLS()
765 struct
767 void check( const Reference<chart2::XChartDocument>& xChartDoc, bool bNumFmtLinkedActual, sal_Int16 nNumFmtTypeFlag ) const
769 Reference<chart2::XAxis> xAxisY = getAxisFromDoc( xChartDoc, 0, 1, 0 );
770 bool bNumFmtLinked = false;
771 Reference<beans::XPropertySet> xPS( xAxisY, uno::UNO_QUERY_THROW );
772 xPS->getPropertyValue( "LinkNumberFormatToSource" ) >>= bNumFmtLinked;
774 if ( bNumFmtLinkedActual )
775 CPPUNIT_ASSERT_MESSAGE( "Y axis should have its number format linked to source.", bNumFmtLinked );
776 else
778 CPPUNIT_ASSERT_MESSAGE( "Y axis should not have its number format linked to source.", !bNumFmtLinked );
780 sal_Int32 nNumFmt = getNumberFormatFromAxis( xAxisY );
781 sal_Int16 nType = getNumberFormatType( xChartDoc, nNumFmt );
782 if ( nNumFmtTypeFlag == util::NumberFormat::PERCENT )
783 CPPUNIT_ASSERT_MESSAGE( "Y axis should be percentage format.", ( nType & util::NumberFormat::PERCENT ) );
784 else
785 CPPUNIT_ASSERT_MESSAGE( "Y axis should be number format.", ( nType & util::NumberFormat::NUMBER ) );
789 void change( const Reference<chart2::XChartDocument>& xChartDoc, bool bSetNumFmtLinked, sal_Int16 nNumFmtTypeFlag )
791 Reference<chart2::XAxis> xAxisY = getAxisFromDoc( xChartDoc, 0, 1, 0 );
792 Reference<beans::XPropertySet> xPS( xAxisY, uno::UNO_QUERY_THROW );
793 Any aAny( bSetNumFmtLinked );
794 xPS->setPropertyValue( "LinkNumberFormatToSource", aAny );
795 if ( !bSetNumFmtLinked )
797 Reference<util::XNumberFormatsSupplier> xNFS( xChartDoc, uno::UNO_QUERY_THROW );
798 Reference<util::XNumberFormats> xNumberFormats = xNFS->getNumberFormats();
799 CPPUNIT_ASSERT( xNumberFormats.is() );
800 lang::Locale aLocale{ "en", "US", "" };
801 Sequence<sal_Int32> aNumFmts = xNumberFormats->queryKeys( nNumFmtTypeFlag, aLocale, false );
802 CPPUNIT_ASSERT( aNumFmts.hasElements() );
803 aAny <<= aNumFmts[0];
804 xPS->setPropertyValue( CHART_UNONAME_NUMFMT, aAny );
808 } aTest;
810 load( "/chart2/qa/extras/data/xls/", "axis_sourceformatting.xls" );
812 Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet( 0, mxComponent );
813 aTest.check( xChartDoc, true, util::NumberFormat::PERCENT );
815 aTest.change( xChartDoc, false, util::NumberFormat::NUMBER );
816 // Write the document(xls) with changes made close it, load it and check if changes are intact
817 reload( "MS Excel 97" );
818 xChartDoc = getChartDocFromSheet( 0, mxComponent );
819 aTest.check( xChartDoc, false, util::NumberFormat::NUMBER );
822 void Chart2ExportTest::testDataLabelBordersDOCX()
824 struct Check
826 sal_Int32 mnIndex;
827 css::drawing::LineStyle meStyle;
828 sal_Int32 mnColor;
831 struct
834 * Chart 1 has 4 bars of which 1st and 3rd have labels with borders
835 * around them.
837 void checkObject1( const Reference<chart2::XChartDocument>& xChartDoc )
839 CPPUNIT_ASSERT(xChartDoc.is());
841 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
842 CPPUNIT_ASSERT(xDataSeries.is());
844 // Check to make sure that data points 0 and 2 have local properties.
845 Reference<beans::XPropertySet> xPropSet(xDataSeries, uno::UNO_QUERY);
846 CPPUNIT_ASSERT(xPropSet.is());
848 Sequence<sal_Int32> aIndices;
849 xPropSet->getPropertyValue("AttributedDataPoints") >>= aIndices;
851 CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 2 data points with local properties.", sal_Int32(2), aIndices.getLength());
852 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aIndices[0]);
853 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aIndices[1]);
856 const Check aDataPoints[] =
858 { 0, css::drawing::LineStyle_SOLID, 0x00FFFF00 }, // solid yellow
859 { 2, css::drawing::LineStyle_SOLID, 0x00FF0000 } // solid red
862 for (size_t i = 0; i < SAL_N_ELEMENTS(aDataPoints); ++i)
864 xPropSet = xDataSeries->getDataPointByIndex(aDataPoints[i].mnIndex);
865 CPPUNIT_ASSERT(xPropSet.is());
867 css::drawing::LineStyle eLineStyle = css::drawing::LineStyle_NONE;
868 xPropSet->getPropertyValue(CHART_UNONAME_LABEL_BORDER_STYLE) >>= eLineStyle;
869 CPPUNIT_ASSERT_EQUAL(aDataPoints[i].meStyle, eLineStyle);
871 sal_Int32 nWidth = -1;
872 xPropSet->getPropertyValue(CHART_UNONAME_LABEL_BORDER_WIDTH) >>= nWidth;
873 CPPUNIT_ASSERT(nWidth > 0);
875 sal_Int32 nColor = -1;
876 xPropSet->getPropertyValue(CHART_UNONAME_LABEL_BORDER_COLOR) >>= nColor;
877 CPPUNIT_ASSERT_EQUAL_MESSAGE("Border color is wrong.", aDataPoints[i].mnColor, nColor);
882 * Chart 2 has all its data labels with identical borders.
884 void checkObject2( const Reference<chart2::XChartDocument>& xChartDoc )
886 CPPUNIT_ASSERT(xChartDoc.is());
888 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
889 CPPUNIT_ASSERT(xDataSeries.is());
891 Reference<beans::XPropertySet> xPropSet(xDataSeries, uno::UNO_QUERY);
892 CPPUNIT_ASSERT(xPropSet.is());
894 css::drawing::LineStyle eLineStyle = css::drawing::LineStyle_NONE;
895 xPropSet->getPropertyValue(CHART_UNONAME_LABEL_BORDER_STYLE) >>= eLineStyle;
896 CPPUNIT_ASSERT_EQUAL(css::drawing::LineStyle_SOLID, eLineStyle);
898 sal_Int32 nWidth = -1;
899 xPropSet->getPropertyValue(CHART_UNONAME_LABEL_BORDER_WIDTH) >>= nWidth;
900 CPPUNIT_ASSERT(nWidth > 0);
902 sal_Int32 nColor = -1;
903 xPropSet->getPropertyValue(CHART_UNONAME_LABEL_BORDER_COLOR) >>= nColor;
904 CPPUNIT_ASSERT_EQUAL_MESSAGE("Border color should be green.", sal_Int32(0x0000FF00), nColor);
907 } aTest;
909 load("/chart2/qa/extras/data/docx/", "data-label-borders.docx");
911 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
913 // "Automatic" chart background fill in docx should be loaded as solid white.
914 Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
915 CPPUNIT_ASSERT(xPropSet.is());
916 drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
917 sal_Int32 nColor = xPropSet->getPropertyValue("FillColor").get<sal_Int32>();
918 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in docx should be loaded as solid fill.",
919 drawing::FillStyle_SOLID, eStyle);
920 CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in docx should be loaded as solid white.",
921 sal_Int32(0x00FFFFFF), sal_Int32(nColor & 0x00FFFFFF)); // highest 2 bytes are transparency which we ignore here.
923 aTest.checkObject1(xChartDoc);
924 xChartDoc.set(getChartDocFromWriter(1), uno::UNO_QUERY);
925 aTest.checkObject2(xChartDoc);
927 reload("Office Open XML Text");
929 xChartDoc.set(getChartDocFromWriter(0), uno::UNO_QUERY);
930 aTest.checkObject1(xChartDoc);
931 xChartDoc.set(getChartDocFromWriter(1), uno::UNO_QUERY);
932 aTest.checkObject2(xChartDoc);
935 void Chart2ExportTest::testDataLabel3DChartDOCX()
937 load("/chart2/qa/extras/data/docx/", "3d-bar-label.docx");
939 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
940 CPPUNIT_ASSERT(xChartDoc.is());
942 xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
943 CPPUNIT_ASSERT(pXmlDoc);
945 // We must not export label position attributes for 3D bar charts. The
946 // same rule also applies to several other 3D charts, apparently.
947 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:ser/c:dLbls/c:dLblPos", 0);
948 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:ser/c:dLbls/c:dLbl/c:dLblPos", 0);
951 void Chart2ExportTest::testDataLabelBarChartDOCX()
953 load("/chart2/qa/extras/data/docx/", "bar-chart-labels.docx");
955 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
956 CPPUNIT_ASSERT(xChartDoc.is());
958 xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
959 CPPUNIT_ASSERT(pXmlDoc);
961 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLblPos", "val", "ctr");
962 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[2]/c:dLbls/c:dLblPos", "val", "inEnd");
963 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[3]/c:dLbls/c:dLblPos", "val", "inBase");
966 void Chart2ExportTest::testDataLabelClusteredBarChartDOCX()
968 load("/chart2/qa/extras/data/docx/", "clustered-bar-chart-labels.docx");
970 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
971 CPPUNIT_ASSERT(xChartDoc.is());
973 xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
974 CPPUNIT_ASSERT(pXmlDoc);
976 // This was "t", should be one of the allowed values.
977 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLbl[2]/c:dLblPos", "val", "outEnd");
980 void Chart2ExportTest::testDataLabelRadarChartDOCX()
982 load("/chart2/qa/extras/data/docx/", "radar-chart-labels.docx");
984 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
985 CPPUNIT_ASSERT(xChartDoc.is());
987 xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
988 CPPUNIT_ASSERT(pXmlDoc);
990 // We must not export label position attributes for radar charts.
991 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:radarChart/c:ser/c:dLbls/c:dLblPos", 0);
992 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:radarChart/c:ser/c:dLbls/c:dLbl/c:dLblPos", 0);
995 void Chart2ExportTest::testDataLabelDoughnutChartDOCX()
997 load("/chart2/qa/extras/data/docx/", "doughnut-chart-labels.docx");
999 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
1000 CPPUNIT_ASSERT(xChartDoc.is());
1002 xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
1003 CPPUNIT_ASSERT(pXmlDoc);
1005 // We must not export label position attributes for doughnut charts.
1006 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart/c:ser/c:dLbls/c:dLblPos", 0);
1007 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart/c:ser/c:dLbls/c:dLbl/c:dLblPos", 0);
1010 void Chart2ExportTest::testDataLabelAreaChartDOCX()
1012 load("/chart2/qa/extras/data/docx/", "area-chart-labels.docx");
1014 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
1015 CPPUNIT_ASSERT(xChartDoc.is());
1017 xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
1018 CPPUNIT_ASSERT(pXmlDoc);
1020 // We must not export label position attributes for area charts.
1021 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:dLblPos", 0);
1022 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:dLbl/c:dLblPos", 0);
1025 void Chart2ExportTest::testDataLabelDefaultLineChartDOCX()
1027 // This file was created by Word 2007, which doesn't provide default data
1028 // label position (2010 does). Make sure its default data label position
1029 // is RIGHT when exporting.
1031 load("/chart2/qa/extras/data/docx/", "line-chart-label-default-placement.docx");
1033 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
1034 CPPUNIT_ASSERT(xChartDoc.is());
1036 reload("Office Open XML Text");
1038 xChartDoc.set(getChartDocFromWriter(0), uno::UNO_QUERY);
1039 Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
1040 Reference<beans::XPropertySet> xPropSet(xDataSeries, uno::UNO_QUERY);
1041 CPPUNIT_ASSERT(xPropSet.is());
1042 sal_Int32 nLabelPlacement = -1;
1043 if (xPropSet->getPropertyValue("LabelPlacement") >>= nLabelPlacement)
1044 // This option may not be set. Check its value only when it's set.
1045 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line chart's default label placement should be 'right'.", chart::DataLabelPlacement::RIGHT, nLabelPlacement );
1048 void Chart2ExportTest::testBarChartRotation()
1050 load ("/chart2/qa/extras/data/docx/", "barChartRotation.docx");
1051 xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
1052 CPPUNIT_ASSERT(pXmlDoc);
1054 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:view3D/c:rotX", "val", "30");
1055 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:view3D/c:rotY", "val", "50");
1058 void Chart2ExportTest::testShapeFollowedByChart()
1060 /* If there is a scenario where a chart is followed by a shape
1061 which is being exported as an alternate content then, the
1062 docPr Id is being repeated, ECMA 20.4.2.5 says that the
1063 docPr Id should be unique, ensuring the same here.
1065 load("/chart2/qa/extras/data/docx/", "FDO74430.docx");
1066 xmlDocPtr pXmlDoc = parseExport("word/document", "Office Open XML Text" );
1067 CPPUNIT_ASSERT(pXmlDoc);
1069 OUString aValueOfFirstDocPR = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/w:drawing[1]/wp:inline[1]/wp:docPr[1]", "id");
1070 OUString aValueOfSecondDocPR;
1072 aValueOfSecondDocPR = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:docPr[1]", "id");
1074 CPPUNIT_ASSERT( aValueOfFirstDocPR != aValueOfSecondDocPR );
1077 void Chart2ExportTest::testPieChartDataLabels()
1079 load("/chart2/qa/extras/data/docx/", "PieChartDataLabels.docx");
1080 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
1081 CPPUNIT_ASSERT(pXmlDoc);
1082 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser[1]/c:dLbls/c:dLbl[1]/c:dLblPos", "val", "bestFit");
1085 void Chart2ExportTest::testSeriesIdxOrder()
1087 load("/chart2/qa/extras/data/docx/", "testSeriesIdxOrder.docx");
1088 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
1089 CPPUNIT_ASSERT(pXmlDoc);
1090 assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:idx[1]", "val", "1");
1091 assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:order[1]", "val", "1");
1094 void Chart2ExportTest::testScatterPlotLabels()
1096 load("/chart2/qa/extras/data/odt/", "scatter-plot-labels.odt");
1097 Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
1098 CPPUNIT_ASSERT(xChartDoc.is());
1100 Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
1101 CPPUNIT_ASSERT(xCT.is());
1103 // Make sure the original chart has 'a', 'b', 'c' as its data labels.
1104 std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
1105 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
1106 CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels[0][0].get<OUString>());
1107 CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels[1][0].get<OUString>());
1108 CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels[2][0].get<OUString>());
1110 // Reload the doc and check again. The labels should not change.
1111 reload("writer8");
1113 xChartDoc.set(getChartDocFromWriter(0), uno::UNO_QUERY);
1114 CPPUNIT_ASSERT(xChartDoc.is());
1116 xCT = getChartTypeFromDoc(xChartDoc, 0);
1117 CPPUNIT_ASSERT(xCT.is());
1119 aLabels = getDataSeriesLabelsFromChartType(xCT);
1120 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
1121 CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels[0][0].get<OUString>());
1122 CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels[1][0].get<OUString>());
1123 CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels[2][0].get<OUString>());
1126 void Chart2ExportTest::testErrorBarDataRangeODS()
1128 load("/chart2/qa/extras/data/ods/", "ErrorBarRange.ods");
1129 reload("calc8");
1131 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
1132 CPPUNIT_ASSERT(xChartDoc.is());
1134 Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
1135 CPPUNIT_ASSERT( xDataSeries.is() );
1137 Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
1138 CPPUNIT_ASSERT( xPropSet.is() );
1140 // test that y error bars are there
1141 Reference< beans::XPropertySet > xErrorBarYProps;
1142 xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarYProps;
1143 uno::Any aAny = xErrorBarYProps->getPropertyValue("ErrorBarRangePositive");
1144 CPPUNIT_ASSERT(aAny.hasValue());
1145 OUString aPosRange;
1146 aAny >>= aPosRange;
1147 CPPUNIT_ASSERT_EQUAL(OUString("$Sheet1.$B$1:$B$3"), aPosRange);
1149 aAny = xErrorBarYProps->getPropertyValue("ErrorBarRangeNegative");
1150 CPPUNIT_ASSERT(aAny.hasValue());
1151 OUString aNegRange;
1152 aAny >>= aNegRange;
1153 CPPUNIT_ASSERT_EQUAL(OUString("$Sheet1.$C$1:$C$3"), aNegRange);
1156 void Chart2ExportTest::testChartCrash()
1158 load("/chart2/qa/extras/data/docx/", "FDO75975.docx");
1159 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
1160 CPPUNIT_ASSERT(pXmlDoc);
1163 void Chart2ExportTest::testPieChartRotation()
1165 load ("/chart2/qa/extras/data/docx/", "pieChartRotation.docx");
1166 xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
1167 CPPUNIT_ASSERT(pXmlDoc);
1168 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:view3D/c:rotX", "val", "40");
1169 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:view3D/c:rotY", "val", "30");
1172 void Chart2ExportTest::testEmbeddingsOleObjectGrabBag()
1174 // The problem was that .bin files were missing from docx file from embeddings folder
1175 // after saving file.
1176 // This test case tests whether embeddings files grabbagged properly in correct object.
1178 load("/chart2/qa/extras/data/docx/", "testchartoleobjectembeddings.docx" );
1179 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
1180 uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
1181 uno::Sequence<beans::PropertyValue> aGrabBag(0);
1182 xTextDocumentPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
1183 CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty
1184 bool bEmbeddings = false;
1185 const char* const testEmbeddedFileNames[] = {"word/embeddings/oleObject1.bin"};
1186 for(int i = 0; i < aGrabBag.getLength(); ++i)
1188 if (aGrabBag[i].Name == "OOXEmbeddings")
1190 bEmbeddings = true;
1191 uno::Sequence<beans::PropertyValue> aEmbeddingsList(0);
1192 uno::Reference<io::XInputStream> aEmbeddingXlsxStream;
1193 OUString aEmbeddedfileName;
1194 CPPUNIT_ASSERT(aGrabBag[i].Value >>= aEmbeddingsList); // PropertyValue of proper type
1195 sal_Int32 length = aEmbeddingsList.getLength();
1196 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), length);
1197 for(int j = 0; j < length; ++j)
1199 aEmbeddingsList[j].Value >>= aEmbeddingXlsxStream;
1200 aEmbeddedfileName = aEmbeddingsList[j].Name;
1201 CPPUNIT_ASSERT(aEmbeddingXlsxStream.get()); // Reference not empty
1202 CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(testEmbeddedFileNames[j]),aEmbeddedfileName);
1206 CPPUNIT_ASSERT(bEmbeddings); // Grab Bag has all the expected elements
1209 namespace {
1211 void checkGapWidth(Reference<beans::XPropertySet> const & xPropSet, sal_Int32 nValue)
1213 uno::Any aAny = xPropSet->getPropertyValue("GapwidthSequence");
1214 CPPUNIT_ASSERT(aAny.hasValue());
1215 uno::Sequence< sal_Int32 > aSequence;
1216 aAny >>= aSequence;
1217 CPPUNIT_ASSERT(aSequence.getLength());
1218 CPPUNIT_ASSERT_EQUAL(nValue, aSequence[0]);
1221 void checkOverlap(Reference<beans::XPropertySet> const & xPropSet, sal_Int32 nValue)
1223 uno::Any aAny = xPropSet->getPropertyValue("OverlapSequence");
1224 CPPUNIT_ASSERT(aAny.hasValue());
1225 uno::Sequence< sal_Int32 > aSequence;
1226 aAny >>= aSequence;
1227 CPPUNIT_ASSERT(aSequence.getLength());
1228 CPPUNIT_ASSERT_EQUAL(nValue, aSequence[0]);
1231 void checkSheetForGapWidthAndOverlap(uno::Reference< chart2::XChartDocument > const & xChartDoc,
1232 sal_Int32 nExpectedGapWidth, sal_Int32 nExpectedOverlap)
1234 CPPUNIT_ASSERT(xChartDoc.is());
1236 Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 );
1237 CPPUNIT_ASSERT(xChartType.is());
1239 Reference< beans::XPropertySet > xPropSet( xChartType, uno::UNO_QUERY_THROW );
1240 checkGapWidth(xPropSet, nExpectedGapWidth);
1241 checkOverlap(xPropSet, nExpectedOverlap);
1247 void Chart2ExportTest::testGapWidthXLSX()
1249 load("/chart2/qa/extras/data/xlsx/", "gapWidth.xlsx");
1251 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
1252 checkSheetForGapWidthAndOverlap(xChartDoc, 120, -60);
1254 xChartDoc = getChartDocFromSheet( 1, mxComponent );
1255 checkSheetForGapWidthAndOverlap(xChartDoc, 50, 30);
1257 reload("Calc Office Open XML");
1259 xChartDoc = getChartDocFromSheet( 0, mxComponent );
1260 checkSheetForGapWidthAndOverlap(xChartDoc, 120, -60);
1262 xChartDoc = getChartDocFromSheet( 1, mxComponent );
1263 checkSheetForGapWidthAndOverlap(xChartDoc, 50, 30);
1266 void Chart2ExportTest::testSmoothedLines()
1268 load("/chart2/qa/extras/data/ods/", "smoothedLines.ods");
1269 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1270 CPPUNIT_ASSERT(pXmlDoc);
1271 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:smooth", "val", "0");
1274 void Chart2ExportTest::testLabelStringODS()
1276 load("/chart2/qa/extras/data/ods/", "labelString.ods");
1278 uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
1279 Reference< chart2::data::XDataSequence > xLabelSeq =
1280 getLabelDataSequenceFromDoc(xChartDoc);
1281 CPPUNIT_ASSERT(xLabelSeq.is());
1283 OUString aLabelString = xLabelSeq->getSourceRangeRepresentation();
1284 CPPUNIT_ASSERT_EQUAL(OUString("\"LabelName\""), aLabelString);
1286 reload("calc8");
1288 xChartDoc = getChartDocFromSheet( 0, mxComponent );
1289 xLabelSeq = getLabelDataSequenceFromDoc(xChartDoc);
1290 CPPUNIT_ASSERT(xLabelSeq.is());
1292 aLabelString = xLabelSeq->getSourceRangeRepresentation();
1293 CPPUNIT_ASSERT_EQUAL(OUString("\"LabelName\""), aLabelString);
1296 void Chart2ExportTest::testFdo83058dlblPos()
1298 load ("/chart2/qa/extras/data/docx/", "fdo83058_dlblPos.docx");
1299 xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
1300 CPPUNIT_ASSERT(pXmlDoc);
1301 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[2]/c:dLblPos", "val", "outEnd");
1302 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[3]/c:dLblPos", "val", "outEnd");
1303 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[4]/c:dLblPos", "val", "outEnd");
1304 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[5]/c:dLblPos", "val", "outEnd");
1307 void Chart2ExportTest::testAutoTitleDelXLSX()
1309 load("/chart2/qa/extras/data/xlsx/", "autotitledel_2007.xlsx");
1310 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
1311 CPPUNIT_ASSERT(pXmlDoc);
1312 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:autoTitleDeleted", "val", "0");
1315 void Chart2ExportTest::testDispBlanksAsXLSX()
1317 load("/chart2/qa/extras/data/xlsx/", "dispBlanksAs_2007.xlsx");
1318 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
1319 CPPUNIT_ASSERT(pXmlDoc);
1320 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "gap");
1323 void Chart2ExportTest::testMarkerColorXLSX()
1325 load("/chart2/qa/extras/data/xlsx/", "markerColor.xlsx");
1326 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1327 CPPUNIT_ASSERT(pXmlDoc);
1328 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:marker/c:spPr/a:solidFill/a:srgbClr", "val", "92d050");
1331 void Chart2ExportTest::testRoundedCornersXLSX()
1333 load("/chart2/qa/extras/data/xlsx/", "markerColor.xlsx");
1334 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1335 CPPUNIT_ASSERT(pXmlDoc);
1336 assertXPath(pXmlDoc, "/c:chartSpace/c:roundedCorners", "val", "0");
1339 void Chart2ExportTest::testAxisNumberFormatXLSX()
1341 load("/chart2/qa/extras/data/ods/", "axis_number_format.ods");
1342 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1343 CPPUNIT_ASSERT(pXmlDoc);
1344 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx", 2);
1345 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:numFmt", "formatCode", "0.00E+000");
1346 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:numFmt", "sourceLinked", "0");
1348 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:numFmt", "formatCode", "[$$-409]#,##0;\\-[$$-409]#,##0");
1349 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:numFmt", "sourceLinked", "1");
1352 void Chart2ExportTest::testDataLabelDefaultValuesXLSX()
1354 load("/chart2/qa/extras/data/xlsx/", "data_label.xlsx");
1355 Reference< chart2::XChartDocument> xDoc = getChartDocFromSheet(0, mxComponent);
1356 Reference<chart2::XDataSeries> xSeries = getDataSeriesFromDoc(xDoc, 0);
1357 Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY_THROW);
1358 uno::Any aAny = xPropSet->getPropertyValue("Label");
1359 chart2::DataPointLabel aLabel;
1360 CPPUNIT_ASSERT(aAny >>= aLabel);
1361 CPPUNIT_ASSERT(aLabel.ShowNumber);
1363 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1364 CPPUNIT_ASSERT(pXmlDoc);
1365 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:showVal", "val", "1");
1366 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLblPos", "val", "outEnd");
1369 void Chart2ExportTest::testTitleOverlayXLSX()
1371 load("/chart2/qa/extras/data/xlsx/", "chart_title.xlsx");
1372 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1373 CPPUNIT_ASSERT(pXmlDoc);
1374 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:overlay", "val", "0");
1377 void Chart2ExportTest::testInvertIfNegativeXLSX()
1379 load("/chart2/qa/extras/data/xlsx/", "bar_chart_simple.xlsx");
1380 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1381 CPPUNIT_ASSERT(pXmlDoc);
1382 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:invertIfNegative", "val", "0");
1385 void Chart2ExportTest::testBubble3DXLSX()
1387 load("/chart2/qa/extras/data/xlsx/", "bubble_chart_simple.xlsx");
1388 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1389 CPPUNIT_ASSERT(pXmlDoc);
1390 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:bubbleChart/c:bubble3D", "val", "0");
1393 void Chart2ExportTest::testNoMarkerXLSX()
1395 load("/chart2/qa/extras/data/xlsx/", "no_marker.xlsx");
1396 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1397 CPPUNIT_ASSERT(pXmlDoc);
1398 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:marker/c:symbol", "val", "none");
1399 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:marker/c:symbol", "val", "none");
1400 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:marker", "val", "0");
1403 void Chart2ExportTest::testTitleManualLayoutXLSX()
1405 load("/chart2/qa/extras/data/xlsx/", "title_manual_layout.xlsx");
1406 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1407 CPPUNIT_ASSERT(pXmlDoc);
1408 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:xMode", "val", "edge");
1409 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:yMode", "val", "edge");
1411 OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:x", "val");
1412 double nX = aXVal.toDouble();
1413 CPPUNIT_ASSERT(nX > 0 && nX < 1);
1415 OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:y", "val");
1416 double nY = aYVal.toDouble();
1417 CPPUNIT_ASSERT(nY > 0 && nY < 1);
1418 CPPUNIT_ASSERT(nX != nY);
1420 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:bodyPr", "rot", "1200000");
1423 void Chart2ExportTest::testPlotAreaManualLayoutXLSX()
1425 load("/chart2/qa/extras/data/xlsx/", "plot_area_manual_layout.xlsx");
1426 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1427 CPPUNIT_ASSERT(pXmlDoc);
1429 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:xMode", "val", "edge");
1430 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:yMode", "val", "edge");
1432 OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:x", "val");
1433 double nX = aXVal.toDouble();
1434 CPPUNIT_ASSERT(nX > 0 && nX < 1);
1436 OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:y", "val");
1437 double nY = aYVal.toDouble();
1438 CPPUNIT_ASSERT(nY > 0 && nY < 1);
1439 CPPUNIT_ASSERT(nX != nY);
1441 OUString aWVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:w", "val");
1442 double nW = aWVal.toDouble();
1443 CPPUNIT_ASSERT(nW > 0 && nW < 1);
1445 OUString aHVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:h", "val");
1446 double nH = aHVal.toDouble();
1447 CPPUNIT_ASSERT(nH > 0 && nH < 1);
1448 CPPUNIT_ASSERT(nH != nW);
1451 void Chart2ExportTest::testLegendManualLayoutXLSX()
1453 load("/chart2/qa/extras/data/xlsx/", "legend_manual_layout.xlsx");
1454 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1455 CPPUNIT_ASSERT(pXmlDoc);
1457 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:xMode", "val", "edge");
1458 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:yMode", "val", "edge");
1460 OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:x", "val");
1461 double nX = aXVal.toDouble();
1462 CPPUNIT_ASSERT(nX > 0 && nX < 1);
1464 OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:y", "val");
1465 double nY = aYVal.toDouble();
1466 CPPUNIT_ASSERT(nY > 0 && nY < 1);
1467 CPPUNIT_ASSERT(nX != nY);
1470 void Chart2ExportTest::testAxisCharacterPropertiesXLSX()
1472 load("/chart2/qa/extras/data/xlsx/", "axis_character_properties.xlsx");
1473 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1474 CPPUNIT_ASSERT(pXmlDoc);
1476 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "sz", "1000");
1477 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "b", "1");
1478 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "i", "1");
1479 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "u", "sng");
1481 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr", "sz", "900");
1482 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr", "b", "1");
1483 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr", "strike", "sngStrike");
1484 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr", "val", "ff0000");
1487 void Chart2ExportTest::testTitleCharacterPropertiesXLSX()
1489 load("/chart2/qa/extras/data/xlsx/", "title_character_properties.xlsx");
1490 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1491 CPPUNIT_ASSERT(pXmlDoc);
1493 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "sz", "2400");
1494 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "b", "1");
1496 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr", "sz", "2400");
1497 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr", "b", "1");
1500 void Chart2ExportTest::testPlotVisOnlyXLSX()
1502 load("/chart2/qa/extras/data/xlsx/", "hidden_cells.xlsx");
1503 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1504 CPPUNIT_ASSERT(pXmlDoc);
1506 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotVisOnly", "val", "0");
1509 void Chart2ExportTest::testBarChartVaryColorsXLSX()
1511 load("/chart2/qa/extras/data/xlsx/", "tdf90876.xlsx");
1512 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1513 CPPUNIT_ASSERT(pXmlDoc);
1515 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", "0");
1518 void Chart2ExportTest::testMultipleAxisXLSX()
1520 load("/chart2/qa/extras/data/ods/", "multiple_axis.ods");
1521 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1522 CPPUNIT_ASSERT(pXmlDoc);
1524 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart", 2);
1525 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart[1]/c:ser", 1);
1526 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart[2]/c:ser", 1);
1527 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx", 4);
1528 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:delete[@val='1']", 1);
1529 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:axPos[@val='l']", 1);
1530 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:axPos[@val='r']", 1);
1533 void Chart2ExportTest::testAxisTitleRotationXLSX()
1535 load("/chart2/qa/extras/data/xlsx/", "axis_title_rotation.xlsx");
1536 xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
1537 CPPUNIT_ASSERT(pXmlDoc);
1539 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:tx/c:rich/a:bodyPr", "rot", "0");
1542 void Chart2ExportTest::testAxisCrossBetweenXSLX()
1544 load("/chart2/qa/extras/data/odt/", "axis-position.odt");
1545 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
1546 assertXPath(pXmlDoc, "(//c:crossBetween)[1]", "val", "midCat");
1549 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
1551 CPPUNIT_PLUGIN_IMPLEMENT();
1553 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */