chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx    |    2 
 chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx   |    2 
 chart2/source/controller/dialogs/DataBrowserModel.cxx                  |    2 
 chart2/source/controller/dialogs/ObjectNameProvider.cxx                |    2 
 chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx               |    2 
 chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx     |    2 
 chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx |    4 
 chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx     |    2 
 chart2/source/controller/main/ChartController_Tools.cxx                |    2 
 chart2/source/controller/main/ChartController_Window.cxx               |    2 
 chart2/source/inc/Diagram.hxx                                          |   12 
++
 chart2/source/inc/DiagramHelper.hxx                                    |   13 
--
 chart2/source/model/main/Diagram.cxx                                   |   50 
++++++++++
 chart2/source/tools/AxisHelper.cxx                                     |    4 
 chart2/source/tools/ChartModelHelper.cxx                               |    6 -
 chart2/source/tools/DiagramHelper.cxx                                  |   49 
---------
 16 files changed, 80 insertions(+), 76 deletions(-)

New commits:
commit 3d4ac66e25427a71798ab720df8078a541d745da
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 16 09:01:48 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 20 05:40:42 2023 +0000

    move getAttachedAxis inside chart2::Diagram
    
    Change-Id: I520633863103a966f1836b4473bc6be32a134ac0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149093
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx 
b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx
index 7f00dcc976db..fcd573a04d73 100644
--- a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx
+++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx
@@ -79,7 +79,7 @@ double 
InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals(
     {
         rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
xChartModel ) );
         rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel );
-        rtl::Reference< Axis > xAxis = DiagramHelper::getAttachedAxis( 
xSeries, xDiagram );
+        rtl::Reference< Axis > xAxis = xDiagram->getAttachedAxis( xSeries );
         if(!xAxis.is())
             xAxis = AxisHelper::getAxis( 1/*nDimensionIndex*/, 
true/*bMainAxis*/, xDiagram );
         if(xAxis.is())
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx 
b/chart2/source/controller/main/ChartController_Tools.cxx
index 8cd3fd99045c..8c1cdf6a3b92 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -114,7 +114,7 @@ bool lcl_deleteDataSeries(
                 xUndoManager );
 
             rtl::Reference< Diagram > xDiagram = 
ChartModelHelper::findDiagram( xModel );
-            rtl::Reference< Axis > xAxis = DiagramHelper::getAttachedAxis( 
xSeries, xDiagram );
+            rtl::Reference< Axis > xAxis = xDiagram->getAttachedAxis( xSeries 
);
 
             DataSeriesHelper::deleteSeries( xSeries, xChartType );
 
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index 2eeab80fe5c9..403dfbb15385 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -39,6 +39,7 @@ namespace com::sun::star::uno { class XComponentContext; }
 
 namespace chart
 {
+class Axis;
 class BaseCoordinateSystem;
 class ChartType;
 class DataSeries;
@@ -251,6 +252,12 @@ public:
     rtl::Reference< ChartType >
         getChartTypeOfSeries( const rtl::Reference< DataSeries >& xSeries );
 
+    rtl::Reference< ::chart::Axis > getAttachedAxis(
+        const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
+
+    rtl::Reference< ::chart::Axis > getAttachedAxis(
+        const rtl::Reference< ::chart::DataSeries >& xSeries );
+
 private:
     // ____ XModifyListener ____
     virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/DiagramHelper.hxx 
b/chart2/source/inc/DiagramHelper.hxx
index 7a4f637d7f89..a6679c6e5ec4 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -153,14 +153,6 @@ public:
         const css::uno::Reference< css::uno::XComponentContext > & xContext,
         bool bAdaptAxes=true );
 
-    static rtl::Reference< ::chart::Axis > getAttachedAxis(
-        const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
-        const rtl::Reference< ::chart::Diagram >& xDiagram );
-
-    static rtl::Reference< ::chart::Axis > getAttachedAxis(
-        const rtl::Reference< ::chart::DataSeries >& xSeries,
-        const rtl::Reference< ::chart::Diagram >& xDiagram );
-
     static css::uno::Sequence< OUString >
         getExplicitSimpleCategories( ChartModel& rModel );
 
diff --git a/chart2/source/model/main/Diagram.cxx 
b/chart2/source/model/main/Diagram.cxx
index 9ff4c0d1c2f0..106d68af35cf 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <Diagram.hxx>
+#include <AxisHelper.hxx>
 #include <ChartTypeHelper.hxx>
 #include <ChartTypeManager.hxx>
 #include <ChartTypeTemplate.hxx>
@@ -1287,7 +1288,17 @@ rtl::Reference< ChartType > 
Diagram::getChartTypeOfSeries(
     return nullptr;
 }
 
+rtl::Reference< Axis > Diagram::getAttachedAxis(
+        const uno::Reference< css::chart2::XDataSeries >& xSeries )
+{
+    return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( 
xSeries ), this );
+}
 
+rtl::Reference< Axis > Diagram::getAttachedAxis(
+        const rtl::Reference< DataSeries >& xSeries )
+{
+    return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( 
xSeries ), this );
+}
 
 } //  namespace chart
 
diff --git a/chart2/source/tools/AxisHelper.cxx 
b/chart2/source/tools/AxisHelper.cxx
index d00e74608eed..9fd50566a540 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -489,7 +489,7 @@ void AxisHelper::hideAxisIfNoDataIsAttached( const 
rtl::Reference< Axis >& xAxis
     std::vector< rtl::Reference< DataSeries > > aSeriesVector = 
xDiagram->getDataSeries();
     for (auto const& series : aSeriesVector)
     {
-        rtl::Reference< Axis > xCurrentAxis = 
DiagramHelper::getAttachedAxis(series, xDiagram );
+        rtl::Reference< Axis > xCurrentAxis = 
xDiagram->getAttachedAxis(series);
         if( xCurrentAxis==xAxis )
         {
             bOtherSeriesAttachedToThisAxis = true;
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index 029305e918b0..6eff3ba0a8b4 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -519,7 +519,7 @@ bool DiagramHelper::attachSeriesToAxis( bool 
bAttachToMainAxis
 
     sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1;
     sal_Int32 nOldAxisIndex = 
DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
-    rtl::Reference< Axis > xOldAxis = DiagramHelper::getAttachedAxis( 
xDataSeries, xDiagram );
+    rtl::Reference< Axis > xOldAxis = xDiagram->getAttachedAxis( xDataSeries );
 
     if( nOldAxisIndex != nNewAxisIndex )
     {
@@ -549,20 +549,6 @@ bool DiagramHelper::attachSeriesToAxis( bool 
bAttachToMainAxis
     return bChanged;
 }
 
-rtl::Reference< Axis > DiagramHelper::getAttachedAxis(
-        const uno::Reference< XDataSeries >& xSeries,
-        const rtl::Reference< Diagram >& xDiagram )
-{
-    return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( 
xSeries ), xDiagram );
-}
-
-rtl::Reference< Axis > DiagramHelper::getAttachedAxis(
-        const rtl::Reference< DataSeries >& xSeries,
-        const rtl::Reference< Diagram >& xDiagram )
-{
-    return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( 
xSeries ), xDiagram );
-}
-
 static void lcl_generateAutomaticCategoriesFromChartType(
             Sequence< OUString >& rRet,
             const rtl::Reference< ChartType >& xChartType )
commit 6a4bcb83f6ac6d240f1358c7334f221a5b8a3d83
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 16 08:57:04 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 20 05:40:32 2023 +0000

    move getChartTypeOfSeries inside chart2::Diagram
    
    Change-Id: I496b180c1e7d6641760251186357d2b11f4434ea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149089
    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 fc7ae7c4f272..4466b78cee82 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -547,7 +547,7 @@ bool DataSeriesPointWrapper::isSupportingAreaProperties()
 {
     rtl::Reference< DataSeries > xSeries( getDataSeries() );
     rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
-    rtl::Reference< ::chart::ChartType > xChartType( 
DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
+    rtl::Reference< ::chart::ChartType > xChartType( 
xDiagram->getChartTypeOfSeries( xSeries ) );
     sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
 
     return ChartTypeHelper::isSupportingAreaProperties( xChartType, 
nDimensionCount );
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx 
b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx
index 4a07622b3e14..50d4b2c0edd2 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx
@@ -287,7 +287,7 @@ beans::PropertyState 
WrappedSymbolTypeProperty::getPropertyState( const Referenc
     {
         rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
         Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, 
uno::UNO_QUERY );
-        rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
+        rtl::Reference< ChartType > xChartType( 
xDiagram->getChartTypeOfSeries( xSeries ) );
         if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) )
             return beans::PropertyState_DIRECT_VALUE;
     }
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx 
b/chart2/source/controller/dialogs/DataBrowserModel.cxx
index 75e4edbbca57..d26db62f76b9 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.cxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx
@@ -297,7 +297,7 @@ void DataBrowserModel::insertDataSeries( sal_Int32 
nAfterColumnIndex )
     if( xSeries.is())
     {
         // Use the chart type of the currently selected data series.
-        xChartType = DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries );
+        xChartType = xDiagram->getChartTypeOfSeries( xSeries );
 
         // Find the corresponding header and determine the last column of this
         // data series.
diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx 
b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
index d70a555bb4fd..b1a023136706 100644
--- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx
+++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
@@ -70,7 +70,7 @@ OUString lcl_getDataSeriesName( std::u16string_view 
rObjectCID, const rtl::Refer
     rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel );
     if( xDiagram.is() && xSeries.is() )
     {
-        rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
+        rtl::Reference< ChartType > xChartType( 
xDiagram->getChartTypeOfSeries( xSeries ) );
         if( xChartType.is() )
         {
             aRet = ::chart::DataSeriesHelper::getDataSeriesLabel(
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index 76393c598b7b..b0155174cd94 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -239,7 +239,7 @@ DataPointItemConverter::DataPointItemConverter(
     }
 
     rtl::Reference< Diagram > xDiagram( 
ChartModelHelper::findDiagram(xChartModel) );
-    rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeOfSeries( xDiagram , xSeries ) );
+    rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( 
xSeries ) );
     bool bFound = false;
     bool bAmbiguous = false;
     bool bSwapXAndY = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous 
);
diff --git 
a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
index 2af1e694156f..90adfba537cc 100644
--- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
@@ -77,7 +77,7 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter(
         m_bAttachToMainAxis = DiagramHelper::isSeriesAttachedToMainAxis( 
xDataSeries );
 
         rtl::Reference< Diagram > xDiagram( 
ChartModelHelper::findDiagram(xChartModel) );
-        rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ) );
+        rtl::Reference< ChartType > xChartType( 
xDiagram->getChartTypeOfSeries( xDataSeries ) );
 
         m_xCooSys = DataSeriesHelper::getCoordinateSystemOfSeries( 
xDataSeries, xDiagram );
         if( m_xCooSys.is() )
@@ -207,7 +207,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( 
sal_uInt16 nWhichId, const Sf
 
                 uno::Reference< XDataSeries > xDataSeries( GetPropertySet(), 
uno::UNO_QUERY );
                 rtl::Reference< Diagram > xDiagram( 
ChartModelHelper::findDiagram(m_xChartModel) );
-                rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ) );
+                rtl::Reference< ChartType > xChartType( 
xDiagram->getChartTypeOfSeries( xDataSeries ) );
                 if( xChartType.is() )
                 {
                     sal_Int32 nAxisIndex = 
DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
index 68867c5a81fc..929f1c7c48b9 100644
--- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
@@ -212,7 +212,7 @@ TextLabelItemConverter::TextLabelItemConverter(
     maConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, 
rItemPool, pRefSize, "ReferencePageSize"));
 
     rtl::Reference< Diagram > 
xDiagram(ChartModelHelper::findDiagram(xChartModel));
-    rtl::Reference< ChartType > 
xChartType(DiagramHelper::getChartTypeOfSeries(xDiagram, xSeries));
+    rtl::Reference< ChartType > 
xChartType(xDiagram->getChartTypeOfSeries(xSeries));
     bool bFound = false;
     bool bAmbiguous = false;
     bool bSwapXAndY = DiagramHelper::getVertical(xDiagram, bFound, bAmbiguous);
diff --git a/chart2/source/controller/main/ChartController_Window.cxx 
b/chart2/source/controller/main/ChartController_Window.cxx
index a3b108ee99de..540cedb4d6fa 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -1095,7 +1095,7 @@ void ChartController::execute_Command( const 
CommandEvent& rCEvt )
                     lcl_insertMenuCommand( xPopupMenu, nUniqueId++, 
".uno:FormatDataSeries" );
                 }
 
