chart2/qa/extras/chart2import.cxx | 23 +++++++++++++++++++++++ chart2/qa/extras/data/docx/bubblechart.docx |binary chart2/source/tools/InternalDataProvider.cxx | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-)
New commits: commit 0bdbd099bb52ae687196e06561e03c5c4d9c90eb Author: Dennis Francis <dennis.fran...@collabora.co.uk> Date: Thu Jul 20 13:15:57 2017 +0530 tdf#103984 : For bubble charts append data column... for "values-size" role too, after parsing in InternalDataProvider::createDataSequenceFromArray(). Without this, embedded bubble charts in documents(MSO) other than spreadsheets will be empty when imported. Also adds docx import chart2-unit-test in chart2import.cxx Change-Id: I63168074b30090a8b7cf977eb5af443f6b9ac240 Reviewed-on: https://gerrit.libreoffice.org/40258 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 871b41bc5376..e38612724ed0 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -39,6 +39,7 @@ public: void testODTChartSeries(); void testDOCChartSeries(); void testDOCXChartSeries(); + void testDOCXChartValuesSize(); void testPPTXChartSeries(); void testPPTXSparseChartSeries(); /** @@ -105,6 +106,7 @@ public: CPPUNIT_TEST(testODTChartSeries); CPPUNIT_TEST(testDOCChartSeries); CPPUNIT_TEST(testDOCXChartSeries); + CPPUNIT_TEST(testDOCXChartValuesSize); CPPUNIT_TEST(testPPTChartSeries); CPPUNIT_TEST(testPPTXChartSeries); CPPUNIT_TEST(testPPTXSparseChartSeries); @@ -375,6 +377,27 @@ void Chart2ImportTest::testDOCXChartSeries() CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), aLabels[2][0].get<OUString>()); } +void Chart2ImportTest::testDOCXChartValuesSize() +{ + load( "/chart2/qa/extras/data/docx/", "bubblechart.docx" ); + Reference<chart2::XChartDocument> xChartDoc( getChartDocFromWriter(0), uno::UNO_QUERY ); + CPPUNIT_ASSERT( xChartDoc.is() ); + + uno::Reference< chart::XChartDataArray > xDataArray( xChartDoc->getDataProvider(), UNO_QUERY_THROW ); + Sequence<OUString> aColumnDesc = xDataArray->getColumnDescriptions(); + // Number of columns = 3 (Y-values, X-values and bubble sizes). + // Without the fix there would only be 2 columns (no bubble sizes). + CPPUNIT_ASSERT_EQUAL_MESSAGE( "There must be 3 columns and descriptions", static_cast<sal_Int32>(3), aColumnDesc.getLength() ); + Sequence<Sequence<double>> aData = xDataArray->getData(); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "There must be exactly 3 data points", static_cast<sal_Int32>(3), aData.getLength() ); + + std::vector<std::vector<double>> aExpected = { { 2.7, 0.7, 10.0 }, { 3.2, 1.8, 4.0 }, { 0.8, 2.6, 8.0 } }; + + for ( sal_Int32 nRowIdx = 0; nRowIdx < 3; ++nRowIdx ) + for( sal_Int32 nColIdx = 0; nColIdx < 3; ++nColIdx ) + CPPUNIT_ASSERT_DOUBLES_EQUAL( aExpected[nRowIdx][nColIdx], aData[nRowIdx][nColIdx], 1e-1 ); +} + void Chart2ImportTest::testPPTChartSeries() { //test chart series names for ppt diff --git a/chart2/qa/extras/data/docx/bubblechart.docx b/chart2/qa/extras/data/docx/bubblechart.docx new file mode 100644 index 000000000000..c2040730cfcc Binary files /dev/null and b/chart2/qa/extras/data/docx/bubblechart.docx differ diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index c407c3ac9cdd..f936cd664a92 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -566,7 +566,7 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, co } if (rRole == "values-y" || rRole == "values-first" || rRole == "values-last" || - rRole == "values-min" || rRole == "values-max") + rRole == "values-min" || rRole == "values-max" || rRole == "values-size") { // Column values. Append a new data column and populate it. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits