chart2/qa/extras/chart2import.cxx | 18 ++++++++++++++++++ chart2/qa/extras/data/docx/tdf124083.docx |binary chart2/source/tools/InternalDataProvider.cxx | 11 +++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-)
New commits: commit 7eb4d9d0763b8e0d6dc1d35a30f3bb9291b596f5 Author: Balazs Varga <balazs.varga...@gmail.com> AuthorDate: Tue Aug 27 10:55:30 2019 +0200 Commit: Xisco Faulí <xiscofa...@libreoffice.org> CommitDate: Mon Sep 2 21:41:31 2019 +0200 tdf#124083 OOXML import: fix broken charts with missing value X Importing NaN value X, ie. where only "ptCount" was defined without explicit data, messed up the charts replacing all X values with sequence 1, 2, 3..., showing data points in wrong X positions, also showing the invalid "NaN" data points. Now internal data table contains the original X values, including NaNs, fixing broken charts. Change-Id: Ic3c69e15095d9b29643f5daef8f58c58b4a442db Reviewed-on: https://gerrit.libreoffice.org/78177 Reviewed-by: László Németh <nem...@numbertext.org> Tested-by: László Németh <nem...@numbertext.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/78404 Tested-by: Jenkins diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 72b96c97dc48..e0333c7811e2 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -129,6 +129,7 @@ public: void testDataPointInheritedColorDOCX(); void testExternalStrRefsXLSX(); void testSourceNumberFormatComplexCategoriesXLS(); + void testXaxisValues(); void testTdf123504(); void testTdf122765(); @@ -212,6 +213,7 @@ public: CPPUNIT_TEST(testDataPointInheritedColorDOCX); CPPUNIT_TEST(testExternalStrRefsXLSX); CPPUNIT_TEST(testSourceNumberFormatComplexCategoriesXLS); + CPPUNIT_TEST(testXaxisValues); CPPUNIT_TEST(testTdf123504); CPPUNIT_TEST(testTdf122765); @@ -1892,6 +1894,22 @@ void Chart2ImportTest::testSourceNumberFormatComplexCategoriesXLS() CPPUNIT_ASSERT(nNumberFormat != 0); } +void Chart2ImportTest::testXaxisValues() +{ + load("/chart2/qa/extras/data/docx/", "tdf124083.docx"); + uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + const uno::Reference< chart2::data::XDataSequence > xDataSeq = getDataSequenceFromDocByRole(xChartDoc, "values-x"); + Sequence<uno::Any> xSequence = xDataSeq->getData(); + // test X values + CPPUNIT_ASSERT_EQUAL(uno::Any(0.04), xSequence[0]); + CPPUNIT_ASSERT(rtl::math::isNan(*static_cast<const double*>(xSequence[1].getValue()))); + CPPUNIT_ASSERT_EQUAL(uno::Any(0.16), xSequence[2]); + CPPUNIT_ASSERT_EQUAL(uno::Any(0.11), xSequence[3]); + CPPUNIT_ASSERT(rtl::math::isNan(*static_cast<const double*>(xSequence[4].getValue()))); +} + void Chart2ImportTest::testTdf123504() { load("/chart2/qa/extras/data/ods/", "pie_chart_100_and_0.ods"); diff --git a/chart2/qa/extras/data/docx/tdf124083.docx b/chart2/qa/extras/data/docx/tdf124083.docx new file mode 100644 index 000000000000..b8030ca9a807 Binary files /dev/null and b/chart2/qa/extras/data/docx/tdf124083.docx differ diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index 9fdd59d66fbb..15eb6fdf3ef0 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -526,7 +526,6 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, co if (bInQuote) { // Opening quote. - bAllNumeric = false; pElem = nullptr; } else @@ -534,6 +533,9 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, co // Closing quote. if (pElem) aElem = OUString(pElem, p-pElem); + // Non empty string + if (!aElem.isEmpty()) + bAllNumeric = false; aRawElems.push_back(aElem); pElem = nullptr; aElem.clear(); @@ -591,7 +593,12 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, co if (bAllNumeric) { for (OUString & aRawElem : aRawElems) - aValues.push_back(aRawElem.toDouble()); + { + if (!aRawElem.isEmpty()) + aValues.push_back(aRawElem.toDouble()); + else + aValues.push_back(NAN); + } } else { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits