summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.co.uk>2017-07-20 13:15:57 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-07-23 22:43:54 +0200
commit19c6f02868bb7ce8ebfbe1c44bc214b4caa604f5 (patch)
treef05904a0941508cf887695cd03639048a009333b
parentad287a1f4fae8a890faa475f0500097680bcf2b2 (diff)
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 <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> (cherry picked from commit 0bdbd099bb52ae687196e06561e03c5c4d9c90eb) Reviewed-on: https://gerrit.libreoffice.org/40336
-rw-r--r--chart2/qa/extras/chart2import.cxx23
-rw-r--r--chart2/qa/extras/data/docx/bubblechart.docxbin0 -> 17740 bytes
-rw-r--r--chart2/source/tools/InternalDataProvider.cxx2
3 files changed, 24 insertions, 1 deletions
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
--- /dev/null
+++ b/chart2/qa/extras/data/docx/bubblechart.docx
Binary files differ
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx
index fa77624adc44..ff4319a1a623 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.