chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx       |    6 --
 chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx        |    8 +--
 chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx |    4 -
 chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx |   12 
++---
 chart2/source/controller/dialogs/DialogModel.cxx                     |    4 -
 chart2/source/inc/Diagram.hxx                                        |    2 
 chart2/source/inc/DiagramHelper.hxx                                  |    4 -
 chart2/source/model/main/Diagram.cxx                                 |   22 
++++++++-
 chart2/source/model/template/ChartTypeTemplate.cxx                   |    4 -
 chart2/source/tools/DiagramHelper.cxx                                |   24 
----------
 10 files changed, 41 insertions(+), 49 deletions(-)

New commits:
commit 57914a4084da9107ec6815b1916a4be117c400bf
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Mar 15 16:27:11 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Mar 17 13:46:21 2023 +0000

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

diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx
index 925c85834fa0..65be4793f01c 100644
--- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx
@@ -157,8 +157,7 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL 
MinMaxLineWrapper::getPropert
 void SAL_CALL MinMaxLineWrapper::setPropertyValue( const OUString& 
rPropertyName, const uno::Any& rValue )
 {
     rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
-    const std::vector< rtl::Reference< ChartType > > & aTypes(
-            ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
+    const std::vector< rtl::Reference< ChartType > > & aTypes = 
xDiagram->getChartTypes();
     for( rtl::Reference< ChartType > const & xType : aTypes )
     {
         if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK 
)
@@ -189,8 +188,7 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyValue( 
const OUString& rProperty
     rtl::Reference< DataSeries > xPropSet;
 
     rtl::Reference< ::chart::Diagram > xDiagram( 
m_spChart2ModelContact->getDiagram() );
-    const std::vector< rtl::Reference< ChartType > > aTypes(
-            ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
+    const std::vector< rtl::Reference< ChartType > > aTypes = 
xDiagram->getChartTypes();
     for( rtl::Reference< ChartType > const & xType : aTypes )
     {
         if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK 
)
diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx
index febfa344870b..143d0123ee63 100644
--- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx
@@ -165,8 +165,8 @@ void SAL_CALL UpDownBarWrapper::setPropertyValue( const 
OUString& rPropertyName,
 {
     Reference< beans::XPropertySet > xPropSet;
 
-    const std::vector< rtl::Reference< ChartType > > aTypes(
-            ::chart::DiagramHelper::getChartTypesFromDiagram( 
m_spChart2ModelContact->getDiagram() ) );
+    const std::vector< rtl::Reference< ChartType > > aTypes =
+            m_spChart2ModelContact->getDiagram()->getChartTypes();
     for( rtl::Reference< ChartType > const & xType : aTypes )
     {
         if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK 
)
@@ -183,8 +183,8 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyValue( const 
OUString& rPropertyN
 
     Reference< beans::XPropertySet > xPropSet;
 
-    const std::vector< rtl::Reference< ChartType > > aTypes(
-            ::chart::DiagramHelper::getChartTypesFromDiagram( 
m_spChart2ModelContact->getDiagram() ) );
+    const std::vector< rtl::Reference< ChartType > > aTypes =
+            m_spChart2ModelContact->getDiagram()->getChartTypes();
     for( rtl::Reference<ChartType > const & xType : aTypes )
     {
         if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK 
)
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx 
b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx
index 7be1af161593..3c0cbb353192 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx
@@ -78,7 +78,7 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const 
Any& rOuterValue,
     if( m_nDimensionIndex!=1 )
         return;
 
-    const std::vector< rtl::Reference< ChartType > > aChartTypeList( 
DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
+    const std::vector< rtl::Reference< ChartType > > aChartTypeList( 
xDiagram->getChartTypes() );
     for( rtl::Reference< ChartType > const & chartType : aChartTypeList )
     {
         try
@@ -117,7 +117,7 @@ Any WrappedBarPositionProperty_Base::getPropertyValue( 
const Reference< beans::X
 
         if( m_nDimensionIndex==1 )
         {
-            std::vector< rtl::Reference< ChartType > > aChartTypeList( 
DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
+            std::vector< rtl::Reference< ChartType > > aChartTypeList = 
xDiagram->getChartTypes();
             for( std::size_t nN = 0; nN < aChartTypeList.size() && 
!bInnerValueDetected; nN++ )
             {
                 try
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx 
b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx
index 62242a9fb69b..89a4f6e3bc0a 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx
@@ -62,10 +62,12 @@ public:
 
     bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) 
const
     {
-        bool bHasDetectableInnerValue = false;
         rHasAmbiguousValue = false;
-        std::vector< rtl::Reference< ChartType > > aChartTypes(
-            ::chart::DiagramHelper::getChartTypesFromDiagram( 
m_spChart2ModelContact->getDiagram() ) );
+        rtl::Reference<Diagram> xDiagram = 
m_spChart2ModelContact->getDiagram();
+        if (!xDiagram)
+            return false;
+        bool bHasDetectableInnerValue = false;
+        std::vector< rtl::Reference< ChartType > > aChartTypes = 
xDiagram->getChartTypes();
         for( sal_Int32 nN = aChartTypes.size(); nN--; )
         {
             try
@@ -112,8 +114,8 @@ public:
         if( !(bHasAmbiguousValue || aNewValue != aOldValue) )
             return;
 
-        std::vector< rtl::Reference< ChartType > > aChartTypes(
-            ::chart::DiagramHelper::getChartTypesFromDiagram( 
m_spChart2ModelContact->getDiagram() ) );
+        std::vector< rtl::Reference< ChartType > > aChartTypes =
+            m_spChart2ModelContact->getDiagram()->getChartTypes();
         for( sal_Int32 nN = aChartTypes.size(); nN--; )
         {
             try
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx 
b/chart2/source/controller/dialogs/DialogModel.cxx
index 36015c560285..aa9663e7d0bc 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -245,8 +245,8 @@ rtl::Reference< ::chart::DataSeries > lcl_CreateNewSeries(
         std::size_t nGroupIndex=0;
         if( xChartType.is())
         {
-            std::vector< rtl::Reference< ::chart::ChartType > > aCTs(
-                ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ));
+            std::vector< rtl::Reference< ::chart::ChartType > > aCTs =
+                xDiagram->getChartTypes();
             for( ; nGroupIndex < aCTs.size(); ++nGroupIndex)
                 if( aCTs[nGroupIndex] == xChartType )
                     break;
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index 4c1d40df28bf..534403b6f70b 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -220,6 +220,8 @@ public:
             const rtl::Reference< DataSeries >& xGivenDataSeries,
             bool bForward );
 
+    std::vector< rtl::Reference< ChartType > > getChartTypes();
+
 private:
     // ____ XModifyListener ____
     virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/DiagramHelper.hxx 
b/chart2/source/inc/DiagramHelper.hxx
index 3e4a8ea30e12..908a6f808e62 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -215,10 +215,6 @@ public:
     static rtl::Reference< ChartType >
         getChartTypeByIndex( const rtl::Reference< ::chart::Diagram >& 
xDiagram, sal_Int32 nIndex );
 
-    static std::vector< rtl::Reference< ChartType > >
-        getChartTypesFromDiagram(
-            const rtl::Reference< ::chart::Diagram > & xDiagram );
-
     SAL_DLLPRIVATE static bool areChartTypesCompatible(
                 const rtl::Reference< ::chart::ChartType >& xFirstType,
                 const rtl::Reference< ::chart::ChartType >& xSecondType );
diff --git a/chart2/source/model/main/Diagram.cxx 
b/chart2/source/model/main/Diagram.cxx
index aced36a4a98d..6576141dbe65 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -828,8 +828,7 @@ bool Diagram::isSupportingFloorAndWall()
     //todo: allow this in future again, if fileversion is available for OLE 
objects (metastream)
     //thus the wrong bottom can be removed on import
 
-    const std::vector< rtl::Reference< ChartType > > aTypes(
-            ::chart::DiagramHelper::getChartTypesFromDiagram( this ) );
+    const std::vector< rtl::Reference< ChartType > > aTypes = getChartTypes();
     for( rtl::Reference< ChartType > const & xType : aTypes )
     {
         OUString sChartType = xType->getChartType();
@@ -1023,6 +1022,25 @@ bool Diagram::moveSeries( const rtl::Reference< 
DataSeries >& xGivenDataSeries,
     return bMoved;
 }
 
+std::vector< rtl::Reference< ChartType > > Diagram::getChartTypes()
+{
+    std::vector< rtl::Reference< ChartType > > aResult;
+    try
+    {
+        for( rtl::Reference< BaseCoordinateSystem > const & coords : 
getBaseCoordinateSystems() )
+        {
+            const std::vector< rtl::Reference< ChartType > > & aChartTypeSeq( 
coords->getChartTypes2());
+            aResult.insert( aResult.end(), aChartTypeSeq.begin(), 
aChartTypeSeq.end() );
+        }
+    }
+    catch( const uno::Exception & )
+    {
+        DBG_UNHANDLED_EXCEPTION("chart2");
+    }
+
+    return aResult;
+}
+
 
 } //  namespace chart
 
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx 
b/chart2/source/model/template/ChartTypeTemplate.cxx
index 1e49054f5b8b..17ae7dc215f9 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -224,7 +224,7 @@ void ChartTypeTemplate::changeDiagram( const 
rtl::Reference< Diagram >& xDiagram
 
         // remove charttype groups from all coordinate systems
         std::vector< rtl::Reference< ChartType > > aOldChartTypesSeq =
-            DiagramHelper::getChartTypesFromDiagram(xDiagram);
+            xDiagram->getChartTypes();
 
         for( rtl::Reference< BaseCoordinateSystem > const & coords : 
xDiagram->getBaseCoordinateSystems() )
         {
@@ -274,7 +274,7 @@ void ChartTypeTemplate::changeDiagramData(
         DiagramHelper::setCategoriesToDiagram( aData.Categories, xDiagram, 
true, supportsCategories() );
 
         std::vector< rtl::Reference< ChartType > > aChartTypes =
-            DiagramHelper::getChartTypesFromDiagram( xDiagram );
+            xDiagram->getChartTypes();
         sal_Int32 nMax = std::min( aChartTypes.size(), aData.Series.size());
         for( sal_Int32 i=0; i<nMax; ++i )
         {
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index cfbb0cc7d834..09f1872ddf5a 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -1092,30 +1092,6 @@ sal_Int32 DiagramHelper::getPercentNumberFormat( const 
Reference< util::XNumberF
     return nRet;
 }
 
-std::vector< rtl::Reference< ChartType > >
-    DiagramHelper::getChartTypesFromDiagram(
-        const rtl::Reference< Diagram > & xDiagram )
-{
-    if(!xDiagram)
-        return {};
-
-    std::vector< rtl::Reference< ChartType > > aResult;
-    try
-    {
-        for( rtl::Reference< BaseCoordinateSystem > const & coords : 
xDiagram->getBaseCoordinateSystems() )
-        {
-            const std::vector< rtl::Reference< ChartType > > & aChartTypeSeq( 
coords->getChartTypes2());
-            aResult.insert( aResult.end(), aChartTypeSeq.begin(), 
aChartTypeSeq.end() );
-        }
-    }
-    catch( const uno::Exception & )
-    {
-        DBG_UNHANDLED_EXCEPTION("chart2");
-    }
-
-    return aResult;
-}
-
 bool DiagramHelper::areChartTypesCompatible( const rtl::Reference< ChartType 
>& xFirstType,
                 const rtl::Reference< ChartType >& xSecondType )
 {

Reply via email to