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 <comphelper/propertyvalue.hxx>
13 #include <vcl/scheduler.hxx>
15 using namespace ::com::sun::star
;
17 class Chart2UiChartTest
: public ChartTest
21 : ChartTest("/chart2/qa/extras/data/")
25 void testCopyPasteToNewSheet(uno::Reference
<chart::XChartDocument
> xChartDoc
,
26 OUString aObjectName
, sal_Int32 nColumns
, sal_Int32 nRows
);
29 void Chart2UiChartTest::testCopyPasteToNewSheet(uno::Reference
<chart::XChartDocument
> xChartDoc
,
30 OUString aObjectName
, sal_Int32 nColumns
,
33 CPPUNIT_ASSERT(xChartDoc
.is());
34 uno::Reference
<chart::XChartDataArray
> xChartData(xChartDoc
->getData(), uno::UNO_QUERY_THROW
);
36 uno::Sequence
<OUString
> aExpectedColumnDescriptions
= xChartData
->getColumnDescriptions();
37 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of columns in origin file", nColumns
,
38 aExpectedColumnDescriptions
.getLength());
40 uno::Sequence
<OUString
> aExpectedRowDescriptions
= xChartData
->getRowDescriptions();
41 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in origin file", nRows
,
42 aExpectedRowDescriptions
.getLength());
44 Sequence
<Sequence
<double>> aExpectedData
= xChartData
->getData();
46 uno::Sequence
<beans::PropertyValue
> aPropertyValues
= {
47 comphelper::makePropertyValue("ToObject", aObjectName
),
49 dispatchCommand(mxComponent
, ".uno:GoToObject", aPropertyValues
);
51 dispatchCommand(mxComponent
, ".uno:Copy", {});
53 // create a new document
54 load("private:factory/scalc");
56 dispatchCommand(mxComponent
, ".uno:Paste", {});
58 uno::Reference
<chart2::XChartDocument
> xChartDoc2
= getChartDocFromSheet(0, mxComponent
);
59 CPPUNIT_ASSERT(xChartDoc2
.is());
61 uno::Reference
<chart::XChartDataArray
> xDataArray(xChartDoc2
->getDataProvider(),
64 Sequence
<OUString
> aColumnDesc
= xDataArray
->getColumnDescriptions();
65 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of columns in destination file", nColumns
,
66 aColumnDesc
.getLength());
67 for (sal_Int32 i
= 0; i
< nColumns
; ++i
)
69 OString
sMessage("Incorrect description in column: " + OString::number(i
));
70 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), aExpectedColumnDescriptions
[i
],
74 Sequence
<OUString
> aRowDesc
= xDataArray
->getRowDescriptions();
75 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in destination file", nRows
,
76 aRowDesc
.getLength());
77 for (sal_Int32 i
= 0; i
< nRows
; ++i
)
79 OString
sMessage("Incorrect description in row: " + OString::number(i
));
80 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), aExpectedRowDescriptions
[i
], aRowDesc
[i
]);
83 Sequence
<Sequence
<double>> aData
= xDataArray
->getData();
85 for (sal_Int32 nRowIdx
= 0; nRowIdx
< nRows
; ++nRowIdx
)
87 for (sal_Int32 nColIdx
= 0; nColIdx
< nColumns
; ++nColIdx
)
89 double nValue
= aData
[nRowIdx
][nColIdx
];
90 double nExpected
= aExpectedData
[nRowIdx
][nColIdx
];
91 OString
sMessage("Incorrect value in Col: " + OString::number(nColIdx
)
92 + " Row: " + OString::number(nRowIdx
));
94 if (std::isnan(nValue
))
96 // On paste, 0 becomes NaN, check whether it's expected
97 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(sMessage
.getStr(), 0.0, nExpected
, 1e-1);
101 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(sMessage
.getStr(), nExpected
, nValue
, 1e-1);
107 CPPUNIT_TEST_FIXTURE(Chart2UiChartTest
, testTdf120348
)
109 loadFromFile(u
"ods/tdf120348.ods");
110 uno::Reference
<chart::XChartDocument
> xChartDoc(getChartCompFromSheet(0, 0, mxComponent
),
111 uno::UNO_QUERY_THROW
);
113 // Without the fix in place, this test would have failed with
115 // - Actual : 3.33625955201419
116 // - Incorrect value in Col: 2 Row: 51
117 testCopyPasteToNewSheet(xChartDoc
, "Object 2", 4, 158);
120 CPPUNIT_TEST_FIXTURE(Chart2UiChartTest
, testTdf151091
)
122 std::vector
<OUString
> aExpected
123 = { u
"Ωφέλιμο"_ustr
, u
"Επικίνδυνο"_ustr
, u
"Απόσταση"_ustr
, u
"Μάσκα"_ustr
, u
"Εμβόλιο"_ustr
};
125 loadFromFile(u
"ods/tdf151091.ods");
126 uno::Reference
<chart::XChartDocument
> xChartDoc(getChartCompFromSheet(0, 0, mxComponent
),
127 uno::UNO_QUERY_THROW
);
128 CPPUNIT_ASSERT(xChartDoc
.is());
129 uno::Reference
<chart::XChartDataArray
> xChartData(xChartDoc
->getData(), uno::UNO_QUERY_THROW
);
130 uno::Sequence
<OUString
> aSeriesList
= xChartData
->getColumnDescriptions();
131 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(5), aSeriesList
.getLength());
133 for (size_t i
= 0; i
< 5; ++i
)
134 CPPUNIT_ASSERT_EQUAL(aExpected
[i
], aSeriesList
[i
]);
136 uno::Sequence
<beans::PropertyValue
> aPropertyValues
= {
137 comphelper::makePropertyValue("ToObject", OUString("Object 1")),
139 dispatchCommand(mxComponent
, ".uno:GoToObject", aPropertyValues
);
141 dispatchCommand(mxComponent
, ".uno:Copy", {});
143 // create a new writer document
144 load("private:factory/swriter");
146 dispatchCommand(mxComponent
, ".uno:Paste", {});
148 aSeriesList
= getWriterChartColumnDescriptions(mxComponent
);
150 // Without the fix in place, this test would have failed with
153 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(5), aSeriesList
.getLength());
155 for (size_t i
= 0; i
< 5; ++i
)
156 CPPUNIT_ASSERT_EQUAL(aExpected
[i
], aSeriesList
[i
]);
159 CPPUNIT_TEST_FIXTURE(Chart2UiChartTest
, testTdf107097
)
161 loadFromFile(u
"ods/tdf107097.ods");
162 uno::Reference
<chart::XChartDocument
> xChartDoc(getPivotChartDocFromSheet(1, mxComponent
),
163 uno::UNO_QUERY_THROW
);
164 testCopyPasteToNewSheet(xChartDoc
, "Object 1", 4, 12);
167 CPPUNIT_TEST_FIXTURE(Chart2UiChartTest
, testTdf136011
)
169 loadFromFile(u
"ods/tdf136011.ods");
170 uno::Reference
<chart::XChartDocument
> xChartDoc(getChartCompFromSheet(0, 0, mxComponent
),
171 uno::UNO_QUERY_THROW
);
172 testCopyPasteToNewSheet(xChartDoc
, "Object 1", 3, 9);
174 loadFromFile(u
"ods/tdf136011.ods");
175 uno::Reference
<chart::XChartDocument
> xChartDoc2(getChartCompFromSheet(0, 1, mxComponent
),
176 uno::UNO_QUERY_THROW
);
178 // Without the fix in place, this test would have failed with
179 // - Expected: Test 1 1
181 // - Incorrect description in row: 0
182 testCopyPasteToNewSheet(xChartDoc2
, "Object 2", 3, 9);
185 CPPUNIT_TEST_FIXTURE(Chart2UiChartTest
, testTdf62057
)
187 loadFromFile(u
"ods/tdf62057.ods");
188 uno::Reference
<chart::XChartDocument
> xChartDoc(getChartCompFromSheet(0, 0, mxComponent
),
189 uno::UNO_QUERY_THROW
);
191 // Without the fix in place, this test would have failed with
194 // - Incorrect number of columns in destination file
195 testCopyPasteToNewSheet(xChartDoc
, "Object 1", 2, 6);
198 CPPUNIT_TEST_FIXTURE(Chart2UiChartTest
, testTdf98690
)
200 loadFromFile(u
"xlsx/tdf98690.xlsx");
201 uno::Reference
<chart::XChartDocument
> xChartDoc(getChartCompFromSheet(0, 0, mxComponent
),
202 uno::UNO_QUERY_THROW
);
204 CPPUNIT_ASSERT(xChartDoc
.is());
205 uno::Reference
<chart::XChartDataArray
> xChartData(xChartDoc
->getData(), uno::UNO_QUERY_THROW
);
206 uno::Sequence
<OUString
> aSeriesList
= xChartData
->getColumnDescriptions();
207 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(6), aSeriesList
.getLength());
209 uno::Sequence
<beans::PropertyValue
> aPropertyValues
= {
210 comphelper::makePropertyValue("ToObject", OUString("Chart 2")),
212 dispatchCommand(mxComponent
, ".uno:GoToObject", aPropertyValues
);
214 dispatchCommand(mxComponent
, ".uno:Copy", {});
216 // create a new document
217 load("private:factory/scalc");
219 dispatchCommand(mxComponent
, ".uno:Paste", {});
221 uno::Reference
<chart::XChartDocument
> xChartDoc2(getChartCompFromSheet(0, 0, mxComponent
),
222 uno::UNO_QUERY_THROW
);
223 CPPUNIT_ASSERT(xChartDoc2
.is());
224 uno::Reference
<chart::XChartDataArray
> xChartData2(xChartDoc2
->getData(), uno::UNO_QUERY_THROW
);
225 uno::Sequence
<OUString
> aSeriesList2
= xChartData2
->getColumnDescriptions();
227 // Without the fix in place, this test would have failed with
230 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(12), aSeriesList2
.getLength());
233 CPPUNIT_TEST_FIXTURE(Chart2UiChartTest
, testTdf101894
)
235 loadFromFile(u
"ods/tdf101894.ods");
236 uno::Reference
<chart::XChartDocument
> xChartDoc(getChartCompFromSheet(0, 0, mxComponent
),
237 uno::UNO_QUERY_THROW
);
239 CPPUNIT_ASSERT(xChartDoc
.is());
240 uno::Reference
<chart::XChartDataArray
> xChartData(xChartDoc
->getData(), uno::UNO_QUERY_THROW
);
242 uno::Sequence
<OUString
> aExpectedColumnDescriptions
= xChartData
->getColumnDescriptions();
243 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of columns in origin file",
244 static_cast<sal_Int32
>(12),
245 aExpectedColumnDescriptions
.getLength());
247 uno::Sequence
<OUString
> aExpectedRowDescriptions
= xChartData
->getRowDescriptions();
248 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in origin file",
249 static_cast<sal_Int32
>(8), aExpectedRowDescriptions
.getLength());
251 Sequence
<Sequence
<double>> aExpectedData
= xChartData
->getData();
253 // Create a copy of the sheet and move to the end
254 uno::Sequence
<beans::PropertyValue
> aArgs(
255 comphelper::InitPropertySequence({ { "DocName", uno::Any(OUString("tdf101894")) },
256 { "Index", uno::Any(sal_uInt16(32767)) },
257 { "Copy", uno::Any(true) } }));
258 dispatchCommand(mxComponent
, ".uno:Move", aArgs
);
260 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
261 uno::Reference
<container::XIndexAccess
> xIA(xDoc
->getSheets(), UNO_QUERY_THROW
);
262 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xIA
->getCount());
264 for (sal_Int32 sheetIndex
= 0; sheetIndex
< 2; ++sheetIndex
)
266 uno::Reference
<chart::XChartDocument
> xChartDoc2(
267 getChartCompFromSheet(sheetIndex
, 0, mxComponent
), uno::UNO_QUERY_THROW
);
268 CPPUNIT_ASSERT(xChartDoc2
.is());
269 uno::Reference
<chart::XChartDataArray
> xChartData2(xChartDoc2
->getData(),
270 uno::UNO_QUERY_THROW
);
272 uno::Sequence
<OUString
> aColumnDescriptions
= xChartData2
->getColumnDescriptions();
273 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of columns in origin file",
274 static_cast<sal_Int32
>(12), aColumnDescriptions
.getLength());
275 for (sal_Int32 i
= 0; i
< 12; ++i
)
277 OString
sMessage("Incorrect description in column: " + OString::number(i
));
278 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), aExpectedColumnDescriptions
[i
],
279 aColumnDescriptions
[i
]);
282 uno::Sequence
<OUString
> aRowDescriptions
= xChartData2
->getRowDescriptions();
283 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in origin file",
284 static_cast<sal_Int32
>(8), aRowDescriptions
.getLength());
285 for (sal_Int32 i
= 0; i
< 8; ++i
)
287 OString
sMessage("Incorrect description in row: " + OString::number(i
));
288 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), aExpectedRowDescriptions
[i
],
289 aRowDescriptions
[i
]);
292 Sequence
<Sequence
<double>> aData
= xChartData2
->getData();
294 for (sal_Int32 nRowIdx
= 0; nRowIdx
< 8; ++nRowIdx
)
296 for (sal_Int32 nColIdx
= 0; nColIdx
< 12; ++nColIdx
)
298 double nValue
= aData
[nRowIdx
][nColIdx
];
299 double nExpected
= aExpectedData
[nRowIdx
][nColIdx
];
300 OString
sMessage("Incorrect value in Col: " + OString::number(nColIdx
)
301 + " Row: " + OString::number(nRowIdx
));
303 // Without the fix in place, this test would have failed with
305 // - Actual : 2.2250738585072e-308
306 // - Incorrect value in Col: 0 Row: 0
307 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(sMessage
.getStr(), nExpected
, nValue
, 1e-1);
313 CPPUNIT_TEST_FIXTURE(Chart2UiChartTest
, testCopyPasteChartWithDotInSheetName
)
315 loadFromFile(u
"ods/chartWithDotInSheetName.ods");
316 uno::Reference
<chart::XChartDocument
> xChartDoc(getChartCompFromSheet(0, 0, mxComponent
),
317 uno::UNO_QUERY_THROW
);
319 CPPUNIT_ASSERT(xChartDoc
.is());
320 uno::Reference
<chart::XChartDataArray
> xChartData(xChartDoc
->getData(), uno::UNO_QUERY_THROW
);
322 uno::Sequence
<OUString
> aExpectedColumnDescriptions
= xChartData
->getColumnDescriptions();
323 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of columns in origin file",
324 static_cast<sal_Int32
>(4),
325 aExpectedColumnDescriptions
.getLength());
327 uno::Sequence
<OUString
> aExpectedRowDescriptions
= xChartData
->getRowDescriptions();
328 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in origin file",
329 static_cast<sal_Int32
>(7), aExpectedRowDescriptions
.getLength());
331 Sequence
<Sequence
<double>> aExpectedData
= xChartData
->getData();
333 dispatchCommand(mxComponent
, ".uno:SelectAll", {});
334 dispatchCommand(mxComponent
, ".uno:Copy", {});
336 uno::Sequence
<beans::PropertyValue
> aArgs(comphelper::InitPropertySequence(
337 { { "Name", uno::Any(OUString("NewTab")) }, { "Index", uno::Any(sal_uInt16(2)) } }));
338 dispatchCommand(mxComponent
, ".uno:Insert", aArgs
);
340 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
341 uno::Reference
<container::XIndexAccess
> xIA(xDoc
->getSheets(), UNO_QUERY_THROW
);
342 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xIA
->getCount());
344 dispatchCommand(mxComponent
, ".uno:Paste", {});
346 for (sal_Int32 sheetIndex
= 0; sheetIndex
< 2; ++sheetIndex
)
348 uno::Reference
<chart::XChartDocument
> xChartDoc2(
349 getChartCompFromSheet(sheetIndex
, 0, mxComponent
), uno::UNO_QUERY_THROW
);
350 CPPUNIT_ASSERT(xChartDoc2
.is());
351 uno::Reference
<chart::XChartDataArray
> xChartData2(xChartDoc2
->getData(),
352 uno::UNO_QUERY_THROW
);
354 uno::Sequence
<OUString
> aColumnDescriptions
= xChartData2
->getColumnDescriptions();
355 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of columns in origin file",
356 static_cast<sal_Int32
>(4), aColumnDescriptions
.getLength());
357 for (sal_Int32 i
= 0; i
< 4; ++i
)
359 OString
sMessage("Incorrect description in column: " + OString::number(i
));
360 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), aExpectedColumnDescriptions
[i
],
361 aColumnDescriptions
[i
]);
364 uno::Sequence
<OUString
> aRowDescriptions
= xChartData2
->getRowDescriptions();
365 CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in origin file",
366 static_cast<sal_Int32
>(7), aRowDescriptions
.getLength());
367 for (sal_Int32 i
= 0; i
< 7; ++i
)
369 OString
sMessage("Incorrect description in row: " + OString::number(i
));
370 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), aExpectedRowDescriptions
[i
],
371 aRowDescriptions
[i
]);
374 Sequence
<Sequence
<double>> aData
= xChartData2
->getData();
376 for (sal_Int32 nRowIdx
= 0; nRowIdx
< 7; ++nRowIdx
)
378 for (sal_Int32 nColIdx
= 0; nColIdx
< 4; ++nColIdx
)
380 double nValue
= aData
[nRowIdx
][nColIdx
];
381 double nExpected
= aExpectedData
[nRowIdx
][nColIdx
];
382 OString
sMessage("Incorrect value in Col: " + OString::number(nColIdx
)
383 + " Row: " + OString::number(nRowIdx
));
385 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(sMessage
.getStr(), nExpected
, nValue
, 1e-1);
391 CPPUNIT_TEST_FIXTURE(Chart2UiChartTest
, testTdf158223
)
393 loadFromFile(u
"ods/tdf158223.ods");
395 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
396 uno::Reference
<container::XIndexAccess
> xIA(xDoc
->getSheets(), UNO_QUERY_THROW
);
397 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xIA
->getCount());
399 for (sal_Int32 sheetIndex
= 0; sheetIndex
< 2; ++sheetIndex
)
401 OUString
sExpectedValuesX("$Tabelle" + OUString::number(sheetIndex
+ 1) + ".$A$2:$A$11");
402 OUString
sExpectedValuesY("$Tabelle" + OUString::number(sheetIndex
+ 1) + ".$B$2:$B$11");
403 uno::Reference
<chart2::XChartDocument
> xChartDoc
404 = getChartDocFromSheet(sheetIndex
, mxComponent
);
405 Reference
<chart2::data::XDataSequence
> xValuesX
406 = getDataSequenceFromDocByRole(xChartDoc
, u
"values-x");
407 CPPUNIT_ASSERT_EQUAL(sExpectedValuesX
, xValuesX
->getSourceRangeRepresentation());
408 Reference
<chart2::data::XDataSequence
> xValuesY
409 = getDataSequenceFromDocByRole(xChartDoc
, u
"values-y");
410 CPPUNIT_ASSERT_EQUAL(sExpectedValuesY
, xValuesY
->getSourceRangeRepresentation());
414 uno::Sequence
<beans::PropertyValue
> aArgs(
415 comphelper::InitPropertySequence({ { "Index", uno::Any(sal_uInt16(3)) } }));
416 dispatchCommand(mxComponent
, ".uno:Remove", aArgs
);
418 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xIA
->getCount());
420 for (sal_Int32 sheetIndex
= 0; sheetIndex
< 2; ++sheetIndex
)
422 OUString
sExpectedValuesX("$Tabelle" + OUString::number(sheetIndex
+ 1) + ".$A$2:$A$11");
423 OUString
sExpectedValuesY("$Tabelle" + OUString::number(sheetIndex
+ 1) + ".$B$2:$B$11");
424 uno::Reference
<chart2::XChartDocument
> xChartDoc
425 = getChartDocFromSheet(sheetIndex
, mxComponent
);
426 Reference
<chart2::data::XDataSequence
> xValuesX
427 = getDataSequenceFromDocByRole(xChartDoc
, u
"values-x");
429 // Without the fix in place, this test would have failed with
430 // - Expected: $Tabelle2.$A$2:$A$11
431 // - Actual : $Tabelle2.$A$2:$Tabelle1.$A$11
432 CPPUNIT_ASSERT_EQUAL(sExpectedValuesX
, xValuesX
->getSourceRangeRepresentation());
433 Reference
<chart2::data::XDataSequence
> xValuesY
434 = getDataSequenceFromDocByRole(xChartDoc
, u
"values-y");
435 CPPUNIT_ASSERT_EQUAL(sExpectedValuesY
, xValuesY
->getSourceRangeRepresentation());
439 CPPUNIT_TEST_FIXTURE(Chart2UiChartTest
, testTdf153706
)
441 // Load a spreadsheet with a to-page XY scatter chart with the sheet as data source
442 loadFromFile(u
"ods/tdf153706_XY_scatter_chart.ods");
444 // Select the cell range around the chart, and copy the range to clipboard, including the chart
445 dispatchCommand(mxComponent
, u
".uno:GoToCell"_ustr
,
446 { comphelper::makePropertyValue(u
"ToPoint"_ustr
, u
"D1:K23"_ustr
) });
447 dispatchCommand(mxComponent
, u
".uno:Copy"_ustr
, {});
449 // create a new document
450 load(u
"private:factory/scalc"_ustr
);
452 // Paste; this must create a chart with own data source having a proper copy of the data
453 dispatchCommand(mxComponent
, u
".uno:Paste"_ustr
, {});
455 css::uno::Reference
xChartDoc(getChartDocFromSheet(0, mxComponent
), css::uno::UNO_SET_THROW
);
456 auto xDataArray(xChartDoc
->getDataProvider().queryThrow
<chart::XChartDataArray
>());
458 css::uno::Sequence
<Sequence
<double>> aData
= xDataArray
->getData();
459 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aData
.getLength());
460 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aData
[0].getLength());
461 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aData
[1].getLength());
462 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aData
[2].getLength());
463 CPPUNIT_ASSERT_EQUAL(2.0, aData
[0][0]);
464 CPPUNIT_ASSERT_EQUAL(3.0, aData
[0][1]);
465 CPPUNIT_ASSERT_EQUAL(3.0, aData
[1][0]);
466 CPPUNIT_ASSERT_EQUAL(2.0, aData
[1][1]);
467 CPPUNIT_ASSERT_EQUAL(4.0, aData
[2][0]);
468 CPPUNIT_ASSERT_EQUAL(1.0, aData
[2][1]);
470 // Without the fix, this would fail with
473 // i.e., the X values were treated as another Y series
474 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getNumberOfDataSeries(xChartDoc
));
476 auto xSeries(getDataSeriesFromDoc(xChartDoc
, 0).queryThrow
<chart2::data::XDataSource
>());
477 auto sequences
= xSeries
->getDataSequences();
478 // Without the fix, this would fail with
481 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), sequences
.getLength());
483 auto propX(sequences
[0]->getValues().queryThrow
<beans::XPropertySet
>());
484 // Without the fix, this would fail with
485 // - Expected: values-x
486 // - Actual : values-y
487 CPPUNIT_ASSERT_EQUAL(u
"values-x"_ustr
, propX
->getPropertyValue("Role").get
<OUString
>());
489 auto propY(sequences
[1]->getValues().queryThrow
<beans::XPropertySet
>());
490 CPPUNIT_ASSERT_EQUAL(u
"values-y"_ustr
, propY
->getPropertyValue("Role").get
<OUString
>());
493 CPPUNIT_PLUGIN_IMPLEMENT();
495 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */