chart2/source/inc/Diagram.hxx         |    7 +++++++
 chart2/source/inc/DiagramHelper.hxx   |    8 --------
 chart2/source/model/main/Diagram.cxx  |   24 ++++++++++++++++++++++++
 chart2/source/tools/DiagramHelper.cxx |   32 +-------------------------------
 4 files changed, 32 insertions(+), 39 deletions(-)

New commits:
commit 369b241a7dd30e5102306273263cc92f613e12b4
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 16 09:13:23 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 20 13:07:47 2023 +0000

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

diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index 234868c3ec27..ee003e1af778 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -266,6 +266,13 @@ public:
         const css::uno::Reference< css::uno::XComponentContext > & xContext,
         bool bAdaptAxes=true );
 
+    /** Replaces all occurrences of xCooSysToReplace in the tree with
+        xReplacement in the diagram's tree
+     */
+    SAL_DLLPRIVATE void replaceCoordinateSystem(
+        const rtl::Reference< ::chart::BaseCoordinateSystem > & 
xCooSysToReplace,
+        const rtl::Reference< ::chart::BaseCoordinateSystem > & xReplacement );
+
 private:
     // ____ XModifyListener ____
     virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/DiagramHelper.hxx 
b/chart2/source/inc/DiagramHelper.hxx
index e041e49bca52..5ec3998f1f3e 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -136,14 +136,6 @@ public:
         const rtl::Reference< ::chart::Diagram > & xDiagram,
         sal_Int32 nNewDimensionCount );
 
-    /** Replaces all occurrences of xCooSysToReplace in the tree with
-        xReplacement in the diagram's tree
-     */
-    SAL_DLLPRIVATE static void replaceCoordinateSystem(
-        const rtl::Reference< ::chart::Diagram > & xDiagram,
-        const rtl::Reference< ::chart::BaseCoordinateSystem > & 
xCooSysToReplace,
-        const rtl::Reference< ::chart::BaseCoordinateSystem > & xReplacement );
-
     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 73fb2b381e29..b3670bc37ee6 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -1342,6 +1342,30 @@ bool Diagram::attachSeriesToAxis( bool bAttachToMainAxis
     return bChanged;
 }
 
+void Diagram::replaceCoordinateSystem(
+    const rtl::Reference< BaseCoordinateSystem > & xCooSysToReplace,
+    const rtl::Reference< BaseCoordinateSystem > & xReplacement )
+{
+    // update the coordinate-system container
+    try
+    {
+        uno::Reference< chart2::data::XLabeledDataSequence > xCategories = 
getCategories();
+
+        // move chart types of xCooSysToReplace to xReplacement
+        xReplacement->setChartTypes( xCooSysToReplace->getChartTypes());
+
+        removeCoordinateSystem( xCooSysToReplace );
+        addCoordinateSystem( xReplacement );
+
+        if( xCategories.is() )
+            setCategories( xCategories );
+    }
+    catch( const uno::Exception & )
+    {
+        DBG_UNHANDLED_EXCEPTION("chart2");
+    }
+}
+
 } //  namespace chart
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index b43afae2aac5..f90da4a02428 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -454,7 +454,7 @@ void DiagramHelper::setDimension(
             }
 
             // replace the old coordinate system at all places where it was 
used
-            DiagramHelper::replaceCoordinateSystem( xDiagram, xOldCooSys, 
xNewCooSys );
+            xDiagram->replaceCoordinateSystem( xOldCooSys, xNewCooSys );
         }
 
         //correct stack mode if necessary
@@ -469,36 +469,6 @@ void DiagramHelper::setDimension(
     }
 }
 
-void DiagramHelper::replaceCoordinateSystem(
-    const rtl::Reference< Diagram > & xDiagram,
-    const rtl::Reference< BaseCoordinateSystem > & xCooSysToReplace,
-    const rtl::Reference< BaseCoordinateSystem > & xReplacement )
-{
-    OSL_ASSERT( xDiagram.is());
-    if( ! xDiagram.is())
-        return;
-
-    // update the coordinate-system container
-
-    try
-    {
-        uno::Reference< chart2::data::XLabeledDataSequence > xCategories = 
xDiagram->getCategories();
-
-        // move chart types of xCooSysToReplace to xReplacement
-        xReplacement->setChartTypes( xCooSysToReplace->getChartTypes());
-
-        xDiagram->removeCoordinateSystem( xCooSysToReplace );
-        xDiagram->addCoordinateSystem( xReplacement );
-
-        if( xCategories.is() )
-            xDiagram->setCategories( xCategories );
-    }
-    catch( const uno::Exception & )
-    {
-        DBG_UNHANDLED_EXCEPTION("chart2");
-    }
-}
-
 bool DiagramHelper::isSeriesAttachedToMainAxis(
                           const uno::Reference< chart2::XDataSeries >& 
xDataSeries )
 {

Reply via email to