chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx    |    2 
 chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx |    4 
 chart2/source/controller/sidebar/ChartSeriesPanel.cxx                  |    2 
 chart2/source/inc/Diagram.hxx                                          |    5 +
 chart2/source/inc/DiagramHelper.hxx                                    |    6 -
 chart2/source/model/main/Diagram.cxx                                   |   42 
+++++++++
 chart2/source/tools/DiagramHelper.cxx                                  |   43 
----------
 7 files changed, 51 insertions(+), 53 deletions(-)

New commits:
commit 514d2c7d20b3d63fc753918e4013eec71d2b342e
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 16 09:04:28 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 20 10:50:47 2023 +0000

    move attachSeriesToAxis inside chart2::Diagram
    
    Change-Id: I3559fe9b9f0830c32a44c23b0b4d1a3683bafbd8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149135
    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 4466b78cee82..6edc2732f2b3 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -331,7 +331,7 @@ void WrappedAttachedAxisProperty::setPropertyValue( const 
Any& rOuterValue, cons
     {
         rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
         if( xDiagram.is() )
-            ::chart::DiagramHelper::attachSeriesToAxis( 
bNewAttachedToMainAxis, xDataSeries, xDiagram, 
m_spChart2ModelContact->m_xContext, false );
+            xDiagram->attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, 
m_spChart2ModelContact->m_xContext, false );
     }
 }
 
diff --git 
a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
index 90adfba537cc..3823d1577ed9 100644
--- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
@@ -184,8 +184,8 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( 
sal_uInt16 nWhichId, const Sf
             if( bAttachToMainAxis != m_bAttachToMainAxis )
             {
                 //change model:
-                bChanged = DiagramHelper::attachSeriesToAxis( 
bAttachToMainAxis, uno::Reference< XDataSeries >::query( GetPropertySet() )
-                    , ChartModelHelper::findDiagram(m_xChartModel), m_xCC );
+                bChanged = 
ChartModelHelper::findDiagram(m_xChartModel)->attachSeriesToAxis( 
bAttachToMainAxis, uno::Reference< XDataSeries >::query( GetPropertySet() )
+                    , m_xCC );
 
                 if( bChanged )
                     m_bAttachToMainAxis = bAttachToMainAxis;
diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx 
b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
index ad77a6aa5e5d..2b8417eaa48c 100644
--- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
@@ -219,7 +219,7 @@ void setAttachedAxisType(const 
rtl::Reference<::chart::ChartModel>&
         return;
 
     rtl::Reference<Diagram> xDiagram = xModel->getFirstChartDiagram();
-    DiagramHelper::attachSeriesToAxis(bPrimary, xDataSeries, xDiagram, 
comphelper::getProcessComponentContext());
+    xDiagram->attachSeriesToAxis(bPrimary, xDataSeries, 
comphelper::getProcessComponentContext());
 }
 
 rtl::Reference<ChartType> getChartType(
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index 2d40831c1892..234868c3ec27 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -261,6 +261,11 @@ public:
     rtl::Reference< ::chart::Axis > getAttachedAxis(
         const rtl::Reference< ::chart::DataSeries >& xSeries );
 
+    bool attachSeriesToAxis( bool bMainAxis,
+        const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+        const css::uno::Reference< css::uno::XComponentContext > & xContext,
+        bool bAdaptAxes=true );
+
 private:
     // ____ XModifyListener ____
     virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/DiagramHelper.hxx 
b/chart2/source/inc/DiagramHelper.hxx
index a6679c6e5ec4..e041e49bca52 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -147,12 +147,6 @@ public:
     static bool isSeriesAttachedToMainAxis(
         const css::uno::Reference< css::chart2::XDataSeries >& xDataSeries );
 
-    static bool attachSeriesToAxis( bool bMainAxis,
-        const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
-        const rtl::Reference< ::chart::Diagram >& xDiagram,
-        const css::uno::Reference< css::uno::XComponentContext > & xContext,
-        bool bAdaptAxes=true );
-
     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 106d68af35cf..73fb2b381e29 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -1300,6 +1300,48 @@ rtl::Reference< Axis > Diagram::getAttachedAxis(
     return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( 
xSeries ), this );
 }
 
+bool Diagram::attachSeriesToAxis( bool bAttachToMainAxis
+                        , const uno::Reference< chart2::XDataSeries >& 
xDataSeries
+                        , const uno::Reference< uno::XComponentContext > & 
xContext
+                        , bool bAdaptAxes )
+{
+    bool bChanged = false;
+
+    //set property at axis
+    Reference< beans::XPropertySet > xProp( xDataSeries, uno::UNO_QUERY_THROW 
);
+
+    sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1;
+    sal_Int32 nOldAxisIndex = 
DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
+    rtl::Reference< Axis > xOldAxis = getAttachedAxis( xDataSeries );
+
+    if( nOldAxisIndex != nNewAxisIndex )
+    {
+        try
+        {
+            xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( 
nNewAxisIndex ) );
+            bChanged = true;
+        }
+        catch( const uno::Exception & )
+        {
+            DBG_UNHANDLED_EXCEPTION("chart2");
+        }
+    }
+
+    if( bChanged )
+    {
+        rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 1, 
bAttachToMainAxis, this );
+        if(!xAxis.is()) //create an axis if necessary
+            xAxis = AxisHelper::createAxis( 1, bAttachToMainAxis, this, 
xContext );
+        if( bAdaptAxes )
+        {
+            AxisHelper::makeAxisVisible( xAxis );
+            AxisHelper::hideAxisIfNoDataIsAttached( xOldAxis, this );
+        }
+    }
+
+    return bChanged;
+}
+
 } //  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 6eff3ba0a8b4..b43afae2aac5 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -506,49 +506,6 @@ bool DiagramHelper::isSeriesAttachedToMainAxis(
     return (nAxisIndex==0);
 }
 
-bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis
-                        , const uno::Reference< chart2::XDataSeries >& 
xDataSeries
-                        , const rtl::Reference< Diagram >& xDiagram
-                        , const uno::Reference< uno::XComponentContext > & 
xContext
-                        , bool bAdaptAxes )
-{
-    bool bChanged = false;
-
-    //set property at axis
-    Reference< beans::XPropertySet > xProp( xDataSeries, uno::UNO_QUERY_THROW 
);
-
-    sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1;
-    sal_Int32 nOldAxisIndex = 
DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
-    rtl::Reference< Axis > xOldAxis = xDiagram->getAttachedAxis( xDataSeries );
-
-    if( nOldAxisIndex != nNewAxisIndex )
-    {
-        try
-        {
-            xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( 
nNewAxisIndex ) );
-            bChanged = true;
-        }
-        catch( const uno::Exception & )
-        {
-            DBG_UNHANDLED_EXCEPTION("chart2");
-        }
-    }
-
-    if( bChanged && xDiagram.is() )
-    {
-        rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 1, 
bAttachToMainAxis, xDiagram );
-        if(!xAxis.is()) //create an axis if necessary
-            xAxis = AxisHelper::createAxis( 1, bAttachToMainAxis, xDiagram, 
xContext );
-        if( bAdaptAxes )
-        {
-            AxisHelper::makeAxisVisible( xAxis );
-            AxisHelper::hideAxisIfNoDataIsAttached( xOldAxis, xDiagram );
-        }
-    }
-
-    return bChanged;
-}
-
 static void lcl_generateAutomaticCategoriesFromChartType(
             Sequence< OUString >& rRet,
             const rtl::Reference< ChartType >& xChartType )

Reply via email to