summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorofftkp <parisoplop@gmail.com>2022-11-30 00:54:08 +0200
committerTomaž Vajngerl <quikee@gmail.com>2022-12-08 00:15:46 +0000
commitad085990b8073a122ac5222e5220f8f1d6826dcf (patch)
treef9077aaf967b106221b38d89b599931f10c2e5bb /chart2
parent40a59e3e58de1c3f60ae52d09fbc386399f8f122 (diff)
xlsx: Don't add cell data to chart data sequence if in totalsRow
When importing data from a cell range to use in a chart, if a cell is in the totalsRow it is now ignored if it's the last row in the range. Change-Id: Ie8c79b995c4d46b361492e8f7687894e2640392f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143488 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2import.cxx29
-rw-r--r--chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsxbin0 -> 20117 bytes
2 files changed, 29 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 68791e3b2d21..a9c301a94b93 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -137,6 +137,7 @@ public:
void testTdf121205();
void testFixedSizeBarChartVeryLongLabel();
void testAutomaticSizeBarChartVeryLongLabel();
+ void testTotalsRowIgnored();
CPPUNIT_TEST_SUITE(Chart2ImportTest);
CPPUNIT_TEST(Fdo60083);
@@ -223,6 +224,7 @@ public:
CPPUNIT_TEST(testTdf121205);
CPPUNIT_TEST(testFixedSizeBarChartVeryLongLabel);
CPPUNIT_TEST(testAutomaticSizeBarChartVeryLongLabel);
+ CPPUNIT_TEST(testTotalsRowIgnored);
CPPUNIT_TEST_SUITE_END();
};
@@ -2274,6 +2276,33 @@ void Chart2ImportTest::testAutomaticSizeBarChartVeryLongLabel()
CPPUNIT_ASSERT_DOUBLES_EQUAL(1192, xXAxis->getSize().Height, 100);
}
+void Chart2ImportTest::testTotalsRowIgnored()
+{
+ loadFromURL(u"xlsx/barchart_totalsrow.xlsx");
+ {
+ uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ Reference<chart2::data::XDataSequence> xDataSeq =
+ getDataSequenceFromDocByRole(xChartDoc, u"values-y");
+ CPPUNIT_ASSERT(xDataSeq.is());
+
+ // Table data range is D2:D9 (8 rows) but because last row is totals row it is ignored
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(7u), xDataSeq->getData().size());
+ }
+ {
+ uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(1, mxComponent);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ Reference<chart2::data::XDataSequence> xDataSeq =
+ getDataSequenceFromDocByRole(xChartDoc, u"values-y");
+ CPPUNIT_ASSERT(xDataSeq.is());
+
+ // Table data range is D2:D10 (9 rows) and totals row isn't the last row so it's not ignored
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(9u), xDataSeq->getData().size());
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx b/chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx
new file mode 100644
index 000000000000..c87b2b3186ac
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx
Binary files differ