summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-12-06 21:04:24 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2023-12-07 18:56:02 +0100
commitf47ad18cbac928d3ee2511fe4fb25ed61240feb0 (patch)
tree646907712e5c8233024724f69b7bf50c4753fe65 /chart2
parent12b96aca8666bca5bf905c8c9da44a20e0c06ef3 (diff)
tdf#158223: chart2_uichart: Add unittest
Change-Id: I11e20682155c524fcc119701111f5bc91f6beed8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160404 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/data/ods/tdf158223.odsbin0 -> 27391 bytes
-rw-r--r--chart2/qa/extras/uichart.cxx48
2 files changed, 48 insertions, 0 deletions
diff --git a/chart2/qa/extras/data/ods/tdf158223.ods b/chart2/qa/extras/data/ods/tdf158223.ods
new file mode 100644
index 000000000000..33a71697444f
--- /dev/null
+++ b/chart2/qa/extras/data/ods/tdf158223.ods
Binary files differ
diff --git a/chart2/qa/extras/uichart.cxx b/chart2/qa/extras/uichart.cxx
index 229c7f21f0f7..314f51415d24 100644
--- a/chart2/qa/extras/uichart.cxx
+++ b/chart2/qa/extras/uichart.cxx
@@ -388,6 +388,54 @@ CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testCopyPasteChartWithDotInSheetName)
}
}
+CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf158223)
+{
+ loadFromURL(u"ods/tdf158223.ods");
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
+ uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xIA->getCount());
+
+ for (sal_Int32 sheetIndex = 0; sheetIndex < 2; ++sheetIndex)
+ {
+ OUString sExpectedValuesX("$Tabelle" + OUString::number(sheetIndex + 1) + ".$A$2:$A$11");
+ OUString sExpectedValuesY("$Tabelle" + OUString::number(sheetIndex + 1) + ".$B$2:$B$11");
+ uno::Reference<chart2::XChartDocument> xChartDoc
+ = getChartDocFromSheet(sheetIndex, mxComponent);
+ Reference<chart2::data::XDataSequence> xValuesX
+ = getDataSequenceFromDocByRole(xChartDoc, u"values-x");
+ CPPUNIT_ASSERT_EQUAL(sExpectedValuesX, xValuesX->getSourceRangeRepresentation());
+ Reference<chart2::data::XDataSequence> xValuesY
+ = getDataSequenceFromDocByRole(xChartDoc, u"values-y");
+ CPPUNIT_ASSERT_EQUAL(sExpectedValuesY, xValuesY->getSourceRangeRepresentation());
+ }
+
+ // Remove last sheet
+ uno::Sequence<beans::PropertyValue> aArgs(
+ comphelper::InitPropertySequence({ { "Index", uno::Any(sal_uInt16(3)) } }));
+ dispatchCommand(mxComponent, ".uno:Remove", aArgs);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xIA->getCount());
+
+ for (sal_Int32 sheetIndex = 0; sheetIndex < 2; ++sheetIndex)
+ {
+ OUString sExpectedValuesX("$Tabelle" + OUString::number(sheetIndex + 1) + ".$A$2:$A$11");
+ OUString sExpectedValuesY("$Tabelle" + OUString::number(sheetIndex + 1) + ".$B$2:$B$11");
+ uno::Reference<chart2::XChartDocument> xChartDoc
+ = getChartDocFromSheet(sheetIndex, mxComponent);
+ Reference<chart2::data::XDataSequence> xValuesX
+ = getDataSequenceFromDocByRole(xChartDoc, u"values-x");
+
+ // Without the fix in place, this test would have failed with
+ // - Expected: $Tabelle2.$A$2:$A$11
+ // - Actual : $Tabelle2.$A$2:$Tabelle1.$A$11
+ CPPUNIT_ASSERT_EQUAL(sExpectedValuesX, xValuesX->getSourceRangeRepresentation());
+ Reference<chart2::data::XDataSequence> xValuesY
+ = getDataSequenceFromDocByRole(xChartDoc, u"values-y");
+ CPPUNIT_ASSERT_EQUAL(sExpectedValuesY, xValuesY->getSourceRangeRepresentation());
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */