chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx         |  
 25 +--
 chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx         |  
  7 
 chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx                 |  
 51 ++----
 chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx |  
 17 --
 chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx         |  
  9 -
 chart2/source/controller/dialogs/ChartTypeDialogController.cxx              |  
  1 
 chart2/source/controller/dialogs/DialogModel.cxx                            |  
 13 +
 chart2/source/controller/dialogs/DialogModel.hxx                            |  
  5 
 chart2/source/controller/dialogs/ObjectNameProvider.cxx                     |  
 43 ++---
 chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx                    |  
  3 
 chart2/source/controller/dialogs/dlg_ObjectProperties.cxx                   |  
  6 
 chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx         |  
 19 +-
 chart2/source/controller/main/ChartController.cxx                           |  
  5 
 chart2/source/controller/main/ChartController_Insert.cxx                    |  
 27 +--
 chart2/source/controller/main/ChartController_Properties.cxx                |  
 20 +-
 chart2/source/controller/main/ChartController_Tools.cxx                     |  
  8 -
 chart2/source/controller/main/ChartController_Window.cxx                    |  
 13 -
 chart2/source/controller/main/ControllerCommandDispatch.cxx                 |  
 19 +-
 chart2/source/controller/sidebar/ChartSeriesPanel.cxx                       |  
 19 +-
 chart2/source/inc/ChartModelHelper.hxx                                      |  
  8 -
 chart2/source/inc/DataInterpreter.hxx                                       |  
 10 +
 chart2/source/inc/DataSeries.hxx                                            |  
  5 
 chart2/source/inc/DataSeriesHelper.hxx                                      |  
  6 
 chart2/source/inc/DiagramHelper.hxx                                         |  
  7 
 chart2/source/inc/ObjectIdentifier.hxx                                      |  
  3 
 chart2/source/inc/RangeHighlighter.hxx                                      |  
  3 
 chart2/source/model/main/DataSeries.cxx                                     |  
 21 ++
 chart2/source/model/template/AreaChartTypeTemplate.cxx                      |  
 11 -
 chart2/source/model/template/BarChartTypeTemplate.cxx                       |  
 17 --
 chart2/source/model/template/BubbleDataInterpreter.cxx                      |  
 16 --
 chart2/source/model/template/BubbleDataInterpreter.hxx                      |  
  2 
 chart2/source/model/template/ChartTypeTemplate.cxx                          |  
  7 
 chart2/source/model/template/ColumnLineDataInterpreter.cxx                  |  
  2 
 chart2/source/model/template/ColumnLineDataInterpreter.hxx                  |  
  9 -
 chart2/source/model/template/DataInterpreter.cxx                            |  
 70 ++++++++
 chart2/source/model/template/LineChartTypeTemplate.cxx                      |  
 10 -
 chart2/source/model/template/NetChartTypeTemplate.cxx                       |  
 10 -
 chart2/source/model/template/PieChartTypeTemplate.cxx                       |  
 30 +--
 chart2/source/model/template/ScatterChartTypeTemplate.cxx                   |  
 10 -
 chart2/source/model/template/StockChartTypeTemplate.cxx                     |  
  9 -
 chart2/source/model/template/StockDataInterpreter.cxx                       |  
 15 -
 chart2/source/model/template/StockDataInterpreter.hxx                       |  
  2 
 chart2/source/model/template/XYDataInterpreter.cxx                          |  
 16 --
 chart2/source/model/template/XYDataInterpreter.hxx                          |  
  2 
 chart2/source/tools/AxisHelper.cxx                                          |  
  5 
 chart2/source/tools/ChartModelHelper.cxx                                    |  
 12 +
 chart2/source/tools/DataSeriesHelper.cxx                                    |  
 21 ++
 chart2/source/tools/DataSourceHelper.cxx                                    |  
 19 +-
 chart2/source/tools/DiagramHelper.cxx                                       |  
 25 ++-
 chart2/source/tools/ExplicitCategoriesProvider.cxx                          |  
  5 
 chart2/source/tools/InternalDataProvider.cxx                                |  
 14 -
 chart2/source/tools/ObjectIdentifier.cxx                                    |  
 31 ++-
 chart2/source/tools/RangeHighlighter.cxx                                    |  
 11 -
 chart2/source/tools/ReferenceSizeProvider.cxx                               |  
 79 ++++------
 chart2/source/tools/RegressionCurveHelper.cxx                               |  
 15 -
 chart2/source/tools/ThreeDHelper.cxx                                        |  
 22 +-
 chart2/source/view/main/ChartView.cxx                                       |  
  2 
 57 files changed, 496 insertions(+), 376 deletions(-)

New commits:
commit 47bbacb2b170c156fa0be751bc5213d412db8cff
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Jan 30 20:59:24 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jan 31 10:39:29 2022 +0100

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

diff --git 
a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
index 8d49237ddcaa..c9ef38c82460 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -22,6 +22,7 @@
 #include <ChartType.hxx>
 #include <ChartTypeHelper.hxx>
 #include <DiagramHelper.hxx>
+#include <DataSeries.hxx>
 #include <LinePropertiesHelper.hxx>
 #include <FillProperties.hxx>
 #include <CharacterProperties.hxx>
