[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - 3 commits - chart2/qa chart2/source dbaccess/source include/oox offapi/com oox/source sc/inc sc/source sw/inc sw/source

Kohei Yoshida kohei.yoshida at collabora.com
Wed Jul 2 20:31:17 PDT 2014


 chart2/qa/extras/chart2import.cxx                  |   30 ++-
 chart2/qa/extras/charttest.hxx                     |   89 +++++++++
 chart2/source/inc/InternalDataProvider.hxx         |    8 
 chart2/source/tools/InternalDataProvider.cxx       |  200 ++++++++++++++-------
 dbaccess/source/core/inc/DatabaseDataProvider.hxx  |    6 
 dbaccess/source/core/misc/DatabaseDataProvider.cxx |    8 
 include/oox/drawingml/chart/chartconverter.hxx     |    8 
 offapi/com/sun/star/chart2/data/XDataProvider.idl  |    3 
 oox/source/drawingml/chart/chartconverter.cxx      |    6 
 oox/source/drawingml/chart/datasourceconverter.cxx |    4 
 oox/source/drawingml/chart/seriesconverter.cxx     |    6 
 sc/inc/chart2uno.hxx                               |    4 
 sc/source/filter/inc/excelchartconverter.hxx       |    2 
 sc/source/filter/oox/excelchartconverter.cxx       |    3 
 sc/source/ui/unoobj/chart2uno.cxx                  |    8 
 sw/inc/unochart.hxx                                |    5 
 sw/source/core/unocore/unochart.cxx                |    8 
 17 files changed, 321 insertions(+), 77 deletions(-)

New commits:
commit d4088f84a9617f886173fddf4a3426345ce1704b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jul 2 11:19:05 2014 -0400

    More fine-grained check of data series labels in the unit test.
    
    (cherry picked from commit bdad8d9051c207b2eff0d5a7842da83e6119a600)
    
    Change-Id: I6b23126816bb114407f2b75545094bc297ee7cc3

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 9ca95b6..1441903 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -244,10 +244,17 @@ void Chart2ImportTest::testDOCChartSeries()
 void Chart2ImportTest::testDOCXChartSeries()
 {
     load("/chart2/qa/extras/data/docx/", "chart.docx");
-    uno::Sequence< OUString > seriesList = getWriterChartColumnDescriptions(mxComponent);
-    CPPUNIT_ASSERT_EQUAL(OUString("Series 1"), seriesList[0]);
-    CPPUNIT_ASSERT_EQUAL(OUString("Series 2"), seriesList[1]);
-    CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), seriesList[2]);
+    Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xChartDoc.is());
+
+    Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0, 0);
+    CPPUNIT_ASSERT(xCT.is());
+
+    std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
+    CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
+    CPPUNIT_ASSERT_EQUAL(OUString("Series 1"), aLabels[0][0].get<OUString>());
+    CPPUNIT_ASSERT_EQUAL(OUString("Series 2"), aLabels[1][0].get<OUString>());
+    CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), aLabels[2][0].get<OUString>());
 }
 
 void Chart2ImportTest::testPPTChartSeries()
@@ -264,11 +271,18 @@ void Chart2ImportTest::testPPTChartSeries()
 void Chart2ImportTest::testPPTXChartSeries()
 {
     //test chart series names for pptx
-    uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions("/chart2/qa/extras/data/pptx/", "chart.pptx");
-    CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[1]);
-    CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[2]);
-    CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[3]);
+    load("/chart2/qa/extras/data/pptx/", "chart.pptx");
+    Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xChartDoc.is());
+
+    Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0, 0);
+    CPPUNIT_ASSERT(xCT.is());
 
+    std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
+    CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
+    CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), aLabels[0][0].get<OUString>());
+    CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), aLabels[1][0].get<OUString>());
+    CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), aLabels[2][0].get<OUString>());
 }
 
 void Chart2ImportTest::testODPChartSeries()
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 637cfe0..53a465b 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -50,6 +50,10 @@ public:
     void reload( const OUString& rFilterName );
     uno::Sequence < OUString > getImpressChartColumnDescriptions( const char* pDir, const char* pName );
 
+    uno::Reference<chart::XChartDocument> getChartDocFromWriter( sal_Int32 nShape );
+
+    uno::Reference<chart::XChartDocument> getChartDocFromDrawImpress( sal_Int32 nPage, sal_Int32 nShape );
+
     virtual void setUp();
     virtual void tearDown();
 protected:
@@ -205,4 +209,89 @@ uno::Sequence < OUString > ChartTest::getImpressChartColumnDescriptions( const c
     return seriesList;
 }
 
+uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromWriter( sal_Int32 nShape )
+{
+    Reference<drawing::XDrawPageSupplier> xPageSupp(mxComponent, uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xPageSupp.is());
+
+    Reference<drawing::XDrawPage> xPage = xPageSupp->getDrawPage();
+    CPPUNIT_ASSERT(xPage.is());
+
+    Reference<beans::XPropertySet> xShapeProps(xPage->getByIndex(nShape), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xShapeProps.is());
+
+    Reference<frame::XModel> xDocModel;
+    xShapeProps->getPropertyValue("Model") >>= xDocModel;
+    CPPUNIT_ASSERT(xDocModel.is());
+
+    uno::Reference<chart::XChartDocument> xChartDoc(xDocModel, uno::UNO_QUERY);
+    return xChartDoc;
+}
+
+uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromDrawImpress(
+    sal_Int32 nPage, sal_Int32 nShape )
+{
+    uno::Reference<chart::XChartDocument> xEmpty;
+
+    uno::Reference<drawing::XDrawPagesSupplier> xPages(mxComponent, uno::UNO_QUERY);
+    if (!xPages.is())
+        return xEmpty;
+
+    uno::Reference<drawing::XDrawPage> xPage(
+        xPages->getDrawPages()->getByIndex(nPage), uno::UNO_QUERY_THROW);
+    if (!xPage.is())
+        return xEmpty;
+
+    uno::Reference<beans::XPropertySet> xShapeProps(xPage->getByIndex(nShape), uno::UNO_QUERY);
+    if (!xShapeProps.is())
+        return xEmpty;
+
+    uno::Reference<frame::XModel> xDocModel;
+    xShapeProps->getPropertyValue("Model") >>= xDocModel;
+    if (!xDocModel.is())
+        return xEmpty;
+
+    uno::Reference<chart::XChartDocument> xChartDoc(xDocModel, uno::UNO_QUERY);
+    return xChartDoc;
+}
+
+std::vector<uno::Sequence<uno::Any> > getDataSeriesLabelsFromChartType( const Reference<chart2::XChartType>& xCT )
+{
+    OUString aLabelRole = xCT->getRoleOfSequenceForSeriesLabel();
+
+    Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xDSCont.is());
+    Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
+
+    std::vector<uno::Sequence<uno::Any> > aRet;
+    for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)
+    {
+        uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY);
+        CPPUNIT_ASSERT(xDSrc.is());
+        uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
+        for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j)
+        {
+            Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues();
+            CPPUNIT_ASSERT(xValues.is());
+            Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY);
+            if (!xPropSet.is())
+                continue;
+
+            OUString aRoleName;
+            xPropSet->getPropertyValue("Role") >>= aRoleName;
+            if (aRoleName == aLabelRole)
+            {
+                Reference<chart2::data::XLabeledDataSequence> xLabel = aDataSeqs[j];
+                CPPUNIT_ASSERT(xLabel.is());
+                Reference<chart2::data::XDataSequence> xDS2 = xLabel->getLabel();
+                CPPUNIT_ASSERT(xDS2.is());
+                uno::Sequence<uno::Any> aData = xDS2->getData();
+                aRet.push_back(aData);
+            }
+        }
+    }
+
+    return aRet;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 7554f619f03e1fcadd333f2792913f412c0a7031
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jul 2 09:53:54 2014 -0400

    bnc#812796: Correctly handle static value array for OOXML charts.
    
    We need to pass the role of the data sequence in order to avoid unreliable
    guess work when importing static value array.
    
    Also, not all Excel's scatter plots have real numeric X values; some have
    textural X values in which case Excel switch to generating 1, 2, 3, ... as
    X values.  When importing to our chart implementation, using "categories" role
    in such cases instead of "values-x" results in a more faithful chart rendering.
    
    (cherry picked from commit 6c4e21a234f12e1310ba06f9859e08b424acf8bf)
    
    Conflicts:
    	chart2/source/inc/InternalDataProvider.hxx
    	chart2/source/tools/InternalDataProvider.cxx
    
    Conflicts:
    	chart2/source/inc/InternalDataProvider.hxx
    	dbaccess/source/core/inc/DatabaseDataProvider.hxx
    	dbaccess/source/core/misc/DatabaseDataProvider.cxx
    	sc/source/filter/inc/excelchartconverter.hxx
    
    Change-Id: If4bc1f650bb024dcd1b1b36537f457fb38404a78

diff --git a/chart2/source/inc/InternalDataProvider.hxx b/chart2/source/inc/InternalDataProvider.hxx
index 9c03b23..6ddcded 100644
--- a/chart2/source/inc/InternalDataProvider.hxx
+++ b/chart2/source/inc/InternalDataProvider.hxx
@@ -135,6 +135,11 @@ public:
         const OUString& aRangeRepresentation )
         throw (::com::sun::star::lang::IllegalArgumentException,
                ::com::sun::star::uno::RuntimeException);
+
+    virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
+        createDataSequenceByValueArray( const OUString& aRole, const OUString& aRangeRepresentation )
+            throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection()
         throw (::com::sun::star::uno::RuntimeException);
 
@@ -233,6 +238,9 @@ private:
 
     void lcl_deleteMapReferences( const OUString & rRangeRepresentation );
 
+    css::uno::Reference<css::chart2::data::XDataSequence>
+        createDataSequenceFromArray( const OUString& rArrayStr, const OUString& rRole );
+
     void lcl_adaptMapReferences(
         const OUString & rOldRangeRepresentation,
         const OUString & rNewRangeRepresentation );
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx
index fe70d7c..842dd63 100644
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -492,79 +492,155 @@ void InternalDataProvider::lcl_decreaseMapReferences(
 Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSequenceAndAddToMap(
     const OUString & rRangeRepresentation )
 {
-    OUString aRangeRepresentation = rRangeRepresentation;
-    if( aRangeRepresentation.indexOf('{') >= 0 )
-    {
-        ::std::vector< double > aNewData;
-        ::std::vector< uno::Any > aNewLabels;
-        OUString    aToken;
-        sal_Int32   nCategories     = 0;
-        sal_Int32   nIndex          = 0;
-        bool        bValues         = true;
-        bool        bLabelSet       = false;
-        OUString str = aRangeRepresentation.replace('{',' ').replace('}',' ');
-
-        m_aInternalData.clearDefaultData();
-        sal_Int32 n = m_aInternalData.getColumnCount();
-        if( n )
-            n = n - 1;
-
-        do
+    Reference<chart2::data::XDataSequence> xSeq = createDataSequenceFromArray(rRangeRepresentation, OUString());
+    if (xSeq.is())
+        return xSeq;
+
+    xSeq.set(new UncachedDataSequence(this, rRangeRepresentation));
+    lcl_addDataSequenceToMap(rRangeRepresentation, xSeq);
+    return xSeq;
+}
+
+uno::Reference<chart2::data::XDataSequence>
+InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, const OUString& rRole )
+{
+    if (rArrayStr.indexOf('{') != 0 || rArrayStr[rArrayStr.getLength()-1] != '}')
+    {
+        // Not an array string.
+        return uno::Reference<chart2::data::XDataSequence>();
+    }
+
+    bool bAllNumeric = true;
+    uno::Reference<chart2::data::XDataSequence> xSeq;
+
+    const sal_Unicode* p = rArrayStr.getStr();
+    const sal_Unicode* pEnd = p + rArrayStr.getLength();
+    const sal_Unicode* pElem = NULL;
+    OUString aElem;
+
+    std::vector<OUString> aRawElems;
+    ++p; // Skip the first '{'.
+    --pEnd; // Skip the last '}'.
+    bool bInQuote = false;
+    for (; p != pEnd; ++p)
+    {
+        if (*p == '"')
         {
-            // TODO: This will be problematic if ';' is used in label names
-            // '"' character also needs to be considered in such cases
-            aToken = str.getToken(0,';',nIndex);
-            if( aToken.isEmpty() )
-                break;
-            if( aToken.indexOf('"') < 0 )
+            bInQuote = !bInQuote;
+            if (bInQuote)
             {
-                aNewData.push_back( aToken.toDouble() );
+                // Opening quote.
+                bAllNumeric = false;
+                ++p;
+                if (p == pEnd)
+                    break;
+                pElem = p;
             }
             else
             {
-                aNewLabels.push_back( uno::makeAny(aToken.replace('"', ' ').trim()) );
-                if( !nCategories &&
-                   ( !m_aInternalData.getComplexColumnLabel(n).size() ||
-                     !m_aInternalData.getComplexColumnLabel(n).front().hasValue() ) )
-                {
-                    m_aInternalData.setComplexColumnLabel( n,  aNewLabels );
-                    bLabelSet = true;
-                }
-                else
-                {
-                    m_aInternalData.setComplexRowLabel(nCategories, aNewLabels);
-                    if(nCategories==1 && bLabelSet)
-                    {
-                        ::std::vector< uno::Any > aLabels;
-                        m_aInternalData.setComplexRowLabel( 0, m_aInternalData.getComplexColumnLabel( n ) );
-                        m_aInternalData.setComplexColumnLabel( n, aLabels );
-                    }
-                }
-                aNewLabels.pop_back();
-                nCategories++;
-                bValues = false;
+                // Closing quote.
+                if (pElem)
+                    aElem = OUString(pElem, p-pElem);
+                aRawElems.push_back(aElem);
+                pElem = NULL;
+                aElem = OUString();
+
+                ++p; // Skip '"'.
+                if (p == pEnd)
+                    break;
             }
-        } while( nIndex >= 0 );
-
-        if( bValues )
+        }
+        else if (bInQuote)
+        {
+            // Do nothing.
+        }
+        else if (*p == ';')
         {
-            m_aInternalData.insertColumn( n );
-            m_aInternalData.setColumnValues( n, aNewData );
-            aRangeRepresentation = OUString::number( n );
+            // element separator.
+            if (pElem)
+                aElem = OUString(pElem, p-pElem);
+            aRawElems.push_back(aElem);
+            pElem = NULL;
+            aElem = OUString();
         }
-        else if( nCategories > 1 )
+        else if (!pElem)
+            pElem = p;
+    }
+
+    if (pElem)
+    {
+        aElem = OUString(pElem, p-pElem);
+        aRawElems.push_back(aElem);
+    }
+
+    if (rRole == "values-y" || rRole == "values-first" || rRole == "values-last" ||
+        rRole == "values-min" || rRole == "values-max")
+    {
+        // Column values.  Append a new data column and populate it.
+
+        std::vector<double> aValues;
+        aValues.reserve(aRawElems.size());
+        for (size_t i = 0; i < aRawElems.size(); ++i)
+            aValues.push_back(aRawElems[i].toDouble());
+        sal_Int32 n = m_aInternalData.appendColumn();
+
+        m_aInternalData.setColumnValues(n, aValues);
+
+        OUString aRangeRep = OUString::number(n);
+        xSeq.set(new UncachedDataSequence(this, aRangeRep));
+        lcl_addDataSequenceToMap(aRangeRep, xSeq);
+    }
+    else if (rRole == "values-x")
+    {
+        std::vector<double> aValues;
+        aValues.reserve(aRawElems.size());
+        if (bAllNumeric)
         {
-            aRangeRepresentation = lcl_aCategoriesRangeName;
+            for (size_t i = 0; i < aRawElems.size(); ++i)
+                aValues.push_back(aRawElems[i].toDouble());
         }
         else
         {
-            aRangeRepresentation = lcl_aLabelRangePrefix+OUString::number( n );
+            for (size_t i = 0; i < aRawElems.size(); ++i)
+                aValues.push_back(i+1);
+        }
+
+        sal_Int32 n = m_aInternalData.appendColumn();
+        m_aInternalData.setColumnValues(n, aValues);
+
+        OUString aRangeRep = OUString::number(n);
+        xSeq.set(new UncachedDataSequence(this, aRangeRep));
+        lcl_addDataSequenceToMap(aRangeRep, xSeq);
+    }
+    else if (rRole == "categories")
+    {
+        // Category labels.
+
+        for (size_t i = 0; i < aRawElems.size(); ++i)
+        {
+            std::vector<uno::Any> aLabels(1, uno::makeAny(aRawElems[i]));
+            m_aInternalData.setComplexRowLabel(i, aLabels);
+        }
+
+        xSeq.set(new UncachedDataSequence(this, lcl_aCategoriesRangeName));
+        lcl_addDataSequenceToMap(lcl_aCategoriesRangeName, xSeq);
+    }
+    else if (rRole == "label")
+    {
+        // Data series label.  There should be only one element.  This always
+        // goes to the last data column.
+        sal_Int32 nColSize = m_aInternalData.getColumnCount();
+        if (!aRawElems.empty() && nColSize)
+        {
+            std::vector<uno::Any> aLabels(1, uno::makeAny(aRawElems[0]));
+            m_aInternalData.setComplexColumnLabel(nColSize-1, aLabels);
+
+            OUString aRangeRep = lcl_aLabelRangePrefix + OUString::number(nColSize-1);
+            xSeq.set(new UncachedDataSequence(this, aRangeRep));
+            lcl_addDataSequenceToMap(aRangeRep, xSeq);
         }
     }
 
-    Reference< chart2::data::XDataSequence > xSeq(
-        new UncachedDataSequence( this, aRangeRepresentation ));
-    lcl_addDataSequenceToMap( aRangeRepresentation, xSeq );
     return xSeq;
 }
 
