chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx | 4 +- chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx | 6 +-- chart2/source/controller/sidebar/ChartSeriesPanel.cxx | 2 - chart2/source/inc/DataSeries.hxx | 4 ++ chart2/source/inc/DataSeriesHelper.hxx | 3 - chart2/source/inc/DiagramHelper.hxx | 3 - chart2/source/model/main/DataSeries.cxx | 14 +++++++ chart2/source/model/main/Diagram.cxx | 4 +- chart2/source/tools/AxisHelper.cxx | 4 +- chart2/source/tools/DataSeriesHelper.cxx | 19 ---------- chart2/source/tools/DiagramHelper.cxx | 9 ---- chart2/source/view/main/SeriesPlotterContainer.cxx | 2 - 12 files changed, 31 insertions(+), 43 deletions(-)
New commits: commit c804e7ffd6ba89426f6d80002aeeab7034c4030b Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Apr 11 18:53:53 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Sat Apr 12 13:15:13 2025 +0200 fold DataSeriesHelper functions into DataSeries This moves functions from ChartModelHelper to ChartModel where it better belongs. We can access the concrete classes now instead of accessing through UNO. Change-Id: I35ea769fdbd0af75ae791931505b61c73c4eeac6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184066 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 c102a706af08..2ba43e61c326 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -296,7 +296,7 @@ Any WrappedAttachedAxisProperty::getPropertyValue( const Reference< beans::XProp Any aRet; rtl::Reference< ::chart::DataSeries > xDataSeries( dynamic_cast<::chart::DataSeries*>(xInnerPropertySet.get()) ); - bool bAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); + bool bAttachedToMainAxis = xDataSeries->isAttachedToMainAxis(); if( bAttachedToMainAxis ) aRet <<= css::chart::ChartAxisAssign::PRIMARY_Y; else @@ -313,7 +313,7 @@ void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, cons throw lang::IllegalArgumentException(u"Property Axis requires value of type sal_Int32"_ustr, nullptr, 0 ); bool bNewAttachedToMainAxis = nChartAxisAssign == css::chart::ChartAxisAssign::PRIMARY_Y; - bool bOldAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); + bool bOldAttachedToMainAxis = xDataSeries->isAttachedToMainAxis(); if( bNewAttachedToMainAxis != bOldAttachedToMainAxis) { diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index be3d8ea00170..737b6793a30c 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -69,7 +69,7 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( { try { - m_bAttachToMainAxis = DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); + m_bAttachToMainAxis = xDataSeries->isAttachedToMainAxis(); rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xDataSeries ) ); @@ -88,7 +88,7 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( if( m_bSupportingOverlapAndGapWidthProperties ) { - sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + sal_Int32 nAxisIndex = xDataSeries->getAttachedAxisIndex(); uno::Sequence< sal_Int32 > aBarPositionSequence; if( xChartType.is() ) @@ -206,7 +206,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xDataSeries ) ); if( xChartType.is() ) { - sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + sal_Int32 nAxisIndex = xDataSeries->getAttachedAxisIndex(); uno::Sequence< sal_Int32 > aBarPositionSequence; if( xChartType->getPropertyValue( aPropName ) >>= aBarPositionSequence ) { diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx index 6801c452ec6b..18d7a16e24d6 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx @@ -206,7 +206,7 @@ bool isPrimaryAxis(const rtl::Reference<::chart::ChartModel>& if (!xSeries.is()) return true; - return DataSeriesHelper::getAttachedAxisIndex(xSeries) == 0; + return xSeries->getAttachedAxisIndex() == 0; } void setAttachedAxisType(const rtl::Reference<::chart::ChartModel>& diff --git a/chart2/source/inc/DataSeries.hxx b/chart2/source/inc/DataSeries.hxx index c20c2048975c..756c1949afc1 100644 --- a/chart2/source/inc/DataSeries.hxx +++ b/chart2/source/inc/DataSeries.hxx @@ -162,6 +162,10 @@ public: // property Color is DEFAULT bool hasPointOwnProperties( sal_Int32 nPointIndex ); + sal_Int32 getAttachedAxisIndex(); + + bool isAttachedToMainAxis() { return getAttachedAxisIndex() == 0; } + private: // late initialization to call after copy-constructing diff --git a/chart2/source/inc/DataSeriesHelper.hxx b/chart2/source/inc/DataSeriesHelper.hxx index 4078da33e1ae..facedfb8ce79 100644 --- a/chart2/source/inc/DataSeriesHelper.hxx +++ b/chart2/source/inc/DataSeriesHelper.hxx @@ -93,9 +93,6 @@ void setStackModeAtSeries( const rtl::Reference< ::chart::BaseCoordinateSystem > & xCorrespondingCoordinateSystem, StackMode eStackMode ); -sal_Int32 getAttachedAxisIndex( - const rtl::Reference< ::chart::DataSeries > & xSeries ); - /// @param nAxisIndex, if -1 it is determined by the given data series via getAttachedAxisIndex sal_Int32 getNumberFormatKeyFromAxis( const rtl::Reference< ::chart::DataSeries > & xSeries, diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index 5ba0438dc0a9..1a7585dce8bf 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -53,9 +53,6 @@ public: const rtl::Reference< ::chart::BaseCoordinateSystem > & xCorrespondingCoordinateSystem ); - static bool isSeriesAttachedToMainAxis( - const rtl::Reference< ::chart::DataSeries >& xDataSeries ); - static css::uno::Sequence< OUString > getExplicitSimpleCategories( ChartModel& rModel ); diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx index 2445a5e6e771..8758bbd76f63 100644 --- a/chart2/source/model/main/DataSeries.cxx +++ b/chart2/source/model/main/DataSeries.cxx @@ -752,6 +752,20 @@ bool DataSeries::hasPointOwnProperties( sal_Int32 nPointIndex ) return m_aAttributedDataPoints.find(nPointIndex) != m_aAttributedDataPoints.end(); } +sal_Int32 DataSeries::getAttachedAxisIndex() +{ + sal_Int32 nRet = 0; + try + { + getFastPropertyValue( ::chart::DataSeriesProperties::PROP_DATASERIES_ATTACHED_AXIS_INDEX ) >>= nRet; + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + return nRet; +} + } // namespace chart extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 4466b752e9b8..b8ce37d2579f 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -1423,7 +1423,7 @@ rtl::Reference< ChartType > Diagram::getChartTypeOfSeries( rtl::Reference< Axis > Diagram::getAttachedAxis( const rtl::Reference< DataSeries >& xSeries ) { - return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( xSeries ), this ); + return AxisHelper::getAxis( 1, !xSeries || xSeries->isAttachedToMainAxis(), this ); } bool Diagram::attachSeriesToAxis( bool bAttachToMainAxis @@ -1436,7 +1436,7 @@ bool Diagram::attachSeriesToAxis( bool bAttachToMainAxis //set property at axis sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1; - sal_Int32 nOldAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + sal_Int32 nOldAxisIndex = xDataSeries->getAttachedAxisIndex(); rtl::Reference< Axis > xOldAxis = getAttachedAxis( xDataSeries ); if( nOldAxisIndex != nNewAxisIndex ) diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 3ace41123085..17a845076fcb 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -241,7 +241,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( if( nDimensionIndex == 1 ) { //only take those series into account that are attached to this axis - sal_Int32 nAttachedAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + sal_Int32 nAttachedAxisIndex = xDataSeries->getAttachedAxisIndex(); if( nAttachedAxisIndex != nAxisIndex ) continue; } @@ -1081,7 +1081,7 @@ rtl::Reference< ChartType > AxisHelper::getFirstChartTypeWithSeriesAttachedToAxi std::vector< rtl::Reference< DataSeries > > aSeriesVector = xDiagram->getDataSeries(); for (auto const& series : aSeriesVector) { - sal_Int32 nCurrentIndex = DataSeriesHelper::getAttachedAxisIndex(series); + sal_Int32 nCurrentIndex = series->getAttachedAxisIndex(); if( nAttachedAxisIndex == nCurrentIndex ) { xChartType = xDiagram->getChartTypeOfSeries(series); diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index baba1a530294..0880d30914f9 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -308,23 +308,6 @@ void setStackModeAtSeries( } } -sal_Int32 getAttachedAxisIndex( const rtl::Reference< DataSeries > & xSeries ) -{ - sal_Int32 nRet = 0; - try - { - if( xSeries.is() ) - { - xSeries->getFastPropertyValue( PROP_DATASERIES_ATTACHED_AXIS_INDEX ) >>= nRet; - } - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } - return nRet; -} - sal_Int32 getNumberFormatKeyFromAxis( const rtl::Reference< DataSeries > & xSeries, const rtl::Reference< BaseCoordinateSystem > & xCorrespondingCoordinateSystem, @@ -333,7 +316,7 @@ sal_Int32 getNumberFormatKeyFromAxis( { sal_Int32 nResult = 0; if( nAxisIndex == -1 ) - nAxisIndex = getAttachedAxisIndex( xSeries ); + nAxisIndex = xSeries->getAttachedAxisIndex(); try { rtl::Reference< Axis > xAxisProp = diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 5593eb098b24..0efff69cbe6c 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -122,7 +122,7 @@ StackMode DiagramHelper::getStackModeFromChartType( { sal_Int32 nAxisIndex = 0; if( nSeriesCount ) - nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(aSeries[0]); + nAxisIndex = aSeries[0]->getAttachedAxisIndex(); rtl::Reference< Axis > xAxis = xCorrespondingCoordinateSystem->getAxisByDimension2( 1,nAxisIndex ); @@ -145,13 +145,6 @@ StackMode DiagramHelper::getStackModeFromChartType( return eStackMode; } -bool DiagramHelper::isSeriesAttachedToMainAxis( - const rtl::Reference< ::chart::DataSeries >& xDataSeries ) -{ - sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); - return (nAxisIndex==0); -} - static void lcl_generateAutomaticCategoriesFromChartType( Sequence< OUString >& rRet, const rtl::Reference< ChartType >& xChartType ) diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx b/chart2/source/view/main/SeriesPlotterContainer.cxx index 714ae7288feb..ec9e38b031d0 100644 --- a/chart2/source/view/main/SeriesPlotterContainer.cxx +++ b/chart2/source/view/main/SeriesPlotterContainer.cxx @@ -594,7 +594,7 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries(ChartModel& std::vector<rtl::Reference<DataSeries>> aSeriesVector = xDiagram->getDataSeries(); for (auto const& series : aSeriesVector) { - sal_Int32 nCurrentIndex = DataSeriesHelper::getAttachedAxisIndex(series); + sal_Int32 nCurrentIndex = series->getAttachedAxisIndex(); if (nAxisIndex == nCurrentIndex) { bSeriesAttachedToThisAxis = true;