@@ -475,7 +476,11 @@ void SAL_CALL DataSeriesPointWrapper::initialize( const 
uno::Sequence< uno::Any
     m_nPointIndex = -1;
     if( aArguments.hasElements() )
     {
-        aArguments[0] >>= m_xDataSeries;
+        uno::Reference<chart2::XDataSeries> xTmp;
+        aArguments[0] >>= xTmp;
+        auto p = dynamic_cast<DataSeries*>(xTmp.get());
+        assert(p);
+        m_xDataSeries = p;
         if( aArguments.getLength() >= 2 )
             aArguments[1] >>= m_nPointIndex;
     }
@@ -538,7 +543,7 @@ void SAL_CALL DataSeriesPointWrapper::disposing( const 
lang::EventObject& /*Sour
 
 bool DataSeriesPointWrapper::isSupportingAreaProperties()
 {
-    Reference< chart2::XDataSeries > xSeries( getDataSeries() );
+    rtl::Reference< DataSeries > xSeries( getDataSeries() );
     rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
     rtl::Reference< ::chart::ChartType > xChartType( 
DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
     sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
@@ -546,14 +551,14 @@ bool DataSeriesPointWrapper::isSupportingAreaProperties()
     return ChartTypeHelper::isSupportingAreaProperties( xChartType, 
nDimensionCount );
 }
 
-Reference< chart2::XDataSeries > DataSeriesPointWrapper::getDataSeries()
+rtl::Reference< DataSeries > DataSeriesPointWrapper::getDataSeries()
 {
-    Reference< chart2::XDataSeries > xSeries( m_xDataSeries );
+    rtl::Reference< DataSeries > xSeries = m_xDataSeries;
     if( !xSeries.is() )
     {
         rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
-        std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
-            ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+        std::vector< rtl::Reference< DataSeries > > aSeriesList =
+            ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram );
 
         if( m_nSeriesIndexInNewAPI >= 0 && m_nSeriesIndexInNewAPI < 
static_cast<sal_Int32>(aSeriesList.size()) )
             xSeries = aSeriesList[m_nSeriesIndexInNewAPI];
@@ -624,7 +629,7 @@ beans::PropertyState SAL_CALL 
DataSeriesPointWrapper::getPropertyState( const OU
         {
             if( rPropertyName == "FillColor")
             {
-                Reference< beans::XPropertySet > xSeriesProp( getDataSeries(), 
uno::UNO_QUERY );
+                rtl::Reference< DataSeries > xSeriesProp = getDataSeries();
                 bool bVaryColorsByPoint = false;
                 if( xSeriesProp.is() && 
(xSeriesProp->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint)
                     && bVaryColorsByPoint )
@@ -685,7 +690,7 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyDefault( 
const OUString& rProper
         if( nHandle > 0 )
         {
             //always take the series current value as default for points
-            Reference< beans::XPropertySet > xInnerPropertySet( 
getDataSeries(), uno::UNO_QUERY );
+            rtl::Reference< DataSeries > xInnerPropertySet = getDataSeries();
             if( xInnerPropertySet.is() )
             {
                 const WrappedProperty* pWrappedProperty = getWrappedProperty( 
rPropertyName );
@@ -706,7 +711,7 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyDefault( 
const OUString& rProper
 Reference< beans::XPropertySet > DataSeriesPointWrapper::getInnerPropertySet()
 {
     if( m_eType == DATA_SERIES )
-        return Reference< beans::XPropertySet >( getDataSeries(), 
uno::UNO_QUERY );
+        return getDataSeries();
     return getDataPointProperties();
 }
 
@@ -843,7 +848,7 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyValue( 
const OUString& rProperty
     {
         if( rPropertyName == "FillColor" )
         {
-            Reference< beans::XPropertySet > xSeriesProp( getDataSeries(), 
uno::UNO_QUERY );
+            rtl::Reference< DataSeries > xSeriesProp = getDataSeries();
             bool bVaryColorsByPoint = false;
             if( xSeriesProp.is() && 
(xSeriesProp->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint)
                 && bVaryColorsByPoint )
diff --git 
a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx
index f5fbab3f332b..8936ec4180f0 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx
@@ -26,10 +26,11 @@
 #include <com/sun/star/lang/XEventListener.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
-
+#include <rtl/ref.hxx>
 #include <memory>
 
 namespace com::sun::star::chart2 { class XDataSeries; }
+namespace chart { class DataSeries; }
 
 namespace chart::wrapper
 {
@@ -100,7 +101,7 @@ private:
     virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& 
aPropertyName ) override;
 
     //own methods
-    css::uno::Reference< css::chart2::XDataSeries > getDataSeries();
+    rtl::Reference< ::chart::DataSeries > getDataSeries();
     css::uno::Reference< css::beans::XPropertySet > getDataPointProperties();
 
     std::shared_ptr< Chart2ModelContact >         m_spChart2ModelContact;
@@ -115,7 +116,7 @@ private:
     //this should only be used, if the DataSeriesPointWrapper is initialized 
via the XInitialize interface
     //because a big change in the chartmodel may lead to a dataseriespointer 
that is not connected to the model anymore
     //with the indices instead we can always get the new dataseries
-    css::uno::Reference< css::chart2::XDataSeries >     m_xDataSeries;
+    rtl::Reference< ::chart::DataSeries >     m_xDataSeries;
 };
 
 } //  namespace chart::wrapper
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index b3263d45c090..3918462e4ac4 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -30,6 +30,7 @@
 #include <DataSourceHelper.hxx>
 #include <ChartModelHelper.hxx>
 #include <ChartType.hxx>
+#include <DataSeries.hxx>
 #include <WrappedIgnoreProperty.hxx>
 #include "WrappedAxisAndGridExistenceProperties.hxx"
 #include "WrappedStatisticProperties.hxx"
@@ -464,8 +465,8 @@ sal_Int32 lcl_getNewAPIIndexForOldAPIIndex(
             nNewAPIIndex -= 1;
     }
 
-    std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
-        ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+    std::vector< rtl::Reference< ::chart::DataSeries > > aSeriesList =
+        ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram );
     if( nNewAPIIndex >= static_cast<sal_Int32>(aSeriesList.size()) )
         nNewAPIIndex = -1;
 
@@ -1465,8 +1466,8 @@ bool WrappedNumberOfLinesProperty::detectInnerValue( 
uno::Any& rInnerValue ) con
     rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     if( xDiagram.is() && xChartDoc.is() )
     {
-        std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector(
-            DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+        std::vector< rtl::Reference< DataSeries > > aSeriesVector =
+            DiagramHelper::getDataSeriesFromDiagram( xDiagram );
         if( !aSeriesVector.empty() )
         {
             rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
@@ -1614,25 +1615,21 @@ void 
WrappedAttributedDataPointsProperty::setPropertyValue( const Any& rOuterVal
     if( !xDiagram )
         return;
 
-    std::vector< Reference< chart2::XDataSeries > > aSeriesVector(
-        ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+    std::vector< rtl::Reference< DataSeries > > aSeriesVector =
+        ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram );
     sal_Int32 i = 0;
     for (auto const& series : aSeriesVector)
     {
-        Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
-        if( xProp.is())
+        uno::Any aVal;
+        if( i < aNewValue.getLength() )
+            aVal <<= aNewValue[i];
+        else
         {
-            uno::Any aVal;
-            if( i < aNewValue.getLength() )
-                aVal <<= aNewValue[i];
-            else
-            {
-                //set empty sequence
-                uno::Sequence< sal_Int32 > aSeq;
-                aVal <<= aSeq;
-            }
-            xProp->setPropertyValue( "AttributedDataPoints", aVal );
+            //set empty sequence
+            uno::Sequence< sal_Int32 > aSeq;
+            aVal <<= aSeq;
         }
+        series->setPropertyValue( "AttributedDataPoints", aVal );
         ++i;
     }
 }
@@ -1643,23 +1640,19 @@ Any 
WrappedAttributedDataPointsProperty::getPropertyValue( const Reference< bean
 
     if( xDiagram )
     {
-        std::vector< Reference< chart2::XDataSeries > > aSeriesVector(
-            ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+        std::vector< rtl::Reference< DataSeries > > aSeriesVector =
+            ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram );
 
         uno::Sequence< uno::Sequence< sal_Int32 > > aResult( 
aSeriesVector.size() );
         auto aResultRange = asNonConstRange(aResult);
         sal_Int32 i = 0;
         for (auto const& series : aSeriesVector)
         {
-            Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
-            if( xProp.is())
-            {
-                uno::Any aVal(
-                    xProp->getPropertyValue("AttributedDataPoints"));
-                uno::Sequence< sal_Int32 > aSeq;
-                if( aVal >>= aSeq )
-                    aResultRange[ i ] = aSeq;
-            }
+            uno::Any aVal(
+                series->getPropertyValue("AttributedDataPoints"));
+            uno::Sequence< sal_Int32 > aSeq;
+            if( aVal >>= aSeq )
+                aResultRange[ i ] = aSeq;
             ++i;
         }
         m_aOuterValue <<= aResult;
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx 
b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx
index 529df87d72c1..b3149088b10b 100644
--- 
a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx
+++ 
b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx
@@ -22,6 +22,7 @@
 #include "Chart2ModelContact.hxx"
 #include <DiagramHelper.hxx>
 #include <com/sun/star/chart2/XDataSeries.hpp>
+#include <DataSeries.hxx>
 
 #include <memory>
 #include <vector>
@@ -64,11 +65,11 @@ public:
         if( m_ePropertyType == DIAGRAM &&
             m_spChart2ModelContact )
         {
-            std::vector< css::uno::Reference< css::chart2::XDataSeries > > 
aSeriesVector(
-                ::chart::DiagramHelper::getDataSeriesFromDiagram( 
m_spChart2ModelContact->getDiagram() ) );
+            std::vector< rtl::Reference< DataSeries > > aSeriesVector =
+                ::chart::DiagramHelper::getDataSeriesFromDiagram( 
m_spChart2ModelContact->getDiagram() );
             for (auto const& series : aSeriesVector)
             {
-                PROPERTYTYPE aCurValue = getValueFromSeries( 
css::uno::Reference< css::beans::XPropertySet >::query(series) );
+                PROPERTYTYPE aCurValue = getValueFromSeries( series );
                 if( !bHasDetectableInnerValue )
                     rValue = aCurValue;
                 else
@@ -91,15 +92,11 @@ public:
         if( m_ePropertyType == DIAGRAM &&
             m_spChart2ModelContact )
         {
-            std::vector< css::uno::Reference< css::chart2::XDataSeries > > 
aSeriesVector(
-                ::chart::DiagramHelper::getDataSeriesFromDiagram( 
m_spChart2ModelContact->getDiagram() ) );
+            std::vector< rtl::Reference< DataSeries > > aSeriesVector =
+                ::chart::DiagramHelper::getDataSeriesFromDiagram( 
m_spChart2ModelContact->getDiagram() );
             for (auto const& series : aSeriesVector)
             {
-                css::uno::Reference< css::beans::XPropertySet > 
xSeriesPropertySet(series, css::uno::UNO_QUERY);
-                if( xSeriesPropertySet.is() )
-                {
-                    setValueToSeries( xSeriesPropertySet, aNewValue );
-                }
+                setValueToSeries( series, aNewValue );
             }
         }
     }
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx 
b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
index 852c50bfc829..593089029d74 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
@@ -20,6 +20,7 @@
 #include "WrappedStockProperties.hxx"
 #include "Chart2ModelContact.hxx"
 #include <FastPropertyIdRanges.hxx>
+#include <DataSeries.hxx>
 #include <DiagramHelper.hxx>
 #include <ControllerLockGuard.hxx>
 #include <WrappedProperty.hxx>
@@ -135,8 +136,8 @@ css::uno::Any WrappedVolumeProperty::getPropertyValue( 
const css::uno::Reference
     rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
     if( xDiagram.is() && xChartDoc.is() )
     {
-        std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector(
-            DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+        std::vector< rtl::Reference< DataSeries > > aSeriesVector =
+            DiagramHelper::getDataSeriesFromDiagram( xDiagram );
         if( !aSeriesVector.empty() )
         {
             rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
@@ -204,8 +205,8 @@ css::uno::Any WrappedUpDownProperty::getPropertyValue( 
const css::uno::Reference
     rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
     if( xDiagram.is() && xChartDoc.is() )
     {
-        std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector(
-            DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+        std::vector< rtl::Reference< DataSeries > > aSeriesVector =
+            DiagramHelper::getDataSeriesFromDiagram( xDiagram );
         if( !aSeriesVector.empty() )
         {
             rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx 
b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
index 2dccc37c2798..585393f1ecdd 100644
--- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
+++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
@@ -24,6 +24,7 @@
 #include <strings.hrc>
 #include <bitmaps.hlst>
 #include <ChartModelHelper.hxx>
+#include <DataSeries.hxx>
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
 #include <ControllerLockGuard.hxx>
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx 
b/chart2/source/controller/dialogs/DialogModel.cxx
index 08b171f47f00..94659adf1114 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -20,6 +20,7 @@
 #include "DialogModel.hxx"
 #include <RangeSelectionHelper.hxx>
 #include <DataInterpreter.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <DataSourceHelper.hxx>
 #include <DiagramHelper.hxx>
@@ -724,12 +725,12 @@ void DialogModel::setData(
             rtl::Reference< Diagram > xDiagram( 
m_xChartDocument->getFirstChartDiagram() );
             ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram 
);
 
-            std::vector< Reference< XDataSeries > > aSeriesToReUse(
-                DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+            std::vector< rtl::Reference< DataSeries > > aSeriesToReUse =
+                DiagramHelper::getDataSeriesFromDiagram( xDiagram );
             applyInterpretedData(
                 xInterpreter->interpretDataSource(
                     xDataSource, rArguments,
-                    comphelper::containerToSequence( aSeriesToReUse )),
+                    aSeriesToReUse ),
                 aSeriesToReUse);
 
             ThreeDHelper::setScheme( xDiagram, e3DScheme );
@@ -773,7 +774,7 @@ sal_Int32 DialogModel::GetRoleIndexForSorting( const 
OUString & rInternalRoleStr
 
 void DialogModel::applyInterpretedData(
     const InterpretedData & rNewData,
-    const std::vector< Reference< XDataSeries > > & rSeriesToReUse )
+    const std::vector< rtl::Reference< DataSeries > > & rSeriesToReUse )
 {
     if( ! m_xChartDocument.is())
         return;
@@ -797,7 +798,9 @@ void DialogModel::applyInterpretedData(
             const sal_Int32 nSeriesInGroup = aSeries.getLength();
             for( sal_Int32 nSeries=0; nSeries<nSeriesInGroup; ++nSeries, 
++nSeriesCounter )
             {
-                if( std::find( rSeriesToReUse.begin(), rSeriesToReUse.end(), 
aSeries[nSeries] )
+                auto pSeries = 
dynamic_cast<DataSeries*>(aSeries[nSeries].get());
+                assert(pSeries);
+                if( std::find( rSeriesToReUse.begin(), rSeriesToReUse.end(), 
pSeries )
                     == rSeriesToReUse.end())
                 {
                     Reference< beans::XPropertySet > xSeriesProp( 
aSeries[nSeries], uno::UNO_QUERY );
diff --git a/chart2/source/controller/dialogs/DialogModel.hxx 
b/chart2/source/controller/dialogs/DialogModel.hxx
index 3266a5553e25..7d70a3b82cd5 100644
--- a/chart2/source/controller/dialogs/DialogModel.hxx
+++ b/chart2/source/controller/dialogs/DialogModel.hxx
@@ -47,9 +47,10 @@ namespace com::sun::star::chart2 {
 namespace chart
 {
 
-class RangeSelectionHelper;
 class ChartType;
 class ChartTypeTemplate;
+class DataSeries;
+class RangeSelectionHelper;
 
 struct DialogModelTimeBasedInfo
 {
@@ -168,7 +169,7 @@ private:
 private:
     void applyInterpretedData(
         const css::chart2::InterpretedData & rNewData,
-        const std::vector< css::uno::Reference< css::chart2::XDataSeries > > & 
rSeriesToReUse );
+        const std::vector< rtl::Reference< ::chart::DataSeries > > & 
rSeriesToReUse );
 
     sal_Int32 countSeries() const;
 
diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx 
b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
index 7221030ba494..e9d1a7a97692 100644
--- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx
+++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
@@ -30,6 +30,7 @@
 #include <ChartType.hxx>
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <TitleHelper.hxx>
 #include <ExplicitCategoriesProvider.hxx>
@@ -65,7 +66,7 @@ OUString lcl_getDataSeriesName( const OUString& rObjectCID, 
const rtl::Reference
     OUString aRet;
 
     rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
xChartModel ) );
-    Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( 
rObjectCID , xChartModel );
+    rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel );
     if( xDiagram.is() && xSeries.is() )
     {
         rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
@@ -501,7 +502,7 @@ OUString ObjectNameProvider::getHelpText( const OUString& 
rObjectCID, const rtl:
             aRet=SchResId(STR_TIP_DATAPOINT);
 
         rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
xChartModel ) );
-        Reference< XDataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel );
+        rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel );
         if( xDiagram.is() && xSeries.is() )
         {
             sal_Int32 nPointIndex( 
ObjectIdentifier::getParticleID(rObjectCID).toInt32() );
@@ -519,8 +520,8 @@ OUString ObjectNameProvider::getHelpText( const OUString& 
rObjectCID, const rtl:
             nIndex = aRet.indexOf( aWildcard );
             if( nIndex != -1 )
             {
-                std::vector< Reference< chart2::XDataSeries > > aSeriesVector(
-                    DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+                std::vector< rtl::Reference< DataSeries > > aSeriesVector =
+                    DiagramHelper::getDataSeriesFromDiagram( xDiagram );
                 sal_Int32 nSeriesIndex = -1;
                 for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;)
                 {
@@ -553,13 +554,12 @@ OUString ObjectNameProvider::getHelpText( const OUString& 
rObjectCID, const rtl:
         if( bVerbose )
         {
             aRet = SchResId( STR_OBJECT_CURVE_WITH_PARAMETERS );
-            Reference< chart2::XDataSeries > xSeries( 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ));
-            Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, 
uno::UNO_QUERY );
+            rtl::Reference< DataSeries > xSeries( 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ));
 
-            if( xCurveCnt.is())
+            if( xSeries.is())
             {
                 sal_Int32 nCurveIndex = 
ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID );
-                Reference< chart2::XRegressionCurve > xCurve( 
RegressionCurveHelper::getRegressionCurveAtIndex(xCurveCnt, nCurveIndex) );
+                Reference< chart2::XRegressionCurve > xCurve( 
RegressionCurveHelper::getRegressionCurveAtIndex(xSeries, nCurveIndex) );
                 if( xCurve.is())
                 {
                     try
@@ -640,14 +640,13 @@ OUString ObjectNameProvider::getHelpText( const OUString& 
rObjectCID, const rtl:
         }
         else
         {
-            Reference< chart2::XDataSeries > xSeries( 
ObjectIdentifier::getDataSeriesForCID(rObjectCID , xChartModel));
-            Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, 
uno::UNO_QUERY );
+            rtl::Reference< DataSeries > xSeries( 
ObjectIdentifier::getDataSeriesForCID(rObjectCID , xChartModel));
             aRet += getName(eObjectType);
 
-            if( xCurveCnt.is())
+            if( xSeries.is())
             {
                 sal_Int32 nCurveIndex = 
ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID );
-                Reference< chart2::XRegressionCurve > xCurve( 
RegressionCurveHelper::getRegressionCurveAtIndex(xCurveCnt, nCurveIndex) );
+                Reference< chart2::XRegressionCurve > xCurve( 
RegressionCurveHelper::getRegressionCurveAtIndex(xSeries, nCurveIndex) );
                 if( xCurve.is())
                 {
                     aRet += " (" + 
RegressionCurveHelper::getRegressionCurveName(xCurve) + " )";
@@ -660,11 +659,10 @@ OUString ObjectNameProvider::getHelpText( const OUString& 
rObjectCID, const rtl:
         if( bVerbose )
         {
             aRet = SchResId(STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS);
-            Reference< chart2::XDataSeries > xSeries( 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ));
-            Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, 
uno::UNO_QUERY );
-            if( xCurveCnt.is())
+            rtl::Reference< DataSeries > xSeries( 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ));
+            if( xSeries.is())
             {
-                Reference< chart2::XRegressionCurve > xCurve( 
RegressionCurveHelper::getMeanValueLine( xCurveCnt ));
+                Reference< chart2::XRegressionCurve > xCurve( 
RegressionCurveHelper::getMeanValueLine( xSeries ));
                 if( xCurve.is())
                 {
                     try
@@ -730,7 +728,7 @@ OUString ObjectNameProvider::getSelectedObjectText( const 
OUString & rObjectCID,
         aRet = SchResId( STR_STATUS_DATAPOINT_MARKED );
 
         rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
xChartDocument ) );
-        Reference< XDataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartDocument );
+        rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartDocument );
         if( xDiagram.is() && xSeries.is() )
         {
             sal_Int32 nPointIndex( 
ObjectIdentifier::getParticleID(rObjectCID).toInt32() );
@@ -740,7 +738,7 @@ OUString ObjectNameProvider::getSelectedObjectText( const 
OUString & rObjectCID,
 
             // replace data series index
             {
-                std::vector< Reference< chart2::XDataSeries > > aSeriesVector(
+                std::vector< rtl::Reference< DataSeries > > aSeriesVector(
                     DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
                 sal_Int32 nSeriesIndex = -1;
                 for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;)
@@ -811,15 +809,14 @@ OUString ObjectNameProvider::getNameForCID(
                 }
                 else if (eType == OBJECTTYPE_DATA_CURVE || eType == 
OBJECTTYPE_DATA_CURVE_EQUATION)
                 {
-                    Reference< chart2::XDataSeries > xSeries( 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartDocument ));
-                    Reference< chart2::XRegressionCurveContainer > xCurveCnt( 
xSeries, uno::UNO_QUERY );
+                    rtl::Reference< DataSeries > xSeries( 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartDocument ));
 
                     aRet += " " + getName(eType);
 
-                    if( xCurveCnt.is())
+                    if( xSeries.is())
                     {
                         sal_Int32 nCurveIndex = 
ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID );
-                        Reference< chart2::XRegressionCurve > xCurve( 
RegressionCurveHelper::getRegressionCurveAtIndex(xCurveCnt, nCurveIndex) );
+                        Reference< chart2::XRegressionCurve > xCurve( 
RegressionCurveHelper::getRegressionCurveAtIndex(xSeries, nCurveIndex) );
                         if( xCurve.is())
                         {
                            aRet += " (" + 
RegressionCurveHelper::getRegressionCurveName(xCurve) + ")";
@@ -844,7 +841,7 @@ OUString ObjectNameProvider::getName_ObjectForSeries(
         const OUString& rSeriesCID,
         const rtl::Reference<::chart::ChartModel>& xChartDocument )
 {
-    Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( 
rSeriesCID , xChartDocument );
+    rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rSeriesCID , xChartDocument );
     if( xSeries.is() )
     {
         OUString aRet = SchResId(STR_OBJECT_FOR_SERIES);
diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx 
b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx
index ceec42d736e8..0008d6e7d00f 100644
--- a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx
+++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx
@@ -28,6 +28,7 @@
 #include <Diagram.hxx>
 #include <AxisHelper.hxx>
 #include <ObjectNameProvider.hxx>
+#include <DataSeries.hxx>
 
 #include <com/sun/star/frame/XModel.hpp>
 #include <comphelper/servicehelper.hxx>
@@ -77,7 +78,7 @@ double 
InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals(
     {
         Reference< XAxis > xAxis;
         rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
xChartModel ) );
-        Reference< XDataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel );
+        rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel );
         xAxis = DiagramHelper::getAttachedAxis( xSeries, xDiagram );
         if(!xAxis.is())
             xAxis = AxisHelper::getAxis( 1/*nDimensionIndex*/, 
true/*bMainAxis*/, xDiagram );
diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx 
b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
index d7d1c5514633..ed2f5569b1b5 100644
--- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
+++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
@@ -37,6 +37,7 @@
 #include <ChartType.hxx>
 #include <ChartTypeHelper.hxx>
 #include <ObjectNameProvider.hxx>
+#include <DataSeries.hxx>
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
 #include <NumberFormatterWrapper.hxx>
@@ -116,7 +117,7 @@ void ObjectPropertiesDialogParameter::init( const 
rtl::Reference<::chart::ChartM
 {
     m_xChartDocument = xChartModel;
     rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( 
xChartModel );
-    uno::Reference< XDataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( m_aObjectCID, xChartModel );
+    rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( m_aObjectCID, xChartModel );
     rtl::Reference< ChartType > xChartType = 
ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries );
     sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
 
@@ -213,8 +214,7 @@ void ObjectPropertiesDialogParameter::init( const 
rtl::Reference<::chart::ChartM
 
     if( m_eObjectType == OBJECTTYPE_DATA_CURVE )
     {
-        uno::Reference< data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
-        Sequence< Reference< data::XLabeledDataSequence > > aDataSeqs( 
xSource->getDataSequences());
+        Sequence< Reference< data::XLabeledDataSequence > > aDataSeqs( 
xSeries->getDataSequences());
         Sequence< double > aXValues, aYValues;
         bool bXValuesFound = false, bYValuesFound = false;
         m_nNbPoints = 0;
diff --git 
a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx 
b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
index 7c67ef59c139..b44d13f9fa97 100644
--- a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
+++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
@@ -27,6 +27,7 @@
 #include <ChartModelHelper.hxx>
 #include <ChartModel.hxx>
 #include <Diagram.hxx>
+#include <DataSeries.hxx>
 #include <TitleHelper.hxx>
 #include <TitleItemConverter.hxx>
 #include <AxisHelper.hxx>
@@ -107,21 +108,20 @@ AllDataLabelItemConverter::AllDataLabelItemConverter(
     const uno::Reference< lang::XMultiServiceFactory > & 
xNamedPropertyContainerFactory )
         : MultipleItemConverter( rItemPool )
 {
-    std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
-        ::chart::ChartModelHelper::getDataSeries( xChartModel ));
+    std::vector< rtl::Reference< DataSeries > > aSeriesList =
+        ::chart::ChartModelHelper::getDataSeries( xChartModel );
 
     for (auto const& series : aSeriesList)
     {
-        uno::Reference< beans::XPropertySet > xObjectProperties(series, 
uno::UNO_QUERY);
         uno::Reference< uno::XComponentContext> xContext;//do not need Context 
for label properties
 
-        sal_Int32 
nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( 
xObjectProperties );
+        sal_Int32 
nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( 
series );
         sal_Int32 
nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
-                xObjectProperties,xChartModel);
+                series,xChartModel);
 
         m_aConverters.emplace_back(
             new ::chart::wrapper::DataPointItemConverter(
-                xChartModel, xContext, xObjectProperties, series, rItemPool, 
rDrawModel,
+                xChartModel, xContext, series, series, rItemPool, rDrawModel,
                 xNamedPropertyContainerFactory, 
GraphicObjectType::FilledDataPoint,
                 nullptr, true, false, 0, true, nNumberFormat, 
nPercentNumberFormat));
     }
@@ -171,14 +171,13 @@ 
AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
     SfxItemPool& rItemPool )
         : MultipleItemConverter( rItemPool )
 {
-    std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
-        ::chart::ChartModelHelper::getDataSeries( xChartModel ));
+    std::vector< rtl::Reference< DataSeries > > aSeriesList =
+        ::chart::ChartModelHelper::getDataSeries( xChartModel );
 
     for (auto const& series : aSeriesList)
     {
-        uno::Reference< beans::XPropertySet > xObjectProperties(series, 
uno::UNO_QUERY);
         m_aConverters.emplace_back( new 
::chart::wrapper::StatisticsItemConverter(
-                                     xChartModel, xObjectProperties, rItemPool 
));
+                                     xChartModel, series, rItemPool ));
     }
 }
 
diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index c1f8d1c774e2..1de882f0bde0 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -29,6 +29,7 @@
 #include <ChartModelHelper.hxx>
 #include <ChartType.hxx>
 #include "ControllerCommandDispatch.hxx"
+#include <DataSeries.hxx>
 #include <Diagram.hxx>
 #include <strings.hrc>
 #include <chartview/ExplicitValueProvider.hxx>
@@ -1394,8 +1395,8 @@ void ChartController::executeDispatch_MoveSeries( bool 
bForward )
 
     //get selected series
     OUString aObjectCID(m_aSelection.getSelectedCID());
-    uno::Reference< XDataSeries > xGivenDataSeries( 
ObjectIdentifier::getDataSeriesForCID( //yyy todo also legend entries and 
labels?
-            aObjectCID, getChartModel() ) );
+    rtl::Reference< DataSeries > xGivenDataSeries = 
ObjectIdentifier::getDataSeriesForCID( //yyy todo also legend entries and 
labels?
+            aObjectCID, getChartModel() );
 
     UndoGuardWithSelection aUndoGuard(
         ActionDescriptionProvider::createDescription(
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx 
b/chart2/source/controller/main/ChartController_Insert.cxx
index 1928aec09b2a..e25dab50fd0c 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -31,6 +31,7 @@
 #include <ChartModelHelper.hxx>
 #include <AxisHelper.hxx>
 #include <TitleHelper.hxx>
+#include <DataSeries.hxx>
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
 #include <chartview/DrawModelWrapper.hxx>
@@ -247,7 +248,7 @@ void 
ChartController::executeDispatch_InsertMenu_DataLabels()
         m_xUndoManager );
 
     //if a series is selected insert labels for that series only:
-    uno::Reference< chart2::XDataSeries > xSeries =
+    rtl::Reference< DataSeries > xSeries =
         ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel());
     if( xSeries.is() )
     {
@@ -327,8 +328,8 @@ void 
ChartController::executeDispatch_InsertMenu_MeanValues()
     }
     else
     {
-        std::vector< uno::Reference< chart2::XDataSeries > > aSeries(
-            DiagramHelper::getDataSeriesFromDiagram( getFirstDiagram()));
+        std::vector< rtl::Reference< DataSeries > > aSeries =
+            DiagramHelper::getDataSeriesFromDiagram( getFirstDiagram());
 
         for( const auto& xSrs : aSeries )
             lcl_InsertMeanValueLine( xSrs );
@@ -351,8 +352,8 @@ void 
ChartController::executeDispatch_InsertMenu_Trendlines()
 
 void ChartController::executeDispatch_InsertTrendline()
 {
-    uno::Reference< chart2::XRegressionCurveContainer > 
xRegressionCurveContainer(
-        ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel()), uno::UNO_QUERY );
+    rtl::Reference< DataSeries > xRegressionCurveContainer =
+        ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel());
 
     if( !xRegressionCurveContainer.is() )
         return;
@@ -516,8 +517,8 @@ void 
ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 )
         ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
getChartModel() ), uno::UNO_QUERY );
     if( !xRegCurve.is() )
     {
-        uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
-            ObjectIdentifier::getDataSeriesForCID( 
m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY );
+        rtl::Reference< DataSeries > xRegCurveCnt =
+            ObjectIdentifier::getDataSeriesForCID( 
m_aSelection.getSelectedCID(), getChartModel() );
         xRegCurve.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( 
xRegCurveCnt ) );
     }
     if( !xRegCurve.is())
@@ -570,8 +571,8 @@ void ChartController::executeDispatch_DeleteR2Value()
 
 void ChartController::executeDispatch_DeleteMeanValue()
 {
-    uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
-        ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel() ), uno::UNO_QUERY );
+    rtl::Reference< DataSeries > xRegCurveCnt =
+        ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel() );
     if( xRegCurveCnt.is())
     {
         UndoGuard aUndoGuard(
@@ -585,8 +586,8 @@ void ChartController::executeDispatch_DeleteMeanValue()
 
 void ChartController::executeDispatch_DeleteTrendline()
 {
-    uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
-        ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel() ), uno::UNO_QUERY );
+    rtl::Reference< DataSeries > xRegCurveCnt =
+        ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel() );
     if( xRegCurveCnt.is())
     {
         UndoGuard aUndoGuard(
@@ -600,8 +601,8 @@ void ChartController::executeDispatch_DeleteTrendline()
 
 void ChartController::executeDispatch_DeleteTrendlineEquation()
 {
-    uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
-        ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel() ), uno::UNO_QUERY );
+    rtl::Reference< DataSeries > xRegCurveCnt =
+        ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel() );
     if( xRegCurveCnt.is())
     {
         UndoGuard aUndoGuard(
diff --git a/chart2/source/controller/main/ChartController_Properties.cxx 
b/chart2/source/controller/main/ChartController_Properties.cxx
index 95c21c1ac80c..ae6a6a54f4d5 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -44,6 +44,7 @@
 #include <ChartTypeHelper.hxx>
 #include <ChartModel.hxx>
 #include <ColorPerPointHelper.hxx>
+#include <DataSeries.hxx>
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
 #include <ControllerLockGuard.hxx>
@@ -175,7 +176,7 @@ wrapper::ItemConverter* createItemConverter(
                 if (pRefSizeProvider)
                     pRefSize.reset( new awt::Size( 
pRefSizeProvider->getPageSize()));
 
-                uno::Reference<XDataSeries> xSeries = 
ObjectIdentifier::getDataSeriesForCID(aObjectCID, xChartModel);
+                rtl::Reference<DataSeries> xSeries = 
ObjectIdentifier::getDataSeriesForCID(aObjectCID, xChartModel);
 
                 bool bDataSeries = eObjectType == OBJECTTYPE_DATA_LABELS;
 
@@ -199,7 +200,7 @@ wrapper::ItemConverter* createItemConverter(
                 wrapper::GraphicObjectType eMapTo =
                     wrapper::GraphicObjectType::FilledDataPoint;
 
-                uno::Reference< XDataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel );
+                rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel );
                 rtl::Reference< ChartType > xChartType = 
ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries );
 
                 rtl::Reference< Diagram > xDiagram = 
ChartModelHelper::findDiagram( xChartModel );
@@ -216,13 +217,12 @@ wrapper::ItemConverter* createItemConverter(
                 if(!bDataSeries)
                 {
                     nPointIndex = aParticleID.toInt32();
-                    uno::Reference< beans::XPropertySet > xSeriesProp( 
xSeries, uno::UNO_QUERY );
                     bool bVaryColorsByPoint = false;
-                    if( xSeriesProp.is() &&
-                        (xSeriesProp->getPropertyValue("VaryColorsByPoint") 
>>= bVaryColorsByPoint) &&
+                    if( xSeries.is() &&
+                        (xSeries->getPropertyValue("VaryColorsByPoint") >>= 
bVaryColorsByPoint) &&
                         bVaryColorsByPoint )
                     {
-                        if( !ColorPerPointHelper::hasPointOwnColor( 
xSeriesProp, nPointIndex, xObjectProperties ) )
+                        if( !ColorPerPointHelper::hasPointOwnColor( xSeries, 
nPointIndex, xObjectProperties ) )
                         {
                             bUseSpecialFillColor = true;
                             OSL_ASSERT( xDiagram.is());
@@ -262,10 +262,10 @@ wrapper::ItemConverter* createItemConverter(
 
             case OBJECTTYPE_DATA_CURVE:
                 pItemConverter =  new wrapper::RegressionCurveItemConverter(
-                    xObjectProperties, uno::Reference< 
chart2::XRegressionCurveContainer >(
-                        ObjectIdentifier::getDataSeriesForCID( aObjectCID, 
xChartModel ), uno::UNO_QUERY ),
-                    rDrawModel.GetItemPool(), rDrawModel,
-                    xChartModel);
+                        xObjectProperties,
+                        ObjectIdentifier::getDataSeriesForCID( aObjectCID, 
xChartModel ),
+                        rDrawModel.GetItemPool(), rDrawModel,
+                        xChartModel);
                 break;
             case OBJECTTYPE_DATA_CURVE_EQUATION:
             {
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx 
b/chart2/source/controller/main/ChartController_Tools.cxx
index cf42d00c08fd..9859e816c7d3 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -24,6 +24,7 @@
 #include <ChartType.hxx>
 #include <TitleHelper.hxx>
 #include <ThreeDHelper.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include "UndoGuard.hxx"
 #include <ControllerLockGuard.hxx>
@@ -37,6 +38,7 @@
 #include <Legend.hxx>
 #include <LegendHelper.hxx>
 #include <AxisHelper.hxx>
+#include <RegressionCurveModel.hxx>
 #include <RegressionCurveHelper.hxx>
 #include "ShapeController.hxx"
 #include <DiagramHelper.hxx>
@@ -99,7 +101,7 @@ bool lcl_deleteDataSeries(
     const Reference< document::XUndoManager > & xUndoManager )
 {
     bool bResult = false;
-    uno::Reference< chart2::XDataSeries > xSeries( 
ObjectIdentifier::getDataSeriesForCID( rCID, xModel ));
+    rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rCID, xModel );
     if( xSeries.is() && xModel.is())
     {
         rtl::Reference< ::chart::ChartType > xChartType =
@@ -221,8 +223,8 @@ void ChartController::executeDispatch_NewArrangement()
             }
 
             // regression curve equations
-            std::vector< Reference< chart2::XRegressionCurve > > 
aRegressionCurves(
-                RegressionCurveHelper::getAllRegressionCurvesNotMeanValueLine( 
xDiagram ));
+            std::vector< uno::Reference< chart2::XRegressionCurve > > 
aRegressionCurves =
+                RegressionCurveHelper::getAllRegressionCurvesNotMeanValueLine( 
xDiagram );
 
             // reset equation position
             for( const auto& xCurve : aRegressionCurves )
diff --git a/chart2/source/controller/main/ChartController_Window.cxx 
b/chart2/source/controller/main/ChartController_Window.cxx
index e69adac2b741..e489cf757f77 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -44,6 +44,7 @@
 #include <chartview/DrawModelWrapper.hxx>
 #include <RegressionCurveHelper.hxx>
 #include <StatisticsHelper.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <AxisHelper.hxx>
 #include <LegendHelper.hxx>
@@ -1043,11 +1044,10 @@ void ChartController::execute_Command( const 
CommandEvent& rCEvt )
                 if( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == 
OBJECTTYPE_DATA_POINT )
                 {
                     bool bIsPoint = ( eObjectType == OBJECTTYPE_DATA_POINT );
-                    uno::Reference< XDataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel() );
-                    uno::Reference< chart2::XRegressionCurveContainer > 
xCurveCnt( xSeries, uno::UNO_QUERY );
-                    Reference< chart2::XRegressionCurve > xTrendline( 
RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ) );
+                    rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), 
getChartModel() );
+                    Reference< XRegressionCurve > xTrendline = 
RegressionCurveHelper::getFirstCurveNotMeanValueLine( xSeries );
                     bool bHasEquation = RegressionCurveHelper::hasEquation( 
xTrendline );
-                    Reference< chart2::XRegressionCurve > xMeanValue( 
RegressionCurveHelper::getMeanValueLine( xCurveCnt ) );
+                    Reference< XRegressionCurve > xMeanValue = 
RegressionCurveHelper::getMeanValueLine( xSeries );
                     bool bHasYErrorBars = StatisticsHelper::hasErrorBars( 
xSeries );
                     bool bHasXErrorBars = StatisticsHelper::hasErrorBars( 
xSeries, false );
                     bool bHasDataLabelsAtSeries = 
DataSeriesHelper::hasDataLabelsAtSeries( xSeries );
@@ -1062,11 +1062,10 @@ void ChartController::execute_Command( const 
CommandEvent& rCEvt )
                     bool bSelectedPointIsFormatted = false;
                     bool bHasFormattedDataPointsOtherThanSelected = false;
 
-                    Reference< beans::XPropertySet > xSeriesProperties( 
xSeries, uno::UNO_QUERY );
-                    if( xSeriesProperties.is() )
+                    if( xSeries.is() )
                     {
                         uno::Sequence< sal_Int32 > 
aAttributedDataPointIndexList;
-                        if( xSeriesProperties->getPropertyValue( 
"AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+                        if( xSeries->getPropertyValue( "AttributedDataPoints" 
) >>= aAttributedDataPointIndexList )
                         {
                             if( aAttributedDataPointIndexList.hasElements() )
                             {
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx 
b/chart2/source/controller/main/ControllerCommandDispatch.cxx
index dd4e5022586a..a7d0ff5fc4f2 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.cxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx
@@ -30,6 +30,7 @@
 #include <ChartTypeHelper.hxx>
 #include <ChartController.hxx>
 #include <RegressionCurveHelper.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <StatisticsHelper.hxx>
 #include <ReferenceSizeProvider.hxx>
@@ -201,9 +202,9 @@ void ControllerState::update(
     if( aObjectType==OBJECTTYPE_DIAGRAM || 
aObjectType==OBJECTTYPE_DIAGRAM_WALL || aObjectType==OBJECTTYPE_DIAGRAM_FLOOR )
         bIsFormateableObjectSelected = 
DiagramHelper::isSupportingFloorAndWall( xDiagram );
 
-    uno::Reference< chart2::XDataSeries > xGivenDataSeries(
+    rtl::Reference< DataSeries > xGivenDataSeries =
         ObjectIdentifier::getDataSeriesForCID(
-            aSelObjCID, xModel ) );
+            aSelObjCID, xModel );
 
     bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj 
);
 
@@ -249,16 +250,12 @@ void ControllerState::update(
         if( (aObjectType == OBJECTTYPE_DATA_SERIES || aObjectType == 
OBJECTTYPE_DATA_POINT)
             && ChartTypeHelper::isSupportingRegressionProperties( 
xFirstChartType, nDimensionCount ))
         {
-            uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( 
xGivenDataSeries, uno::UNO_QUERY );
-            if( xRegCurveCnt.is())
-            {
-                // Trendline
-                bMayAddTrendline = true;
+            // Trendline
+            bMayAddTrendline = true;
 
-                // Mean Value
-                bMayFormatMeanValue = bMayDeleteMeanValue = 
RegressionCurveHelper::hasMeanValueLine( xRegCurveCnt );
-                bMayAddMeanValue = ! bMayDeleteMeanValue;
-            }
+            // Mean Value
+            bMayFormatMeanValue = bMayDeleteMeanValue = 
RegressionCurveHelper::hasMeanValueLine( xGivenDataSeries );
+            bMayAddMeanValue = ! bMayDeleteMeanValue;
         }
 
         // error bars
diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx 
b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
index b03e3b721e36..93e56145b05a 100644
--- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
@@ -34,6 +34,7 @@
 #include <ChartController.hxx>
 #include <ChartModel.hxx>
 #include <ChartType.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
@@ -52,7 +53,7 @@ namespace {
 
 bool isDataLabelVisible(const rtl::Reference<::chart::ChartModel>& xModel, 
const OUString& rCID)
 {
-    css::uno::Reference< css::chart2::XDataSeries > xSeries =
+    rtl::Reference< DataSeries > xSeries =
         ObjectIdentifier::getDataSeriesForCID(rCID, xModel);
 
     if (!xSeries.is())
@@ -93,8 +94,8 @@ LabelPlacementMap const aLabelPlacementMap[] = {
 sal_Int32 getDataLabelPlacement(const rtl::Reference<::chart::ChartModel>& 
xModel,
         const OUString& rCID)
 {
-    css::uno::Reference< css::beans::XPropertySet > xSeries(
-        ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY );
+    rtl::Reference< DataSeries > xSeries =
+        ObjectIdentifier::getDataSeriesForCID(rCID, xModel);
 
     if (!xSeries.is())
         return 0;
@@ -118,8 +119,8 @@ sal_Int32 getDataLabelPlacement(const 
rtl::Reference<::chart::ChartModel>& xMode
 void setDataLabelPlacement(const rtl::Reference<::chart::ChartModel>& xModel,
         const OUString& rCID, sal_Int32 nPos)
 {
-    css::uno::Reference< css::beans::XPropertySet > xSeries(
-        ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY );
+    rtl::Reference< DataSeries > xSeries =
+        ObjectIdentifier::getDataSeriesForCID(rCID, xModel);
 
     if (!xSeries.is())
         return;
@@ -140,8 +141,8 @@ void setDataLabelPlacement(const 
rtl::Reference<::chart::ChartModel>& xModel,
 bool isTrendlineVisible(const rtl::Reference<::chart::ChartModel>& xModel,
         const OUString& rCID)
 {
-    css::uno::Reference< css::chart2::XRegressionCurveContainer > 
xRegressionCurveContainer(
-        ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY );
+    rtl::Reference< DataSeries > xRegressionCurveContainer =
+        ObjectIdentifier::getDataSeriesForCID(rCID, xModel);
 
     if (!xRegressionCurveContainer.is())
         return false;
@@ -152,8 +153,8 @@ bool isTrendlineVisible(const 
rtl::Reference<::chart::ChartModel>& xModel,
 void setTrendlineVisible(const rtl::Reference<::chart::ChartModel>&
         xModel, const OUString& rCID, bool bVisible)
 {
-    css::uno::Reference< css::chart2::XRegressionCurveContainer > 
xRegressionCurveContainer(
-        ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY );
+    rtl::Reference< DataSeries > xRegressionCurveContainer =
+        ObjectIdentifier::getDataSeriesForCID(rCID, xModel);
 
     if (!xRegressionCurveContainer.is())
         return;
diff --git a/chart2/source/inc/ChartModelHelper.hxx 
b/chart2/source/inc/ChartModelHelper.hxx
index e83fe0365a88..c15b9a95a7f9 100644
--- a/chart2/source/inc/ChartModelHelper.hxx
+++ b/chart2/source/inc/ChartModelHelper.hxx
@@ -39,6 +39,7 @@ namespace chart
 {
 class BaseCoordinateSystem;
 class ChartType;
+class DataSeries;
 class Diagram;
 class InternalDataProvider;
 
@@ -57,7 +58,7 @@ public:
     static rtl::Reference< ::chart::BaseCoordinateSystem >
         getFirstCoordinateSystem( const rtl::Reference<::chart::ChartModel>& 
xModel );
 
-    static std::vector< css::uno::Reference< css::chart2::XDataSeries > >
+    static std::vector< rtl::Reference< ::chart::DataSeries > >
             getDataSeries( const rtl::Reference< ::chart::ChartModel > & 
xModel );
 
     static rtl::Reference< ChartType >
@@ -65,6 +66,11 @@ public:
             const rtl::Reference<::chart::ChartModel>& xModel
             , const css::uno::Reference< css::chart2::XDataSeries >& 
xGivenDataSeries );
 
+    static rtl::Reference< ChartType >
+        getChartTypeOfSeries(
+            const rtl::Reference<::chart::ChartModel>& xModel
+            , const rtl::Reference< ::chart::DataSeries >& xGivenDataSeries );
+
     static css::awt::Size getDefaultPageSize();
 
     static css::awt::Size getPageSize( const 
rtl::Reference<::chart::ChartModel>& xModel );
diff --git a/chart2/source/inc/DataInterpreter.hxx 
b/chart2/source/inc/DataInterpreter.hxx
index 1776cb0f171e..d4736c00d834 100644
--- a/chart2/source/inc/DataInterpreter.hxx
+++ b/chart2/source/inc/DataInterpreter.hxx
@@ -25,9 +25,12 @@
 #include <com/sun/star/chart2/data/XDataSource.hpp>
 #include <com/sun/star/chart2/XDataSeries.hpp>
 #include "charttoolsdllapi.hxx"
+#include <rtl/ref.hxx>
+#include <vector>
 
 namespace chart
 {
+class DataSeries;
 
 /** offers tooling to interpret different data sources in a structural
     and chart-type-dependent way.
@@ -81,11 +84,16 @@ public:
             use all the data series given here for the result before
             creating new ones.
      */
-    virtual css::chart2::InterpretedData interpretDataSource(
+    css::chart2::InterpretedData interpretDataSource(
         const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
         const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
         const css::uno::Sequence< css::uno::Reference< 
css::chart2::XDataSeries > >& aSeriesToReUse );
 
+    virtual css::chart2::InterpretedData interpretDataSource(
+        const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
+        const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
+        const std::vector< rtl::Reference< ::chart::DataSeries > >& 
aSeriesToReUse );
+
     /** Re-interprets the data given in <code>aInterpretedData</code>
         while keeping the number of data series and the categories.
      */
diff --git a/chart2/source/inc/DataSeries.hxx b/chart2/source/inc/DataSeries.hxx
index 64aab7ff8822..79f3032d132a 100644
--- a/chart2/source/inc/DataSeries.hxx
+++ b/chart2/source/inc/DataSeries.hxx
@@ -37,6 +37,7 @@
 #include <map>
 
 #include "OPropertySet.hxx"
+#include "charttoolsdllapi.hxx"
 
 namespace com::sun::star::beans { class XPropertySet; }
 
@@ -58,7 +59,7 @@ typedef ::cppu::WeakImplHelper<
     DataSeries_Base;
 }
 
-class DataSeries final :
+class OOO_DLLPUBLIC_CHARTTOOLS DataSeries final :
     public cppu::BaseMutex,
     public impl::DataSeries_Base,
     public ::property::OPropertySet
@@ -130,6 +131,8 @@ public:
     virtual void SAL_CALL removeModifyListener(
         const css::uno::Reference< css::util::XModifyListener >& aListener ) 
override;
 
+    void setData( const std::vector< css::uno::Reference< 
css::chart2::data::XLabeledDataSequence > >& aData );
+
     typedef
         std::vector< rtl::Reference< ::chart::RegressionCurveModel > >
         tRegressionCurveContainerType;
diff --git a/chart2/source/inc/DataSeriesHelper.hxx 
b/chart2/source/inc/DataSeriesHelper.hxx
index 72d759afe008..f0f439f2bc8f 100644
--- a/chart2/source/inc/DataSeriesHelper.hxx
+++ b/chart2/source/inc/DataSeriesHelper.hxx
@@ -80,6 +80,10 @@ OOO_DLLPUBLIC_CHARTTOOLS
 std::vector<css::uno::Reference<css::chart2::data::XLabeledDataSequence> >
 getAllDataSequences(
     const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& 
aSeries );
+OOO_DLLPUBLIC_CHARTTOOLS
+std::vector<css::uno::Reference<css::chart2::data::XLabeledDataSequence> >
+getAllDataSequences(
+    const std::vector<rtl::Reference<::chart::DataSeries> >& aSeries );
 
 /** Retrieves all data sequences found in the given data series and puts them
     into a data source.  The order of sequences will match the order of the 
data
@@ -87,6 +91,8 @@ getAllDataSequences(
  */
 OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XDataSource >
     getDataSource( const css::uno::Sequence< css::uno::Reference< 
css::chart2::XDataSeries > > & aSeries );
+OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XDataSource >
+    getDataSource( const std::vector< rtl::Reference< ::chart::DataSeries > > 
& aSeries );
 
 /** Get the label of a series (e.g. for the legend)
 
diff --git a/chart2/source/inc/DiagramHelper.hxx 
b/chart2/source/inc/DiagramHelper.hxx
index 6da483d2f39e..5783ff7f10b2 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -46,6 +46,7 @@ class BaseCoordinateSystem;
 class ChartType;
 class ChartTypeManager;
 class ChartTypeTemplate;
+class DataSeries;
 class Diagram;
 
 enum DiagramPositioningMode
@@ -161,12 +162,16 @@ public:
         const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
         const rtl::Reference< ::chart::Diagram >& xDiagram );
 
+    static css::uno::Reference< css::chart2::XAxis > getAttachedAxis(
+        const rtl::Reference< ::chart::DataSeries >& xSeries,
+        const rtl::Reference< ::chart::Diagram >& xDiagram );
+
     static rtl::Reference< ChartType >
         getChartTypeOfSeries(
             const rtl::Reference< ::chart::Diagram >& xDiagram,
             const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
 
-    static std::vector< css::uno::Reference< css::chart2::XDataSeries > >
+    static std::vector< rtl::Reference< ::chart::DataSeries > >
         getDataSeriesFromDiagram(
             const rtl::Reference< ::chart::Diagram > & xDiagram );
 
diff --git a/chart2/source/inc/ObjectIdentifier.hxx 
b/chart2/source/inc/ObjectIdentifier.hxx
index 94b00e1d5ea6..5e52fbfa1ac5 100644
--- a/chart2/source/inc/ObjectIdentifier.hxx
+++ b/chart2/source/inc/ObjectIdentifier.hxx
@@ -43,6 +43,7 @@ namespace com::sun::star::uno { class XInterface; }
 namespace chart
 {
 class BaseCoordinateSystem;
+class DataSeries;
 class Diagram;
 class Legend;
 
@@ -203,7 +204,7 @@ public:
                 , const rtl::Reference<::chart::ChartModel>& xChartModel );
 
     //return the series object that belongs to rObjectCID if any
-    static css::uno::Reference< css::chart2::XDataSeries >
+    static rtl::Reference< ::chart::DataSeries >
             getDataSeriesForCID(
                   const OUString& rObjectCID
                 , const rtl::Reference<::chart::ChartModel>& xChartModel );
diff --git a/chart2/source/inc/RangeHighlighter.hxx 
b/chart2/source/inc/RangeHighlighter.hxx
index bc876d7dc8f1..c7bcdd2c5c55 100644
--- a/chart2/source/inc/RangeHighlighter.hxx
+++ b/chart2/source/inc/RangeHighlighter.hxx
@@ -37,6 +37,7 @@ namespace com::sun::star::view { class XSelectionSupplier; }
 namespace chart
 {
 class ChartModel;
+class DataSeries;
 class Diagram;
 
 namespace impl
@@ -85,7 +86,7 @@ private:
     void fillRangesForDiagram( const rtl::Reference< ::chart::Diagram > & 
xDiagram );
     void fillRangesForDataSeries( const css::uno::Reference< 
css::chart2::XDataSeries > & xSeries );
     void fillRangesForCategories( const css::uno::Reference< 
css::chart2::XAxis > & xAxis );
-    void fillRangesForDataPoint( const css::uno::Reference< 
css::uno::XInterface > & xDataSeries, sal_Int32 nIndex );
+    void fillRangesForDataPoint( const rtl::Reference< ::chart::DataSeries > & 
xDataSeries, sal_Int32 nIndex );
     void fillRangesForErrorBars( const css::uno::Reference< 
css::beans::XPropertySet > & xErrorBar,
                                  const css::uno::Reference< 
css::chart2::XDataSeries > & xDataSeries );
 
diff --git a/chart2/source/model/main/DataSeries.cxx 
b/chart2/source/model/main/DataSeries.cxx
index 509fa3423f71..4407367e9fab 100644
--- a/chart2/source/model/main/DataSeries.cxx
+++ b/chart2/source/model/main/DataSeries.cxx
@@ -405,6 +405,27 @@ void SAL_CALL DataSeries::setData( const uno::Sequence< 
Reference< chart2::data:
     fireModifyEvent();
 }
 
+void DataSeries::setData( const std::vector< Reference< 
chart2::data::XLabeledDataSequence > >& aData )
+{
+    tDataSequenceContainer aOldDataSequences;
+    tDataSequenceContainer aNewDataSequences;
+    Reference< util::XModifyListener > xModifyEventForwarder;
+    Reference< lang::XEventListener > xListener;
+    {
+        MutexGuard aGuard( m_aMutex );
+        xModifyEventForwarder = m_xModifyEventForwarder;
+        xListener = this;
+        std::swap( aOldDataSequences, m_aDataSequences );
+        aNewDataSequences = aData;
+        m_aDataSequences = aNewDataSequences;
+    }
+    ModifyListenerHelper::removeListenerFromAllElements( aOldDataSequences, 
xModifyEventForwarder );
+    EventListenerHelper::removeListenerFromAllElements( aOldDataSequences, 
xListener );
+    EventListenerHelper::addListenerToAllElements( aNewDataSequences, 
xListener );
+    ModifyListenerHelper::addListenerToAllElements( aNewDataSequences, 
xModifyEventForwarder );
+    fireModifyEvent();
+}
+
 // ____ XDataSource ____
 Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL 
DataSeries::getDataSequences()
 {
diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx 
b/chart2/source/model/template/AreaChartTypeTemplate.cxx
index 5b6ef6c4d0d2..1812671f962b 100644
--- a/chart2/source/model/template/AreaChartTypeTemplate.cxx
+++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx
@@ -22,6 +22,7 @@
 #include <servicenames_charttypes.hxx>
 #include <Diagram.hxx>
 #include <DiagramHelper.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <PropertyHelper.hxx>
 #include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -191,18 +192,14 @@ void AreaChartTypeTemplate::applyStyle(
 void AreaChartTypeTemplate::resetStyles( const rtl::Reference< 
::chart::Diagram >& xDiagram )
 {
     ChartTypeTemplate::resetStyles( xDiagram );
-    std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+    std::vector< rtl::Reference< ::chart::DataSeries > > aSeriesVec(
         DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
     uno::Any aLineStyleAny( drawing::LineStyle_NONE );
     for (auto const& series : aSeriesVec)
     {
-        Reference< beans::XPropertyState > xState(series, uno::UNO_QUERY);
-        Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
-        if( xState.is() &&
-            xProp.is() &&
-            xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
+        if( series->getPropertyValue( "BorderStyle") == aLineStyleAny )
         {
-            xState->setPropertyToDefault( "BorderStyle");
+            series->setPropertyToDefault( "BorderStyle");
         }
     }
 }
diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx 
b/chart2/source/model/template/BarChartTypeTemplate.cxx
index 4a46b502a2d0..5e9ccd0c84d1 100644
--- a/chart2/source/model/template/BarChartTypeTemplate.cxx
+++ b/chart2/source/model/template/BarChartTypeTemplate.cxx
@@ -22,6 +22,7 @@
 #include <Diagram.hxx>
 #include <DiagramHelper.hxx>
 #include <servicenames_charttypes.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <PropertyHelper.hxx>
 #include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -265,22 +266,16 @@ void BarChartTypeTemplate::resetStyles(
     const rtl::Reference< ::chart::Diagram >& xDiagram )
 {
     ChartTypeTemplate::resetStyles( xDiagram );
-    std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+    std::vector< rtl::Reference< DataSeries > > aSeriesVec(
         DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
     uno::Any aLineStyleAny( drawing::LineStyle_NONE );
     for (auto const& series : aSeriesVec)
     {
-        Reference< beans::XPropertyState > xState(series, uno::UNO_QUERY);
-        if( xState.is())
+        if( getDimension() == 3 )
+            series->setPropertyToDefault( "Geometry3D");
+        if( series->getPropertyValue( "BorderStyle") == aLineStyleAny )
         {
-            if( getDimension() == 3 )
-                xState->setPropertyToDefault( "Geometry3D");
-            Reference< beans::XPropertySet > xProp( xState, uno::UNO_QUERY );
-            if( xProp.is() &&
-                xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
-            {
-                xState->setPropertyToDefault( "BorderStyle");
-            }
+            series->setPropertyToDefault( "BorderStyle");
         }
     }
 
diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx 
b/chart2/source/model/template/BubbleDataInterpreter.cxx
index 863126fa48ce..b0196bdd050e 100644
--- a/chart2/source/model/template/BubbleDataInterpreter.cxx
+++ b/chart2/source/model/template/BubbleDataInterpreter.cxx
@@ -47,7 +47,7 @@ BubbleDataInterpreter::~BubbleDataInterpreter()
 chart2::InterpretedData BubbleDataInterpreter::interpretDataSource(
     const Reference< chart2::data::XDataSource >& xSource,
     const Sequence< beans::PropertyValue >& aArguments,
-    const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+    const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
 {
     if( ! xSource.is())
         return InterpretedData();
@@ -135,15 +135,13 @@ chart2::InterpretedData 
BubbleDataInterpreter::interpretDataSource(
             aNewData.push_back( aYValuesVector[nN] );
         aNewData.push_back(aSizeValuesVector[nN]);
 
-        Reference< XDataSeries > xSeries;
-        if( nSeriesIndex < aSeriesToReUse.getLength())
-            xSeries.set( aSeriesToReUse[nSeriesIndex] );
+        rtl::Reference< DataSeries > xSeries;
+        if( nSeriesIndex < static_cast<sal_Int32>(aSeriesToReUse.size()))
+            xSeries = aSeriesToReUse[nSeriesIndex];
         else
-            xSeries.set( new DataSeries );
-        OSL_ASSERT( xSeries.is() );
-        Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
-        OSL_ASSERT( xSink.is() );
-        xSink->setData( comphelper::containerToSequence( aNewData ) );
+            xSeries = new DataSeries;
+        assert( xSeries.is() );
+        xSeries->setData( aNewData );
 
         aSeriesVec.push_back( xSeries );
     }
diff --git a/chart2/source/model/template/BubbleDataInterpreter.hxx 
b/chart2/source/model/template/BubbleDataInterpreter.hxx
index 7c33251790db..f4bb71f8beb4 100644
--- a/chart2/source/model/template/BubbleDataInterpreter.hxx
+++ b/chart2/source/model/template/BubbleDataInterpreter.hxx
@@ -34,7 +34,7 @@ protected:
     virtual css::chart2::InterpretedData interpretDataSource(
         const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
         const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
-        const css::uno::Sequence< css::uno::Reference< 
css::chart2::XDataSeries > >& aSeriesToReUse ) override;
+        const std::vector< rtl::Reference< ::chart::DataSeries > >& 
aSeriesToReUse ) override;
     virtual css::chart2::InterpretedData reinterpretDataSeries(
         const css::chart2::InterpretedData& aInterpretedData ) override;
     virtual bool isDataCompatible(
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx 
b/chart2/source/model/template/ChartTypeTemplate.cxx
index 79aab231d265..f3c84f853385 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -22,6 +22,7 @@
 #include <CommonConverters.hxx>
 #include <ChartTypeHelper.hxx>
 #include <ChartType.hxx>
+#include <DataSeries.hxx>
 
 #include <AxisHelper.hxx>
 #include <Diagram.hxx>
@@ -253,9 +254,9 @@ void ChartTypeTemplate::changeDiagramData(
     try
     {
         // interpret new data and re-use existing series
-        Sequence< Reference< XDataSeries > > aFlatSeriesSeq(
-            comphelper::containerToSequence( 
DiagramHelper::getDataSeriesFromDiagram( xDiagram )));
-        const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.getLength();
+        std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq =
+            DiagramHelper::getDataSeriesFromDiagram( xDiagram );
+        const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.size();
         rtl::Reference< DataInterpreter > xInterpreter( getDataInterpreter());
         chart2::InterpretedData aData =
             xInterpreter->interpretDataSource( xDataSource, aArguments, 
aFlatSeriesSeq );
diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.cxx 
b/chart2/source/model/template/ColumnLineDataInterpreter.cxx
index 8f34411ccb72..c548b8c8eacb 100644
--- a/chart2/source/model/template/ColumnLineDataInterpreter.cxx
+++ b/chart2/source/model/template/ColumnLineDataInterpreter.cxx
@@ -45,7 +45,7 @@ ColumnLineDataInterpreter::~ColumnLineDataInterpreter()
 InterpretedData ColumnLineDataInterpreter::interpretDataSource(
     const Reference< data::XDataSource >& xSource,
     const Sequence< beans::PropertyValue >& aArguments,
-    const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+    const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
 {
     InterpretedData aResult(  DataInterpreter::interpretDataSource( xSource, 
aArguments, aSeriesToReUse ));
 
diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.hxx 
b/chart2/source/model/template/ColumnLineDataInterpreter.hxx
index f7f4d0f36dec..d6318367bc00 100644
--- a/chart2/source/model/template/ColumnLineDataInterpreter.hxx
+++ b/chart2/source/model/template/ColumnLineDataInterpreter.hxx
@@ -30,11 +30,10 @@ public:
 
 protected:
     // ____ DataInterpreter ____
-    virtual css::chart2::InterpretedData
-    interpretDataSource(const 
css::uno::Reference<css::chart2::data::XDataSource>& xSource,
-                        const css::uno::Sequence<css::beans::PropertyValue>& 
aArguments,
-                        const 
css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries>>&
-                            aSeriesToReUse) override;
+    virtual css::chart2::InterpretedData interpretDataSource(
+        const css::uno::Reference<css::chart2::data::XDataSource>& xSource,
+        const css::uno::Sequence<css::beans::PropertyValue>& aArguments,
+        const std::vector<rtl::Reference<::chart::DataSeries>>& 
aSeriesToReUse) override;
 
 private:
     sal_Int32 m_nNumberOfLines;
diff --git a/chart2/source/model/template/DataInterpreter.cxx 
b/chart2/source/model/template/DataInterpreter.cxx
index 2e0981b191ad..a206a448871e 100644
--- a/chart2/source/model/template/DataInterpreter.cxx
+++ b/chart2/source/model/template/DataInterpreter.cxx
@@ -126,6 +126,76 @@ InterpretedData DataInterpreter::interpretDataSource(
     return InterpretedData( { comphelper::containerToSequence( aSeriesVec ) }, 
xCategories );
 }
 
+InterpretedData DataInterpreter::interpretDataSource(
+    const Reference< data::XDataSource >& xSource,
+    const Sequence< beans::PropertyValue >& aArguments,
+    const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
+{
+    if( ! xSource.is())
+        return InterpretedData();
+
+#ifdef DEBUG_CHART2_TEMPLATE
+    lcl_ShowDataSource( xSource );
+#endif
+
+    const Sequence< Reference< data::XLabeledDataSequence > > aData( 
xSource->getDataSequences() );
+
+    Reference< data::XLabeledDataSequence > xCategories;
+    vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
+
+    // check if we should use categories
+
+    bool bHasCategories( HasCategories( aArguments, aData ));
+
+    // parse data
+    bool bCategoriesUsed = false;
+    for( Reference< data::XLabeledDataSequence > const & labeledData : aData )
+    {
+        try
+        {
+            if( bHasCategories && ! bCategoriesUsed )
+            {
+                xCategories.set( labeledData );
+                if( xCategories.is())
+                    SetRole( xCategories->getValues(), "categories");
+                bCategoriesUsed = true;
+            }
+            else
+            {
+                aSequencesVec.push_back( labeledData );
+                if( labeledData.is())
+                    SetRole( labeledData->getValues(), "values-y");
+            }
+        }
+        catch( const uno::Exception & )
+        {
+            DBG_UNHANDLED_EXCEPTION("chart2");
+        }
+    }
+
+    // create DataSeries
+    sal_Int32 nSeriesIndex = 0;
+    vector< Reference< XDataSeries > > aSeriesVec;
+    aSeriesVec.reserve( aSequencesVec.size());
+
+    for (auto const& elem : aSequencesVec)
+    {
+        Sequence< Reference< data::XLabeledDataSequence > > aNewData( &elem, 1 
);
+        rtl::Reference< DataSeries > xSeries;
+        if( nSeriesIndex < static_cast<sal_Int32>(aSeriesToReUse.size()))
+            xSeries = aSeriesToReUse[nSeriesIndex];
+        else
+            xSeries = new DataSeries;
+        assert( xSeries.is() );
+        xSeries->setData( aNewData );
+
+        aSeriesVec.push_back( xSeries );
+        ++nSeriesIndex;
+    }
+
+    return InterpretedData( { comphelper::containerToSequence( aSeriesVec ) }, 
xCategories );
+}
+
 InterpretedData DataInterpreter::reinterpretDataSeries(
     const InterpretedData& aInterpretedData )
 {
diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx 
b/chart2/source/model/template/LineChartTypeTemplate.cxx
index 9629ab9e471b..25d5226664f2 100644
--- a/chart2/source/model/template/LineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/LineChartTypeTemplate.cxx
@@ -22,6 +22,7 @@
 #include <Diagram.hxx>
 #include <DiagramHelper.hxx>
 #include <servicenames_charttypes.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <PropertyHelper.hxx>
 #include <ChartType.hxx>
@@ -215,8 +216,8 @@ bool LineChartTypeTemplate::matchesTemplate(
         bool bSymbolFound = false;
         bool bLineFound = false;
 
-        std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
-            DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+        std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+            DiagramHelper::getDataSeriesFromDiagram( xDiagram );
 
         for (auto const& series : aSeriesVec)
         {
@@ -224,9 +225,8 @@ bool LineChartTypeTemplate::matchesTemplate(
             {
                 chart2::Symbol aSymbProp;
                 drawing::LineStyle eLineStyle;
-                Reference< beans::XPropertySet > xProp(series, 
uno::UNO_QUERY_THROW);
 
-                bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") 
>>= aSymbProp) &&
+                bool bCurrentHasSymbol = (series->getPropertyValue( "Symbol") 
>>= aSymbProp) &&
                     (aSymbProp.Style != chart2::SymbolStyle_NONE);
 
                 if( bCurrentHasSymbol )
@@ -238,7 +238,7 @@ bool LineChartTypeTemplate::matchesTemplate(
                     break;
                 }
 
-                bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") 
>>= eLineStyle) &&
+                bool bCurrentHasLine = (series->getPropertyValue( "LineStyle") 
>>= eLineStyle) &&
                     ( eLineStyle != drawing::LineStyle_NONE );
 
                 if( bCurrentHasLine )
diff --git a/chart2/source/model/template/NetChartTypeTemplate.cxx 
b/chart2/source/model/template/NetChartTypeTemplate.cxx
index 222456629783..49d4e7d8d5bc 100644
--- a/chart2/source/model/template/NetChartTypeTemplate.cxx
+++ b/chart2/source/model/template/NetChartTypeTemplate.cxx
@@ -23,6 +23,7 @@
 #include <Diagram.hxx>
 #include <DiagramHelper.hxx>
 #include <servicenames_charttypes.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <ChartType.hxx>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -108,8 +109,8 @@ bool NetChartTypeTemplate::matchesTemplate(
         bool bSymbolFound = false;
         bool bLineFound = false;
 
-        std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
-            DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+        std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+            DiagramHelper::getDataSeriesFromDiagram( xDiagram );
 
         for (auto const& series : aSeriesVec)
         {
@@ -117,9 +118,8 @@ bool NetChartTypeTemplate::matchesTemplate(
             {
                 chart2::Symbol aSymbProp;
                 drawing::LineStyle eLineStyle;
-                Reference< beans::XPropertySet > xProp(series, 
uno::UNO_QUERY_THROW);
 
-                bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") 
>>= aSymbProp) &&
+                bool bCurrentHasSymbol = (series->getPropertyValue( "Symbol") 
>>= aSymbProp) &&
                     (aSymbProp.Style != chart2::SymbolStyle_NONE);
 
                 if( bCurrentHasSymbol )
@@ -131,7 +131,7 @@ bool NetChartTypeTemplate::matchesTemplate(
                     break;
                 }
 
-                bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") 
>>= eLineStyle) &&
+                bool bCurrentHasLine = (series->getPropertyValue( "LineStyle") 
>>= eLineStyle) &&
                     ( eLineStyle != drawing::LineStyle_NONE );
 
                 if( bCurrentHasLine )
diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx 
b/chart2/source/model/template/PieChartTypeTemplate.cxx
index d89230a7f90e..9b7ef05323fc 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.cxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.cxx
@@ -25,6 +25,7 @@
 #include <Diagram.hxx>
 #include <DiagramHelper.hxx>
 #include <servicenames_charttypes.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <AxisHelper.hxx>
 #include <ThreeDHelper.hxx>
@@ -327,8 +328,8 @@ bool PieChartTypeTemplate::matchesTemplate(
             bool bAllOffsetsEqual = true;
             sal_Int32 nOuterSeriesIndex = 0;
 
-            std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
-                DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+            std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+                DiagramHelper::getDataSeriesFromDiagram( xDiagram );
 
             //tdf#108067 The outer series is the last series in OOXML-heavy 
environments
             if( 
!officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get()
 )
@@ -338,13 +339,12 @@ bool PieChartTypeTemplate::matchesTemplate(
             if( !aSeriesVec.empty() )
             {
                 //@todo in future this will depend on Orientation of the 
radius axis scale
-                Reference< chart2::XDataSeries > xSeries( 
aSeriesVec[nOuterSeriesIndex] );
-                Reference< beans::XPropertySet > xProp( xSeries, 
uno::UNO_QUERY_THROW );
-                xProp->getPropertyValue( "Offset") >>= fOffset;
+                rtl::Reference< DataSeries > xSeries( 
aSeriesVec[nOuterSeriesIndex] );
+                xSeries->getPropertyValue( "Offset") >>= fOffset;
 
                 //get AttributedDataPoints
                 uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
-                if( xProp->getPropertyValue( "AttributedDataPoints" ) >>= 
aAttributedDataPointIndexList )
+                if( xSeries->getPropertyValue( "AttributedDataPoints" ) >>= 
aAttributedDataPointIndexList )
                 {
                     for(sal_Int32 
nN=aAttributedDataPointIndexList.getLength();nN--;)
                     {
@@ -352,7 +352,7 @@ bool PieChartTypeTemplate::matchesTemplate(
                         if(xPointProp.is())
                         {
                             double fPointOffset=0.0;
-                            if( xProp->getPropertyValue( "Offset") >>= 
fPointOffset )
+                            if( xSeries->getPropertyValue( "Offset") >>= 
fPointOffset )
                             {
                                 if( ! ::rtl::math::approxEqual( fPointOffset, 
fOffset ) )
                                 {
@@ -571,21 +571,15 @@ void PieChartTypeTemplate::resetStyles( const 
rtl::Reference< ::chart::Diagram >
 
     // vary colors by point,
     // line style
-    std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
-        DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+    std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+        DiagramHelper::getDataSeriesFromDiagram( xDiagram );
     uno::Any aLineStyleAny( drawing::LineStyle_NONE );
     for (auto const& series : aSeriesVec)
     {
-        Reference< beans::XPropertyState > xState(series, uno::UNO_QUERY);
-        if( xState.is())
+        series->setPropertyToDefault( "VaryColorsByPoint");
+        if( series->getPropertyValue( "BorderStyle") == aLineStyleAny )
         {
-            xState->setPropertyToDefault( "VaryColorsByPoint");
-            Reference< beans::XPropertySet > xProp( xState, uno::UNO_QUERY );
-            if( xProp.is() &&
-                xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
-            {
-                xState->setPropertyToDefault( "BorderStyle");
-            }
+            series->setPropertyToDefault( "BorderStyle");
         }
     }
 
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx 
b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
index b6ebf646e7e4..d77e99e8615a 100644
--- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
@@ -24,6 +24,7 @@
 #include <Diagram.hxx>
 #include <DiagramHelper.hxx>
 #include <servicenames_charttypes.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <PropertyHelper.hxx>
 #include <unonames.hxx>
@@ -244,8 +245,8 @@ bool ScatterChartTypeTemplate::matchesTemplate(
         bool bSymbolFound = false;
         bool bLineFound = false;
 
-        std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
-            DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+        std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+            DiagramHelper::getDataSeriesFromDiagram( xDiagram );
 
         for (auto const& series : aSeriesVec)
         {
@@ -253,9 +254,8 @@ bool ScatterChartTypeTemplate::matchesTemplate(
             {
                 chart2::Symbol aSymbProp;
                 drawing::LineStyle eLineStyle;
-                Reference< beans::XPropertySet > xProp(series, 
uno::UNO_QUERY_THROW);
 
-                bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") 
>>= aSymbProp) &&
+                bool bCurrentHasSymbol = (series->getPropertyValue( "Symbol") 
>>= aSymbProp) &&
                     (aSymbProp.Style != chart2::SymbolStyle_NONE);
 
                 if( bCurrentHasSymbol )
@@ -267,7 +267,7 @@ bool ScatterChartTypeTemplate::matchesTemplate(
                     break;
                 }
 
-                bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") 
>>= eLineStyle) &&
+                bool bCurrentHasLine = (series->getPropertyValue( "LineStyle") 
>>= eLineStyle) &&
                     ( eLineStyle != drawing::LineStyle_NONE );
 
                 if( bCurrentHasLine )
diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx 
b/chart2/source/model/template/StockChartTypeTemplate.cxx
index c437270bc678..9a3fce7ca9c2 100644
--- a/chart2/source/model/template/StockChartTypeTemplate.cxx
+++ b/chart2/source/model/template/StockChartTypeTemplate.cxx
@@ -21,6 +21,7 @@
 #include "ColumnChartType.hxx"
 #include "CandleStickChartType.hxx"
 #include "LineChartType.hxx"
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include "StockDataInterpreter.hxx"
 #include <DiagramHelper.hxx>
@@ -239,13 +240,11 @@ void StockChartTypeTemplate::resetStyles(
     ChartTypeTemplate::resetStyles( xDiagram );
     if( getDimension() == 3 )
     {
-        std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
-            DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+        std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+            DiagramHelper::getDataSeriesFromDiagram( xDiagram );
         for (auto const& series : aSeriesVec)
         {
-            Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
-            if( xProp.is() )
-                xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( 
sal_Int32(0) ) );
+            series->setPropertyValue( "AttachedAxisIndex", uno::Any( 
sal_Int32(0) ) );
         }
     }
 
diff --git a/chart2/source/model/template/StockDataInterpreter.cxx 
b/chart2/source/model/template/StockDataInterpreter.cxx
index 3e82715dd3eb..9860f91927d6 100644
--- a/chart2/source/model/template/StockDataInterpreter.cxx
+++ b/chart2/source/model/template/StockDataInterpreter.cxx
@@ -46,7 +46,7 @@ StockDataInterpreter::~StockDataInterpreter()
 InterpretedData StockDataInterpreter::interpretDataSource(
     const Reference< data::XDataSource >& xSource,
     const Sequence< beans::PropertyValue >& rArguments,
-    const Sequence< Reference< XDataSeries > >& rSeriesToReUse )
+    const std::vector< rtl::Reference< ::chart::DataSeries > >& rSeriesToReUse 
)
 {
     if( ! xSource.is())
         return InterpretedData();
@@ -233,14 +233,13 @@ InterpretedData StockDataInterpreter::interpretDataSource(
         {
             try
             {
-                Reference< XDataSeries > xSeries;
-                if( nReUsedSeriesIdx < rSeriesToReUse.getLength())
-                    xSeries.set( rSeriesToReUse[nReUsedSeriesIdx] );
+                rtl::Reference< DataSeries > xSeries;
+                if( nReUsedSeriesIdx < 
static_cast<sal_Int32>(rSeriesToReUse.size()))
+                    xSeries = rSeriesToReUse[nReUsedSeriesIdx];
                 else
-                    xSeries.set( new DataSeries );
-                OSL_ASSERT( xSeries.is() );
-                Reference< data::XDataSink > xSink( xSeries, 
uno::UNO_QUERY_THROW );
-                xSink->setData( aSequences[nGroupIndex][nSeriesIdx] );
+                    xSeries = new DataSeries;
+                assert( xSeries.is() );
+                xSeries->setData( aSequences[nGroupIndex][nSeriesIdx] );
                 pResultSerie[nSeriesIdx].set( xSeries );
             }
             catch( const uno::Exception & )
diff --git a/chart2/source/model/template/StockDataInterpreter.hxx 
b/chart2/source/model/template/StockDataInterpreter.hxx
index f5a9678f53f8..805c7f8c34b2 100644
--- a/chart2/source/model/template/StockDataInterpreter.hxx
+++ b/chart2/source/model/template/StockDataInterpreter.hxx
@@ -37,7 +37,7 @@ protected:
     virtual css::chart2::InterpretedData interpretDataSource(
         const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
         const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
-        const css::uno::Sequence< css::uno::Reference< 
css::chart2::XDataSeries > >& aSeriesToReUse ) override;
+        const std::vector< rtl::Reference< ::chart::DataSeries > >& 
aSeriesToReUse ) override;
     virtual bool isDataCompatible(
         const css::chart2::InterpretedData& aInterpretedData ) override;
     virtual css::chart2::InterpretedData reinterpretDataSeries(
diff --git a/chart2/source/model/template/XYDataInterpreter.cxx 
b/chart2/source/model/template/XYDataInterpreter.cxx
index 82f5a547a68b..962ea1008d44 100644
--- a/chart2/source/model/template/XYDataInterpreter.cxx
+++ b/chart2/source/model/template/XYDataInterpreter.cxx
@@ -48,7 +48,7 @@ XYDataInterpreter::~XYDataInterpreter()
 chart2::InterpretedData XYDataInterpreter::interpretDataSource(
     const Reference< chart2::data::XDataSource >& xSource,
     const Sequence< beans::PropertyValue >& aArguments,
-    const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+    const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
 {
     if( ! xSource.is())
         return InterpretedData();
@@ -118,15 +118,13 @@ chart2::InterpretedData 
XYDataInterpreter::interpretDataSource(
 
         aNewData.push_back(elem);
 
-        Reference< XDataSeries > xSeries;
-        if( nSeriesIndex < aSeriesToReUse.getLength())
-            xSeries.set( aSeriesToReUse[nSeriesIndex] );
+        rtl::Reference< DataSeries > xSeries;
+        if( nSeriesIndex < static_cast<sal_Int32>(aSeriesToReUse.size()))
+            xSeries = aSeriesToReUse[nSeriesIndex];
         else
-            xSeries.set( new DataSeries );
-        OSL_ASSERT( xSeries.is() );
-        Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
-        OSL_ASSERT( xSink.is() );
-        xSink->setData( comphelper::containerToSequence( aNewData ) );
+            xSeries = new DataSeries;
+        assert( xSeries.is() );
+        xSeries->setData( aNewData );
 
         aSeriesVec.push_back( xSeries );
         ++nSeriesIndex;
diff --git a/chart2/source/model/template/XYDataInterpreter.hxx 
b/chart2/source/model/template/XYDataInterpreter.hxx
index 1e7d93216110..f93f47dba947 100644
--- a/chart2/source/model/template/XYDataInterpreter.hxx
+++ b/chart2/source/model/template/XYDataInterpreter.hxx
@@ -34,7 +34,7 @@ protected:
     virtual css::chart2::InterpretedData interpretDataSource(
         const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
         const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
-        const css::uno::Sequence< css::uno::Reference< 
css::chart2::XDataSeries > >& aSeriesToReUse ) override;
+        const std::vector< rtl::Reference< ::chart::DataSeries > >& 
aSeriesToReUse ) override;
     virtual css::chart2::InterpretedData reinterpretDataSeries(
         const css::chart2::InterpretedData& aInterpretedData ) override;
     virtual bool isDataCompatible(
diff --git a/chart2/source/tools/AxisHelper.cxx 
b/chart2/source/tools/AxisHelper.cxx
index 7fe222f6e635..76204c7e3a5a 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -25,6 +25,7 @@
 #include <AxisIndexDefines.hxx>
 #include <LinePropertiesHelper.hxx>
 #include <servicenames_coosystems.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <Scaling.hxx>
 #include <ChartModel.hxx>
@@ -492,7 +493,7 @@ void AxisHelper::hideAxisIfNoDataIsAttached( const 
Reference< XAxis >& xAxis, co
 {
     //axis is hidden if no data is attached anymore but data is available
     bool bOtherSeriesAttachedToThisAxis = false;
-    std::vector< Reference< chart2::XDataSeries > > aSeriesVector( 
DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+    std::vector< rtl::Reference< DataSeries > > aSeriesVector = 
DiagramHelper::getDataSeriesFromDiagram( xDiagram );
     for (auto const& series : aSeriesVector)
     {
         uno::Reference< chart2::XAxis > xCurrentAxis = 
DiagramHelper::getAttachedAxis(series, xDiagram );
@@ -1105,7 +1106,7 @@ void AxisHelper::setRTLAxisLayout( const rtl::Reference< 
BaseCoordinateSystem >&
 rtl::Reference< ChartType > 
AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisIndex( const 
rtl::Reference< Diagram >& xDiagram, const sal_Int32 nAttachedAxisIndex )
 {
     rtl::Reference< ChartType > xChartType;
-    std::vector< Reference< XDataSeries > > aSeriesVector( 
DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+    std::vector< rtl::Reference< DataSeries > > aSeriesVector = 
DiagramHelper::getDataSeriesFromDiagram( xDiagram );
     for (auto const& series : aSeriesVector)
     {
         sal_Int32 nCurrentIndex = 
DataSeriesHelper::getAttachedAxisIndex(series);
diff --git a/chart2/source/tools/ChartModelHelper.cxx 
b/chart2/source/tools/ChartModelHelper.cxx
index 697c99744a0d..fbce1d27f149 100644
--- a/chart2/source/tools/ChartModelHelper.cxx
+++ b/chart2/source/tools/ChartModelHelper.cxx
@@ -27,6 +27,7 @@
 #include <ChartModel.hxx>
 #include <BaseCoordinateSystem.hxx>
 #include <ChartType.hxx>
+#include <DataSeries.hxx>
 
 #include <com/sun/star/chart/ChartDataRowSource.hpp>
 #include <com/sun/star/chart/XChartDocument.hpp>
@@ -111,10 +112,10 @@ rtl::Reference< BaseCoordinateSystem > 
ChartModelHelper::getFirstCoordinateSyste
     return nullptr;
 }
 
-std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
+std::vector< rtl::Reference< DataSeries > > ChartModelHelper::getDataSeries(
     const rtl::Reference<::chart::ChartModel> & xChartDoc )
 {
-    std::vector< uno::Reference< XDataSeries > > aResult;
+    std::vector< rtl::Reference< DataSeries > > aResult;
 
     rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( 
xChartDoc );
     if( xDiagram.is())
@@ -130,6 +131,13 @@ rtl::Reference< ChartType > 
ChartModelHelper::getChartTypeOfSeries(
     return DiagramHelper::getChartTypeOfSeries( ChartModelHelper::findDiagram( 
xModel ), xGivenDataSeries );
 }
 
+rtl::Reference< ChartType > ChartModelHelper::getChartTypeOfSeries(
+                                const rtl::Reference<::chart::ChartModel>& 
xModel
+                              , const rtl::Reference< DataSeries >&   
xGivenDataSeries )
+{
+    return DiagramHelper::getChartTypeOfSeries( ChartModelHelper::findDiagram( 
xModel ), xGivenDataSeries );
+}
+
 awt::Size ChartModelHelper::getDefaultPageSize()
 {
     return awt::Size( 16000, 9000 );
diff --git a/chart2/source/tools/DataSeriesHelper.cxx 
b/chart2/source/tools/DataSeriesHelper.cxx
index c9cb870404c0..2649238128da 100644
--- a/chart2/source/tools/DataSeriesHelper.cxx
+++ b/chart2/source/tools/DataSeriesHelper.cxx
@@ -251,6 +251,20 @@ getAllDataSequences( const 
uno::Sequence<uno::Reference<chart2::XDataSeries> >&
     return aSeqVec;
 }
 
+std::vector<Reference<css::chart2::data::XLabeledDataSequence> >
+getAllDataSequences( const std::vector<rtl::Reference<DataSeries> >& aSeries )
+{
+    std::vector< Reference< chart2::data::XLabeledDataSequence > > aSeqVec;
+
+    for( rtl::Reference<DataSeries> const & dataSeries : aSeries )
+    {
+        const Sequence< Reference< chart2::data::XLabeledDataSequence > > 
aSeq( dataSeries->getDataSequences());
+        aSeqVec.insert( aSeqVec.end(), aSeq.begin(), aSeq.end() );
+    }
+
+    return aSeqVec;
+}
+
 Reference< chart2::data::XDataSource >
     getDataSource( const Sequence< Reference< chart2::XDataSeries > > & 
aSeries )
 {
@@ -258,6 +272,13 @@ Reference< chart2::data::XDataSource >
         new 
DataSource(comphelper::containerToSequence(getAllDataSequences(aSeries))));
 }
 
+Reference< chart2::data::XDataSource >
+    getDataSource( const std::vector< rtl::Reference< DataSeries > > & aSeries 
)
+{
+    return Reference< chart2::data::XDataSource >(
+        new 
DataSource(comphelper::containerToSequence(getAllDataSequences(aSeries))));
+}
+
 namespace
 {
 OUString lcl_getDataSequenceLabel( const Reference< 
chart2::data::XDataSequence > & xSequence )
diff --git a/chart2/source/tools/DataSourceHelper.cxx 
b/chart2/source/tools/DataSourceHelper.cxx
index 37a1fc666057..cb71316c87cd 100644
--- a/chart2/source/tools/DataSourceHelper.cxx
+++ b/chart2/source/tools/DataSourceHelper.cxx
@@ -23,6 +23,7 @@
 #include <ChartTypeManager.hxx>
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <DataSource.hxx>
 #include <ControllerLockGuard.hxx>
@@ -231,9 +232,9 @@ uno::Reference< chart2::data::XDataSource > 
DataSourceHelper::pressUsedDataIntoR
     if( xCategories.is() )
         aResultVector.push_back( xCategories );
 
-    std::vector< Reference< chart2::XDataSeries > > aSeriesVector( 
DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
-    uno::Reference< chart2::data::XDataSource > xSeriesSource(
-        DataSeriesHelper::getDataSource( 
comphelper::containerToSequence(aSeriesVector) ) );
+    std::vector< rtl::Reference< DataSeries > > aSeriesVector = 
DiagramHelper::getDataSeriesFromDiagram( xDiagram );
+    uno::Reference< chart2::data::XDataSource > xSeriesSource =
+        DataSeriesHelper::getDataSource( aSeriesVector );
     const Sequence< Reference< chart2::data::XLabeledDataSequence > > 
aDataSequences( xSeriesSource->getDataSequences() );
 
     //the first x-values is always the next sequence //todo ... other x-values 
get lost for old format
@@ -264,11 +265,10 @@ uno::Sequence< OUString > 
DataSourceHelper::getUsedDataRanges(
         if( xCategories.is() )
             lcl_addRanges( aResult, xCategories );
 
-        std::vector< uno::Reference< XDataSeries > > aSeriesVector( 
DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+        std::vector< rtl::Reference< DataSeries > > aSeriesVector( 
DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
         for (auto const& series : aSeriesVector)
         {
-            uno::Reference< data::XDataSource > xDataSource(series, 
uno::UNO_QUERY);
-            lcl_addDataSourceRanges( aResult, xDataSource );
+            lcl_addDataSourceRanges( aResult, series );
             lcl_addErrorBarRanges( aResult, series );
         }
     }
@@ -298,13 +298,10 @@ uno::Reference< chart2::data::XDataSource > 
DataSourceHelper::getUsedData(
     if( xCategories.is() )
         aResult.push_back( xCategories );
 
-    std::vector< uno::Reference< XDataSeries > > aSeriesVector( 
ChartModelHelper::getDataSeries( &rModel ) );
+    std::vector< rtl::Reference< DataSeries > > aSeriesVector = 
ChartModelHelper::getDataSeries( &rModel );
     for (auto const& series : aSeriesVector)
     {
-        uno::Reference< data::XDataSource > xDataSource(series, 
uno::UNO_QUERY);
-        if( !xDataSource.is() )
-            continue;
-        const uno::Sequence< uno::Reference< data::XLabeledDataSequence > > 
aDataSequences( xDataSource->getDataSequences() );
+        const uno::Sequence< uno::Reference< data::XLabeledDataSequence > > 
aDataSequences( series->getDataSequences() );
         aResult.insert( aResult.end(), aDataSequences.begin(), 
aDataSequences.end() );
     }
 
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index 1789515e7d7c..15075593360c 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -19,6 +19,7 @@
 
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
+#include <DataSeries.hxx>
 #include <DataSeriesHelper.hxx>
 #include <AxisHelper.hxx>
 #include <ChartType.hxx>
@@ -565,6 +566,13 @@ uno::Reference< XAxis > DiagramHelper::getAttachedAxis(
     return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( 
xSeries ), xDiagram );
 }
 
+uno::Reference< XAxis > DiagramHelper::getAttachedAxis(
+        const rtl::Reference< DataSeries >& xSeries,
+        const rtl::Reference< Diagram >& xDiagram )
+{
+    return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( 
xSeries ), xDiagram );
+}
+
 rtl::Reference< ChartType > DiagramHelper::getChartTypeOfSeries(
                                 const rtl::Reference< Diagram >&   xDiagram

... etc. - the rest is truncated

Reply via email to