-                rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
+                rtl::Reference< ChartType > xChartType( 
xDiagram->getChartTypeOfSeries( xSeries ) );
                 if( xChartType->getChartType() == 
CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
                 {
                     try
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index b9e7a06b1786..2eeab80fe5c9 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -246,6 +246,11 @@ public:
     std::vector< rtl::Reference< ::chart::DataSeries > >
         getDataSeries();
 
+    rtl::Reference< ChartType >
+        getChartTypeOfSeries( const css::uno::Reference< 
css::chart2::XDataSeries >& xSeries );
+    rtl::Reference< ChartType >
+        getChartTypeOfSeries( const rtl::Reference< DataSeries >& xSeries );
+
 private:
     // ____ XModifyListener ____
     virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/DiagramHelper.hxx 
b/chart2/source/inc/DiagramHelper.hxx
index e62c4c5dc3da..7a4f637d7f89 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -161,11 +161,6 @@ public:
         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 css::uno::Sequence< OUString >
         getExplicitSimpleCategories( ChartModel& rModel );
 
diff --git a/chart2/source/model/main/Diagram.cxx 
b/chart2/source/model/main/Diagram.cxx
index 5728b645e1e2..9ff4c0d1c2f0 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -1249,6 +1249,45 @@ std::vector< rtl::Reference< ::chart::DataSeries > >
     return aResult;
 }
 
+rtl::Reference< ChartType > Diagram::getChartTypeOfSeries(
+        const uno::Reference< chart2::XDataSeries >& xGivenDataSeries )
+{
+    if( !xGivenDataSeries.is() )
+        return nullptr;
+    rtl::Reference pGivenDataSeries = 
dynamic_cast<DataSeries*>(xGivenDataSeries.get());
+    assert(pGivenDataSeries);
+    return getChartTypeOfSeries(pGivenDataSeries);
+}
+
+rtl::Reference< ChartType > Diagram::getChartTypeOfSeries(
+        const rtl::Reference< DataSeries >& xGivenDataSeries )
+{
+    if( !xGivenDataSeries.is() )
+        return nullptr;
+
+    //iterate through the model to find the given xSeries
+    //the found parent indicates the charttype
+
+    //iterate through all coordinate systems
+
+    for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : 
getBaseCoordinateSystems() )
+    {
+        //iterate through all chart types in the current coordinate system
+        const std::vector< rtl::Reference< ChartType > > & aChartTypeList( 
xCooSys->getChartTypes2() );
+        for( rtl::Reference< ChartType > const & xChartType : aChartTypeList )
+        {
+            //iterate through all series in this chart type
+            for( rtl::Reference< DataSeries > const & dataSeries : 
xChartType->getDataSeries2() )
+            {
+                if( xGivenDataSeries==dataSeries )
+                    return xChartType;
+            }
+        }
+    }
+    return nullptr;
+}
+
+
 
 } //  namespace chart
 
