[Libreoffice-commits] core.git: chart2/qa chart2/source
Jean-Tiare Le Bigot
admin at jtlebi.fr
Thu Dec 1 17:32:30 UTC 2016
chart2/qa/extras/chart2import.cxx | 17 ++++++++---------
chart2/source/tools/InternalDataProvider.cxx | 7 ++++++-
2 files changed, 14 insertions(+), 10 deletions(-)
New commits:
commit 18b3138a7ac4da823e41640bed8a4707029b8fb0
Author: Jean-Tiare Le Bigot <admin at jtlebi.fr>
Date: Mon Nov 28 09:09:55 2016 +0100
tdf#102621: import empty chart cells as NaN instead of 0
Change-Id: I574c3f719e52bc2244597532783130564621a891
Reviewed-on: https://gerrit.libreoffice.org/31303
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index b508f3e..be36047 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -25,7 +25,6 @@
#include <com/sun/star/util/Color.hpp>
-
class Chart2ImportTest : public ChartTest
{
public:
@@ -413,13 +412,13 @@ void Chart2ImportTest::testPPTXSparseChartSeries()
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( rtl::math::isNan( 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( rtl::math::isNan( 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( rtl::math::isNan( aValues[1][1] ) );
+ CPPUNIT_ASSERT( rtl::math::isNan( aValues[1][2] ) );
CPPUNIT_ASSERT_EQUAL(-2.8, aValues[1][3]);
}
@@ -1169,17 +1168,17 @@ void Chart2ImportTest::testInternalDataProvider() {
// Parse empty first and last
xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{\"\";42;42;\"\"}");
xSequence = xDataSeq->getData();
- CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[0]);
+ CPPUNIT_ASSERT( rtl::math::isNan( *static_cast<const double*>(xSequence[0].getValue())));
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[1]);
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[2]);
- CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[3]);
+ CPPUNIT_ASSERT( rtl::math::isNan( *static_cast<const double*>(xSequence[3].getValue())));
// Parse empty middle
xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"\";\"\";42}");
xSequence = xDataSeq->getData();
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
- CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[1]);
- CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[2]);
+ CPPUNIT_ASSERT( rtl::math::isNan( *static_cast<const double*>(xSequence[1].getValue())) );
+ CPPUNIT_ASSERT( rtl::math::isNan( *static_cast<const double*>(xSequence[2].getValue())) );
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[3]);
// Parse mixed types, numeric only role
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx
index ef6facd..9f5f318 100644
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -573,7 +573,12 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, co
std::vector<double> aValues;
aValues.reserve(aRawElems.size());
for (OUString & aRawElem : aRawElems)
- aValues.push_back(aRawElem.toDouble());
+ {
+ if (aRawElem.isEmpty())
+ aValues.push_back(NAN);
+ else
+ aValues.push_back(aRawElem.toDouble());
+ }
sal_Int32 n = m_aInternalData.appendColumn();
m_aInternalData.setColumnValues(n, aValues);
More information about the Libreoffice-commits
mailing list