chart2/inc/ChartView.hxx                                                 |    
3 
 chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx          |    
7 -
 chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx          |    
3 
 chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx |    
5 
 chart2/source/controller/dialogs/DataBrowserModel.cxx                    |    
3 
 chart2/source/controller/dialogs/DialogModel.cxx                         |    
2 
 chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx      |    
2 
 chart2/source/controller/main/ChartController_Properties.cxx             |    
4 
 chart2/source/controller/main/ChartController_Tools.cxx                  |    
2 
 chart2/source/inc/ChartType.hxx                                          |    
3 
 chart2/source/inc/DataSeries.hxx                                         |    
2 
 chart2/source/inc/DataSeriesHelper.hxx                                   |    
7 -
 chart2/source/model/main/DataSeries.cxx                                  |   
37 ++++++
 chart2/source/model/template/ChartType.cxx                               |   
23 +++
 chart2/source/tools/DataSeriesHelper.cxx                                 |   
60 ----------
 chart2/source/view/main/ChartView.cxx                                    |    
6 -
 16 files changed, 74 insertions(+), 95 deletions(-)

New commits:
commit 4e5ea3b1fd3b21ce6108aab58f9e054dc3442722
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Apr 12 08:57:11 2025 +0200
Commit:     Noel Grandin <noelgran...@gmail.com>
CommitDate: Sun Apr 13 14:20:31 2025 +0200

    fold DataSeriesHelper functions into DataSeries
    
    Where it better belongs, and where we can do a much better implementation.
    
    Change-Id: I370bd23ee0dfb1570d6376d21b8dac4c83591096
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184098
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx
index f30db7613d1a..95abb7d0fd9a 100644
--- a/chart2/inc/ChartView.hxx
+++ b/chart2/inc/ChartView.hxx
@@ -203,9 +203,6 @@ public:
             , const rtl::Reference< ::chart::BaseCoordinateSystem > & 
xCorrespondingCoordinateSystem
             , const rtl::Reference<::chart::ChartModel>& xChartDoc);
 
-    static sal_Int32 getExplicitNumberFormatKeyForDataLabel(
-            const css::uno::Reference< css::beans::XPropertySet >& 
xSeriesOrPointProp );
-
     static sal_Int32 getExplicitPercentageNumberFormatKeyForDataLabel(
             const css::uno::Reference< css::beans::XPropertySet >& 
xSeriesOrPointProp
             , const rtl::Reference< SvNumberFormatsSupplierObj >& 
xNumberFormatsSupplier );
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx 
b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
index 125d65cdc505..73b8780ca718 100644
--- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
@@ -147,13 +147,6 @@ sal_Int32 
Chart2ModelContact::getExplicitNumberFormatKeyForAxis(
               , m_xChartModel.get() );
 }
 
-sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForSeries(
-            const Reference< chart2::XDataSeries >& xSeries )
-{
-    return ChartView::getExplicitNumberFormatKeyForDataLabel(
-        uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ));
-}
-
 awt::Size Chart2ModelContact::GetPageSize() const
 {
     return m_xChartModel.get()->getPageSize();
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx 
b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
index 42750f102756..40ef39fd105f 100644
--- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
@@ -72,9 +72,6 @@ public:
     sal_Int32 getExplicitNumberFormatKeyForAxis(
             const rtl::Reference< ::chart::Axis >& xAxis );
 
-    static sal_Int32 getExplicitNumberFormatKeyForSeries(
-            const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
-
     /** Returns the size of the page in logic coordinates.  This value is used
         for setting an appropriate "ReferencePageSize" for FontHeights.
      */
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx 
b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx
index 1819bb2b2c91..bc1f5aed14f6 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx
@@ -20,6 +20,7 @@
 #include "WrappedNumberFormatProperty.hxx"
 #include "Chart2ModelContact.hxx"
 #include <Axis.hxx>
+#include <DataSeries.hxx>
 #include <com/sun/star/chart2/XDataSeries.hpp>
 #include <unonames.hxx>
 #include <utility>
@@ -64,8 +65,8 @@ Any WrappedNumberFormatProperty::getPropertyValue( const 
Reference< beans::XProp
     {
         sal_Int32 nKey = 0;
         Reference< chart2::XDataSeries > xSeries( xInnerPropertySet, 
uno::UNO_QUERY );
-        if( xSeries.is() )
-            nKey = Chart2ModelContact::getExplicitNumberFormatKeyForSeries( 
xSeries );
+        if( ::chart::DataSeries* pDataSeries = 
dynamic_cast<DataSeries*>(xSeries.get()) )
+            nKey = pDataSeries->getExplicitNumberFormatKeyForDataLabel();
         else
         {
             rtl::Reference< Axis > xAxis = 
dynamic_cast<Axis*>(xInnerPropertySet.get());
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx 
b/chart2/source/controller/dialogs/DataBrowserModel.cxx
index 39ec085f5fbd..e3c4d35a685e 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.cxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx
@@ -835,8 +835,7 @@ void DataBrowserModel::updateFromModel()
 
                         if( aRole == aRoleForDataLabelNumberFormat )
                         {
-                            nSequenceNumberFormatKey = 
ChartView::getExplicitNumberFormatKeyForDataLabel(
-                                xSeries);
+                            nSequenceNumberFormatKey = 
xSeries->getExplicitNumberFormatKeyForDataLabel();
                         }
                         else if( aRole == "values-x" )
                             nSequenceNumberFormatKey = nXAxisNumberFormat;
diff --git 
a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx 
b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
index ead6f3c3b715..b5688f9d40b5 100644
--- a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
+++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
@@ -110,7 +110,7 @@ AllDataLabelItemConverter::AllDataLabelItemConverter(
     {
         uno::Reference< uno::XComponentContext> xContext;//do not need Context 
for label properties
 
-        sal_Int32 
nNumberFormat=ChartView::getExplicitNumberFormatKeyForDataLabel( series );
+        sal_Int32 nNumberFormat = 
series->getExplicitNumberFormatKeyForDataLabel();
         sal_Int32 
nPercentNumberFormat=ChartView::getExplicitPercentageNumberFormatKeyForDataLabel(
                 series, xChartModel->getNumberFormatsSupplier());
 
diff --git a/chart2/source/controller/main/ChartController_Properties.cxx 
b/chart2/source/controller/main/ChartController_Properties.cxx
index 87f3d656d1fc..d1756ee9f6c9 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -175,7 +175,7 @@ wrapper::ItemConverter* createItemConverter(
 
                 bool bDataSeries = eObjectType == OBJECTTYPE_DATA_LABELS;
 
-                sal_Int32 nNumberFormat = 
ChartView::getExplicitNumberFormatKeyForDataLabel( xObjectProperties );
+                sal_Int32 nNumberFormat = 
xSeries->getExplicitNumberFormatKeyForDataLabel();
                 sal_Int32 nPercentNumberFormat = 
ChartView::getExplicitPercentageNumberFormatKeyForDataLabel(
                     xObjectProperties, 
xChartModel->getNumberFormatsSupplier());
 
@@ -228,7 +228,7 @@ wrapper::ItemConverter* createItemConverter(
                         }
                     }
                 }
-                sal_Int32 
nNumberFormat=ChartView::getExplicitNumberFormatKeyForDataLabel( 
xObjectProperties );
+                sal_Int32 
nNumberFormat=xSeries->getExplicitNumberFormatKeyForDataLabel();
                 sal_Int32 
nPercentNumberFormat=ChartView::getExplicitPercentageNumberFormatKeyForDataLabel(
                         xObjectProperties, 
xChartModel->getNumberFormatsSupplier());
 
diff --git a/chart2/source/inc/DataSeries.hxx b/chart2/source/inc/DataSeries.hxx
index 9387b723e263..10dfb0e45840 100644
--- a/chart2/source/inc/DataSeries.hxx
+++ b/chart2/source/inc/DataSeries.hxx
@@ -190,6 +190,8 @@ public:
 
     void deleteDataLabelsFromSeriesAndAllPoints();
 
+    sal_Int32 getExplicitNumberFormatKeyForDataLabel();
+
 private:
 
     // late initialization to call after copy-constructing
diff --git a/chart2/source/inc/DataSeriesHelper.hxx 
b/chart2/source/inc/DataSeriesHelper.hxx
index ae17d8ba5268..1bde79c29fdb 100644
--- a/chart2/source/inc/DataSeriesHelper.hxx
+++ b/chart2/source/inc/DataSeriesHelper.hxx
@@ -117,9 +117,6 @@ void insertDataLabelToPoint( const css::uno::Reference< 
css::beans::XPropertySet
 
 void deleteDataLabelsFromPoint( const css::uno::Reference< 
css::beans::XPropertySet >& xPointPropertySet );
 
-sal_Int32 getExplicitNumberFormatKeyForDataLabel(
-    const css::uno::Reference< css::beans::XPropertySet >& xPointPropertySet);
-
 } //  namespace chart::DataSeriesHelper
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/DataSeries.cxx 
b/chart2/source/model/main/DataSeries.cxx
index ea84e3202f0a..a9843f1d423d 100644
--- a/chart2/source/model/main/DataSeries.cxx
+++ b/chart2/source/model/main/DataSeries.cxx
@@ -1003,6 +1003,43 @@ void 
DataSeries::impl_insertOrDeleteDataLabelsToSeriesAndAllPoints( bool bInsert
     }
 }
 
+sal_Int32 DataSeries::getExplicitNumberFormatKeyForDataLabel()
+{
+    sal_Int32 nFormat = 0;
+    try
+    {
+        bool bLinkToSource = true;
+        getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkToSource;
+        getPropertyValue(CHART_UNONAME_NUMFMT) >>= nFormat;
+
+        if (bLinkToSource)
+        {
+            MutexGuard aGuard( m_aMutex );
+
+            if (!m_aDataSequences.empty())
+            {
+                Reference<chart2::data::XLabeledDataSequence> 
xLabeledSeq(m_aDataSequences[0]);
+                if( xLabeledSeq.is() )
+                {
+                    Reference< chart2::data::XDataSequence > xSeq( 
xLabeledSeq->getValues());
+                    if( xSeq.is() )
+                    {
+                        nFormat = xSeq->getNumberFormatKeyByIndex( -1 );
+                    }
+                }
+            }
+        }
+    }
+    catch (const beans::UnknownPropertyException&)
+    {
+    }
+
+    if (nFormat < 0)
+        nFormat = 0;
+    return nFormat;
+
+}
+
 }  // namespace chart
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/chart2/source/tools/DataSeriesHelper.cxx 
b/chart2/source/tools/DataSeriesHelper.cxx
index 6c52bd396242..d3343d8dbcf3 100644
--- a/chart2/source/tools/DataSeriesHelper.cxx
+++ b/chart2/source/tools/DataSeriesHelper.cxx
@@ -382,45 +382,6 @@ void deleteDataLabelsFromPoint( const Reference< 
beans::XPropertySet >& xPointPr
     }
 }
 
-sal_Int32 getExplicitNumberFormatKeyForDataLabel(
-    const uno::Reference<beans::XPropertySet>& xSeriesOrPointProp)
-{
-    rtl::Reference< ::chart::DataSeries > xDataSeries( 
dynamic_cast<DataSeries*>(xSeriesOrPointProp.get()) );
-    sal_Int32 nFormat = 0;
-    if (!xDataSeries.is())
-        return nFormat;
-    try
-    {
-
-        bool bLinkToSource = true;
-        xDataSeries->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= 
bLinkToSource;
-        xDataSeries->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nFormat;
-
-        if (bLinkToSource && xDataSeries->getDataSequences().getLength())
-        {
-            Reference<data::XLabeledDataSequence> xLabeledSeq(
-                xDataSeries->getDataSequences()[0]);
-            if( xLabeledSeq.is() )
-            {
-                Reference< data::XDataSequence > xSeq( 
xLabeledSeq->getValues());
-                if( xSeq.is() )
-                {
-                    nFormat = xSeq->getNumberFormatKeyByIndex( -1 );
-                }
-            }
-
-        }
-    }
-    catch (const beans::UnknownPropertyException&)
-    {
-    }
-
-    if (nFormat < 0)
-        nFormat = 0;
-    return nFormat;
-
-}
-
 } //  namespace chart
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index b82df788bcf6..ab00e03e5cce 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2116,12 +2116,6 @@ sal_Int32 ChartView::getExplicitNumberFormatKeyForAxis(
         true /*bSearchForParallelAxisIfNothingIsFound*/);
 }
 
-sal_Int32 ChartView::getExplicitNumberFormatKeyForDataLabel(
-    const uno::Reference<beans::XPropertySet>& xSeriesOrPointProp)
-{
-    return 
DataSeriesHelper::getExplicitNumberFormatKeyForDataLabel(xSeriesOrPointProp);
-}
-
 sal_Int32 ChartView::getExplicitPercentageNumberFormatKeyForDataLabel(
     const uno::Reference<beans::XPropertySet>& xSeriesOrPointProp,
     const rtl::Reference<SvNumberFormatsSupplierObj>& xNumberFormatsSupplier)
commit 84f7b8405236dabee247c59858e54a37fa0c67c3
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Apr 12 08:44:42 2025 +0200
Commit:     Noel Grandin <noelgran...@gmail.com>
CommitDate: Sun Apr 13 14:20:23 2025 +0200

    fold DataSeriesHelper functions into ChartType
    
    Where it better belongs, and where we can do a much better implementation.
    
    Change-Id: I00d77c28d3dc78c672e8a6756797a768a2eb0d02
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184097
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/chart2/source/controller/dialogs/DialogModel.cxx 
b/chart2/source/controller/dialogs/DialogModel.cxx
index 2a69b3d3ffe7..0eb6e395c894 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -586,7 +586,7 @@ void DialogModel::deleteSeries(
     m_aTimerTriggeredControllerLock.startTimer();
     ControllerLockGuardUNO aLockedControllers( m_xChartDocument );
 
-    DataSeriesHelper::deleteSeries( xSeries, xChartType );
+    xChartType->deleteSeries( xSeries );
 }
 
 uno::Reference< chart2::data::XLabeledDataSequence > 
DialogModel::getCategories() const
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx 
b/chart2/source/controller/main/ChartController_Tools.cxx
index b2d37e3a1024..13d3098a8533 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -114,7 +114,7 @@ bool lcl_deleteDataSeries(
             rtl::Reference< Diagram > xDiagram = 
xModel->getFirstChartDiagram();
             rtl::Reference< Axis > xAxis = xDiagram->getAttachedAxis( xSeries 
);
 
-            DataSeriesHelper::deleteSeries( xSeries, xChartType );
+            xChartType->deleteSeries( xSeries );
 
             AxisHelper::hideAxisIfNoDataIsAttached( xAxis, xDiagram );
 
diff --git a/chart2/source/inc/ChartType.hxx b/chart2/source/inc/ChartType.hxx
index 1c1bbc0bae0e..2dd05bb53ddc 100644
--- a/chart2/source/inc/ChartType.hxx
+++ b/chart2/source/inc/ChartType.hxx
@@ -115,6 +115,9 @@ public:
         createCoordinateSystem2( sal_Int32 DimensionCount );
 
     virtual void createCalculatedDataSeries();
+
+    void deleteSeries( const rtl::Reference< ::chart::DataSeries > & xSeries );
+
 protected:
 
     // ____ XModifyListener ____
diff --git a/chart2/source/inc/DataSeriesHelper.hxx 
b/chart2/source/inc/DataSeriesHelper.hxx
index e458f2652b0c..ae17d8ba5268 100644
--- a/chart2/source/inc/DataSeriesHelper.hxx
+++ b/chart2/source/inc/DataSeriesHelper.hxx
@@ -110,10 +110,6 @@ rtl::Reference< ::chart::ChartType >
         const rtl::Reference< ::chart::DataSeries > & xSeries,
         const rtl::Reference< ::chart::Diagram > & xDiagram );
 
-void deleteSeries(
-    const rtl::Reference< ::chart::DataSeries > & xSeries,
-    const rtl::Reference< ::chart::ChartType > & xChartType );
-
 sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nClippedIndex, 
const css::uno::Reference<
         css::chart2::data::XDataSequence >& xDataSequence, bool bTranslate );
 
diff --git a/chart2/source/model/template/ChartType.cxx 
b/chart2/source/model/template/ChartType.cxx
index e2bf5e97e61b..6487e4213644 100644
--- a/chart2/source/model/template/ChartType.cxx
+++ b/chart2/source/model/template/ChartType.cxx
@@ -322,6 +322,29 @@ using impl::ChartType_Base;
 IMPLEMENT_FORWARD_XINTERFACE2( ChartType, ChartType_Base, 
::property::OPropertySet )
 IMPLEMENT_FORWARD_XTYPEPROVIDER2( ChartType, ChartType_Base, 
::property::OPropertySet )
 
+void ChartType::deleteSeries( const rtl::Reference< ::chart::DataSeries > & 
xSeries )
+{
+    try
+    {
+        SolarMutexGuard g;
+
+        auto it = std::find( m_aDataSeries.begin(), m_aDataSeries.end(), 
xSeries );
+        if( it == m_aDataSeries.end())
+            return;
+
+        ModifyListenerHelper::removeListener( *it, m_xModifyEventForwarder );
+        fireModifyEvent();
+
+        createCalculatedDataSeries();
+    }
+    catch( const uno::Exception & )
+    {
+        DBG_UNHANDLED_EXCEPTION("chart2");
+    }
+}
+
+
+
 } //  namespace chart
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/tools/DataSeriesHelper.cxx 
b/chart2/source/tools/DataSeriesHelper.cxx
index a7096df64699..6c52bd396242 100644
--- a/chart2/source/tools/DataSeriesHelper.cxx
+++ b/chart2/source/tools/DataSeriesHelper.cxx
@@ -307,27 +307,6 @@ rtl::Reference< ::chart::ChartType > getChartTypeOfSeries(
     return xResult;
 }
 
-void deleteSeries(
-    const rtl::Reference< ::chart::DataSeries > & xSeries,
-    const rtl::Reference< ::chart::ChartType > & xChartType )
-{
-    try
-    {
-        std::vector< rtl::Reference< DataSeries > > aSeries = 
xChartType->getDataSeries2();
-        auto aIt = std::find( aSeries.begin(), aSeries.end(), xSeries );
-        if( aIt != aSeries.end())
-        {
-            aSeries.erase( aIt );
-            xChartType->setDataSeries( aSeries );
-        }
-    }
-    catch( const uno::Exception & )
-    {
-        DBG_UNHANDLED_EXCEPTION("chart2");
-    }
-}
-
-
 sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nIndex, const 
Reference< chart2::data::XDataSequence >& xDataSequence, bool bTranslate )
 {
     if( !bTranslate )

Reply via email to