From e0b0502516a10181bbd1737b93b38b2bba4c98e8 Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Tue, 8 Oct 2019 13:29:12 +0200 Subject: tdf#128016 Chart OOXML Import: fix duplicated category labels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not create category labels if the category axis is deleted. Regression from commit: fa0a981af41a2606541eec1cb20a379a739691e0 (tdf#114166 DOCX chart import: fix missing complex categories) Change-Id: If357b95956fccbbc6142879f22ebe1b6d715e850 Reviewed-on: https://gerrit.libreoffice.org/80443 Tested-by: Jenkins Reviewed-by: László Németh --- chart2/qa/extras/chart2import.cxx | 29 +++++++++++++++++++++ .../extras/data/docx/testSimpleCategoryAxis.docx | Bin 0 -> 31629 bytes 2 files changed, 29 insertions(+) create mode 100644 chart2/qa/extras/data/docx/testSimpleCategoryAxis.docx (limited to 'chart2') diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 34477f69d6ac..d0fcb34faafd 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -136,6 +136,7 @@ public: void testDataPointInheritedColorDOCX(); void testExternalStrRefsXLSX(); void testSourceNumberFormatComplexCategoriesXLS(); + void testSimpleCategoryAxis(); void testMultilevelCategoryAxis(); void testXaxisValues(); void testTdf123504(); @@ -227,6 +228,7 @@ public: CPPUNIT_TEST(testDataPointInheritedColorDOCX); CPPUNIT_TEST(testExternalStrRefsXLSX); CPPUNIT_TEST(testSourceNumberFormatComplexCategoriesXLS); + CPPUNIT_TEST(testSimpleCategoryAxis); CPPUNIT_TEST(testMultilevelCategoryAxis); CPPUNIT_TEST(testXaxisValues); CPPUNIT_TEST(testTdf123504); @@ -2062,6 +2064,33 @@ void Chart2ImportTest::testSourceNumberFormatComplexCategoriesXLS() CPPUNIT_ASSERT(nNumberFormat != 0); } +void Chart2ImportTest::testSimpleCategoryAxis() +{ + load("/chart2/qa/extras/data/docx/", "testSimpleCategoryAxis.docx"); + uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + // Test the internal data. + CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider()); + + Reference xInternalProvider(xChartDoc->getDataProvider(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xInternalProvider.is()); + + Reference xDescAccess(xInternalProvider, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDescAccess.is()); + + // Get the category labels. + Sequence > aCategories = xDescAccess->getComplexRowDescriptions(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[0].getLength()); + CPPUNIT_ASSERT(aCategories[0][0].endsWith("ria 1")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[1].getLength()); + CPPUNIT_ASSERT(aCategories[1][0].endsWith("ria 2")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[2].getLength()); + CPPUNIT_ASSERT(aCategories[2][0].endsWith("ria 3")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[3].getLength()); + CPPUNIT_ASSERT(aCategories[3][0].endsWith("ria 4")); +} + void Chart2ImportTest::testMultilevelCategoryAxis() { load("/chart2/qa/extras/data/docx/", "testMultilevelCategoryAxis.docx"); diff --git a/chart2/qa/extras/data/docx/testSimpleCategoryAxis.docx b/chart2/qa/extras/data/docx/testSimpleCategoryAxis.docx new file mode 100644 index 000000000000..de511664a5ba Binary files /dev/null and b/chart2/qa/extras/data/docx/testSimpleCategoryAxis.docx differ -- cgit