[Libreoffice-commits] core.git: chart2/qa oox/source
Jean-Tiare Le Bigot
admin at jtlebi.fr
Sun Nov 6 06:02:49 UTC 2016
chart2/qa/extras/chart2import.cxx | 24 +++++++++++++++++++++
chart2/qa/extras/data/pptx/sparse-chart.pptx |binary
oox/source/drawingml/chart/chartconverter.cxx | 9 +++----
oox/source/drawingml/chart/datasourceconverter.cxx | 2 -
oox/source/drawingml/chart/typegroupconverter.cxx | 1
5 files changed, 30 insertions(+), 6 deletions(-)
New commits:
commit 4bcf1872bbe9db1388769485a7e4c0cbcce3d53c
Author: Jean-Tiare Le Bigot <admin at jtlebi.fr>
Date: Thu Oct 13 23:43:41 2016 +0200
chartx: fix sparse chart import
Change-Id: I1bcd2257da900c6a88bc78040fabe5696e2bab7d
Reviewed-on: https://gerrit.libreoffice.org/29801
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index c8137b9..b508f3e 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 0000000..d91e8f5
Binary files /dev/null and b/chart2/qa/extras/data/pptx/sparse-chart.pptx differ
diff --git a/oox/source/drawingml/chart/chartconverter.cxx b/oox/source/drawingml/chart/chartconverter.cxx
index d494302..ff43fa7 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 2c3dbcf..738e705 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 e39fba7..f6c88e7 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 );
More information about the Libreoffice-commits
mailing list