@@ -765,6 +841,14 @@ Reference< chart2::data::XDataSequence > SAL_CALL InternalDataProvider::createDa
     return Reference< chart2::data::XDataSequence >();
 }
 
+Reference<chart2::data::XDataSequence> SAL_CALL
+InternalDataProvider::createDataSequenceByValueArray(
+    const OUString& aRole, const OUString& aRangeRepresentation )
+        throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+    return createDataSequenceFromArray(aRangeRepresentation, aRole);
+}
+
 Reference< sheet::XRangeSelection > SAL_CALL InternalDataProvider::getRangeSelection()
     throw (uno::RuntimeException)
 {
diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx
index c19dc81..3d92816 100644
--- a/dbaccess/source/core/inc/DatabaseDataProvider.hxx
+++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx
@@ -81,6 +81,12 @@ private:
     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL detectArguments(const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > & xDataSource) throw (::com::sun::star::uno::RuntimeException);
     virtual ::sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(const OUString & aRangeRepresentation) throw (::com::sun::star::uno::RuntimeException);
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(const OUString & aRangeRepresentation) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException);
+
+    virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
+        createDataSequenceByValueArray(
+            const OUString& aRole, const OUString & aRangeRepresentation)
+                throw (css::uno::RuntimeException, css::lang::IllegalArgumentException);
+
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection() throw (::com::sun::star::uno::RuntimeException);
 
     // ::com::sun::star::chart2::data::XRangeXMLConversion:
diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
index 0666f60..085c61e 100644
--- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx
+++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
@@ -302,6 +302,14 @@ uno::Reference< chart2::data::XDataSequence > SAL_CALL DatabaseDataProvider::cre
     return xData;
 }
 
+uno::Reference<chart2::data::XDataSequence>
+SAL_CALL DatabaseDataProvider::createDataSequenceByValueArray(
+    const OUString& /*aRole*/, const OUString& /*aRangeRepresentation*/ )
+        throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+    return uno::Reference<chart2::data::XDataSequence>();
+}
+
 uno::Sequence< uno::Sequence< OUString > > SAL_CALL DatabaseDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException)
 {
     return m_xComplexDescriptionAccess->getComplexRowDescriptions();
diff --git a/include/oox/drawingml/chart/chartconverter.hxx b/include/oox/drawingml/chart/chartconverter.hxx
index eefc11c..360c930 100644
--- a/include/oox/drawingml/chart/chartconverter.hxx
+++ b/include/oox/drawingml/chart/chartconverter.hxx
@@ -83,10 +83,10 @@ public:
 
     /** Creates a data sequence from a formula. Dummy implementation. Derived
         classes have to override this function to actually parse the formula. */
-    virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >
-                        createDataSequence(
-                            const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >& rxDataProvider,
-                            const DataSequenceModel& rDataSeq );
+    virtual css::uno::Reference<css::chart2::data::XDataSequence>
+        createDataSequence(
+            const css::uno::Reference<css::chart2::data::XDataProvider>& rxDataProvider,
+            const DataSequenceModel& rDataSeq, const OUString& rRole );
 
 private:
                         ChartConverter( const ChartConverter& );
diff --git a/offapi/com/sun/star/chart2/data/XDataProvider.idl b/offapi/com/sun/star/chart2/data/XDataProvider.idl
index 3ed73e2..6ab3fd4 100644
--- a/offapi/com/sun/star/chart2/data/XDataProvider.idl
+++ b/offapi/com/sun/star/chart2/data/XDataProvider.idl
@@ -126,6 +126,9 @@ interface XDataProvider  : ::com::sun::star::uno::XInterface
         [in] string aRangeRepresentation )
         raises( com::sun::star::lang::IllegalArgumentException );
 
+    XDataSequence createDataSequenceByValueArray( [in] string aRole, [in] string aValueArray )
+        raises( com::sun::star::lang::IllegalArgumentException );
+
     /** Returns a component that is able to change a given range
         representation to another one.  This usually is a
         controller-component that uses the GUI to allow a user to
diff --git a/oox/source/drawingml/chart/chartconverter.cxx b/oox/source/drawingml/chart/chartconverter.cxx
index 03eff1b..234d063 100644
--- a/oox/source/drawingml/chart/chartconverter.cxx
+++ b/oox/source/drawingml/chart/chartconverter.cxx
@@ -120,7 +120,9 @@ void ChartConverter::createDataProvider( const Reference< XChartDocument >& rxCh
     }
 }
 
-Reference< XDataSequence > ChartConverter::createDataSequence( const Reference< XDataProvider >& rxDataProvider, const DataSequenceModel& rDataSeq )
+Reference< XDataSequence > ChartConverter::createDataSequence(
+    const Reference< XDataProvider >& rxDataProvider, const DataSequenceModel& rDataSeq,
+    const OUString& rRole )
 {
     Reference< XDataSequence > xDataSeq;
     if( rxDataProvider.is() )
@@ -140,7 +142,7 @@ Reference< XDataSequence > ChartConverter::createDataSequence( const Reference<
         if( !aRangeRep.isEmpty() ) try
         {
             // create the data sequence
-            xDataSeq = rxDataProvider->createDataSequenceByRangeRepresentation( aRangeRep );
+            xDataSeq = rxDataProvider->createDataSequenceByValueArray(rRole, aRangeRep);
             return xDataSeq;
         }
         catch( Exception& )
diff --git a/oox/source/drawingml/chart/datasourceconverter.cxx b/oox/source/drawingml/chart/datasourceconverter.cxx
index ea22348..28ec95f 100644
--- a/oox/source/drawingml/chart/datasourceconverter.cxx
+++ b/oox/source/drawingml/chart/datasourceconverter.cxx
@@ -78,9 +78,9 @@ Reference< XDataSequence > DataSequenceConverter::createDataSequence( const OUSt
                 mrModel.maData.insert(std::make_pair<sal_Int32, Any>(1, Any(aTitle.makeStringAndClear())));
             }
         }
-        xDataSeq = getChartConverter()->createDataSequence( getChartDocument()->getDataProvider(), mrModel );
+        xDataSeq = getChartConverter()->createDataSequence(getChartDocument()->getDataProvider(), mrModel, rRole);
 
-        // set sequen   ce role
+        // set sequence role
         PropertySet aSeqProp( xDataSeq );
         aSeqProp.setProperty( PROP_Role, rRole );
     }
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index 83761e1..dbd3201 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -531,7 +531,7 @@ SeriesConverter::~SeriesConverter()
 
 Reference< XLabeledDataSequence > SeriesConverter::createCategorySequence( const OUString& rRole )
 {
-    return createLabeledDataSequence( SeriesModel::CATEGORIES, rRole, false );
+    return createLabeledDataSequence(SeriesModel::CATEGORIES, rRole, false);
 }
 
 Reference< XLabeledDataSequence > SeriesConverter::createValueSequence( const OUString& rRole )
diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx
index 4f54357..165d3f8 100644
--- a/sc/inc/chart2uno.hxx
+++ b/sc/inc/chart2uno.hxx
@@ -97,6 +97,10 @@ public:
             const OUString& aRangeRepresentation )
             throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
 
+    virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
+        createDataSequenceByValueArray( const OUString& aRole, const OUString& aRangeRepresentation )
+            throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection()
         throw (::com::sun::star::uno::RuntimeException);
 
diff --git a/sc/source/filter/inc/excelchartconverter.hxx b/sc/source/filter/inc/excelchartconverter.hxx
index ca2377a..979cdab 100644
--- a/sc/source/filter/inc/excelchartconverter.hxx
+++ b/sc/source/filter/inc/excelchartconverter.hxx
@@ -42,7 +42,7 @@ public:
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >
                         createDataSequence(
                             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >& rxDataProvider,
-                            const ::oox::drawingml::chart::DataSequenceModel& rDataSeq );
+                            const ::oox::drawingml::chart::DataSequenceModel& rDataSeq, const OUString& rRole );
 };
 
 // ============================================================================
diff --git a/sc/source/filter/oox/excelchartconverter.cxx b/sc/source/filter/oox/excelchartconverter.cxx
index 59870a4..c2f1535 100644
--- a/sc/source/filter/oox/excelchartconverter.cxx
+++ b/sc/source/filter/oox/excelchartconverter.cxx
@@ -68,7 +68,8 @@ void ExcelChartConverter::createDataProvider( const Reference< XChartDocument >&
 }
 
 Reference< XDataSequence > ExcelChartConverter::createDataSequence(
-        const Reference< XDataProvider >& rxDataProvider, const DataSequenceModel& rDataSeq )
+    const Reference< XDataProvider >& rxDataProvider, const DataSequenceModel& rDataSeq,
+    const OUString& /*rRole*/ )
 {
     Reference< XDataSequence > xDataSeq;
     if (!rxDataProvider.is())
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 10e47d0..5d19efb 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2076,6 +2076,14 @@ uno::Reference< chart2::data::XDataSequence > SAL_CALL
     return xResult;
 }
 
+uno::Reference<chart2::data::XDataSequence> SAL_CALL
+ScChart2DataProvider::createDataSequenceByValueArray(
+    const OUString& /*aRole*/, const OUString& /*aRangeRepresentation*/ )
+    throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception)
+{
+    return uno::Reference<chart2::data::XDataSequence>();
+}
+
 uno::Reference< sheet::XRangeSelection > SAL_CALL ScChart2DataProvider::getRangeSelection()
     throw (uno::RuntimeException)
 {
diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx
index 753035d..40b374f 100644
--- a/sw/inc/unochart.hxx
+++ b/sw/inc/unochart.hxx
@@ -178,6 +178,11 @@ public:
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation( const OUString& aRangeRepresentation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection(  ) throw (::com::sun::star::uno::RuntimeException);
 
+    virtual css::uno::Reference<css::chart2::data::XDataSequence>
+        SAL_CALL createDataSequenceByValueArray(
+            const OUString& aRole, const OUString& aRangeRepresentation )
+                throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
     // XRangeXMLConversion
     virtual OUString SAL_CALL convertRangeToXML( const OUString& aRangeRepresentation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     virtual OUString SAL_CALL convertRangeFromXML( const OUString& aXMLRange ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 965c332..7919a8d 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1453,6 +1453,14 @@ uno::Reference< sheet::XRangeSelection > SAL_CALL SwChartDataProvider::getRangeS
     return uno::Reference< sheet::XRangeSelection >();
 }
 
+uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
+    SwChartDataProvider::createDataSequenceByValueArray(
+        const OUString& /*aRole*/, const OUString& /*aRangeRepresentation*/ )
+            throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
+{
+    return uno::Reference<css::chart2::data::XDataSequence>();
+}
+
 void SAL_CALL SwChartDataProvider::dispose(  )
     throw (uno::RuntimeException)
 {
commit 732076e974291a07f29cddfbb4e0763ddce5fc8c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Jul 1 15:10:19 2014 -0400

    bnc#812796: Don't create data series when the series has no values.
    
    Change-Id: I92e2d7a3fab0948aea0557cf3cb65d57d48f3f59
    (cherry picked from commit 5e2b7e37a29edf45f829ccee2302a942b54568a1)

diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index 5c85d99..83761e1 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -562,6 +562,10 @@ Reference< XDataSeries > SeriesConverter::createDataSeries( const TypeGroupConve
             Reference< XDataSequence > xValues = xYValueSeq->getValues();
             if( xValues.is() )
                 nDataPointCount = xValues->getData().getLength();
+
+            if (!nDataPointCount)
+                // No values present.  Don't create a data series.
+                return Reference<XDataSeries>();
         }
         // add X values of scatter and bubble charts
         if( !rTypeInfo.mbCategoryAxis )


More information about the Libreoffice-commits mailing list