diff --git a/chart2/source/tools/AxisHelper.cxx 
b/chart2/source/tools/AxisHelper.cxx
index 54575f97c052..d00e74608eed 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -1132,7 +1132,7 @@ rtl::Reference< ChartType > 
AxisHelper::getFirstChartTypeWithSeriesAttachedToAxi
         sal_Int32 nCurrentIndex = 
DataSeriesHelper::getAttachedAxisIndex(series);
         if( nAttachedAxisIndex == nCurrentIndex )
         {
-            xChartType = DiagramHelper::getChartTypeOfSeries(xDiagram, series);
+            xChartType = xDiagram->getChartTypeOfSeries(series);
             if(xChartType.is())
                 break;
         }
diff --git a/chart2/source/tools/ChartModelHelper.cxx 
b/chart2/source/tools/ChartModelHelper.cxx
index d28f64ee7c7a..c01ca7698274 100644
--- a/chart2/source/tools/ChartModelHelper.cxx
+++ b/chart2/source/tools/ChartModelHelper.cxx
@@ -125,14 +125,16 @@ rtl::Reference< ChartType > 
ChartModelHelper::getChartTypeOfSeries(
                                 const rtl::Reference<::chart::ChartModel>& 
xModel
                               , const uno::Reference< XDataSeries >&   
xGivenDataSeries )
 {
-    return DiagramHelper::getChartTypeOfSeries( ChartModelHelper::findDiagram( 
xModel ), xGivenDataSeries );
+    rtl::Reference<Diagram> xDiagram = ChartModelHelper::findDiagram( xModel );
+    return xDiagram ? xDiagram->getChartTypeOfSeries( xGivenDataSeries ) : 
nullptr;
 }
 
 rtl::Reference< ChartType > ChartModelHelper::getChartTypeOfSeries(
                                 const rtl::Reference<::chart::ChartModel>& 
xModel
                               , const rtl::Reference< DataSeries >&   
xGivenDataSeries )
 {
-    return DiagramHelper::getChartTypeOfSeries( ChartModelHelper::findDiagram( 
xModel ), xGivenDataSeries );
+    rtl::Reference<Diagram> xDiagram = ChartModelHelper::findDiagram( xModel );
+    return xDiagram ? xDiagram->getChartTypeOfSeries( xGivenDataSeries ) : 
nullptr;
 }
 
 awt::Size ChartModelHelper::getDefaultPageSize()
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index 60f1376b2f25..029305e918b0 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -563,39 +563,6 @@ rtl::Reference< Axis > DiagramHelper::getAttachedAxis(
     return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( 
xSeries ), xDiagram );
 }
 
