summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Tiare Le Bigot <admin@jtlebi.fr>2016-10-13 23:43:41 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-11-06 06:02:27 +0000
commit4bcf1872bbe9db1388769485a7e4c0cbcce3d53c (patch)
tree0110875cf6db25b7208099e9394995254111b221
parent17e9dc436bc6ad8d3a5bbde15d4d47262650aa2c (diff)
chartx: fix sparse chart import
Change-Id: I1bcd2257da900c6a88bc78040fabe5696e2bab7d Reviewed-on: https://gerrit.libreoffice.org/29801 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--chart2/qa/extras/chart2import.cxx24
-rwxr-xr-xchart2/qa/extras/data/pptx/sparse-chart.pptxbin0 -> 57398 bytes
-rw-r--r--oox/source/drawingml/chart/chartconverter.cxx9
-rw-r--r--oox/source/drawingml/chart/datasourceconverter.cxx2
-rw-r--r--oox/source/drawingml/chart/typegroupconverter.cxx1
5 files changed, 30 insertions, 6 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index c8137b9ac6ff..b508f3e123dd 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -40,6 +40,7 @@ public:
void testDOCChartSeries();
void testDOCXChartSeries();
void testPPTXChartSeries();
+ void testPPTXSparseChartSeries();
/**
* Original data contains 3 series but 2 of them are hidden. For now, we
* detect and skip those hidden series on import (since we don't support
@@ -105,6 +106,7 @@ public:
CPPUNIT_TEST(testDOCXChartSeries);
CPPUNIT_TEST(testPPTChartSeries);
CPPUNIT_TEST(testPPTXChartSeries);
+ CPPUNIT_TEST(testPPTXSparseChartSeries);
CPPUNIT_TEST(testPPTXHiddenDataSeries);
CPPUNIT_TEST(testPPTXPercentageNumberFormats);
CPPUNIT_TEST(testPPTXStackedNonStackedYAxis);
@@ -399,6 +401,28 @@ void Chart2ImportTest::testPPTXChartSeries()
CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), aLabels[2][0].get<OUString>());
}
+void Chart2ImportTest::testPPTXSparseChartSeries()
+{
+ //test chart series sparse data for pptx
+ load("/chart2/qa/extras/data/pptx/", "sparse-chart.pptx");
+ Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
+ CPPUNIT_ASSERT(xCT.is());
+
+ std::vector<std::vector<double> > aValues = getDataSeriesYValuesFromChartType(xCT);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aValues.size());
+ CPPUNIT_ASSERT_EQUAL(0.0, aValues[0][0]);
+ CPPUNIT_ASSERT_EQUAL(2.5, aValues[0][1]);
+ CPPUNIT_ASSERT_EQUAL(3.5, aValues[0][2]);
+ CPPUNIT_ASSERT_EQUAL(0.0, aValues[0][3]);
+ CPPUNIT_ASSERT_EQUAL(-2.4, aValues[1][0]);
+ CPPUNIT_ASSERT_EQUAL(0.0, aValues[1][1]);
+ CPPUNIT_ASSERT_EQUAL(0.0, aValues[1][2]);
+ CPPUNIT_ASSERT_EQUAL(-2.8, aValues[1][3]);
+}
+
void Chart2ImportTest::testPPTXHiddenDataSeries()
{
load("/chart2/qa/extras/data/pptx/", "stacked-bar-chart-hidden-series.pptx");
diff --git a/chart2/qa/extras/data/pptx/sparse-chart.pptx b/chart2/qa/extras/data/pptx/sparse-chart.pptx
new file mode 100755
index 000000000000..d91e8f52f40a
--- /dev/null
+++ b/chart2/qa/extras/data/pptx/sparse-chart.pptx
Binary files differ
diff --git a/oox/source/drawingml/chart/chartconverter.cxx b/oox/source/drawingml/chart/chartconverter.cxx
index d49430245e7f..ff43fa7a5460 100644
--- a/oox/source/drawingml/chart/chartconverter.cxx
+++ b/oox/source/drawingml/chart/chartconverter.cxx
@@ -133,11 +133,10 @@ Reference< XDataSequence > ChartConverter::createDataSequence(
if( !rDataSeq.maData.empty() )
{
// create a single-row array from constant source data
- Matrix< Any > aMatrix( rDataSeq.maData.size(), 1 );
- Matrix< Any >::iterator aMIt = aMatrix.begin();
- // TODO: how to handle missing values in the map?
- for( DataSequenceModel::AnyMap::const_iterator aDIt = rDataSeq.maData.begin(), aDEnd = rDataSeq.maData.end(); aDIt != aDEnd; ++aDIt, ++aMIt )
- *aMIt = aDIt->second;
+ Matrix< Any > aMatrix( rDataSeq.mnPointCount, 1 );
+ for( DataSequenceModel::AnyMap::const_iterator aDIt = rDataSeq.maData.begin(), aDEnd = rDataSeq.maData.end(); aDIt != aDEnd; ++aDIt )
+ *aMatrix.at(aDIt->first, 0) = aDIt->second;
+
aRangeRep = lclGenerateApiArray( aMatrix );
}
diff --git a/oox/source/drawingml/chart/datasourceconverter.cxx b/oox/source/drawingml/chart/datasourceconverter.cxx
index 2c3dbcf7b1fb..738e7051a409 100644
--- a/oox/source/drawingml/chart/datasourceconverter.cxx
+++ b/oox/source/drawingml/chart/datasourceconverter.cxx
@@ -69,7 +69,7 @@ Reference< XDataSequence > DataSequenceConverter::createDataSequence( const OUSt
if(!bFirst)
{
mrModel.maData.clear();
- mrModel.maData.insert(std::make_pair<sal_Int32, Any>(1, Any(aTitle.makeStringAndClear())));
+ mrModel.maData.insert(std::make_pair<sal_Int32, Any>(0, Any(aTitle.makeStringAndClear())));
}
}
xDataSeq = getChartConverter().createDataSequence(getChartDocument()->getDataProvider(), mrModel, rRole);
diff --git a/oox/source/drawingml/chart/typegroupconverter.cxx b/oox/source/drawingml/chart/typegroupconverter.cxx
index e39fba78686e..f6c88e763376 100644
--- a/oox/source/drawingml/chart/typegroupconverter.cxx
+++ b/oox/source/drawingml/chart/typegroupconverter.cxx
@@ -296,6 +296,7 @@ Reference< XLabeledDataSequence > TypeGroupConverter::createCategorySequence()
SeriesModel &aModel = *mrModel.maSeries.get(0);
DataSourceModel &aSrc = aModel.maSources.create( SeriesModel::CATEGORIES );
DataSequenceModel &aSeq = aSrc.mxDataSeq.create();
+ aSeq.mnPointCount = nMaxValues;
for( sal_Int32 i = 0; i < nMaxValues; i++ )
aSeq.maData[ i ] <<= OUString::number( i + 1 );
SeriesConverter aSeriesConv( *this, aModel );