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@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
This commit is contained in:
parent
6982598524
commit
18b3138a7a
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include <com/sun/star/util/Color.hpp>
|
#include <com/sun/star/util/Color.hpp>
|
||||||
|
|
||||||
|
|
||||||
class Chart2ImportTest : public ChartTest
|
class Chart2ImportTest : public ChartTest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -413,13 +412,13 @@ void Chart2ImportTest::testPPTXSparseChartSeries()
|
|||||||
|
|
||||||
std::vector<std::vector<double> > aValues = getDataSeriesYValuesFromChartType(xCT);
|
std::vector<std::vector<double> > aValues = getDataSeriesYValuesFromChartType(xCT);
|
||||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aValues.size());
|
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(2.5, aValues[0][1]);
|
||||||
CPPUNIT_ASSERT_EQUAL(3.5, aValues[0][2]);
|
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(-2.4, aValues[1][0]);
|
||||||
CPPUNIT_ASSERT_EQUAL(0.0, aValues[1][1]);
|
CPPUNIT_ASSERT( rtl::math::isNan( aValues[1][1] ) );
|
||||||
CPPUNIT_ASSERT_EQUAL(0.0, aValues[1][2]);
|
CPPUNIT_ASSERT( rtl::math::isNan( aValues[1][2] ) );
|
||||||
CPPUNIT_ASSERT_EQUAL(-2.8, aValues[1][3]);
|
CPPUNIT_ASSERT_EQUAL(-2.8, aValues[1][3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1169,17 +1168,17 @@ void Chart2ImportTest::testInternalDataProvider() {
|
|||||||
// Parse empty first and last
|
// Parse empty first and last
|
||||||
xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{\"\";42;42;\"\"}");
|
xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{\"\";42;42;\"\"}");
|
||||||
xSequence = xDataSeq->getData();
|
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[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[2]);
|
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
|
// Parse empty middle
|
||||||
xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"\";\"\";42}");
|
xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"\";\"\";42}");
|
||||||
xSequence = xDataSeq->getData();
|
xSequence = xDataSeq->getData();
|
||||||
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
|
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[1]);
|
CPPUNIT_ASSERT( rtl::math::isNan( *static_cast<const double*>(xSequence[1].getValue())) );
|
||||||
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[2]);
|
CPPUNIT_ASSERT( rtl::math::isNan( *static_cast<const double*>(xSequence[2].getValue())) );
|
||||||
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[3]);
|
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[3]);
|
||||||
|
|
||||||
// Parse mixed types, numeric only role
|
// Parse mixed types, numeric only role
|
||||||
|
@ -573,7 +573,12 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, co
|
|||||||
std::vector<double> aValues;
|
std::vector<double> aValues;
|
||||||
aValues.reserve(aRawElems.size());
|
aValues.reserve(aRawElems.size());
|
||||||
for (OUString & aRawElem : aRawElems)
|
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();
|
sal_Int32 n = m_aInternalData.appendColumn();
|
||||||
|
|
||||||
m_aInternalData.setColumnValues(n, aValues);
|
m_aInternalData.setColumnValues(n, aValues);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user