From e59db22b3b57c9e1a5678218cb56fb75bcc84c26 Mon Sep 17 00:00:00 2001 From: Tünde Tóth Date: Wed, 27 Jul 2022 08:58:35 +0200 Subject: tdf#150434: chart2, XLSX import: strip long legend labels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Full text of legend labels could overflow the chart area, if the legend text was too long. If it's longer than 520 characters, strip it at the first space from the 500th character (or if there is no space, at the 500th character). This results better XLSX interoperability, too. Change-Id: I23a94f6baaf620b40e9b2819738eba5c5a921722 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137492 Reviewed-by: László Németh Tested-by: László Németh --- chart2/qa/extras/chart2import2.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'chart2/qa/extras/chart2import2.cxx') diff --git a/chart2/qa/extras/chart2import2.cxx b/chart2/qa/extras/chart2import2.cxx index ee41c37dd48a..eb983f7687f1 100644 --- a/chart2/qa/extras/chart2import2.cxx +++ b/chart2/qa/extras/chart2import2.cxx @@ -60,6 +60,7 @@ public: void testTdf121281(); void testTdf139658(); void testTdf146066(); + void testTdf150434(); CPPUNIT_TEST_SUITE(Chart2ImportTest2); @@ -101,6 +102,7 @@ public: CPPUNIT_TEST(testTdf121281); CPPUNIT_TEST(testTdf139658); CPPUNIT_TEST(testTdf146066); + CPPUNIT_TEST(testTdf150434); CPPUNIT_TEST_SUITE_END(); }; @@ -930,6 +932,22 @@ void Chart2ImportTest2::testTdf146066() CPPUNIT_ASSERT_EQUAL(OUString("35"), xLabel7->getString()); } +void Chart2ImportTest2::testTdf150434() +{ + load(u"/chart2/qa/extras/data/xlsx/", u"tdf150434.xlsx"); + Reference xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference xLegend = getShapeByName(xShapes, "CID/D=0:Legend="); + CPPUNIT_ASSERT(xLegend.is()); + awt::Point aPosition = xLegend->getPosition(); + + // This failed, if the legend flowed out of the chart area. + CPPUNIT_ASSERT_GREATEREQUAL(static_cast(0), aPosition.Y); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit