chart2/source/controller/dialogs/DialogModel.cxx           |    9 +-
 chart2/source/controller/dialogs/DialogModel.hxx           |    3 
 chart2/source/controller/dialogs/tp_DataSource.cxx         |    5 -
 chart2/source/inc/ChartTypeTemplate.hxx                    |    5 -
 chart2/source/inc/DataInterpreter.hxx                      |    9 ++
 chart2/source/inc/DataSourceHelper.hxx                     |    7 +-
 chart2/source/inc/DiagramHelper.hxx                        |    8 ++
 chart2/source/inc/LabeledDataSequence.hxx                  |    4 -
 chart2/source/model/template/BubbleDataInterpreter.cxx     |    9 +-
 chart2/source/model/template/ChartTypeTemplate.cxx         |    3 
 chart2/source/model/template/ColumnLineDataInterpreter.cxx |    1 
 chart2/source/model/template/DataInterpreter.cxx           |   45 ++++++++++---
 chart2/source/model/template/StockDataInterpreter.cxx      |    9 +-
 chart2/source/model/template/XYDataInterpreter.cxx         |   11 +--
 chart2/source/tools/AxisHelper.cxx                         |    3 
 chart2/source/tools/DataSourceHelper.cxx                   |    6 -
 chart2/source/tools/DiagramHelper.cxx                      |   39 +++++++++--
 chart2/source/tools/InternalDataProvider.cxx               |    6 +
 18 files changed, 133 insertions(+), 49 deletions(-)

New commits:
commit fc03ef1e02da261073994e7478b08fa57b3ea962
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Feb 2 18:40:05 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Feb 4 12:20:00 2022 +0100

    use more concrete types in chart2, LabeledDataSequence
    
    Change-Id: I88d5b7e045814cbd40750ebe927e6a76d5a463d1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129456
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/controller/dialogs/DialogModel.cxx 
b/chart2/source/controller/dialogs/DialogModel.cxx
index 13c7571b4b17..cef69be4ecc3 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -34,6 +34,7 @@
 #include <ThreeDHelper.hxx>
 #include <ChartModel.hxx>
 #include <BaseCoordinateSystem.hxx>
+#include <LabeledDataSequence.hxx>
 
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/chart2/AxisType.hpp>
@@ -595,15 +596,15 @@ void DialogModel::deleteSeries(
     DataSeriesHelper::deleteSeries( xSeries, xChartType );
 }
 
-Reference< data::XLabeledDataSequence > DialogModel::getCategories() const
+rtl::Reference< LabeledDataSequence > DialogModel::getCategories() const
 {
-    Reference< data::XLabeledDataSequence > xResult;
+    rtl::Reference< LabeledDataSequence > xResult;
     try
     {
         if( m_xChartDocument.is())
         {
             rtl::Reference< Diagram > xDiagram( 
m_xChartDocument->getFirstChartDiagram());
-            xResult.set( DiagramHelper::getCategoriesFromDiagram( xDiagram ));
+            xResult = DiagramHelper::getCategoriesFromDiagram( xDiagram );
         }
     }
     catch( const uno::Exception & )
@@ -636,7 +637,7 @@ void DialogModel::setCategories( const Reference< 
chart2::data::XLabeledDataSequ
 
 OUString DialogModel::getCategoriesRange() const
 {
-    Reference< data::XLabeledDataSequence > xLSeq( getCategories());
+    rtl::Reference< LabeledDataSequence > xLSeq( getCategories());
     OUString aRange;
     if( xLSeq.is())
     {
diff --git a/chart2/source/controller/dialogs/DialogModel.hxx 
b/chart2/source/controller/dialogs/DialogModel.hxx
index fd3ef59b1fd5..edc87d2e9356 100644
--- a/chart2/source/controller/dialogs/DialogModel.hxx
+++ b/chart2/source/controller/dialogs/DialogModel.hxx
@@ -49,6 +49,7 @@ class ChartType;
 class ChartTypeTemplate;
 class DataSeries;
 struct InterpretedData;
+class LabeledDataSequence;
 class RangeSelectionHelper;
 
 struct DialogModelTimeBasedInfo
@@ -119,7 +120,7 @@ public:
         const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
         const rtl::Reference< ::chart::ChartType > & xChartType );
 
-    css::uno::Reference< css::chart2::data::XLabeledDataSequence >
+    rtl::Reference< ::chart::LabeledDataSequence >
         getCategories() const;
 
     void setCategories( const css::uno::Reference< 
css::chart2::data::XLabeledDataSequence > & xCategories );
diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx 
b/chart2/source/controller/dialogs/tp_DataSource.cxx
index d9e19e8c5da4..e208db89a6ff 100644
--- a/chart2/source/controller/dialogs/tp_DataSource.cxx
+++ b/chart2/source/controller/dialogs/tp_DataSource.cxx
@@ -29,6 +29,7 @@
 #include <DataSeriesHelper.hxx>
 #include <ControllerLockGuard.hxx>
 #include <DataSourceHelper.hxx>
+#include <LabeledDataSequence.hxx>
 #include "DialogModel.hxx"
 #include <o3tl/safeint.hxx>
 #include <TabPageNotifiable.hxx>
@@ -752,7 +753,7 @@ bool DataSourceTabPage::updateModelFromControl(const 
weld::Entry* pField)
 
     if (bAll || (pField == m_xEDT_CATEGORIES.get()))
     {
-        Reference< data::XLabeledDataSequence > xLabeledSeq( 
m_rDialogModel.getCategories() );
+        rtl::Reference< LabeledDataSequence > xLabeledSeq( 
m_rDialogModel.getCategories() );
         if( xDataProvider.is())
         {
             OUString aRange(m_xEDT_CATEGORIES->get_text());
@@ -761,7 +762,7 @@ bool DataSourceTabPage::updateModelFromControl(const 
weld::Entry* pField)
                 // create or change categories
                 if( !xLabeledSeq.is())
                 {
-                    xLabeledSeq.set( 
DataSourceHelper::createLabeledDataSequence() );
+                    xLabeledSeq = 
DataSourceHelper::createLabeledDataSequence();
                     m_rDialogModel.setCategories( xLabeledSeq );
                 }
                 try
diff --git a/chart2/source/inc/ChartTypeTemplate.hxx 
b/chart2/source/inc/ChartTypeTemplate.hxx
index a6f67d3fa6c7..1997c88e145e 100644
--- a/chart2/source/inc/ChartTypeTemplate.hxx
+++ b/chart2/source/inc/ChartTypeTemplate.hxx
@@ -41,6 +41,7 @@ class BaseCoordinateSystem;
 class ChartType;
 class Diagram;
 class DataInterpreter;
+class LabeledDataSequence;
 
 /** For creating diagrams and modifying existing diagrams.  A base class that
     implements XChartTypeTemplate and offers some tooling for classes that
@@ -249,8 +250,8 @@ private:
                           css::uno::Sequence<
                               css::uno::Reference<
                                   css::chart2::XDataSeries > > > & aSeriesSeq,
-                      const css::uno::Reference<
-                          css::chart2::data::XLabeledDataSequence >& 
xCategories,
+                      const rtl::Reference<
+                          LabeledDataSequence >& xCategories,
                       const std::vector< rtl::Reference< ChartType > > & 
aOldChartTypesSeq);
 };
 
diff --git a/chart2/source/inc/DataInterpreter.hxx 
b/chart2/source/inc/DataInterpreter.hxx
index 561b86f2bfee..d804f4e3eecb 100644
--- a/chart2/source/inc/DataInterpreter.hxx
+++ b/chart2/source/inc/DataInterpreter.hxx
@@ -30,6 +30,7 @@
 namespace chart
 {
 class DataSeries;
+class LabeledDataSequence;
 
 /** offers tooling to interpret different data sources in a structural
      and chart-type-dependent way.
@@ -37,7 +38,7 @@ class DataSeries;
 struct InterpretedData
 {
     css::uno::Sequence< css::uno::Sequence< 
css::uno::Reference<css::chart2::XDataSeries> > > Series;
-    css::uno::Reference<css::chart2::data::XLabeledDataSequence> Categories;
+    rtl::Reference<::chart::LabeledDataSequence> Categories;
 };
 
 /** offers tooling to interpret different data sources in a structural
@@ -69,10 +70,16 @@ public:
     static bool HasCategories(
         const css::uno::Sequence< css::beans::PropertyValue > & rArguments,
         const css::uno::Sequence< css::uno::Reference< 
css::chart2::data::XLabeledDataSequence > > & rData );
+    static bool HasCategories(
+        const css::uno::Sequence< css::beans::PropertyValue > & rArguments,
+        const std::vector< rtl::Reference< LabeledDataSequence > > & rData );
 
     static bool UseCategoriesAsX(
         const css::uno::Sequence< css::beans::PropertyValue > & rArguments );
 
+    static std::vector<rtl::Reference<LabeledDataSequence>> getDataSequences(
+        const css::uno::Reference< css::chart2::data::XDataSource >& xSource);
+
     // ____ DataInterpreter ____
     /** Interprets the given data.
 
diff --git a/chart2/source/inc/DataSourceHelper.hxx 
b/chart2/source/inc/DataSourceHelper.hxx
index 3956ab9d05b5..35aefbd67a6a 100644
--- a/chart2/source/inc/DataSourceHelper.hxx
+++ b/chart2/source/inc/DataSourceHelper.hxx
@@ -36,6 +36,7 @@ namespace com::sun::star::frame { class XModel; }
 namespace chart
 {
 class Diagram;
+class LabeledDataSequence;
 
 class OOO_DLLPUBLIC_CHARTTOOLS DataSourceHelper
 {
@@ -50,16 +51,16 @@ public:
         static css::uno::Reference< css::chart2::data::XDataSequence >
             createCachedDataSequence( const OUString & rSingleText );
 
-        static css::uno::Reference< css::chart2::data::XLabeledDataSequence >
+        static rtl::Reference< LabeledDataSequence >
             createLabeledDataSequence(
                 const css::uno::Reference< css::chart2::data::XDataSequence >& 
xValues ,
                 const css::uno::Reference< css::chart2::data::XDataSequence >& 
xLabels );
 
-        static css::uno::Reference< css::chart2::data::XLabeledDataSequence >
+        static rtl::Reference< LabeledDataSequence >
             createLabeledDataSequence(
                 const css::uno::Reference< css::chart2::data::XDataSequence >& 
xValues );
 
-        static css::uno::Reference< css::chart2::data::XLabeledDataSequence >
+        static rtl::Reference< LabeledDataSequence >
             createLabeledDataSequence();
 
         static css::uno::Sequence< css::beans::PropertyValue >
diff --git a/chart2/source/inc/DiagramHelper.hxx 
b/chart2/source/inc/DiagramHelper.hxx
index 5783ff7f10b2..3a83644696e4 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -48,6 +48,7 @@ class ChartTypeManager;
 class ChartTypeTemplate;
 class DataSeries;
 class Diagram;
+class LabeledDataSequence;
 
 enum DiagramPositioningMode
 {
@@ -191,8 +192,13 @@ public:
             const rtl::Reference< ::chart::Diagram >& xDiagram,
             bool bSetAxisType = false, // when this flag is true ...
             bool bCategoryAxis = true);// set the AxisType to CATEGORY or back 
to REALNUMBER
+    static void setCategoriesToDiagram(
+            const rtl::Reference< LabeledDataSequence >& xCategories,
+            const rtl::Reference< ::chart::Diagram >& xDiagram,
+            bool bSetAxisType = false, // when this flag is true ...
+            bool bCategoryAxis = true);// set the AxisType to CATEGORY or back 
to REALNUMBER
 
-    static css::uno::Reference< css::chart2::data::XLabeledDataSequence >
+    static rtl::Reference< LabeledDataSequence >
         getCategoriesFromDiagram(
             const rtl::Reference< ::chart::Diagram > & xDiagram );
 
diff --git a/chart2/source/inc/LabeledDataSequence.hxx 
b/chart2/source/inc/LabeledDataSequence.hxx
index 811eb1997e49..48a06dd7d0d2 100644
--- a/chart2/source/inc/LabeledDataSequence.hxx
+++ b/chart2/source/inc/LabeledDataSequence.hxx
@@ -24,6 +24,7 @@
 #include <com/sun/star/chart2/data/XLabeledDataSequence2.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include "ModifyListenerHelper.hxx"
+#include "charttoolsdllapi.hxx"
 
 namespace com::sun::star::chart2::data { class XDataSequence; }
 namespace com::sun::star::util { class XCloneable; }
@@ -40,7 +41,7 @@ typedef cppu::WeakImplHelper<
     LabeledDataSequence_Base;
 }
 
-class LabeledDataSequence final :
+class OOO_DLLPUBLIC_CHARTTOOLS LabeledDataSequence final :
         public cppu::BaseMutex,
         public impl::LabeledDataSequence_Base
 {
@@ -59,7 +60,6 @@ public:
     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
 
-protected:
     // ____ XLabeledDataSequence ____
     virtual css::uno::Reference< css::chart2::data::XDataSequence > SAL_CALL 
getValues() override;
     virtual void SAL_CALL setValues(
diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx 
b/chart2/source/model/template/BubbleDataInterpreter.cxx
index cac3ea68d343..8868fbb6ca89 100644
--- a/chart2/source/model/template/BubbleDataInterpreter.cxx
+++ b/chart2/source/model/template/BubbleDataInterpreter.cxx
@@ -21,6 +21,7 @@
 #include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <CommonConverters.hxx>
+#include <LabeledDataSequence.hxx>
 #include <com/sun/star/chart2/data/XDataSink.hpp>
 #include <com/sun/star/util/XCloneable.hpp>
 #include <tools/diagnose_ex.h>
@@ -52,17 +53,17 @@ InterpretedData BubbleDataInterpreter::interpretDataSource(
     if( ! xSource.is())
         return InterpretedData();
 
-    Sequence< Reference< data::XLabeledDataSequence > > aData( 
xSource->getDataSequences() );
+    std::vector< rtl::Reference< LabeledDataSequence > > aData = 
DataInterpreter::getDataSequences(xSource);
 
     Reference< data::XLabeledDataSequence > xValuesX;
     vector< Reference< data::XLabeledDataSequence > > aYValuesVector;
     vector< Reference< data::XLabeledDataSequence > > aSizeValuesVector;
 
-    Reference< data::XLabeledDataSequence > xCategories;
+    rtl::Reference< LabeledDataSequence > xCategories;
     bool bHasCategories = HasCategories( aArguments, aData );
     bool bUseCategoriesAsX = UseCategoriesAsX( aArguments );
 
-    sal_Int32 nDataSeqCount = aData.getLength();
+    sal_Int32 nDataSeqCount = aData.size();
 
     bool bSetXValues = bHasCategories ? ( (nDataSeqCount-1) > 2 && 
(nDataSeqCount-1) % 2 != 0 )
                                  :( nDataSeqCount > 2 && nDataSeqCount % 2 != 
0 );
@@ -75,7 +76,7 @@ InterpretedData BubbleDataInterpreter::interpretDataSource(
         {
             if( bHasCategories && !bCategoriesUsed )
             {
-                xCategories.set( aData[nDataIdx] );
+                xCategories = aData[nDataIdx];
                 if( xCategories.is())
                 {
                     SetRole( xCategories->getValues(), "categories");
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx 
b/chart2/source/model/template/ChartTypeTemplate.cxx
index 8c7ab1e7389a..0183907419ad 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -30,6 +30,7 @@
 #include <AxisIndexDefines.hxx>
 #include <BaseCoordinateSystem.hxx>
 #include <unonames.hxx>
+#include <LabeledDataSequence.hxx>
 
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/chart2/AxisType.hpp>
@@ -716,7 +717,7 @@ sal_Int32 ChartTypeTemplate::getAxisCountByDimension( 
sal_Int32 nDimension )
 void ChartTypeTemplate::FillDiagram(
     const rtl::Reference< ::chart::Diagram >& xDiagram,
     const Sequence< Sequence< Reference< XDataSeries > > >& aSeriesSeq,
-    const Reference< data::XLabeledDataSequence >& xCategories,
+    const rtl::Reference< LabeledDataSequence >& xCategories,
     const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq )
 {
     adaptDiagram( xDiagram );
diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.cxx 
b/chart2/source/model/template/ColumnLineDataInterpreter.cxx
index c548b8c8eacb..c75c7818fd0b 100644
--- a/chart2/source/model/template/ColumnLineDataInterpreter.cxx
+++ b/chart2/source/model/template/ColumnLineDataInterpreter.cxx
@@ -18,6 +18,7 @@
  */
 
 #include "ColumnLineDataInterpreter.hxx"
+#include <LabeledDataSequence.hxx>
 #include <osl/diagnose.h>
 
 #include <algorithm>
diff --git a/chart2/source/model/template/DataInterpreter.cxx 
b/chart2/source/model/template/DataInterpreter.cxx
index 3a619e3ec253..9461008c87ad 100644
--- a/chart2/source/model/template/DataInterpreter.cxx
+++ b/chart2/source/model/template/DataInterpreter.cxx
@@ -22,6 +22,7 @@
 #include <DataSourceHelper.hxx>
 #include <DataSeriesHelper.hxx>
 #include <CommonConverters.hxx>
+#include <LabeledDataSequence.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/chart2/data/XDataSink.hpp>
 #include <cppuhelper/supportsservice.hxx>
@@ -66,9 +67,9 @@ InterpretedData DataInterpreter::interpretDataSource(
     lcl_ShowDataSource( xSource );
 #endif
 
-    const Sequence< Reference< data::XLabeledDataSequence > > aData( 
xSource->getDataSequences() );
+    std::vector< rtl::Reference< LabeledDataSequence > > aData = 
getDataSequences(xSource);
 
-    Reference< data::XLabeledDataSequence > xCategories;
+    rtl::Reference< LabeledDataSequence > xCategories;
     vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
 
     // check if we should use categories
@@ -77,13 +78,13 @@ InterpretedData DataInterpreter::interpretDataSource(
 
     // parse data
     bool bCategoriesUsed = false;
-    for( Reference< data::XLabeledDataSequence > const & labeledData : aData )
+    for( rtl::Reference< LabeledDataSequence > const & labeledData : aData )
     {
         try
         {
             if( bHasCategories && ! bCategoriesUsed )
             {
-                xCategories.set( labeledData );
+                xCategories = labeledData;
                 if( xCategories.is())
                     SetRole( xCategories->getValues(), "categories");
                 bCategoriesUsed = true;
@@ -138,9 +139,9 @@ InterpretedData DataInterpreter::interpretDataSource(
     lcl_ShowDataSource( xSource );
 #endif
 
-    const Sequence< Reference< data::XLabeledDataSequence > > aData( 
xSource->getDataSequences() );
+    std::vector< rtl::Reference< LabeledDataSequence > > aData = 
getDataSequences(xSource);
 
-    Reference< data::XLabeledDataSequence > xCategories;
+    rtl::Reference< LabeledDataSequence > xCategories;
     vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
 
     // check if we should use categories
@@ -149,13 +150,13 @@ InterpretedData DataInterpreter::interpretDataSource(
 
     // parse data
     bool bCategoriesUsed = false;
-    for( Reference< data::XLabeledDataSequence > const & labeledData : aData )
+    for( rtl::Reference< LabeledDataSequence > const & labeledData : aData )
     {
         try
         {
             if( bHasCategories && ! bCategoriesUsed )
             {
-                xCategories.set( labeledData );
+                xCategories = labeledData;
                 if( xCategories.is())
                     SetRole( xCategories->getValues(), "categories");
                 bCategoriesUsed = true;
@@ -433,6 +434,21 @@ bool DataInterpreter::HasCategories(
     return bHasCategories;
 }
 
+bool DataInterpreter::HasCategories(
+    const Sequence< beans::PropertyValue > & rArguments,
+    const std::vector< rtl::Reference< LabeledDataSequence > > & rData )
+{
+    bool bHasCategories = false;
+
+    if( rArguments.hasElements() )
+        GetProperty( rArguments, u"HasCategories" ) >>= bHasCategories;
+
+    for( sal_Int32 nLSeqIdx=0; ! bHasCategories && 
nLSeqIdx<static_cast<sal_Int32>(rData.size()); ++nLSeqIdx )
+        bHasCategories = ( rData[nLSeqIdx].is() && GetRole( 
rData[nLSeqIdx]->getValues() ) == "categories");
+
+    return bHasCategories;
+}
+
 bool DataInterpreter::UseCategoriesAsX( const Sequence< beans::PropertyValue > 
& rArguments )
 {
     bool bUseCategoriesAsX = true;
@@ -456,6 +472,19 @@ css::uno::Sequence< OUString > SAL_CALL 
DataInterpreter::getSupportedServiceName
     return { "com.sun.star.chart2.DataInterpreter" };
 }
 
+std::vector< rtl::Reference< LabeledDataSequence > > 
DataInterpreter::getDataSequences(
+        const css::uno::Reference< css::chart2::data::XDataSource >& xSource)
+{
+    std::vector< rtl::Reference< LabeledDataSequence > > aData;
+    for (const Reference< data::XLabeledDataSequence > & rLDS : 
xSource->getDataSequences() )
+    {
+        auto pLDS = dynamic_cast<LabeledDataSequence*>(rLDS.get());
+        assert(pLDS);
+        aData.push_back(pLDS);
+    }
+    return aData;
+}
+
 } // namespace chart
 
 #ifdef DEBUG_CHART2_TEMPLATE
diff --git a/chart2/source/model/template/StockDataInterpreter.cxx 
b/chart2/source/model/template/StockDataInterpreter.cxx
index 3b9315ee7a30..addf3f71e3f8 100644
--- a/chart2/source/model/template/StockDataInterpreter.cxx
+++ b/chart2/source/model/template/StockDataInterpreter.cxx
@@ -20,6 +20,7 @@
 #include "StockDataInterpreter.hxx"
 #include "StockChartTypeTemplate.hxx"
 #include <DataSeries.hxx>
+#include <LabeledDataSequence.hxx>
 #include <com/sun/star/chart2/data/XDataSink.hpp>
 #include <tools/diagnose_ex.h>
 
@@ -51,9 +52,9 @@ InterpretedData StockDataInterpreter::interpretDataSource(
     if( ! xSource.is())
         return InterpretedData();
 
-    Reference< data::XLabeledDataSequence > xCategories;
-    Sequence< Reference< data::XLabeledDataSequence > > aData( 
xSource->getDataSequences() );
-    const sal_Int32 nDataCount( aData.getLength());
+    rtl::Reference< LabeledDataSequence > xCategories;
+    std::vector< rtl::Reference< LabeledDataSequence > > aData = 
DataInterpreter::getDataSequences(xSource);
+    const sal_Int32 nDataCount( aData.size());
 
     // sub-type properties
     const StockChartTypeTemplate::StockVariant eVar( GetStockVariant());
@@ -114,7 +115,7 @@ InterpretedData StockDataInterpreter::interpretDataSource(
     // 1. categories
     if( bHasCategories )
     {
-        xCategories.set( aData[nSourceIndex] );
+        xCategories = aData[nSourceIndex];
         ++nSourceIndex;
     }
 
diff --git a/chart2/source/model/template/XYDataInterpreter.cxx 
b/chart2/source/model/template/XYDataInterpreter.cxx
index c61088a268f0..090e77b609d5 100644
--- a/chart2/source/model/template/XYDataInterpreter.cxx
+++ b/chart2/source/model/template/XYDataInterpreter.cxx
@@ -21,6 +21,7 @@
 #include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <CommonConverters.hxx>
+#include <LabeledDataSequence.hxx>
 #include <com/sun/star/chart2/data/XDataSink.hpp>
 #include <com/sun/star/util/XCloneable.hpp>
 #include <tools/diagnose_ex.h>
@@ -53,25 +54,25 @@ InterpretedData XYDataInterpreter::interpretDataSource(
     if( ! xSource.is())
         return InterpretedData();
 
-    const Sequence< Reference< data::XLabeledDataSequence > > aData( 
xSource->getDataSequences() );
+    std::vector< rtl::Reference< LabeledDataSequence > > aData = 
DataInterpreter::getDataSequences(xSource);
 
     Reference< data::XLabeledDataSequence > xValuesX;
     vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
 
-    Reference< data::XLabeledDataSequence > xCategories;
+    rtl::Reference< LabeledDataSequence > xCategories;
     bool bHasCategories = HasCategories( aArguments, aData );
     bool bUseCategoriesAsX = UseCategoriesAsX( aArguments );
 
     // parse data
     bool bCategoriesUsed = false;
-    bool bSetXValues = aData.getLength()>1;
-    for( Reference< data::XLabeledDataSequence > const & labelData : aData )
+    bool bSetXValues = aData.size()>1;
+    for( rtl::Reference< LabeledDataSequence > const & labelData : aData )
     {
         try
         {
             if( bHasCategories && ! bCategoriesUsed )
             {
-                xCategories.set( labelData );
+                xCategories = labelData;
                 if( xCategories.is())
                 {
                     SetRole( xCategories->getValues(), "categories");
diff --git a/chart2/source/tools/AxisHelper.cxx 
b/chart2/source/tools/AxisHelper.cxx
index 76204c7e3a5a..c15b6f18a5f8 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -23,6 +23,7 @@
 #include <ChartTypeHelper.hxx>
 #include <ChartType.hxx>
 #include <AxisIndexDefines.hxx>
+#include <LabeledDataSequence.hxx>
 #include <LinePropertiesHelper.hxx>
 #include <servicenames_coosystems.hxx>
 #include <DataSeries.hxx>
@@ -197,7 +198,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
                             DataSeriesHelper::getAllDataSequencesByRole( 
xSource->getDataSequences(), "values-x" ) );
                         if( aXValues.empty() )
                         {
-                            Reference< data::XLabeledDataSequence > 
xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) );
+                            rtl::Reference< LabeledDataSequence > xCategories( 
DiagramHelper::getCategoriesFromDiagram( xDiagram ) );
                             if( xCategories.is() )
                             {
                                 Reference< data::XDataSequence > xSeq( 
xCategories->getValues());
diff --git a/chart2/source/tools/DataSourceHelper.cxx 
b/chart2/source/tools/DataSourceHelper.cxx
index cb71316c87cd..33d613e6f25b 100644
--- a/chart2/source/tools/DataSourceHelper.cxx
+++ b/chart2/source/tools/DataSourceHelper.cxx
@@ -134,20 +134,20 @@ Reference< chart2::data::XDataSequence > 
DataSourceHelper::createCachedDataSeque
     return new ::chart::CachedDataSequence( rSingleText );
 }
 
-Reference< chart2::data::XLabeledDataSequence > 
DataSourceHelper::createLabeledDataSequence(
+rtl::Reference< LabeledDataSequence > 
DataSourceHelper::createLabeledDataSequence(
         const Reference< chart2::data::XDataSequence >& xValues ,
         const Reference< chart2::data::XDataSequence >& xLabels )
 {
     return new ::chart::LabeledDataSequence( xValues, xLabels );
 }
 
-Reference< chart2::data::XLabeledDataSequence > 
DataSourceHelper::createLabeledDataSequence(
+rtl::Reference< LabeledDataSequence > 
DataSourceHelper::createLabeledDataSequence(
         const Reference< chart2::data::XDataSequence >& xValues )
 {
     return new ::chart::LabeledDataSequence( xValues );
 }
 
-Reference< chart2::data::XLabeledDataSequence > 
DataSourceHelper::createLabeledDataSequence()
+rtl::Reference< LabeledDataSequence > 
DataSourceHelper::createLabeledDataSequence()
 {
     return new ::chart::LabeledDataSequence;
 }
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index 15075593360c..a20c8bbd7510 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -29,6 +29,7 @@
 #include <ChartModel.hxx>
 #include <ChartModelHelper.hxx>
 #include <ExplicitCategoriesProvider.hxx>
+#include <LabeledDataSequence.hxx>
 #include <servicenames_charttypes.hxx>
 #include <RelativePositionHelper.hxx>
 #include <ControllerLockGuard.hxx>
@@ -492,7 +493,7 @@ void DiagramHelper::replaceCoordinateSystem(
 
     try
     {
-        Reference< chart2::data::XLabeledDataSequence > xCategories = 
DiagramHelper::getCategoriesFromDiagram( xDiagram );
+        rtl::Reference< LabeledDataSequence > xCategories = 
DiagramHelper::getCategoriesFromDiagram( xDiagram );
 
         // move chart types of xCooSysToReplace to xReplacement
         xReplacement->setChartTypes( xCooSysToReplace->getChartTypes());
@@ -784,11 +785,38 @@ void DiagramHelper::setCategoriesToDiagram(
     }
 }
 
-Reference< data::XLabeledDataSequence >
+void DiagramHelper::setCategoriesToDiagram(
+    const rtl::Reference< LabeledDataSequence >& xCategories,
+    const rtl::Reference< Diagram >& xDiagram,
+    bool bSetAxisType  /* = false */,
+    bool bCategoryAxis /* = true */ )
+{
+    std::vector< Reference< chart2::XAxis > > aCatAxes(
+        lcl_getAxisHoldingCategoriesFromDiagram( xDiagram ));
+
+    for (const Reference< chart2::XAxis >& xCatAxis : aCatAxes)
+    {
+        if( xCatAxis.is())
+        {
+            ScaleData aScaleData( xCatAxis->getScaleData());
+            aScaleData.Categories = xCategories;
+            if( bSetAxisType )
+            {
+                if( bCategoryAxis )
+                    aScaleData.AxisType = AxisType::CATEGORY;
+                else if( aScaleData.AxisType == AxisType::CATEGORY || 
aScaleData.AxisType == AxisType::DATE )
+                    aScaleData.AxisType = AxisType::REALNUMBER;
+            }
+            xCatAxis->setScaleData( aScaleData );
+        }
+    }
+}
+
+rtl::Reference< LabeledDataSequence >
     DiagramHelper::getCategoriesFromDiagram(
         const rtl::Reference< Diagram > & xDiagram )
 {
-    Reference< data::XLabeledDataSequence > xResult;
+    rtl::Reference< LabeledDataSequence > xResult;
 
     try
     {
@@ -803,8 +831,9 @@ Reference< data::XLabeledDataSequence >
                 ScaleData aScaleData( xCatAxis->getScaleData());
                 if( aScaleData.Categories.is() )
                 {
-                    xResult.set( aScaleData.Categories );
-                    uno::Reference<beans::XPropertySet> 
xProp(aScaleData.Categories->getValues(), uno::UNO_QUERY );
+                    xResult = 
dynamic_cast<LabeledDataSequence*>(aScaleData.Categories.get());
+                    assert(!aScaleData.Categories || xResult);
+                    uno::Reference<beans::XPropertySet> 
xProp(xResult->getValues(), uno::UNO_QUERY );
                     if( xProp.is() )
                     {
                         try
diff --git a/chart2/source/tools/InternalDataProvider.cxx 
b/chart2/source/tools/InternalDataProvider.cxx
index a93003c6d7af..13f9bca3786c 100644
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -377,8 +377,10 @@ InternalDataProvider::InternalDataProvider(
                 else
                     m_aInternalData.setComplexColumnLabels( 
std::move(aNewCategories) );
                 if( bConnectToModel )
-                    DiagramHelper::setCategoriesToDiagram( new 
LabeledDataSequence(
-                        createDataSequenceByRangeRepresentation( 
lcl_aCategoriesRangeName )), xDiagram );
+                    DiagramHelper::setCategoriesToDiagram(
+                        rtl::Reference< LabeledDataSequence >(new 
LabeledDataSequence(
+                            createDataSequenceByRangeRepresentation( 
lcl_aCategoriesRangeName ))),
+                        xDiagram );
             }
 
             // data series

Reply via email to