chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx          |    2 
 chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx    |    2 
 chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx            |   18 
 chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx    |    6 
 chart2/source/controller/dialogs/dlg_ObjectProperties.cxx              |    4 
 chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx |    2 
 chart2/source/controller/main/ChartController_Properties.cxx           |    2 
 chart2/source/controller/main/ControllerCommandDispatch.cxx            |    6 
 chart2/source/controller/main/ObjectHierarchy.cxx                      |    6 
 chart2/source/controller/main/SelectionHelper.cxx                      |    2 
 chart2/source/controller/sidebar/ChartElementsPanel.cxx                |    4 
 chart2/source/inc/Diagram.hxx                                          |   27 +
 chart2/source/inc/DiagramHelper.hxx                                    |   33 -
 chart2/source/model/main/Diagram.cxx                                   |  171 
+++++++++
 chart2/source/tools/AxisHelper.cxx                                     |    2 
 chart2/source/tools/DiagramHelper.cxx                                  |  182 
----------
 chart2/source/view/main/ChartView.cxx                                  |    7 
 chart2/source/view/main/SeriesPlotterContainer.cxx                     |    2 
 18 files changed, 237 insertions(+), 241 deletions(-)

New commits:
commit 770dd89094a8e60e4d8d9f927fde742e9349fa5d
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 16 09:27:44 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 20 17:54:47 2023 +0000

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

diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
index c624f9074687..b54e029d54db 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
@@ -672,7 +672,7 @@ void ChartDataWrapper::applyData( lcl_Operator& 
rDataOperator )
             eStackMode = StackMode::ZStacked;
         else if( bPercent )
             eStackMode = StackMode::YStackedPercent;
-        DiagramHelper::setStackMode( xDia, eStackMode );
+        xDia->setStackMode( eStackMode );
     }
 
     // notify listeners
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index 29127127da6f..657751ed3c23 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -1229,8 +1229,8 @@ bool WrappedStackingProperty::detectInnerValue( 
StackMode& eStackMode ) const
 {
     bool bHasDetectableInnerValue = false;
     bool bIsAmbiguous = false;
-    eStackMode = DiagramHelper::getStackMode( 
m_spChart2ModelContact->getDiagram()
-        , bHasDetectableInnerValue, bIsAmbiguous );
+    rtl::Reference<Diagram> xDiagram = m_spChart2ModelContact->getDiagram();
+    eStackMode = xDiagram ? xDiagram->getStackMode( bHasDetectableInnerValue, 
bIsAmbiguous ) : StackMode::NONE;
     return bHasDetectableInnerValue;
 }
 
@@ -1258,7 +1258,7 @@ void WrappedStackingProperty::setPropertyValue( const 
Any& rOuterValue, const Re
     if( xDiagram.is() )
     {
         StackMode eNewStackMode = bNewValue ? m_eStackMode : StackMode::NONE;
-        DiagramHelper::setStackMode( xDiagram, eNewStackMode );
+        xDiagram->setStackMode( eNewStackMode );
     }
 }
 
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index e6f31bf5db46..9ff0f94bb020 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -45,6 +45,7 @@ class ChartType;
 class DataSeries;
 class Legend;
 class DataTable;
+enum class StackMode;
 class Wall;
 
 enum class DiagramPositioningMode
@@ -288,6 +289,17 @@ public:
      */
     void setDimension( sal_Int32 nNewDimensionCount );
 
+
+    StackMode getStackMode(bool& rbFound, bool& rbAmbiguous);
+
+    /** The stacking mode is only set at the series found inside
+        the first chart type.  This is the standard for all current
+        templates (the only template that has more than one chart-type and
+        allows stacking is bar/line combi, and for this the stacking only
+        applies to the first chart type/the bars)
+     */
+    void setStackMode(StackMode eStackMode);
+
 private:
     // ____ XModifyListener ____
     virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/DiagramHelper.hxx 
b/chart2/source/inc/DiagramHelper.hxx
index efb696ffaf01..35f1de7e9eaf 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -88,22 +88,6 @@ public:
     static bool getVertical( const rtl::Reference< ::chart::Diagram > & 
xDiagram,
                              bool& rbOutFoundResult, bool& 
rbOutAmbiguousResult );
 
-    static StackMode getStackMode(
-        const rtl::Reference< ::chart::Diagram > & xDiagram,
-        bool& rbFound, bool& rbAmbiguous
-        );
-
-    /** The stacking mode is only set at the series found inside
-        the first chart type.  This is the standard for all current
-        templates (the only template that has more than one chart-type and
-        allows stacking is bar/line combi, and for this the stacking only
-        applies to the first chart type/the bars)
-     */
-    static void setStackMode(
-        const rtl::Reference< ::chart::Diagram > & xDiagram,
-        StackMode eStackMode
-        );
-
     /** Retrieves the stackmode of the first DataSeries or none. If the series 
have differing stack
         modes, rbAmbiguous is set to true. If no series is there rbFound is 
set to false.
 
diff --git a/chart2/source/model/main/Diagram.cxx 
b/chart2/source/model/main/Diagram.cxx
index a52713c27d93..d2068529f93d 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -44,6 +44,7 @@
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/chart2/AxisType.hpp>
 #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
+#include <com/sun/star/chart2/StackingDirection.hpp>
 #include <com/sun/star/chart2/RelativePosition.hpp>
 #include <com/sun/star/chart2/RelativeSize.hpp>
 #include <com/sun/star/chart/MissingValueTreatment.hpp>
@@ -1399,7 +1400,7 @@ void Diagram::setDimension( sal_Int32 nNewDimensionCount )
     {
         bool rbFound = false;
         bool rbAmbiguous = true;
-        StackMode eStackMode = DiagramHelper::getStackMode( this, rbFound, 
rbAmbiguous );
+        StackMode eStackMode = getStackMode( rbFound, rbAmbiguous );
         bool bIsSupportingOnlyDeepStackingFor3D=false;
 
         //change all coordinate systems:
@@ -1429,9 +1430,9 @@ void Diagram::setDimension( sal_Int32 nNewDimensionCount )
 
         //correct stack mode if necessary
         if( nNewDimensionCount==3 && eStackMode != StackMode::ZStacked && 
bIsSupportingOnlyDeepStackingFor3D )
-            DiagramHelper::setStackMode( this, StackMode::ZStacked );
+            setStackMode( StackMode::ZStacked );
         else if( nNewDimensionCount==2 && eStackMode == StackMode::ZStacked )
-            DiagramHelper::setStackMode( this, StackMode::NONE );
+            setStackMode( StackMode::NONE );
     }
     catch( const uno::Exception & )
     {
@@ -1439,6 +1440,102 @@ void Diagram::setDimension( sal_Int32 
nNewDimensionCount )
     }
 }
 
+void Diagram::setStackMode( StackMode eStackMode )
+{
+    try
+    {
+        bool bValueFound = false;
+        bool bIsAmbiguous = false;
+        StackMode eOldStackMode = getStackMode( bValueFound, bIsAmbiguous );
+
+        if( eStackMode == eOldStackMode && !bIsAmbiguous )
+            return;
+
+        chart2::StackingDirection eNewDirection = 
chart2::StackingDirection_NO_STACKING;
+        if( eStackMode == StackMode::YStacked || eStackMode == 
StackMode::YStackedPercent )
+            eNewDirection = chart2::StackingDirection_Y_STACKING;
+        else if( eStackMode == StackMode::ZStacked )
+            eNewDirection = chart2::StackingDirection_Z_STACKING;
+
+        uno::Any aNewDirection( eNewDirection );
+
+        bool bPercent = false;
+        if( eStackMode == StackMode::YStackedPercent )
+            bPercent = true;
+
+        //iterate through all coordinate systems
+        for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : 
getBaseCoordinateSystems() )
+        {
+            //set correct percent stacking
+            const sal_Int32 nMaximumScaleIndex = 
xCooSys->getMaximumAxisIndexByDimension(1);
+            for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
+            {
+                rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( 
1,nI );
+                if( xAxis.is())
+                {
+                    chart2::ScaleData aScaleData = xAxis->getScaleData();
+                    if( (aScaleData.AxisType==chart2::AxisType::PERCENT) != 
bPercent )
+                    {
+                        if( bPercent )
+                            aScaleData.AxisType = chart2::AxisType::PERCENT;
+                        else
+                            aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+                        xAxis->setScaleData( aScaleData );
+                    }
+                }
+            }
+            //iterate through all chart types in the current coordinate system
+            const std::vector< rtl::Reference< ChartType > > & aChartTypeList( 
xCooSys->getChartTypes2() );
+            if (aChartTypeList.empty())
+                continue;
+
+            rtl::Reference< ChartType > xChartType( aChartTypeList[0] );
+
+            //iterate through all series in this chart type
+            for( rtl::Reference< DataSeries > const & dataSeries : 
xChartType->getDataSeries2() )
+            {
+                dataSeries->setPropertyValue( "StackingDirection", 
aNewDirection );
+            }
+        }
+    }
+    catch( const uno::Exception & )
+    {
+        DBG_UNHANDLED_EXCEPTION("chart2");
+    }
+}
+
+StackMode Diagram::getStackMode( bool& rbFound, bool& rbAmbiguous )
+{
+    rbFound=false;
+    rbAmbiguous=false;
+
+    StackMode eGlobalStackMode = StackMode::NONE;
+
+    //iterate through all coordinate systems
+    for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : 
getBaseCoordinateSystems() )
+    {
+        //iterate through all chart types in the current coordinate system
+        std::vector< rtl::Reference< ChartType > > aChartTypeList( 
xCooSys->getChartTypes2() );
+        for( std::size_t nT = 0; nT < aChartTypeList.size(); ++nT )
+        {
+            rtl::Reference< ChartType > xChartType( aChartTypeList[nT] );
+
+            StackMode eLocalStackMode = 
DiagramHelper::getStackModeFromChartType(
+                xChartType, rbFound, rbAmbiguous, xCooSys );
+
+            if( rbFound && eLocalStackMode != eGlobalStackMode && nT>0 )
+            {
+                rbAmbiguous = true;
+                return eGlobalStackMode;
+            }
+
+            eGlobalStackMode = eLocalStackMode;
+        }
+    }
+
+    return eGlobalStackMode;
+}
+
 
 } //  namespace chart
 
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index 15037d3c6038..40dc56c2dfbe 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -207,108 +207,6 @@ bool DiagramHelper::getVertical( const rtl::Reference< 
Diagram > & xDiagram,
     return bValue;
 }
 
-void DiagramHelper::setStackMode(
-    const rtl::Reference< Diagram > & xDiagram,
-    StackMode eStackMode
-)
-{
-    try
-    {
-        bool bValueFound = false;
-        bool bIsAmbiguous = false;
-        StackMode eOldStackMode = DiagramHelper::getStackMode( xDiagram, 
bValueFound, bIsAmbiguous );
-
-        if( eStackMode == eOldStackMode && !bIsAmbiguous )
-            return;
-
-        StackingDirection eNewDirection = StackingDirection_NO_STACKING;
-        if( eStackMode == StackMode::YStacked || eStackMode == 
StackMode::YStackedPercent )
-            eNewDirection = StackingDirection_Y_STACKING;
-        else if( eStackMode == StackMode::ZStacked )
-            eNewDirection = StackingDirection_Z_STACKING;
-
-        uno::Any aNewDirection( eNewDirection );
-
-        bool bPercent = false;
-        if( eStackMode == StackMode::YStackedPercent )
-            bPercent = true;
-
-        //iterate through all coordinate systems
-        for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : 
xDiagram->getBaseCoordinateSystems() )
-        {
-            //set correct percent stacking
-            const sal_Int32 nMaximumScaleIndex = 
xCooSys->getMaximumAxisIndexByDimension(1);
-            for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
-            {
-                rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( 
1,nI );
-                if( xAxis.is())
-                {
-                    chart2::ScaleData aScaleData = xAxis->getScaleData();
-                    if( (aScaleData.AxisType==AxisType::PERCENT) != bPercent )
-                    {
-                        if( bPercent )
-                            aScaleData.AxisType = AxisType::PERCENT;
-                        else
-                            aScaleData.AxisType = AxisType::REALNUMBER;
-                        xAxis->setScaleData( aScaleData );
-                    }
-                }
-            }
-            //iterate through all chart types in the current coordinate system
-            const std::vector< rtl::Reference< ChartType > > & aChartTypeList( 
xCooSys->getChartTypes2() );
-            if (aChartTypeList.empty())
-                continue;
-
-            rtl::Reference< ChartType > xChartType( aChartTypeList[0] );
-
-            //iterate through all series in this chart type
-            for( rtl::Reference< DataSeries > const & dataSeries : 
xChartType->getDataSeries2() )
-            {
-                dataSeries->setPropertyValue( "StackingDirection", 
aNewDirection );
-            }
-        }
-    }
-    catch( const uno::Exception & )
-    {
-        DBG_UNHANDLED_EXCEPTION("chart2");
-    }
-}
-
-StackMode DiagramHelper::getStackMode( const rtl::Reference< Diagram > & 
xDiagram, bool& rbFound, bool& rbAmbiguous )
-{
-    rbFound=false;
-    rbAmbiguous=false;
-
-    StackMode eGlobalStackMode = StackMode::NONE;
-
-    if( !xDiagram.is() )
-        return eGlobalStackMode;
-
-    //iterate through all coordinate systems
-    for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : 
xDiagram->getBaseCoordinateSystems() )
-    {
-        //iterate through all chart types in the current coordinate system
-        std::vector< rtl::Reference< ChartType > > aChartTypeList( 
xCooSys->getChartTypes2() );
-        for( std::size_t nT = 0; nT < aChartTypeList.size(); ++nT )
-        {
-            rtl::Reference< ChartType > xChartType( aChartTypeList[nT] );
-
-            StackMode eLocalStackMode = 
DiagramHelper::getStackModeFromChartType(
-                xChartType, rbFound, rbAmbiguous, xCooSys );
-
-            if( rbFound && eLocalStackMode != eGlobalStackMode && nT>0 )
-            {
-                rbAmbiguous = true;
-                return eGlobalStackMode;
-            }
-
-            eGlobalStackMode = eLocalStackMode;
-        }
-    }
-
-    return eGlobalStackMode;
-}
-
 StackMode DiagramHelper::getStackModeFromChartType(
     const rtl::Reference< ChartType > & xChartType,
     bool& rbFound, bool& rbAmbiguous,
commit 70595c0291e4cc137158c77f6136025b10ce6728
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 16 09:20:17 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 20 17:54:39 2023 +0000

    move setDimension/getDimension inside chart2::Diagram
    
    Change-Id: If52f92e152011ead81a1b25f30ba15124e6a8e75
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149151
    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 6edc2732f2b3..8961c2731f71 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -548,7 +548,7 @@ bool DataSeriesPointWrapper::isSupportingAreaProperties()
     rtl::Reference< DataSeries > xSeries( getDataSeries() );
     rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
     rtl::Reference< ::chart::ChartType > xChartType( 
xDiagram->getChartTypeOfSeries( xSeries ) );
-    sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+    sal_Int32 nDimensionCount = xDiagram->getDimension();
 
     return ChartTypeHelper::isSupportingAreaProperties( xChartType, 
nDimensionCount );
 }
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index 2de5055c41aa..29127127da6f 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -1320,9 +1320,9 @@ void WrappedDim3DProperty::setPropertyValue( const Any& 
rOuterValue, const Refer
     if( !xDiagram.is() )
         return;
 
-    bool bOld3D = DiagramHelper::getDimension( xDiagram ) == 3;
+    bool bOld3D = xDiagram->getDimension() == 3;
     if( bOld3D != bNew3D )
-        DiagramHelper::setDimension( xDiagram, bNew3D ? 3 : 2 );
+        xDiagram->setDimension( bNew3D ? 3 : 2 );
 }
 
 Any WrappedDim3DProperty::getPropertyValue( const Reference< 
beans::XPropertySet >& /*xInnerPropertySet*/ ) const
@@ -1330,7 +1330,7 @@ Any WrappedDim3DProperty::getPropertyValue( const 
Reference< beans::XPropertySet
     rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
     if( xDiagram.is() )
     {
-        bool b3D = DiagramHelper::getDimension( xDiagram ) == 3;
+        bool b3D = xDiagram->getDimension() == 3;
         m_aOuterValue <<= b3D;
     }
     return m_aOuterValue;
@@ -1487,8 +1487,10 @@ void WrappedNumberOfLinesProperty::setPropertyValue( 
const Any& rOuterValue, con
 
     rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
-    sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram );
-    if( !(xChartDoc.is() && xDiagram.is() && nDimension == 2) )
+    if( !xChartDoc || !xDiagram )
+        return;
+    sal_Int32 nDimension = xDiagram->getDimension();
+    if( nDimension != 2 )
         return;
 
     rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx 
b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
index 31ae76810df8..83566cf89230 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
@@ -79,8 +79,10 @@ void WrappedStockProperty::setPropertyValue( const 
css::uno::Any& rOuterValue, c
 
     rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
-    sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram );
-    if( !(xChartDoc.is() && xDiagram.is() && nDimension==2) )
+    if( !xChartDoc || !xDiagram )
+        return;
+    sal_Int32 nDimension = xDiagram->getDimension();
+    if( nDimension != 2 )
         return;
 
     rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx 
b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
index a838f784d1a4..eac12af2971e 100644
--- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
+++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
@@ -125,7 +125,9 @@ void ObjectPropertiesDialogParameter::init( const 
rtl::Reference<::chart::ChartM
     rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( 
xChartModel );
     rtl::Reference< DataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( m_aObjectCID, xChartModel );
     rtl::Reference< ChartType > xChartType = 
ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries );
-    sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+    sal_Int32 nDimensionCount = 0;
+    if (xDiagram)
+        nDimensionCount = xDiagram->getDimension();
 
     bool bHasSeriesProperties = (m_eObjectType==OBJECTTYPE_DATA_SERIES);
     bool bHasDataPointproperties = (m_eObjectType==OBJECTTYPE_DATA_POINT);
diff --git 
a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
index 3823d1577ed9..946647cdf2bd 100644
--- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
@@ -87,7 +87,7 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter(
             m_bClockwise = (aScale.Orientation == 
chart2::AxisOrientation_REVERSE);
         }
 
-        sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+        sal_Int32 nDimensionCount = xDiagram->getDimension();
         m_bSupportingOverlapAndGapWidthProperties = 
ChartTypeHelper::isSupportingOverlapAndGapWidthProperties( xChartType, 
nDimensionCount );
 
         if( m_bSupportingOverlapAndGapWidthProperties )
diff --git a/chart2/source/controller/main/ChartController_Properties.cxx 
b/chart2/source/controller/main/ChartController_Properties.cxx
index 209bbf0e0653..7f20576ab756 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -205,7 +205,7 @@ wrapper::ItemConverter* createItemConverter(
                 rtl::Reference< ChartType > xChartType = 
ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries );
 
                 rtl::Reference< Diagram > xDiagram = 
ChartModelHelper::findDiagram( xChartModel );
-                sal_Int32 nDimensionCount = DiagramHelper::getDimension( 
xDiagram );
+                sal_Int32 nDimensionCount = xDiagram->getDimension();
                 if( !ChartTypeHelper::isSupportingAreaProperties( xChartType, 
nDimensionCount ) )
                     eMapTo = wrapper::GraphicObjectType::LineDataPoint;
 
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx 
b/chart2/source/controller/main/ControllerCommandDispatch.cxx
index af0dd5f9f0f2..4feb43e7c845 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.cxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx
@@ -236,7 +236,7 @@ void ControllerState::update(
     if( xGivenDataSeries.is())
     {
         bMayAddMenuTrendline = true;
-        sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+        sal_Int32 nDimensionCount = xDiagram->getDimension();
         rtl::Reference< ::chart::ChartType > xFirstChartType(
             DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries, xDiagram 
));
 
@@ -399,7 +399,9 @@ void ModelState::update( const 
rtl::Reference<::chart::ChartModel> & xModel )
 
     bIsReadOnly = xModel->isReadonly();
 
-    sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+    sal_Int32 nDimensionCount = 0;
+    if (xDiagram)
+        nDimensionCount = xDiagram->getDimension();
 
     rtl::Reference< ChartType > xFirstChartType;
     if (xDiagram)
diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx 
b/chart2/source/controller/main/ObjectHierarchy.cxx
index fd9ee04c7374..975cf145f56b 100644
--- a/chart2/source/controller/main/ObjectHierarchy.cxx
+++ b/chart2/source/controller/main/ObjectHierarchy.cxx
@@ -211,7 +211,7 @@ void ObjectHierarchy::createAxesTree(
     const rtl::Reference<::chart::ChartModel> & xChartDoc,
     const rtl::Reference< Diagram > & xDiagram  )
 {
-    sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+    sal_Int32 nDimensionCount = xDiagram->getDimension();
     rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) 
);
     bool bSupportsAxesGrids = ChartTypeHelper::isSupportingMainAxis( 
xChartType, nDimensionCount, 0 );
     if( !bSupportsAxesGrids )
@@ -282,7 +282,7 @@ void ObjectHierarchy::createWallAndFloor(
     tChildContainer & rContainer,
     const rtl::Reference< Diagram > & xDiagram )
 {
-    sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+    sal_Int32 nDimensionCount = xDiagram->getDimension();
     bool bIsThreeD = ( nDimensionCount == 3 );
     bool bHasWall = xDiagram->isSupportingFloorAndWall();
     if( bHasWall && bIsThreeD )
@@ -320,7 +320,7 @@ void ObjectHierarchy::createDataSeriesTree(
 {
     try
     {
-        sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+        sal_Int32 nDimensionCount = xDiagram->getDimension();
         std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysSeq(
             xDiagram->getBaseCoordinateSystems());
         for( std::size_t nCooSysIdx=0; nCooSysIdx<aCooSysSeq.size(); 
++nCooSysIdx )
diff --git a/chart2/source/controller/main/SelectionHelper.cxx 
b/chart2/source/controller/main/SelectionHelper.cxx
index 46f648399980..4ece0245f8b7 100644
--- a/chart2/source/controller/main/SelectionHelper.cxx
+++ b/chart2/source/controller/main/SelectionHelper.cxx
@@ -448,7 +448,7 @@ bool SelectionHelper::isRotateableObject( 
std::u16string_view rCID
     if( !ObjectIdentifier::isRotateableObject( rCID ) )
         return false;
 
-    sal_Int32 nDimensionCount = DiagramHelper::getDimension( 
ChartModelHelper::findDiagram( xChartModel ) );
+    sal_Int32 nDimensionCount = ChartModelHelper::findDiagram( xChartModel 
)->getDimension();
 
     return nDimensionCount == 3;
 }
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx 
b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index 75dc7ed962c2..3b9bac2cbfb9 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -433,7 +433,9 @@ void ChartElementsPanel::updateData()
         return;
 
     rtl::Reference< Diagram > xDiagram(ChartModelHelper::findDiagram(mxModel));
-    sal_Int32 nDimension = DiagramHelper::getDimension(xDiagram);
+    sal_Int32 nDimension = 0;
+    if (xDiagram)
+        nDimension = xDiagram->getDimension();
     SolarMutexGuard aGuard;
 
     mxCBLegend->set_active(isLegendVisible(mxModel));
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index 5e4bc2ed1c62..e6f31bf5db46 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -273,6 +273,21 @@ public:
         const rtl::Reference< ::chart::BaseCoordinateSystem > & 
xCooSysToReplace,
         const rtl::Reference< ::chart::BaseCoordinateSystem > & xReplacement );
 
+
+    /** Returns the dimension found for all chart types in the tree.  If the
+        dimension is not unique, 0 is returned.
+     */
+    sal_Int32 getDimension();
+
+    /** Sets the dimension of the diagram given.
+
+        1. Sets the dimension of all used ChartTypes
+        2. Adapts the DataSeriesTree to reflect the new dimension
+        3. If new coordinate-systems have to be created, adapts the
+           XCoordinateSystemContainer of the diagram.
+     */
+    void setDimension( sal_Int32 nNewDimensionCount );
+
 private:
     // ____ XModifyListener ____
     virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/DiagramHelper.hxx 
b/chart2/source/inc/DiagramHelper.hxx
index 5ec3998f1f3e..efb696ffaf01 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -119,23 +119,6 @@ public:
         const rtl::Reference< ::chart::BaseCoordinateSystem > & 
xCorrespondingCoordinateSystem
         );
 
-    /** Returns the dimension found for all chart types in the tree.  If the
-        dimension is not unique, 0 is returned.
-     */
-    static sal_Int32 getDimension(
-        const rtl::Reference< ::chart::Diagram > & xDiagram );
-
-    /** Sets the dimension of the diagram given.
-
-        1. Sets the dimension of all used ChartTypes
-        2. Adapts the DataSeriesTree to reflect the new dimension
-        3. If new coordinate-systems have to be created, adapts the
-           XCoordinateSystemContainer of the diagram.
-     */
-    static void setDimension(
-        const rtl::Reference< ::chart::Diagram > & xDiagram,
-        sal_Int32 nNewDimensionCount );
-
     static bool isSeriesAttachedToMainAxis(
         const css::uno::Reference< css::chart2::XDataSeries >& xDataSeries );
 
diff --git a/chart2/source/model/main/Diagram.cxx 
b/chart2/source/model/main/Diagram.cxx
index b3670bc37ee6..a52713c27d93 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -1366,6 +1366,80 @@ void Diagram::replaceCoordinateSystem(
     }
 }
 
+sal_Int32 Diagram::getDimension()
+{
+    // -1: not yet set
+    sal_Int32 nResult = -1;
+
+    try
+    {
+        for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : 
getBaseCoordinateSystems() )
+        {
+            if(xCooSys.is())
+            {
+                nResult = xCooSys->getDimension();
+                break;
+            }
+        }
+    }
+    catch( const uno::Exception & )
+    {
+        DBG_UNHANDLED_EXCEPTION("chart2");
+    }
+
+    return nResult;
+}
+
+void Diagram::setDimension( sal_Int32 nNewDimensionCount )
+{
+    if( getDimension() == nNewDimensionCount )
+        return;
+
+    try
+    {
+        bool rbFound = false;
+        bool rbAmbiguous = true;
+        StackMode eStackMode = DiagramHelper::getStackMode( this, rbFound, 
rbAmbiguous );
+        bool bIsSupportingOnlyDeepStackingFor3D=false;
+
+        //change all coordinate systems:
+        auto aCoordSystems = getBaseCoordinateSystems();
+        for( rtl::Reference<BaseCoordinateSystem> const & xOldCooSys : 
aCoordSystems )
+        {
+            rtl::Reference< BaseCoordinateSystem > xNewCooSys;
+
+            const std::vector< rtl::Reference< ChartType > > aChartTypeList( 
xOldCooSys->getChartTypes2() );
+            for( rtl::Reference< ChartType > const & xChartType : 
aChartTypeList )
+            {
+                bIsSupportingOnlyDeepStackingFor3D = 
ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( xChartType );
+                if(!xNewCooSys.is())
+                {
+                    xNewCooSys = 
dynamic_cast<BaseCoordinateSystem*>(xChartType->createCoordinateSystem( 
nNewDimensionCount ).get());
+                    assert(xNewCooSys);
+                    break;
+                }
+                //@todo make sure that all following charttypes are also 
capable of the new dimension
+                //otherwise separate them in a different group
+                //BM: might be done in replaceCoordinateSystem()
+            }
+
+            // replace the old coordinate system at all places where it was 
used
+            replaceCoordinateSystem( xOldCooSys, xNewCooSys );
+        }
+
+        //correct stack mode if necessary
+        if( nNewDimensionCount==3 && eStackMode != StackMode::ZStacked && 
bIsSupportingOnlyDeepStackingFor3D )
+            DiagramHelper::setStackMode( this, StackMode::ZStacked );
+        else if( nNewDimensionCount==2 && eStackMode == StackMode::ZStacked )
+            DiagramHelper::setStackMode( this, StackMode::NONE );
+    }
+    catch( const uno::Exception & )
+    {
+        DBG_UNHANDLED_EXCEPTION("chart2");
+    }
+}
+
+
 } //  namespace chart
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/chart2/source/tools/AxisHelper.cxx 
b/chart2/source/tools/AxisHelper.cxx
index 9fd50566a540..cee0547b618f 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -886,7 +886,7 @@ void AxisHelper::getAxisOrGridPossibilities( Sequence< 
sal_Bool >& rPossibilityL
     rPossibilityList.realloc(6);
     sal_Bool* pPossibilityList = rPossibilityList.getArray();
 
-    sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+    sal_Int32 nDimensionCount = xDiagram->getDimension();
 
     //set possibilities:
     sal_Int32 nIndex=0;
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index f90da4a02428..15037d3c6038 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -389,86 +389,6 @@ StackMode DiagramHelper::getStackModeFromChartType(
     return eStackMode;
 }
 
-sal_Int32 DiagramHelper::getDimension( const rtl::Reference< Diagram > & 
xDiagram )
-{
-    // -1: not yet set
-    sal_Int32 nResult = -1;
-    if (!xDiagram)
-        return nResult;
-
-    try
-    {
-        for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : 
xDiagram->getBaseCoordinateSystems() )
-        {
-            if(xCooSys.is())
-            {
-                nResult = xCooSys->getDimension();
-                break;
-            }
-        }
-    }
-    catch( const uno::Exception & )
-    {
-        DBG_UNHANDLED_EXCEPTION("chart2");
-    }
-
-    return nResult;
-}
-
-void DiagramHelper::setDimension(
-    const rtl::Reference< Diagram > & xDiagram,
-    sal_Int32 nNewDimensionCount )
-{
-    if( ! xDiagram.is())
-        return;
-
-    if( DiagramHelper::getDimension( xDiagram ) == nNewDimensionCount )
-        return;
-
-    try
-    {
-        bool rbFound = false;
-        bool rbAmbiguous = true;
-        StackMode eStackMode = DiagramHelper::getStackMode( xDiagram, rbFound, 
rbAmbiguous );
-        bool bIsSupportingOnlyDeepStackingFor3D=false;
-
-        //change all coordinate systems:
-        auto aCoordSystems = xDiagram->getBaseCoordinateSystems();
-        for( rtl::Reference<BaseCoordinateSystem> const & xOldCooSys : 
aCoordSystems )
-        {
-            rtl::Reference< BaseCoordinateSystem > xNewCooSys;
-
-            const std::vector< rtl::Reference< ChartType > > aChartTypeList( 
xOldCooSys->getChartTypes2() );
-            for( rtl::Reference< ChartType > const & xChartType : 
aChartTypeList )
-            {
-                bIsSupportingOnlyDeepStackingFor3D = 
ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( xChartType );
-                if(!xNewCooSys.is())
-                {
-                    xNewCooSys = 
dynamic_cast<BaseCoordinateSystem*>(xChartType->createCoordinateSystem( 
nNewDimensionCount ).get());
-                    assert(xNewCooSys);
-                    break;
-                }
-                //@todo make sure that all following charttypes are also 
capable of the new dimension
-                //otherwise separate them in a different group
-                //BM: might be done in replaceCoordinateSystem()
-            }
-
-            // replace the old coordinate system at all places where it was 
used
-            xDiagram->replaceCoordinateSystem( xOldCooSys, xNewCooSys );
-        }
-
-        //correct stack mode if necessary
-        if( nNewDimensionCount==3 && eStackMode != StackMode::ZStacked && 
bIsSupportingOnlyDeepStackingFor3D )
-            DiagramHelper::setStackMode( xDiagram, StackMode::ZStacked );
-        else if( nNewDimensionCount==2 && eStackMode == StackMode::ZStacked )
-            DiagramHelper::setStackMode( xDiagram, StackMode::NONE );
-    }
-    catch( const uno::Exception & )
-    {
-        DBG_UNHANDLED_EXCEPTION("chart2");
-    }
-}
-
 bool DiagramHelper::isSeriesAttachedToMainAxis(
                           const uno::Reference< chart2::XDataSeries >& 
xDataSeries )
 {
diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index a102821cc409..2e1eb7b7a398 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -505,7 +505,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( 
const CreateShapeParam2D
     if( !xDiagram.is())
         return aUsedOuterRect;
 
-    sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+    sal_Int32 nDimensionCount = xDiagram->getDimension();
     if(!nDimensionCount)
     {
         //@todo handle mixed dimension
@@ -1995,9 +1995,12 @@ bool ChartView::createAxisTitleShapes2D( 
CreateShapeParam2D& rParam, const css::
     rtl::Reference<Diagram> xDiagram = mrChartModel.getFirstChartDiagram();
 
     rtl::Reference< ChartType > xChartType;
+    sal_Int32 nDimension = 0;
     if (xDiagram)
+    {
         xChartType = xDiagram->getChartTypeByIndex( 0 );
-    sal_Int32 nDimension = DiagramHelper::getDimension( xDiagram );
+        nDimension = xDiagram->getDimension();
+    }
 
     if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) )
         rParam.mpVTitleX = lcl_createTitle( 
TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, mxRootShape, mrChartModel
diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx 
b/chart2/source/view/main/SeriesPlotterContainer.cxx
index 43a04c70e5d3..b965812b6528 100644
--- a/chart2/source/view/main/SeriesPlotterContainer.cxx
+++ b/chart2/source/view/main/SeriesPlotterContainer.cxx
@@ -138,7 +138,7 @@ void 
SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart
     if (rChartModel.hasInternalDataProvider() && 
xDiagram->isSupportingDateAxis())
         m_nDefaultDateNumberFormat = 
DiagramHelper::getDateNumberFormat(xNumberFormatsSupplier);
 
-    sal_Int32 nDimensionCount = DiagramHelper::getDimension(xDiagram);
+    sal_Int32 nDimensionCount = xDiagram->getDimension();
     if (!nDimensionCount)
     {
         //@todo handle mixed dimension

Reply via email to