From 86be3422cd55fa9e44104f1628648061bb6a3495 Mon Sep 17 00:00:00 2001 From: Tünde Tóth Date: Wed, 18 Dec 2019 16:46:36 +0100 Subject: tdf#129857 Chart OOXML export: fix deleted legend entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The legend showed deleted legend entries too after export. Change-Id: I872654d6e4d3f385c468b7fde03d39e233692fa1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86161 Reviewed-by: László Németh Tested-by: László Németh --- chart2/qa/extras/chart2export.cxx | 40 +++++++++++++++++++++++++++++++++++++++ chart2/qa/extras/chart2import.cxx | 39 -------------------------------------- 2 files changed, 40 insertions(+), 39 deletions(-) (limited to 'chart2') diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 62aa0764a69a..96278053d59f 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -150,6 +150,7 @@ public: void testTdf122031(); void testTdf115012(); void testTdf123206_customLabelText(); + void testDeletedLegendEntries(); CPPUNIT_TEST_SUITE(Chart2ExportTest); CPPUNIT_TEST(testErrorBarXLSX); @@ -263,6 +264,7 @@ public: CPPUNIT_TEST(testTdf122031); CPPUNIT_TEST(testTdf115012); CPPUNIT_TEST(testTdf123206_customLabelText); + CPPUNIT_TEST(testDeletedLegendEntries); CPPUNIT_TEST_SUITE_END(); @@ -2403,6 +2405,44 @@ void Chart2ExportTest::testTdf123206_customLabelText() assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/c:rich/a:p/a:r/a:t", "kiscica"); } +void Chart2ExportTest::testDeletedLegendEntries() +{ + load("/chart2/qa/extras/data/xlsx/", "deleted_legend_entry.xlsx"); + { + reload("Calc Office Open XML"); + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 1)); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); + bool bShowLegendEntry = true; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("ShowLegendEntry") >>= bShowLegendEntry); + CPPUNIT_ASSERT(!bShowLegendEntry); + } + + load("/chart2/qa/extras/data/xlsx/", "deleted_legend_entry2.xlsx"); + { + reload("Calc Office Open XML"); + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); + bool bShowLegendEntry = true; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("ShowLegendEntry") >>= bShowLegendEntry); + CPPUNIT_ASSERT(!bShowLegendEntry); + + Reference xChartDoc2 = getChartDocFromSheet(1, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries2(getDataSeriesFromDoc(xChartDoc2, 0)); + CPPUNIT_ASSERT(xDataSeries2.is()); + Reference xPropertySet2(xDataSeries2, uno::UNO_QUERY_THROW); + Sequence deletedLegendEntriesSeq; + CPPUNIT_ASSERT(xPropertySet2->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), deletedLegendEntriesSeq[0]); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 5fcf205df813..9317785520c6 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -148,10 +148,8 @@ public: void testXaxisValues(); void testTdf123504(); void testTdf122765(); - void testTdf121991(); void testTdf123206CustomLabelField(); void testTdf125444PercentageCustomLabel(); - void testDeletedLegendEntries(); CPPUNIT_TEST_SUITE(Chart2ImportTest); CPPUNIT_TEST(Fdo60083); @@ -249,10 +247,8 @@ public: CPPUNIT_TEST(testXaxisValues); CPPUNIT_TEST(testTdf123504); CPPUNIT_TEST(testTdf122765); - CPPUNIT_TEST(testTdf121991); CPPUNIT_TEST(testTdf123206CustomLabelField); CPPUNIT_TEST(testTdf125444PercentageCustomLabel); - CPPUNIT_TEST(testDeletedLegendEntries); CPPUNIT_TEST_SUITE_END(); @@ -2289,19 +2285,6 @@ void Chart2ImportTest::testTdf122765() CPPUNIT_ASSERT_GREATER(sal_Int32(7000), aSlicePosition.X); } -void Chart2ImportTest::testTdf121991() -{ - load("/chart2/qa/extras/data/xlsx/", "deleted_legend_entry.xlsx"); - Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 1)); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); - bool bShowLegendEntry = true; - CPPUNIT_ASSERT(xPropertySet->getPropertyValue("ShowLegendEntry") >>= bShowLegendEntry); - CPPUNIT_ASSERT(!bShowLegendEntry); -} - void Chart2ImportTest::testTdf123206CustomLabelField() { // File contains the deprecated "custom-label-field" attribute of the @@ -2339,28 +2322,6 @@ void Chart2ImportTest::testTdf125444PercentageCustomLabel() CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType_PERCENTAGE, aLabelFields[2]->getFieldType()); } -void Chart2ImportTest::testDeletedLegendEntries() -{ - load("/chart2/qa/extras/data/xlsx/", "deleted_legend_entry2.xlsx"); - Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); - bool bShowLegendEntry = true; - CPPUNIT_ASSERT(xPropertySet->getPropertyValue("ShowLegendEntry") >>= bShowLegendEntry); - CPPUNIT_ASSERT(!bShowLegendEntry); - - Reference xChartDoc2 = getChartDocFromSheet(1, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries2(getDataSeriesFromDoc(xChartDoc2, 0)); - CPPUNIT_ASSERT(xDataSeries2.is()); - Reference xPropertySet2(xDataSeries2, uno::UNO_QUERY_THROW); - Sequence deletedLegendEntriesSeq; - CPPUNIT_ASSERT(xPropertySet2->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), deletedLegendEntriesSeq[0]); -} - CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit