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>
This commit is contained in:
committed by
Markus Mohrhard
parent
17e9dc436b
commit
4bcf1872bb
@@ -40,6 +40,7 @@ public:
|
|||||||
void testDOCChartSeries();
|
void testDOCChartSeries();
|
||||||
void testDOCXChartSeries();
|
void testDOCXChartSeries();
|
||||||
void testPPTXChartSeries();
|
void testPPTXChartSeries();
|
||||||
|
void testPPTXSparseChartSeries();
|
||||||
/**
|
/**
|
||||||
* Original data contains 3 series but 2 of them are hidden. For now, we
|
* 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
|
* detect and skip those hidden series on import (since we don't support
|
||||||
@@ -105,6 +106,7 @@ public:
|
|||||||
CPPUNIT_TEST(testDOCXChartSeries);
|
CPPUNIT_TEST(testDOCXChartSeries);
|
||||||
CPPUNIT_TEST(testPPTChartSeries);
|
CPPUNIT_TEST(testPPTChartSeries);
|
||||||
CPPUNIT_TEST(testPPTXChartSeries);
|
CPPUNIT_TEST(testPPTXChartSeries);
|
||||||
|
CPPUNIT_TEST(testPPTXSparseChartSeries);
|
||||||
CPPUNIT_TEST(testPPTXHiddenDataSeries);
|
CPPUNIT_TEST(testPPTXHiddenDataSeries);
|
||||||
CPPUNIT_TEST(testPPTXPercentageNumberFormats);
|
CPPUNIT_TEST(testPPTXPercentageNumberFormats);
|
||||||
CPPUNIT_TEST(testPPTXStackedNonStackedYAxis);
|
CPPUNIT_TEST(testPPTXStackedNonStackedYAxis);
|
||||||
@@ -399,6 +401,28 @@ void Chart2ImportTest::testPPTXChartSeries()
|
|||||||
CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), aLabels[2][0].get<OUString>());
|
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()
|
void Chart2ImportTest::testPPTXHiddenDataSeries()
|
||||||
{
|
{
|
||||||
load("/chart2/qa/extras/data/pptx/", "stacked-bar-chart-hidden-series.pptx");
|
load("/chart2/qa/extras/data/pptx/", "stacked-bar-chart-hidden-series.pptx");
|
||||||
|
BIN
chart2/qa/extras/data/pptx/sparse-chart.pptx
Executable file
BIN
chart2/qa/extras/data/pptx/sparse-chart.pptx
Executable file
Binary file not shown.
@@ -133,11 +133,10 @@ Reference< XDataSequence > ChartConverter::createDataSequence(
|
|||||||
if( !rDataSeq.maData.empty() )
|
if( !rDataSeq.maData.empty() )
|
||||||
{
|
{
|
||||||
// create a single-row array from constant source data
|
// create a single-row array from constant source data
|
||||||
Matrix< Any > aMatrix( rDataSeq.maData.size(), 1 );
|
Matrix< Any > aMatrix( rDataSeq.mnPointCount, 1 );
|
||||||
Matrix< Any >::iterator aMIt = aMatrix.begin();
|
for( DataSequenceModel::AnyMap::const_iterator aDIt = rDataSeq.maData.begin(), aDEnd = rDataSeq.maData.end(); aDIt != aDEnd; ++aDIt )
|
||||||
// TODO: how to handle missing values in the map?
|
*aMatrix.at(aDIt->first, 0) = aDIt->second;
|
||||||
for( DataSequenceModel::AnyMap::const_iterator aDIt = rDataSeq.maData.begin(), aDEnd = rDataSeq.maData.end(); aDIt != aDEnd; ++aDIt, ++aMIt )
|
|
||||||
*aMIt = aDIt->second;
|
|
||||||
aRangeRep = lclGenerateApiArray( aMatrix );
|
aRangeRep = lclGenerateApiArray( aMatrix );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,7 +69,7 @@ Reference< XDataSequence > DataSequenceConverter::createDataSequence( const OUSt
|
|||||||
if(!bFirst)
|
if(!bFirst)
|
||||||
{
|
{
|
||||||
mrModel.maData.clear();
|
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);
|
xDataSeq = getChartConverter().createDataSequence(getChartDocument()->getDataProvider(), mrModel, rRole);
|
||||||
|
@@ -296,6 +296,7 @@ Reference< XLabeledDataSequence > TypeGroupConverter::createCategorySequence()
|
|||||||
SeriesModel &aModel = *mrModel.maSeries.get(0);
|
SeriesModel &aModel = *mrModel.maSeries.get(0);
|
||||||
DataSourceModel &aSrc = aModel.maSources.create( SeriesModel::CATEGORIES );
|
DataSourceModel &aSrc = aModel.maSources.create( SeriesModel::CATEGORIES );
|
||||||
DataSequenceModel &aSeq = aSrc.mxDataSeq.create();
|
DataSequenceModel &aSeq = aSrc.mxDataSeq.create();
|
||||||
|
aSeq.mnPointCount = nMaxValues;
|
||||||
for( sal_Int32 i = 0; i < nMaxValues; i++ )
|
for( sal_Int32 i = 0; i < nMaxValues; i++ )
|
||||||
aSeq.maData[ i ] <<= OUString::number( i + 1 );
|
aSeq.maData[ i ] <<= OUString::number( i + 1 );
|
||||||
SeriesConverter aSeriesConv( *this, aModel );
|
SeriesConverter aSeriesConv( *this, aModel );
|
||||||
|
Reference in New Issue
Block a user