chart2: fix unserialization of empty cells

Change-Id: Ib7e5c8c4db6cac7ef1255246eea13325cf7cca69
Reviewed-on: https://gerrit.libreoffice.org/30030
Reviewed-by: jan iversen <jani@documentfoundation.org>
Tested-by: jan iversen <jani@documentfoundation.org>
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 7d0f8f2..bff7e81 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -90,6 +90,8 @@ public:
    void testSecondaryAxisTitleDefaultRotationXLSX();
    void testAxisTitleRotationXLSX();

    void testInternalDataProvider();

    CPPUNIT_TEST_SUITE(Chart2ImportTest);
    CPPUNIT_TEST(Fdo60083);
    CPPUNIT_TEST(testSteppedLines);
@@ -139,6 +141,9 @@ public:
    CPPUNIT_TEST(testAxisTitleDefaultRotationXLSX);
    CPPUNIT_TEST(testSecondaryAxisTitleDefaultRotationXLSX);
    CPPUNIT_TEST(testAxisTitleRotationXLSX);

    CPPUNIT_TEST(testInternalDataProvider);

    CPPUNIT_TEST_SUITE_END();

private:
@@ -1125,6 +1130,51 @@ void Chart2ImportTest::testAxisTitleRotationXLSX()

}

void Chart2ImportTest::testInternalDataProvider() {
    uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromImpress("/chart2/qa/extras/data/odp/", "chart.odp"), uno::UNO_QUERY_THROW);
    const uno::Reference< chart2::data::XDataProvider >& rxDataProvider = xChartDoc->getDataProvider();

    // Parse 42 array
    Reference<chart2::data::XDataSequence> xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;42;42;42}");
    Sequence<Any> xSequence = xDataSeq->getData();
    CPPUNIT_ASSERT_EQUAL(uno::Any(42), xSequence[0]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(42), xSequence[1]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(42), xSequence[2]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(42), xSequence[3]);

    // Parse empty first and last
    xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{\"\";42;42;\"\"}");
    xSequence = xDataSeq->getData();
    CPPUNIT_ASSERT_EQUAL(uno::Any(0),  xSequence[0]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(42), xSequence[1]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(42), xSequence[2]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(0),  xSequence[3]);

    // Parse empty middle
    xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"\";\"\";42}");
    xSequence = xDataSeq->getData();
    CPPUNIT_ASSERT_EQUAL(uno::Any(42), xSequence[0]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(0),  xSequence[1]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(0),  xSequence[2]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(42), xSequence[3]);

    // Parse mixed types, numeric only role
    xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"hello\";0;\"world\"}");
    xSequence = xDataSeq->getData();
    CPPUNIT_ASSERT_EQUAL(uno::Any(42), xSequence[0]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(0),  xSequence[1]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(0),  xSequence[2]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(0),  xSequence[3]);

    // Parse mixed types, mixed role
    xDataSeq = rxDataProvider->createDataSequenceByValueArray("categories", "{42;\"hello\";0;\"world\"}");
    xSequence = xDataSeq->getData();
    CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("42")),    xSequence[0]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("hello")), xSequence[1]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("0")),     xSequence[2]);
    CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("world")), xSequence[3]);
}

CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);

CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx
index 32dd3c7..7bcb65f0 100644
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -533,10 +533,7 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, co
            {
                // Opening quote.
                bAllNumeric = false;
                ++p;
                if (p == pEnd)
                    break;
                pElem = p;
                pElem = nullptr;
            }
            else
            {
@@ -552,11 +549,7 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, co
                    break;
            }
        }
        else if (bInQuote)
        {
            // Do nothing.
        }
        else if (*p == ';')
        else if (*p == ';' and !bInQuote)
        {
            // element separator.
            if (pElem)