diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2019-07-17 12:57:47 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-07-24 14:04:06 +0200 |
commit | fa0a981af41a2606541eec1cb20a379a739691e0 (patch) | |
tree | a90104181609266bdd21538ef85b1bafbb297465 /chart2 | |
parent | 9c4945a6767c298258f8aab053841242dc4f7afc (diff) |
tdf#114166 DOCX chart import: fix missing complex categories
Now complex category labels are visible, and the inner data
table contains the correct texts of the category columns.
Note: repeating call of createDataSequenceByValueArray() API function
can create all columns of the complex categories. See also
commit 6c4e21a234f12e1310ba06f9859e08b424acf8bf
"bnc#812796: Correctly handle static value array for OOXML charts."
Change-Id: I333b79be35a24a912bb9e662116d0c85809a8fb2
Reviewed-on: https://gerrit.libreoffice.org/75776
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/qa/extras/chart2import.cxx | 38 | ||||
-rw-r--r-- | chart2/qa/extras/data/docx/testMultilevelCategoryAxis.docx | bin | 0 -> 5890 bytes | |||
-rw-r--r-- | chart2/source/tools/InternalData.cxx | 11 |
3 files changed, 44 insertions, 5 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 107daed69fea..710d15ebd60e 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -131,6 +131,7 @@ public: void testDataPointInheritedColorDOCX(); void testExternalStrRefsXLSX(); void testSourceNumberFormatComplexCategoriesXLS(); + void testMultilevelCategoryAxis(); void testTdf123504(); void testTdf122765(); @@ -216,6 +217,7 @@ public: CPPUNIT_TEST(testDataPointInheritedColorDOCX); CPPUNIT_TEST(testExternalStrRefsXLSX); CPPUNIT_TEST(testSourceNumberFormatComplexCategoriesXLS); + CPPUNIT_TEST(testMultilevelCategoryAxis); CPPUNIT_TEST(testTdf123504); CPPUNIT_TEST(testTdf122765); @@ -1534,10 +1536,10 @@ void Chart2ImportTest::testInternalDataProvider() { // Parse mixed types, mixed role xDataSeq = rxDataProvider->createDataSequenceByValueArray("categories", "{42;\"hello\";0;\"world\"}"); xSequence = xDataSeq->getData(); - CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("42")), xSequence[0]); - CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("hello")), xSequence[1]); - CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("0")), xSequence[2]); - CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("world")), xSequence[3]); + CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 1 42")), xSequence[0]); + CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 2 hello")), xSequence[1]); + CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 3 0")), xSequence[2]); + CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 4 world")), xSequence[3]); } void Chart2ImportTest::testTdf90510() @@ -1946,6 +1948,34 @@ void Chart2ImportTest::testSourceNumberFormatComplexCategoriesXLS() CPPUNIT_ASSERT(nNumberFormat != 0); } +void Chart2ImportTest::testMultilevelCategoryAxis() +{ + load("/chart2/qa/extras/data/docx/", "testMultilevelCategoryAxis.docx"); + uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + // Test the internal data. + CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider()); + + Reference<chart2::XInternalDataProvider> xInternalProvider(xChartDoc->getDataProvider(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xInternalProvider.is()); + + Reference<chart::XComplexDescriptionAccess> xDescAccess(xInternalProvider, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDescAccess.is()); + + // Get the complex category labels. + Sequence<Sequence<OUString> > aCategories = xDescAccess->getComplexRowDescriptions(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aCategories.getLength()); + CPPUNIT_ASSERT_EQUAL(OUString("2011"), aCategories[0][0]); + CPPUNIT_ASSERT_EQUAL(OUString(""), aCategories[1][0]); + CPPUNIT_ASSERT_EQUAL(OUString("2012"), aCategories[2][0]); + CPPUNIT_ASSERT_EQUAL(OUString(""), aCategories[3][0]); + CPPUNIT_ASSERT_EQUAL(OUString("Categoria 1"), aCategories[0][1]); + CPPUNIT_ASSERT_EQUAL(OUString("Categoria 2"), aCategories[1][1]); + CPPUNIT_ASSERT_EQUAL(OUString("Categoria 3"), aCategories[2][1]); + CPPUNIT_ASSERT_EQUAL(OUString("Categoria 4"), aCategories[3][1]); +} + void Chart2ImportTest::testTdf123504() { load("/chart2/qa/extras/data/ods/", "pie_chart_100_and_0.ods"); diff --git a/chart2/qa/extras/data/docx/testMultilevelCategoryAxis.docx b/chart2/qa/extras/data/docx/testMultilevelCategoryAxis.docx Binary files differnew file mode 100644 index 000000000000..75605de72fc5 --- /dev/null +++ b/chart2/qa/extras/data/docx/testMultilevelCategoryAxis.docx diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx index b99578fab118..b7a5118004ba 100644 --- a/chart2/source/tools/InternalData.cxx +++ b/chart2/source/tools/InternalData.cxx @@ -220,7 +220,16 @@ void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< uno::A m_aRowLabels.resize(nRowIndex+1); enlargeData( 0, nRowIndex+1 ); } - m_aRowLabels[nRowIndex] = rComplexLabel; + sal_Int32 nSize = static_cast<sal_Int32>( m_aRowLabels[nRowIndex].size() ); + if( nSize >= 1 ) + { + m_aRowLabels[nRowIndex].resize(nSize+1); + m_aRowLabels[nRowIndex][nSize] = rComplexLabel[0]; + } + else + { + m_aRowLabels[nRowIndex] = rComplexLabel; + } } vector< uno::Any > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const |