-rtl::Reference< ChartType > DiagramHelper::getChartTypeOfSeries(
-                                const rtl::Reference< Diagram >&   xDiagram
-                              , const uno::Reference< XDataSeries >&        
xGivenDataSeries )
-{
-    if( !xGivenDataSeries.is() )
-        return nullptr;
-    if(!xDiagram.is())
-        return nullptr;
-    rtl::Reference pGivenDataSeries = 
dynamic_cast<DataSeries*>(xGivenDataSeries.get());
-    assert(pGivenDataSeries);
-
-    //iterate through the model to find the given xSeries
-    //the found parent indicates the charttype
-
-    //iterate through all coordinate systems
-
-    for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : 
xDiagram->getBaseCoordinateSystems() )
-    {
-        //iterate through all chart types in the current coordinate system
-        const std::vector< rtl::Reference< ChartType > > & aChartTypeList( 
xCooSys->getChartTypes2() );
-        for( rtl::Reference< ChartType > const & xChartType : aChartTypeList )
-        {
-            //iterate through all series in this chart type
-            for( rtl::Reference< DataSeries > const & dataSeries : 
xChartType->getDataSeries2() )
-            {
-                if( pGivenDataSeries==dataSeries )
-                    return xChartType;
-            }
-        }
-    }
-    return nullptr;
-}
-
 static void lcl_generateAutomaticCategoriesFromChartType(
             Sequence< OUString >& rRet,
             const rtl::Reference< ChartType >& xChartType )

Reply via email to