1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include "charttest.hxx"
12 #include <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>
32 using beans::XPropertySet
;
34 class Chart2ExportTest
: public ChartTest
, public XmlTestTools
38 virtual void registerNamespaces(xmlXPathContextPtr
& pXmlXPathCtx
) SAL_OVERRIDE
;
40 Chart2ExportTest() : ChartTest() {}
41 void testErrorBarXLSX();
43 void testTrendlineOOXML();
44 void testTrendlineXLS();
45 void testStockChart();
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 testDataLabelBordersDOCX();
75 void testDataLabel3DChartDOCX();
76 void testDataLabelBarChartDOCX();
77 void testDataLabelClusteredBarChartDOCX();
78 void testDataLabelRadarChartDOCX();
79 void testDataLabelDoughnutChartDOCX();
80 void testDataLabelAreaChartDOCX();
81 void testDataLabelDefaultLineChartDOCX();
82 void testFdo83058dlblPos();
83 void testAutoTitleDelXLSX();
84 void testDispBlanksAsXLSX();
85 void testMarkerColorXLSX();
86 void testRoundedCornersXLSX();
87 void testAxisNumberFormatXLSX();
88 void testDataLabelDefaultValuesXLSX();
89 void testTitleOverlayXLSX();
90 void testInvertIfNegativeXLSX();
91 void testBubble3DXLSX();
92 void testNoMarkerXLSX();
93 void testTitleManualLayoutXLSX();
94 void testPlotAreaManualLayoutXLSX();
95 void testLegendManualLayoutXLSX();
96 void testAxisCharacterPropertiesXLSX();
97 void testTitleCharacterPropertiesXLSX();
98 void testPlotVisOnlyXLSX();
99 void testBarChartVaryColorsXLSX();
100 void testMultipleAxisXLSX();
102 CPPUNIT_TEST_SUITE(Chart2ExportTest
);
103 CPPUNIT_TEST(testErrorBarXLSX
);
104 CPPUNIT_TEST(testTrendline
);
105 CPPUNIT_TEST(testTrendlineOOXML
);
106 CPPUNIT_TEST(testTrendlineXLS
);
107 CPPUNIT_TEST(testStockChart
);
108 CPPUNIT_TEST(testBarChart
);
109 CPPUNIT_TEST(testCrosses
);
110 CPPUNIT_TEST(testScatterChartTextXValues
);
111 CPPUNIT_TEST(testChartDataTable
);
112 CPPUNIT_TEST(testChartExternalData
);
113 CPPUNIT_TEST(testEmbeddingsGrabBag
);
114 CPPUNIT_TEST(testAreaChartLoad
);
115 CPPUNIT_TEST(testUpDownBars
);
116 CPPUNIT_TEST(testDoughnutChart
);
117 CPPUNIT_TEST(testDisplayUnits
);
118 // CPPUNIT_TEST(testFdo74115WallGradientFill);
119 CPPUNIT_TEST(testFdo74115WallBitmapFill
);
120 CPPUNIT_TEST(testBarChartRotation
);
121 CPPUNIT_TEST(testShapeFollowedByChart
);
122 CPPUNIT_TEST(testPieChartDataLabels
);
123 CPPUNIT_TEST(testSeriesIdxOrder
);
124 CPPUNIT_TEST(testScatterPlotLabels
);
125 CPPUNIT_TEST(testErrorBarDataRangeODS
);
126 CPPUNIT_TEST(testChartCrash
);
127 CPPUNIT_TEST(testPieChartRotation
);
128 CPPUNIT_TEST(testEmbeddingsOleObjectGrabBag
);
129 CPPUNIT_TEST(testGapWidthXLSX
);
130 CPPUNIT_TEST(testSmoothedLines
);
131 CPPUNIT_TEST(testLabelStringODS
);
132 CPPUNIT_TEST(testFdo78290LineChartMarkerX
);
133 CPPUNIT_TEST(testFdo78290ScatterChartMarkerX
);
134 CPPUNIT_TEST(testFdo78290CombinationChartMarkerX
);
135 CPPUNIT_TEST(testAxisNumberFormatODS
);
136 CPPUNIT_TEST(testDataLabelBordersDOCX
);
137 CPPUNIT_TEST(testDataLabel3DChartDOCX
);
138 CPPUNIT_TEST(testDataLabelBarChartDOCX
);
139 CPPUNIT_TEST(testDataLabelClusteredBarChartDOCX
);
140 CPPUNIT_TEST(testDataLabelRadarChartDOCX
);
141 CPPUNIT_TEST(testDataLabelDoughnutChartDOCX
);
142 CPPUNIT_TEST(testDataLabelAreaChartDOCX
);
143 CPPUNIT_TEST(testDataLabelDefaultLineChartDOCX
);
144 CPPUNIT_TEST(testFdo83058dlblPos
);
145 CPPUNIT_TEST(testAutoTitleDelXLSX
);
146 CPPUNIT_TEST(testDispBlanksAsXLSX
);
147 CPPUNIT_TEST(testMarkerColorXLSX
);
148 CPPUNIT_TEST(testRoundedCornersXLSX
);
149 CPPUNIT_TEST(testAxisNumberFormatXLSX
);
150 CPPUNIT_TEST(testDataLabelDefaultValuesXLSX
);
151 CPPUNIT_TEST(testTitleOverlayXLSX
);
152 CPPUNIT_TEST(testInvertIfNegativeXLSX
);
153 CPPUNIT_TEST(testBubble3DXLSX
);
154 CPPUNIT_TEST(testNoMarkerXLSX
);
155 CPPUNIT_TEST(testTitleManualLayoutXLSX
);
156 CPPUNIT_TEST(testPlotAreaManualLayoutXLSX
);
157 CPPUNIT_TEST(testLegendManualLayoutXLSX
);
158 CPPUNIT_TEST(testAxisCharacterPropertiesXLSX
);
159 CPPUNIT_TEST(testTitleCharacterPropertiesXLSX
);
160 CPPUNIT_TEST(testPlotVisOnlyXLSX
);
161 CPPUNIT_TEST(testBarChartVaryColorsXLSX
);
162 CPPUNIT_TEST(testMultipleAxisXLSX
);
163 CPPUNIT_TEST_SUITE_END();
167 * Given that some problem doesn't affect the result in the importer, we
168 * test the resulting file directly, by opening the zip file, parsing an
169 * xml stream, and asserting an XPath expression. This method returns the
170 * xml stream, so that you can do the asserting.
172 xmlDocPtr
parseExport(const OUString
& rDir
, const OUString
& rFilterFormat
);
178 struct CheckForChartName
184 CheckForChartName( const OUString
& rDir
):
187 bool operator()(const OUString
& rName
)
189 if(!rName
.startsWith(aDir
))
192 if(!rName
.endsWith(".xml"))
199 OUString
findChartFile(const OUString
& rDir
, uno::Reference
< container::XNameAccess
> xNames
)
201 uno::Sequence
<OUString
> rNames
= xNames
->getElementNames();
202 OUString
* pElement
= std::find_if(rNames
.begin(), rNames
.end(), CheckForChartName(rDir
));
204 CPPUNIT_ASSERT(pElement
);
205 CPPUNIT_ASSERT(pElement
!= rNames
.end());
211 xmlDocPtr
Chart2ExportTest::parseExport(const OUString
& rDir
, const OUString
& rFilterFormat
)
213 boost::shared_ptr
<utl::TempFile
> pTempFile
= reload(rFilterFormat
);
215 // Read the XML stream we're interested in.
216 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory
), pTempFile
->GetURL());
217 uno::Reference
<io::XInputStream
> xInputStream(xNameAccess
->getByName(findChartFile(rDir
, xNameAccess
)), uno::UNO_QUERY
);
218 CPPUNIT_ASSERT(xInputStream
.is());
219 boost::shared_ptr
<SvStream
> pStream(utl::UcbStreamHelper::CreateStream(xInputStream
, true));
221 return parseXmlStream(pStream
.get());
224 void Chart2ExportTest::registerNamespaces(xmlXPathContextPtr
& pXmlXPathCtx
)
226 struct { xmlChar
* pPrefix
; xmlChar
* pURI
; } aNamespaces
[] =
228 { BAD_CAST("w"), BAD_CAST("http://schemas.openxmlformats.org/wordprocessingml/2006/main") },
229 { BAD_CAST("v"), BAD_CAST("urn:schemas-microsoft-com:vml") },
230 { BAD_CAST("c"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart") },
231 { BAD_CAST("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main") },
232 { BAD_CAST("mc"), BAD_CAST("http://schemas.openxmlformats.org/markup-compatibility/2006") },
233 { BAD_CAST("wps"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingShape") },
234 { BAD_CAST("wpg"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup") },
235 { BAD_CAST("wp"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing") },
236 { BAD_CAST("office"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0") },
237 { BAD_CAST("table"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:table:1.0") },
238 { BAD_CAST("text"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:text:1.0") },
239 { BAD_CAST("xlink"), BAD_CAST("http://www.w3c.org/1999/xlink") }
241 for(size_t i
= 0; i
< SAL_N_ELEMENTS(aNamespaces
); ++i
)
243 xmlXPathRegisterNs(pXmlXPathCtx
, aNamespaces
[i
].pPrefix
, aNamespaces
[i
].pURI
);
249 void testErrorBar( Reference
< XPropertySet
> xErrorBar
)
251 sal_Int32 nErrorBarStyle
;
253 xErrorBar
->getPropertyValue("ErrorBarStyle") >>= nErrorBarStyle
);
254 CPPUNIT_ASSERT_EQUAL(nErrorBarStyle
, chart::ErrorBarStyle::RELATIVE
);
255 bool bShowPositive
= bool(), bShowNegative
= bool();
257 xErrorBar
->getPropertyValue("ShowPositiveError") >>= bShowPositive
);
258 CPPUNIT_ASSERT(bShowPositive
);
260 xErrorBar
->getPropertyValue("ShowNegativeError") >>= bShowNegative
);
261 CPPUNIT_ASSERT(bShowNegative
);
263 CPPUNIT_ASSERT(xErrorBar
->getPropertyValue("PositiveError") >>= nVal
);
264 CPPUNIT_ASSERT_DOUBLES_EQUAL(nVal
, 10.0, 1e-10);
267 void checkCommonTrendline(
268 Reference
<chart2::XRegressionCurve
> xCurve
,
269 double aExpectedExtrapolateForward
, double aExpectedExtrapolateBackward
,
270 bool aExpectedForceIntercept
, double aExpectedInterceptValue
,
271 bool aExpectedShowEquation
, bool aExpectedR2
)
273 Reference
<XPropertySet
> xProperties( xCurve
, uno::UNO_QUERY
);
274 CPPUNIT_ASSERT(xProperties
.is());
276 double aExtrapolateForward
= 0.0;
277 CPPUNIT_ASSERT(xProperties
->getPropertyValue("ExtrapolateForward") >>= aExtrapolateForward
);
278 CPPUNIT_ASSERT_EQUAL(aExpectedExtrapolateForward
, aExtrapolateForward
);
280 double aExtrapolateBackward
= 0.0;
281 CPPUNIT_ASSERT(xProperties
->getPropertyValue("ExtrapolateBackward") >>= aExtrapolateBackward
);
282 CPPUNIT_ASSERT_EQUAL(aExpectedExtrapolateBackward
, aExtrapolateBackward
);
284 bool aForceIntercept
= false;
285 CPPUNIT_ASSERT(xProperties
->getPropertyValue("ForceIntercept") >>= aForceIntercept
);
286 CPPUNIT_ASSERT_EQUAL(aExpectedForceIntercept
, aForceIntercept
);
290 double aInterceptValue
= 0.0;
291 CPPUNIT_ASSERT(xProperties
->getPropertyValue("InterceptValue") >>= aInterceptValue
);
292 CPPUNIT_ASSERT_EQUAL(aExpectedInterceptValue
, aInterceptValue
);
295 Reference
< XPropertySet
> xEquationProperties( xCurve
->getEquationProperties() );
296 CPPUNIT_ASSERT(xEquationProperties
.is());
298 bool aShowEquation
= false;
299 CPPUNIT_ASSERT(xEquationProperties
->getPropertyValue("ShowEquation") >>= aShowEquation
);
300 CPPUNIT_ASSERT_EQUAL(aExpectedShowEquation
, aShowEquation
);
302 bool aShowCorrelationCoefficient
= false;
303 CPPUNIT_ASSERT(xEquationProperties
->getPropertyValue("ShowCorrelationCoefficient") >>= aShowCorrelationCoefficient
);
304 CPPUNIT_ASSERT_EQUAL(aExpectedR2
, aShowCorrelationCoefficient
);
307 void checkNameAndType(Reference
<XPropertySet
> xProperties
, const OUString
& aExpectedName
, const OUString
& aExpectedServiceName
)
309 Reference
< lang::XServiceName
> xServiceName( xProperties
, UNO_QUERY
);
310 CPPUNIT_ASSERT(xServiceName
.is());
312 OUString aServiceName
= xServiceName
->getServiceName();
313 CPPUNIT_ASSERT_EQUAL(aExpectedServiceName
, aServiceName
);
316 CPPUNIT_ASSERT(xProperties
->getPropertyValue("CurveName") >>= aCurveName
);
317 CPPUNIT_ASSERT_EQUAL(aExpectedName
, aCurveName
);
320 void checkLinearTrendline(
321 Reference
<chart2::XRegressionCurve
> xCurve
, const OUString
& aExpectedName
,
322 double aExpectedExtrapolateForward
, double aExpectedExtrapolateBackward
,
323 bool aExpectedForceIntercept
, double aExpectedInterceptValue
,
324 bool aExpectedShowEquation
, bool aExpectedR2
)
326 Reference
<XPropertySet
> xProperties( xCurve
, uno::UNO_QUERY
);
327 CPPUNIT_ASSERT(xProperties
.is());
329 checkNameAndType(xProperties
, aExpectedName
, "com.sun.star.chart2.LinearRegressionCurve");
331 checkCommonTrendline(
333 aExpectedExtrapolateForward
, aExpectedExtrapolateBackward
,
334 aExpectedForceIntercept
, aExpectedInterceptValue
,
335 aExpectedShowEquation
, aExpectedR2
);
338 void checkPolynomialTrendline(
339 Reference
<chart2::XRegressionCurve
> xCurve
, const OUString
& aExpectedName
,
340 sal_Int32 aExpectedDegree
,
341 double aExpectedExtrapolateForward
, double aExpectedExtrapolateBackward
,
342 bool aExpectedForceIntercept
, double aExpectedInterceptValue
,
343 bool aExpectedShowEquation
, bool aExpectedR2
)
345 Reference
<XPropertySet
> xProperties( xCurve
, uno::UNO_QUERY
);
346 CPPUNIT_ASSERT(xProperties
.is());
348 checkNameAndType(xProperties
, aExpectedName
, "com.sun.star.chart2.PolynomialRegressionCurve");
350 sal_Int32 aDegree
= 2;
351 CPPUNIT_ASSERT(xProperties
->getPropertyValue("PolynomialDegree") >>= aDegree
);
352 CPPUNIT_ASSERT_EQUAL(aExpectedDegree
, aDegree
);
354 checkCommonTrendline(
356 aExpectedExtrapolateForward
, aExpectedExtrapolateBackward
,
357 aExpectedForceIntercept
, aExpectedInterceptValue
,
358 aExpectedShowEquation
, aExpectedR2
);
361 void checkMovingAverageTrendline(
362 Reference
<chart2::XRegressionCurve
> xCurve
, const OUString
& aExpectedName
, sal_Int32 aExpectedPeriod
)
364 Reference
<XPropertySet
> xProperties( xCurve
, uno::UNO_QUERY
);
365 CPPUNIT_ASSERT(xProperties
.is());
367 checkNameAndType(xProperties
, aExpectedName
, "com.sun.star.chart2.MovingAverageRegressionCurve");
369 sal_Int32 aPeriod
= 2;
370 CPPUNIT_ASSERT(xProperties
->getPropertyValue("MovingAveragePeriod") >>= aPeriod
);
371 CPPUNIT_ASSERT_EQUAL(aExpectedPeriod
, aPeriod
);
374 void checkTrendlinesInChart(uno::Reference
< chart2::XChartDocument
> xChartDoc
)
376 CPPUNIT_ASSERT(xChartDoc
.is());
378 Reference
< chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc( xChartDoc
, 0 );
379 CPPUNIT_ASSERT( xDataSeries
.is() );
381 Reference
< chart2::XRegressionCurveContainer
> xRegressionCurveContainer( xDataSeries
, UNO_QUERY
);
382 CPPUNIT_ASSERT( xRegressionCurveContainer
.is() );
384 Sequence
< Reference
< chart2::XRegressionCurve
> > xRegressionCurveSequence
= xRegressionCurveContainer
->getRegressionCurves();
385 CPPUNIT_ASSERT_EQUAL((sal_Int32
) 3, xRegressionCurveSequence
.getLength());
387 Reference
<chart2::XRegressionCurve
> xCurve
;
389 xCurve
= xRegressionCurveSequence
[0];
390 CPPUNIT_ASSERT(xCurve
.is());
391 checkPolynomialTrendline(xCurve
, "col2_poly", 3, 0.1, -0.1, true, -1.0, true, true);
393 xCurve
= xRegressionCurveSequence
[1];
394 CPPUNIT_ASSERT(xCurve
.is());
395 checkLinearTrendline(xCurve
, "col2_linear", -0.5, -0.5, false, 0.0, true, false);
397 xCurve
= xRegressionCurveSequence
[2];
398 CPPUNIT_ASSERT(xCurve
.is());
399 checkMovingAverageTrendline(xCurve
, "col2_moving_avg", 3);
405 void Chart2ExportTest::testErrorBarXLSX()
407 load("/chart2/qa/extras/data/ods/", "error_bar.ods");
409 // make sure the ODS import was successful
410 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
411 CPPUNIT_ASSERT(xChartDoc
.is());
413 Reference
< chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc( xChartDoc
, 0 );
414 CPPUNIT_ASSERT( xDataSeries
.is() );
416 Reference
< beans::XPropertySet
> xPropSet( xDataSeries
, UNO_QUERY_THROW
);
417 CPPUNIT_ASSERT( xPropSet
.is() );
419 // test that y error bars are there
420 Reference
< beans::XPropertySet
> xErrorBarYProps
;
421 xPropSet
->getPropertyValue(CHART_UNONAME_ERRORBAR_Y
) >>= xErrorBarYProps
;
422 testErrorBar(xErrorBarYProps
);
425 reload("Calc Office Open XML");
427 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
428 CPPUNIT_ASSERT(xChartDoc
.is());
430 Reference
< chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc( xChartDoc
, 0 );
431 CPPUNIT_ASSERT( xDataSeries
.is() );
433 Reference
< beans::XPropertySet
> xPropSet( xDataSeries
, UNO_QUERY_THROW
);
434 CPPUNIT_ASSERT( xPropSet
.is() );
436 // test that y error bars are there
437 Reference
< beans::XPropertySet
> xErrorBarYProps
;
438 xPropSet
->getPropertyValue(CHART_UNONAME_ERRORBAR_Y
) >>= xErrorBarYProps
;
439 testErrorBar(xErrorBarYProps
);
443 // This method tests the preservation of properties for trendlines / regression curves
444 // in an export -> import cycle using different file formats - ODS, XLS and XLSX.
445 void Chart2ExportTest::testTrendline()
447 mbSkipValidation
= true;
448 load("/chart2/qa/extras/data/ods/", "trendline.ods");
449 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent
));
451 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent
));
454 void Chart2ExportTest::testTrendlineOOXML()
456 load("/chart2/qa/extras/data/ods/", "trendline.ods");
457 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent
));
458 reload("Calc Office Open XML");
459 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent
));
462 void Chart2ExportTest::testTrendlineXLS()
464 load("/chart2/qa/extras/data/ods/", "trendline.ods");
465 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent
));
466 reload("MS Excel 97");
467 checkTrendlinesInChart(getChartDocFromSheet( 0, mxComponent
));
470 void Chart2ExportTest::testStockChart()
472 /* For attached file Stock_Chart.docx, in chart1.xml,
473 * <c:stockChart>, there are four types of series as
474 * Open,Low,High and Close.
475 * For Open series, in <c:idx val="0" />
476 * an attribute val of index should start from 1 and not from 0.
477 * Which was problem area.
479 load("/chart2/qa/extras/data/docx/", "testStockChart.docx");
481 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
485 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:stockChart/c:ser[1]/c:idx", "val", "1");
486 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:stockChart/c:ser[1]/c:order", "val", "1");
487 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:stockChart/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v", "Open");
490 void Chart2ExportTest::testBarChart()
492 load("/chart2/qa/extras/data/docx/", "testBarChart.docx");
493 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
497 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:barDir", "val", "col");
500 void Chart2ExportTest::testCrosses()
502 load("/chart2/qa/extras/data/docx/", "Bar_horizontal_cone.docx");
503 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
505 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:crosses", "val", "autoZero");
508 void Chart2ExportTest::testScatterChartTextXValues()
510 load("/chart2/qa/extras/data/docx/", "scatter-chart-text-x-values.docx");
512 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
513 CPPUNIT_ASSERT(xChartDoc
.is());
515 Reference
<chart2::XChartType
> xCT
= getChartTypeFromDoc(xChartDoc
, 0, 0);
516 CPPUNIT_ASSERT(xCT
.is());
518 // Make sure we have exactly 3 data series.
519 std::vector
<uno::Sequence
<uno::Any
> > aLabels
= getDataSeriesLabelsFromChartType(xCT
);
520 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels
.size());
521 CPPUNIT_ASSERT_EQUAL(OUString("Series 1"), aLabels
[0][0].get
<OUString
>());
522 CPPUNIT_ASSERT_EQUAL(OUString("Series 2"), aLabels
[1][0].get
<OUString
>());
523 CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), aLabels
[2][0].get
<OUString
>());
525 std::vector
<std::vector
<double> > aYValues
= getDataSeriesYValuesFromChartType(xCT
);
526 CPPUNIT_ASSERT_EQUAL(size_t(3), aYValues
.size());
528 // Check the Y values of "Series 1".
529 CPPUNIT_ASSERT_EQUAL(size_t(4), aYValues
[0].size());
530 CPPUNIT_ASSERT_EQUAL(4.3, aYValues
[0][0]);
531 CPPUNIT_ASSERT_EQUAL(2.5, aYValues
[0][1]);
532 CPPUNIT_ASSERT_EQUAL(3.5, aYValues
[0][2]);
533 CPPUNIT_ASSERT_EQUAL(4.5, aYValues
[0][3]);
536 CPPUNIT_ASSERT_EQUAL(size_t(4), aYValues
[1].size());
537 CPPUNIT_ASSERT_EQUAL(2.4, aYValues
[1][0]);
538 CPPUNIT_ASSERT_EQUAL(4.4, aYValues
[1][1]);
539 CPPUNIT_ASSERT_EQUAL(1.8, aYValues
[1][2]);
540 CPPUNIT_ASSERT_EQUAL(2.8, aYValues
[1][3]);
543 CPPUNIT_ASSERT_EQUAL(size_t(4), aYValues
[2].size());
544 CPPUNIT_ASSERT_EQUAL(2.0, aYValues
[2][0]);
545 CPPUNIT_ASSERT_EQUAL(2.0, aYValues
[2][1]);
546 CPPUNIT_ASSERT_EQUAL(3.0, aYValues
[2][2]);
547 CPPUNIT_ASSERT_EQUAL(5.0, aYValues
[2][3]);
550 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
554 assertXPathContent(pXmlDoc
, "//c:scatterChart/c:ser[1]/c:xVal[1]/c:numRef[1]/c:numCache[1]/c:pt[1]/c:v[1]", "1");
557 void Chart2ExportTest::testChartDataTable()
559 load("/chart2/qa/extras/data/docx/", "testChartDataTable.docx");
561 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
562 CPPUNIT_ASSERT(pXmlDoc
);
563 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:dTable/c:showHorzBorder", "val", "1");
564 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:dTable/c:showVertBorder", "val", "1");
565 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:dTable/c:showOutline", "val", "1");
568 void Chart2ExportTest::testChartExternalData()
570 load("/chart2/qa/extras/data/docx/", "testMultipleChart.docx");
572 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
573 CPPUNIT_ASSERT(pXmlDoc
);
574 xmlXPathObjectPtr pXmlPathObj
= getXPathNode(pXmlDoc
, "/c:chartSpace/c:externalData");
575 xmlNodeSetPtr pXmlNodes
= pXmlPathObj
->nodesetval
;
576 CPPUNIT_ASSERT(pXmlNodes
);
579 void Chart2ExportTest::testEmbeddingsGrabBag()
581 // The problem was that .xlsx files were missing from docx file from embeddings folder
582 // after saving file.
583 // This test case tests whether embeddings files grabbagged properly in correct object.
585 load("/chart2/qa/extras/data/docx/", "testMultiplechartembeddings.docx" );
586 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
587 uno::Reference
<beans::XPropertySet
> xTextDocumentPropertySet(xTextDocument
, uno::UNO_QUERY
);
588 uno::Sequence
<beans::PropertyValue
> aGrabBag(0);
589 xTextDocumentPropertySet
->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag
;
590 CPPUNIT_ASSERT(aGrabBag
.hasElements()); // Grab Bag not empty
591 bool bEmbeddings
= false;
592 const char* testEmbeddedFileNames
[3] = {"word/embeddings/Microsoft_Excel_Worksheet3.xlsx",
593 "word/embeddings/Microsoft_Excel_Worksheet2.xlsx",
594 "word/embeddings/Microsoft_Excel_Worksheet1.xlsx"};
595 for(int i
= 0; i
< aGrabBag
.getLength(); ++i
)
597 if (aGrabBag
[i
].Name
== "OOXEmbeddings")
600 uno::Sequence
<beans::PropertyValue
> aEmbeddingsList(0);
601 uno::Reference
<io::XInputStream
> aEmbeddingXlsxStream
;
602 OUString aEmbeddedfileName
;
603 CPPUNIT_ASSERT(aGrabBag
[i
].Value
>>= aEmbeddingsList
); // PropertyValue of proper type
604 sal_Int32 length
= aEmbeddingsList
.getLength();
605 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), length
);
606 for(int j
= 0; j
< length
; ++j
)
608 aEmbeddingsList
[j
].Value
>>= aEmbeddingXlsxStream
;
609 aEmbeddedfileName
= aEmbeddingsList
[j
].Name
;
610 CPPUNIT_ASSERT(aEmbeddingXlsxStream
.get()); // Reference not empty
611 CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(testEmbeddedFileNames
[j
]),aEmbeddedfileName
);
615 CPPUNIT_ASSERT(bEmbeddings
); // Grab Bag has all the expected elements
618 void Chart2ExportTest::testAreaChartLoad()
620 load ("/chart2/qa/extras/data/docx/", "testAreaChartLoad.docx");
621 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart","Office Open XML Text");
622 CPPUNIT_ASSERT(pXmlDoc
);
623 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:showVal", "val", "1");
624 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:dLbl", 0);
627 void Chart2ExportTest::testUpDownBars()
630 load("/chart2/qa/extras/data/docx/", "UpDownBars.docx");
631 xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
632 CPPUNIT_ASSERT(pXmlDoc);
633 assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:upDownBars");
637 void Chart2ExportTest::testDoughnutChart()
639 load("/chart2/qa/extras/data/docx/", "doughnutChart.docx");
640 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
641 CPPUNIT_ASSERT(pXmlDoc
);
643 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart", "1");
646 void Chart2ExportTest::testDisplayUnits()
648 load("/chart2/qa/extras/data/docx/", "DisplayUnits.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:valAx/c:dispUnits/c:builtInUnit", "val", "billions");
655 // void Chart2ExportTest::testFdo74115WallGradientFill()
657 // load("/chart2/qa/extras/data/docx/", "fdo74115_WallGradientFill.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:spPr/a:gradFill");
664 void Chart2ExportTest::testFdo74115WallBitmapFill()
666 load("/chart2/qa/extras/data/docx/", "fdo74115_WallBitmapFill.docx");
667 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
668 CPPUNIT_ASSERT(pXmlDoc
);
669 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:blipFill");
672 //The below test case tests the built in marker 'x' for Office 2010 in Line charts
674 void Chart2ExportTest::testFdo78290LineChartMarkerX()
676 load("/chart2/qa/extras/data/docx/", "fdo78290_Line_Chart_Marker_x.docx");
677 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
678 CPPUNIT_ASSERT(pXmlDoc
);
679 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");
680 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");
683 // We can also use the built in marker 'x' in scatter chart, hence writing the test case for the same.
685 void Chart2ExportTest::testFdo78290ScatterChartMarkerX()
687 load("/chart2/qa/extras/data/docx/", "fdo78290_Scatter_Chart_Marker_x.docx");
688 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
689 CPPUNIT_ASSERT(pXmlDoc
);
690 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");
691 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");
694 // Also in a combination of charts like a column chart and line chart, we can use the built in marker 'x'
695 // for the line chart too. hence put a test case for the combination chart also.
697 void Chart2ExportTest::testFdo78290CombinationChartMarkerX()
699 load("/chart2/qa/extras/data/docx/", "fdo78290_Combination_Chart_Marker_x.docx");
700 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
701 CPPUNIT_ASSERT(pXmlDoc
);
702 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");
703 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");
706 void Chart2ExportTest::testAxisNumberFormatODS()
710 void check( const Reference
<chart2::XChartDocument
>& xChartDoc
)
712 Reference
<chart2::XAxis
> xAxisX
= getAxisFromDoc(xChartDoc
, 0, 0, 0);
713 Reference
<chart2::XTitled
> xTitle(xAxisX
, UNO_QUERY_THROW
);
714 OUString aTitleText
= getTitleString(xTitle
);
715 CPPUNIT_ASSERT_EQUAL(OUString("Linked To Source"), aTitleText
);
717 sal_Int32 nNumFmt
= getNumberFormatFromAxis(xAxisX
);
718 sal_Int16 nType
= getNumberFormatType(xChartDoc
, nNumFmt
);
719 CPPUNIT_ASSERT_MESSAGE("X axis should be percentage format.", (nType
& util::NumberFormat::PERCENT
));
721 bool bNumFmtLinked
= false;
722 Reference
<beans::XPropertySet
> xPS(xAxisX
, uno::UNO_QUERY_THROW
);
723 xPS
->getPropertyValue("LinkNumberFormatToSource") >>= bNumFmtLinked
;
724 CPPUNIT_ASSERT_MESSAGE("X axis should have its number format linked to source.", bNumFmtLinked
);
726 Reference
<chart2::XAxis
> xAxisY
= getAxisFromDoc(xChartDoc
, 0, 1, 0);
727 xTitle
.set(xAxisY
, UNO_QUERY_THROW
);
728 aTitleText
= getTitleString(xTitle
);
729 CPPUNIT_ASSERT_EQUAL(OUString("Not Linked"), aTitleText
);
731 nNumFmt
= getNumberFormatFromAxis(xAxisY
);
732 nType
= getNumberFormatType(xChartDoc
, nNumFmt
);
733 CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType
& util::NumberFormat::NUMBER
));
735 bNumFmtLinked
= true;
736 xPS
.set(xAxisY
, uno::UNO_QUERY_THROW
);
737 xPS
->getPropertyValue("LinkNumberFormatToSource") >>= bNumFmtLinked
;
738 CPPUNIT_ASSERT_MESSAGE("Y axis should not have its number format linked to source.", !bNumFmtLinked
);
743 load("/chart2/qa/extras/data/ods/", "axis-numformats-linked.ods");
745 Reference
<chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet(0, mxComponent
);
746 aTest
.check(xChartDoc
);
748 // Reload the document and make sure everything remains intact.
750 xChartDoc
= getChartDocFromSheet(0, mxComponent
);
751 aTest
.check(xChartDoc
);
754 void Chart2ExportTest::testDataLabelBordersDOCX()
759 css::drawing::LineStyle meStyle
;
766 * Chart 1 has 4 bars of which 1st and 3rd have labels with borders
769 void checkObject1( const Reference
<chart2::XChartDocument
>& xChartDoc
)
771 CPPUNIT_ASSERT(xChartDoc
.is());
773 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
774 CPPUNIT_ASSERT(xDataSeries
.is());
776 // Check to make sure that data points 0 and 2 have local properties.
777 Reference
<beans::XPropertySet
> xPropSet(xDataSeries
, uno::UNO_QUERY
);
778 CPPUNIT_ASSERT(xPropSet
.is());
780 Sequence
<sal_Int32
> aIndices
;
781 xPropSet
->getPropertyValue("AttributedDataPoints") >>= aIndices
;
783 CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 2 data points with local properties.", sal_Int32(2), aIndices.getLength());
784 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aIndices[0]);
785 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aIndices[1]);
788 const Check aDataPoints
[] =
790 { 0, css::drawing::LineStyle_SOLID
, 0x00FFFF00 }, // solid yellow
791 { 2, css::drawing::LineStyle_SOLID
, 0x00FF0000 } // solid red
794 for (size_t i
= 0, n
= SAL_N_ELEMENTS(aDataPoints
); i
< n
; ++i
)
796 xPropSet
= xDataSeries
->getDataPointByIndex(aDataPoints
[i
].mnIndex
);
797 CPPUNIT_ASSERT(xPropSet
.is());
799 css::drawing::LineStyle eLineStyle
= css::drawing::LineStyle_NONE
;
800 xPropSet
->getPropertyValue(CHART_UNONAME_LABEL_BORDER_STYLE
) >>= eLineStyle
;
801 CPPUNIT_ASSERT_EQUAL(aDataPoints
[i
].meStyle
, eLineStyle
);
803 sal_Int32 nWidth
= -1;
804 xPropSet
->getPropertyValue(CHART_UNONAME_LABEL_BORDER_WIDTH
) >>= nWidth
;
805 CPPUNIT_ASSERT(nWidth
> 0);
807 sal_Int32 nColor
= -1;
808 xPropSet
->getPropertyValue(CHART_UNONAME_LABEL_BORDER_COLOR
) >>= nColor
;
809 CPPUNIT_ASSERT_EQUAL_MESSAGE("Border color is wrong.", aDataPoints
[i
].mnColor
, nColor
);
814 * Chart 2 has all its data labels with identical borders.
816 void checkObject2( const Reference
<chart2::XChartDocument
>& xChartDoc
)
818 CPPUNIT_ASSERT(xChartDoc
.is());
820 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
821 CPPUNIT_ASSERT(xDataSeries
.is());
823 Reference
<beans::XPropertySet
> xPropSet(xDataSeries
, uno::UNO_QUERY
);
824 CPPUNIT_ASSERT(xPropSet
.is());
826 css::drawing::LineStyle eLineStyle
= css::drawing::LineStyle_NONE
;
827 xPropSet
->getPropertyValue(CHART_UNONAME_LABEL_BORDER_STYLE
) >>= eLineStyle
;
828 CPPUNIT_ASSERT_EQUAL(css::drawing::LineStyle_SOLID
, eLineStyle
);
830 sal_Int32 nWidth
= -1;
831 xPropSet
->getPropertyValue(CHART_UNONAME_LABEL_BORDER_WIDTH
) >>= nWidth
;
832 CPPUNIT_ASSERT(nWidth
> 0);
834 sal_Int32 nColor
= -1;
835 xPropSet
->getPropertyValue(CHART_UNONAME_LABEL_BORDER_COLOR
) >>= nColor
;
836 CPPUNIT_ASSERT_EQUAL_MESSAGE("Border color should be green.", sal_Int32(0x0000FF00), nColor
);
841 load("/chart2/qa/extras/data/docx/", "data-label-borders.docx");
843 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
845 // "Automatic" chart background fill in docx should be loaded as solid white.
846 Reference
<beans::XPropertySet
> xPropSet
= xChartDoc
->getPageBackground();
847 CPPUNIT_ASSERT(xPropSet
.is());
848 drawing::FillStyle eStyle
= xPropSet
->getPropertyValue("FillStyle").get
<drawing::FillStyle
>();
849 sal_Int32 nColor
= xPropSet
->getPropertyValue("FillColor").get
<sal_Int32
>();
850 CPPUNIT_ASSERT_MESSAGE("'Automatic' chart background fill in docx should be loaded as solid fill.",
851 eStyle
== drawing::FillStyle_SOLID
);
852 CPPUNIT_ASSERT_MESSAGE("'Automatic' chart background fill in docx should be loaded as solid white.",
853 (nColor
& 0x00FFFFFF) == 0x00FFFFFF); // highest 2 bytes are transparency which we ignore here.
855 aTest
.checkObject1(xChartDoc
);
856 xChartDoc
.set(getChartDocFromWriter(1), uno::UNO_QUERY
);
857 aTest
.checkObject2(xChartDoc
);
859 reload("Office Open XML Text");
861 xChartDoc
.set(getChartDocFromWriter(0), uno::UNO_QUERY
);
862 aTest
.checkObject1(xChartDoc
);
863 xChartDoc
.set(getChartDocFromWriter(1), uno::UNO_QUERY
);
864 aTest
.checkObject2(xChartDoc
);
867 void Chart2ExportTest::testDataLabel3DChartDOCX()
869 load("/chart2/qa/extras/data/docx/", "3d-bar-label.docx");
871 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
872 CPPUNIT_ASSERT(xChartDoc
.is());
874 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart","Office Open XML Text");
875 CPPUNIT_ASSERT(pXmlDoc
);
877 // We must not export label position attributes for 3D bar charts. The
878 // same rule also applies to several other 3D charts, apparently.
879 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:ser/c:dLbls/c:dLblPos", 0);
880 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:ser/c:dLbls/c:dLbl/c:dLblPos", 0);
883 void Chart2ExportTest::testDataLabelBarChartDOCX()
885 load("/chart2/qa/extras/data/docx/", "bar-chart-labels.docx");
887 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
888 CPPUNIT_ASSERT(xChartDoc
.is());
890 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart","Office Open XML Text");
891 CPPUNIT_ASSERT(pXmlDoc
);
893 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLblPos", "val", "ctr");
894 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[2]/c:dLbls/c:dLblPos", "val", "inEnd");
895 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[3]/c:dLbls/c:dLblPos", "val", "inBase");
898 void Chart2ExportTest::testDataLabelClusteredBarChartDOCX()
900 load("/chart2/qa/extras/data/docx/", "clustered-bar-chart-labels.docx");
902 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
903 CPPUNIT_ASSERT(xChartDoc
.is());
905 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart","Office Open XML Text");
906 CPPUNIT_ASSERT(pXmlDoc
);
908 // This was "t", should be one of the allowed values.
909 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLbl[2]/c:dLblPos", "val", "outEnd");
912 void Chart2ExportTest::testDataLabelRadarChartDOCX()
914 load("/chart2/qa/extras/data/docx/", "radar-chart-labels.docx");
916 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
917 CPPUNIT_ASSERT(xChartDoc
.is());
919 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart","Office Open XML Text");
920 CPPUNIT_ASSERT(pXmlDoc
);
922 // We must not export label position attributes for radar charts.
923 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:radarChart/c:ser/c:dLbls/c:dLblPos", 0);
924 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:radarChart/c:ser/c:dLbls/c:dLbl/c:dLblPos", 0);
927 void Chart2ExportTest::testDataLabelDoughnutChartDOCX()
929 load("/chart2/qa/extras/data/docx/", "doughnut-chart-labels.docx");
931 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
932 CPPUNIT_ASSERT(xChartDoc
.is());
934 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart","Office Open XML Text");
935 CPPUNIT_ASSERT(pXmlDoc
);
937 // We must not export label position attributes for doughnut charts.
938 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart/c:ser/c:dLbls/c:dLblPos", 0);
939 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart/c:ser/c:dLbls/c:dLbl/c:dLblPos", 0);
942 void Chart2ExportTest::testDataLabelAreaChartDOCX()
944 load("/chart2/qa/extras/data/docx/", "area-chart-labels.docx");
946 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
947 CPPUNIT_ASSERT(xChartDoc
.is());
949 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart","Office Open XML Text");
950 CPPUNIT_ASSERT(pXmlDoc
);
952 // We must not export label position attributes for area charts.
953 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:dLblPos", 0);
954 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:dLbl/c:dLblPos", 0);
957 void Chart2ExportTest::testDataLabelDefaultLineChartDOCX()
959 // This file was created by Word 2007, which doesn't provide default data
960 // label position (2010 does). Make sure its default data label position
961 // is RIGHT when exporting.
963 load("/chart2/qa/extras/data/docx/", "line-chart-label-default-placement.docx");
965 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
966 CPPUNIT_ASSERT(xChartDoc
.is());
968 reload("Office Open XML Text");
970 xChartDoc
.set(getChartDocFromWriter(0), uno::UNO_QUERY
);
971 Reference
<chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc(xChartDoc
, 0);
972 Reference
<beans::XPropertySet
> xPropSet(xDataSeries
, uno::UNO_QUERY
);
973 CPPUNIT_ASSERT(xPropSet
.is());
974 sal_Int32 nLabelPlacement
= -1;
975 if (xPropSet
->getPropertyValue("LabelPlacement") >>= nLabelPlacement
)
976 // This option may not be set. Check its value only when it's set.
977 CPPUNIT_ASSERT_MESSAGE("Line chart's default label placement should be 'right'.", nLabelPlacement
== chart::DataLabelPlacement::RIGHT
);
980 void Chart2ExportTest::testBarChartRotation()
982 load ("/chart2/qa/extras/data/docx/", "barChartRotation.docx");
983 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart","Office Open XML Text");
984 CPPUNIT_ASSERT(pXmlDoc
);
986 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:view3D/c:rotX", "val", "30");
987 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:view3D/c:rotY", "val", "50");
990 void Chart2ExportTest::testShapeFollowedByChart()
992 /* If there is a scenario where a chart is followed by a shape
993 which is being exported as an alternate content then, the
994 docPr Id is being repeated, ECMA 20.4.2.5 says that the
995 docPr Id should be unique, ensuring the same here.
997 load("/chart2/qa/extras/data/docx/", "FDO74430.docx");
998 xmlDocPtr pXmlDoc
= parseExport("word/document", "Office Open XML Text" );
999 CPPUNIT_ASSERT(pXmlDoc
);
1001 OUString aValueOfFirstDocPR
= getXPath(pXmlDoc
, "/w:document/w:body/w:p[3]/w:r[1]/w:drawing[1]/wp:inline[1]/wp:docPr[1]", "id");
1002 OUString aValueOfSecondDocPR
;
1004 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");
1006 CPPUNIT_ASSERT( aValueOfFirstDocPR
!= aValueOfSecondDocPR
);
1009 void Chart2ExportTest::testPieChartDataLabels()
1011 load("/chart2/qa/extras/data/docx/", "PieChartDataLabels.docx");
1012 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
1013 CPPUNIT_ASSERT(pXmlDoc
);
1014 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser[1]/c:dLbls/c:dLbl[1]/c:dLblPos", "val", "bestFit");
1017 void Chart2ExportTest::testSeriesIdxOrder()
1019 load("/chart2/qa/extras/data/docx/", "testSeriesIdxOrder.docx");
1020 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
1021 CPPUNIT_ASSERT(pXmlDoc
);
1022 assertXPath(pXmlDoc
, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:idx[1]", "val", "1");
1023 assertXPath(pXmlDoc
, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:order[1]", "val", "1");
1026 void Chart2ExportTest::testScatterPlotLabels()
1028 load("/chart2/qa/extras/data/odt/", "scatter-plot-labels.odt");
1029 Reference
<chart2::XChartDocument
> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY
);
1030 CPPUNIT_ASSERT(xChartDoc
.is());
1032 Reference
<chart2::XChartType
> xCT
= getChartTypeFromDoc(xChartDoc
, 0, 0);
1033 CPPUNIT_ASSERT(xCT
.is());
1035 // Make sure the original chart has 'a', 'b', 'c' as its data labels.
1036 std::vector
<uno::Sequence
<uno::Any
> > aLabels
= getDataSeriesLabelsFromChartType(xCT
);
1037 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels
.size());
1038 CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels
[0][0].get
<OUString
>());
1039 CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels
[1][0].get
<OUString
>());
1040 CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels
[2][0].get
<OUString
>());
1042 // Reload the doc and check again. The labels should not change.
1045 xChartDoc
.set(getChartDocFromWriter(0), uno::UNO_QUERY
);
1046 CPPUNIT_ASSERT(xChartDoc
.is());
1048 xCT
= getChartTypeFromDoc(xChartDoc
, 0, 0);
1049 CPPUNIT_ASSERT(xCT
.is());
1051 aLabels
= getDataSeriesLabelsFromChartType(xCT
);
1052 CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels
.size());
1053 CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels
[0][0].get
<OUString
>());
1054 CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels
[1][0].get
<OUString
>());
1055 CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels
[2][0].get
<OUString
>());
1058 void Chart2ExportTest::testErrorBarDataRangeODS()
1060 load("/chart2/qa/extras/data/ods/", "ErrorBarRange.ods");
1063 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
1064 CPPUNIT_ASSERT(xChartDoc
.is());
1066 Reference
< chart2::XDataSeries
> xDataSeries
= getDataSeriesFromDoc( xChartDoc
, 0 );
1067 CPPUNIT_ASSERT( xDataSeries
.is() );
1069 Reference
< beans::XPropertySet
> xPropSet( xDataSeries
, UNO_QUERY_THROW
);
1070 CPPUNIT_ASSERT( xPropSet
.is() );
1072 // test that y error bars are there
1073 Reference
< beans::XPropertySet
> xErrorBarYProps
;
1074 xPropSet
->getPropertyValue(CHART_UNONAME_ERRORBAR_Y
) >>= xErrorBarYProps
;
1075 uno::Any aAny
= xErrorBarYProps
->getPropertyValue("ErrorBarRangePositive");
1076 CPPUNIT_ASSERT(aAny
.hasValue());
1079 CPPUNIT_ASSERT_EQUAL(OUString("$Sheet1.$B$1:$B$3"), aPosRange
);
1081 aAny
= xErrorBarYProps
->getPropertyValue("ErrorBarRangeNegative");
1082 CPPUNIT_ASSERT(aAny
.hasValue());
1085 CPPUNIT_ASSERT_EQUAL(OUString("$Sheet1.$C$1:$C$3"), aNegRange
);
1088 void Chart2ExportTest::testChartCrash()
1090 load("/chart2/qa/extras/data/docx/", "FDO75975.docx");
1091 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart", "Office Open XML Text");
1092 CPPUNIT_ASSERT(pXmlDoc
);
1095 void Chart2ExportTest::testPieChartRotation()
1097 load ("/chart2/qa/extras/data/docx/", "pieChartRotation.docx");
1098 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart","Office Open XML Text");
1099 CPPUNIT_ASSERT(pXmlDoc
);
1100 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:view3D/c:rotX", "val", "40");
1101 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:view3D/c:rotY", "val", "30");
1104 void Chart2ExportTest::testEmbeddingsOleObjectGrabBag()
1106 // The problem was that .bin files were missing from docx file from embeddings folder
1107 // after saving file.
1108 // This test case tests whether embeddings files grabbagged properly in correct object.
1110 load("/chart2/qa/extras/data/docx/", "testchartoleobjectembeddings.docx" );
1111 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
1112 uno::Reference
<beans::XPropertySet
> xTextDocumentPropertySet(xTextDocument
, uno::UNO_QUERY
);
1113 uno::Sequence
<beans::PropertyValue
> aGrabBag(0);
1114 xTextDocumentPropertySet
->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag
;
1115 CPPUNIT_ASSERT(aGrabBag
.hasElements()); // Grab Bag not empty
1116 bool bEmbeddings
= false;
1117 const char* testEmbeddedFileNames
[1] = {"word/embeddings/oleObject1.bin"};
1118 for(int i
= 0; i
< aGrabBag
.getLength(); ++i
)
1120 if (aGrabBag
[i
].Name
== "OOXEmbeddings")
1123 uno::Sequence
<beans::PropertyValue
> aEmbeddingsList(0);
1124 uno::Reference
<io::XInputStream
> aEmbeddingXlsxStream
;
1125 OUString aEmbeddedfileName
;
1126 CPPUNIT_ASSERT(aGrabBag
[i
].Value
>>= aEmbeddingsList
); // PropertyValue of proper type
1127 sal_Int32 length
= aEmbeddingsList
.getLength();
1128 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), length
);
1129 for(int j
= 0; j
< length
; ++j
)
1131 aEmbeddingsList
[j
].Value
>>= aEmbeddingXlsxStream
;
1132 aEmbeddedfileName
= aEmbeddingsList
[j
].Name
;
1133 CPPUNIT_ASSERT(aEmbeddingXlsxStream
.get()); // Reference not empty
1134 CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(testEmbeddedFileNames
[j
]),aEmbeddedfileName
);
1138 CPPUNIT_ASSERT(bEmbeddings
); // Grab Bag has all the expected elements
1143 void checkGapWidth(Reference
<beans::XPropertySet
> xPropSet
, sal_Int32 nValue
)
1145 uno::Any aAny
= xPropSet
->getPropertyValue("GapwidthSequence");
1146 CPPUNIT_ASSERT(aAny
.hasValue());
1147 uno::Sequence
< sal_Int32
> aSequence
;
1149 CPPUNIT_ASSERT(aSequence
.getLength());
1150 CPPUNIT_ASSERT_EQUAL(nValue
, aSequence
[0]);
1153 void checkOverlap(Reference
<beans::XPropertySet
> xPropSet
, sal_Int32 nValue
)
1155 uno::Any aAny
= xPropSet
->getPropertyValue("OverlapSequence");
1156 CPPUNIT_ASSERT(aAny
.hasValue());
1157 uno::Sequence
< sal_Int32
> aSequence
;
1159 CPPUNIT_ASSERT(aSequence
.getLength());
1160 CPPUNIT_ASSERT_EQUAL(nValue
, aSequence
[0]);
1163 void checkSheetForGapWidthAndOverlap(uno::Reference
< chart2::XChartDocument
> xChartDoc
,
1164 sal_Int32 nExpectedGapWidth
, sal_Int32 nExpectedOverlap
)
1166 CPPUNIT_ASSERT(xChartDoc
.is());
1168 Reference
< chart2::XChartType
> xChartType
= getChartTypeFromDoc( xChartDoc
, 0, 0 );
1169 CPPUNIT_ASSERT(xChartType
.is());
1171 Reference
< beans::XPropertySet
> xPropSet( xChartType
, uno::UNO_QUERY_THROW
);
1172 checkGapWidth(xPropSet
, nExpectedGapWidth
);
1173 checkOverlap(xPropSet
, nExpectedOverlap
);
1179 void Chart2ExportTest::testGapWidthXLSX()
1181 load("/chart2/qa/extras/data/xlsx/", "gapWidth.xlsx");
1183 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
1184 checkSheetForGapWidthAndOverlap(xChartDoc
, 120, -60);
1186 xChartDoc
= getChartDocFromSheet( 1, mxComponent
);
1187 checkSheetForGapWidthAndOverlap(xChartDoc
, 50, 30);
1189 reload("Calc Office Open XML");
1191 xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
1192 checkSheetForGapWidthAndOverlap(xChartDoc
, 120, -60);
1194 xChartDoc
= getChartDocFromSheet( 1, mxComponent
);
1195 checkSheetForGapWidthAndOverlap(xChartDoc
, 50, 30);
1198 void Chart2ExportTest::testSmoothedLines()
1200 load("/chart2/qa/extras/data/ods/", "smoothedLines.ods");
1201 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1202 CPPUNIT_ASSERT(pXmlDoc
);
1203 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:smooth", "val", "0");
1206 void Chart2ExportTest::testLabelStringODS()
1208 load("/chart2/qa/extras/data/ods/", "labelString.ods");
1210 uno::Reference
< chart2::XChartDocument
> xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
1211 Reference
< chart2::data::XDataSequence
> xLabelSeq
=
1212 getLabelDataSequenceFromDoc(xChartDoc
);
1213 CPPUNIT_ASSERT(xLabelSeq
.is());
1215 OUString aLabelString
= xLabelSeq
->getSourceRangeRepresentation();
1216 CPPUNIT_ASSERT_EQUAL(OUString("\"LabelName\""), aLabelString
);
1220 xChartDoc
= getChartDocFromSheet( 0, mxComponent
);
1221 xLabelSeq
= getLabelDataSequenceFromDoc(xChartDoc
);
1222 CPPUNIT_ASSERT(xLabelSeq
.is());
1224 aLabelString
= xLabelSeq
->getSourceRangeRepresentation();
1225 CPPUNIT_ASSERT_EQUAL(OUString("\"LabelName\""), aLabelString
);
1228 void Chart2ExportTest::testFdo83058dlblPos()
1230 load ("/chart2/qa/extras/data/docx/", "fdo83058_dlblPos.docx");
1231 xmlDocPtr pXmlDoc
= parseExport("word/charts/chart","Office Open XML Text");
1232 CPPUNIT_ASSERT(pXmlDoc
);
1233 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[2]/c:dLblPos", "val", "outEnd");
1234 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[3]/c:dLblPos", "val", "outEnd");
1235 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[4]/c:dLblPos", "val", "outEnd");
1236 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[5]/c:dLblPos", "val", "outEnd");
1239 void Chart2ExportTest::testAutoTitleDelXLSX()
1241 load("/chart2/qa/extras/data/xlsx/", "autotitledel_2007.xlsx");
1242 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart","Calc Office Open XML");
1243 CPPUNIT_ASSERT(pXmlDoc
);
1244 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:autoTitleDeleted", "val", "0");
1247 void Chart2ExportTest::testDispBlanksAsXLSX()
1249 load("/chart2/qa/extras/data/xlsx/", "dispBlanksAs_2007.xlsx");
1250 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart","Calc Office Open XML");
1251 CPPUNIT_ASSERT(pXmlDoc
);
1252 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "gap");
1255 void Chart2ExportTest::testMarkerColorXLSX()
1257 load("/chart2/qa/extras/data/xlsx/", "markerColor.xlsx");
1258 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1259 CPPUNIT_ASSERT(pXmlDoc
);
1260 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:marker/c:spPr/a:solidFill/a:srgbClr", "val", "92d050");
1263 void Chart2ExportTest::testRoundedCornersXLSX()
1265 load("/chart2/qa/extras/data/xlsx/", "markerColor.xlsx");
1266 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1267 CPPUNIT_ASSERT(pXmlDoc
);
1268 assertXPath(pXmlDoc
, "/c:chartSpace/c:roundedCorners", "val", "0");
1271 void Chart2ExportTest::testAxisNumberFormatXLSX()
1273 load("/chart2/qa/extras/data/ods/", "axis_number_format.ods");
1274 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1275 CPPUNIT_ASSERT(pXmlDoc
);
1276 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx", 2);
1277 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:numFmt", "formatCode", "0.00E+000");
1278 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:numFmt", "sourceLinked", "0");
1280 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:numFmt", "formatCode", "[$$-409]#,##0;-[$$-409]#,##0");
1281 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:numFmt", "sourceLinked", "1");
1284 void Chart2ExportTest::testDataLabelDefaultValuesXLSX()
1286 load("/chart2/qa/extras/data/xlsx/", "data_label.xlsx");
1287 Reference
< chart2::XChartDocument
> xDoc
= getChartDocFromSheet(0, mxComponent
);
1288 Reference
<chart2::XDataSeries
> xSeries
= getDataSeriesFromDoc(xDoc
, 0);
1289 Reference
<beans::XPropertySet
> xPropSet(xSeries
, uno::UNO_QUERY_THROW
);
1290 uno::Any aAny
= xPropSet
->getPropertyValue("Label");
1291 chart2::DataPointLabel aLabel
;
1292 CPPUNIT_ASSERT(aAny
>>= aLabel
);
1293 CPPUNIT_ASSERT(aLabel
.ShowNumber
);
1295 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1296 CPPUNIT_ASSERT(pXmlDoc
);
1297 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:showVal", "val", "1");
1298 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLblPos", "val", "outEnd");
1301 void Chart2ExportTest::testTitleOverlayXLSX()
1303 load("/chart2/qa/extras/data/xlsx/", "chart_title.xlsx");
1304 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1305 CPPUNIT_ASSERT(pXmlDoc
);
1306 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:overlay", "val", "0");
1309 void Chart2ExportTest::testInvertIfNegativeXLSX()
1311 load("/chart2/qa/extras/data/xlsx/", "bar_chart_simple.xlsx");
1312 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1313 CPPUNIT_ASSERT(pXmlDoc
);
1314 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:invertIfNegative", "val", "0");
1317 void Chart2ExportTest::testBubble3DXLSX()
1319 load("/chart2/qa/extras/data/xlsx/", "bubble_chart_simple.xlsx");
1320 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1321 CPPUNIT_ASSERT(pXmlDoc
);
1322 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:bubbleChart/c:bubble3D", "val", "0");
1325 void Chart2ExportTest::testNoMarkerXLSX()
1327 load("/chart2/qa/extras/data/xlsx/", "no_marker.xlsx");
1328 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1329 CPPUNIT_ASSERT(pXmlDoc
);
1330 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:marker/c:symbol", "val", "none");
1331 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:marker/c:symbol", "val", "none");
1332 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:marker", "val", "0");
1335 void Chart2ExportTest::testTitleManualLayoutXLSX()
1337 load("/chart2/qa/extras/data/xlsx/", "title_manual_layout.xlsx");
1338 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1339 CPPUNIT_ASSERT(pXmlDoc
);
1340 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:xMode", "val", "edge");
1341 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:yMode", "val", "edge");
1343 OUString aXVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:x", "val");
1344 double nX
= aXVal
.toDouble();
1345 CPPUNIT_ASSERT(nX
> 0 && nX
< 1);
1347 OUString aYVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:y", "val");
1348 double nY
= aYVal
.toDouble();
1349 CPPUNIT_ASSERT(nY
> 0 && nY
< 1);
1350 CPPUNIT_ASSERT(nX
!= nY
);
1352 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:bodyPr", "rot", "1200000");
1355 void Chart2ExportTest::testPlotAreaManualLayoutXLSX()
1357 load("/chart2/qa/extras/data/xlsx/", "plot_area_manual_layout.xlsx");
1358 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1359 CPPUNIT_ASSERT(pXmlDoc
);
1361 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:xMode", "val", "edge");
1362 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:yMode", "val", "edge");
1364 OUString aXVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:x", "val");
1365 double nX
= aXVal
.toDouble();
1366 CPPUNIT_ASSERT(nX
> 0 && nX
< 1);
1368 OUString aYVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:y", "val");
1369 double nY
= aYVal
.toDouble();
1370 CPPUNIT_ASSERT(nY
> 0 && nY
< 1);
1371 CPPUNIT_ASSERT(nX
!= nY
);
1373 OUString aWVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:w", "val");
1374 double nW
= aWVal
.toDouble();
1375 CPPUNIT_ASSERT(nW
> 0 && nW
< 1);
1377 OUString aHVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:h", "val");
1378 double nH
= aHVal
.toDouble();
1379 CPPUNIT_ASSERT(nH
> 0 && nH
< 1);
1380 CPPUNIT_ASSERT(nH
!= nW
);
1383 void Chart2ExportTest::testLegendManualLayoutXLSX()
1385 load("/chart2/qa/extras/data/xlsx/", "legend_manual_layout.xlsx");
1386 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1387 CPPUNIT_ASSERT(pXmlDoc
);
1389 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:xMode", "val", "edge");
1390 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:yMode", "val", "edge");
1392 OUString aXVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:x", "val");
1393 double nX
= aXVal
.toDouble();
1394 CPPUNIT_ASSERT(nX
> 0 && nX
< 1);
1396 OUString aYVal
= getXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:y", "val");
1397 double nY
= aYVal
.toDouble();
1398 CPPUNIT_ASSERT(nY
> 0 && nY
< 1);
1399 CPPUNIT_ASSERT(nX
!= nY
);
1402 void Chart2ExportTest::testAxisCharacterPropertiesXLSX()
1404 load("/chart2/qa/extras/data/xlsx/", "axis_character_properties.xlsx");
1405 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1406 CPPUNIT_ASSERT(pXmlDoc
);
1408 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "sz", "1000");
1409 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "b", "1");
1410 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "i", "1");
1411 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "u", "sng");
1413 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr", "sz", "900");
1414 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr", "b", "1");
1415 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr", "strike", "sngStrike");
1416 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr", "val", "ff0000");
1419 void Chart2ExportTest::testTitleCharacterPropertiesXLSX()
1421 load("/chart2/qa/extras/data/xlsx/", "title_character_properties.xlsx");
1422 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1423 CPPUNIT_ASSERT(pXmlDoc
);
1425 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "sz", "2400");
1426 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "b", "1");
1428 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr", "sz", "2400");
1429 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:rPr", "b", "1");
1432 void Chart2ExportTest::testPlotVisOnlyXLSX()
1434 load("/chart2/qa/extras/data/xlsx/", "hidden_cells.xlsx");
1435 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1436 CPPUNIT_ASSERT(pXmlDoc
);
1438 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotVisOnly", "val", "0");
1441 void Chart2ExportTest::testBarChartVaryColorsXLSX()
1443 load("/chart2/qa/extras/data/xlsx/", "tdf90876.xlsx");
1444 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1445 CPPUNIT_ASSERT(pXmlDoc
);
1447 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", "0");
1450 void Chart2ExportTest::testMultipleAxisXLSX()
1452 load("/chart2/qa/extras/data/ods/", "multiple_axis.ods");
1453 xmlDocPtr pXmlDoc
= parseExport("xl/charts/chart", "Calc Office Open XML");
1454 CPPUNIT_ASSERT(pXmlDoc
);
1456 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart", 2);
1457 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart[1]/c:ser", 1);
1458 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart[2]/c:ser", 1);
1459 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx", 4);
1460 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:delete[@val='1']", 1);
1461 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:axPos[@val='l']", 1);
1462 assertXPath(pXmlDoc
, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:axPos[@val='r']", 1);
1465 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest
);
1467 CPPUNIT_PLUGIN_IMPLEMENT();
1469 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */