chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx | 30 - chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx | 30 - chart2/source/controller/main/ChartController_Insert.cxx | 6 chart2/source/controller/main/ChartController_Tools.cxx | 4 chart2/source/controller/main/ChartController_Window.cxx | 6 chart2/source/controller/main/ObjectHierarchy.cxx | 2 chart2/source/controller/sidebar/ChartSeriesPanel.cxx | 6 chart2/source/inc/DataSeries.hxx | 20 + chart2/source/inc/DataSeriesHelper.hxx | 21 - chart2/source/model/main/DataSeries.cxx | 189 +++++++++ chart2/source/model/main/Diagram.cxx | 4 chart2/source/model/template/AreaChartTypeTemplate.cxx | 2 chart2/source/model/template/BarChartTypeTemplate.cxx | 4 chart2/source/model/template/BubbleChartTypeTemplate.cxx | 2 chart2/source/model/template/ColumnLineChartTypeTemplate.cxx | 2 chart2/source/model/template/HistogramChartTypeTemplate.cxx | 4 chart2/source/model/template/PieChartTypeTemplate.cxx | 2 chart2/source/model/template/ScatterChartTypeTemplate.cxx | 2 chart2/source/model/template/StockChartTypeTemplate.cxx | 2 chart2/source/tools/DataSeriesHelper.cxx | 199 ---------- chart2/source/tools/ThreeDHelper.cxx | 20 - 21 files changed, 273 insertions(+), 284 deletions(-)
New commits: commit 7bb586c436e1b6c12937741a0e170587989ee020 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Apr 11 19:43:47 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Sat Apr 12 19:48:37 2025 +0200 fold DataSeriesHelper functions into DataSeries Where it better belongs, and where we can do a much better implementation. Change-Id: I81aa687f28816aabed58a3fd26d22a8340c8bfc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184070 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 94c4ba6129b2..22da867ff371 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -368,7 +368,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() if( xSeries.is() ) { // add labels - DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); + xSeries->insertDataLabelsToSeriesAndAllPoints(); OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) + "=" ); OUString aObjectCID = ObjectIdentifier::createClassifiedIdentifierForParticles( @@ -755,7 +755,7 @@ void ChartController::executeDispatch_InsertDataLabels() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_DATALABELS )), m_xUndoManager ); - DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); + xSeries->insertDataLabelsToSeriesAndAllPoints(); aUndoGuard.commit(); } } @@ -778,7 +778,7 @@ void ChartController::executeDispatch_DeleteDataLabels() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_DATALABELS )), m_xUndoManager ); - DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries ); + xSeries->deleteDataLabelsFromSeriesAndAllPoints(); aUndoGuard.commit(); } } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 92e2983409ea..cd57689af263 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -989,14 +989,14 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) rtl::Reference< RegressionCurveModel > xMeanValue = RegressionCurveHelper::getMeanValueLine( xSeries ); bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries ); bool bHasXErrorBars = StatisticsHelper::hasErrorBars( xSeries, false ); - bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xSeries ); - bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xSeries ); + bool bHasDataLabelsAtSeries = xSeries->hasDataLabelsAtSeries(); + bool bHasDataLabelsAtPoints = xSeries->hasDataLabelsAtPoints(); bool bHasDataLabelAtPoint = false; sal_Int32 nPointIndex = -1; if( bIsPoint ) { nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); - bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xSeries, nPointIndex ); + bHasDataLabelAtPoint = xSeries->hasDataLabelAtPoint( nPointIndex ); } bool bSelectedPointIsFormatted = false; bool bHasFormattedDataPointsOtherThanSelected = false; diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index 7b1674acc673..fc49f718b38b 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -344,7 +344,7 @@ void ObjectHierarchy::createDataSeriesTree( rtl::Reference< DataSeries > const & xSeries = aSeriesSeq[nSeriesIdx]; // data labels - if( DataSeriesHelper::hasDataLabelsAtSeries( xSeries ) ) + if( xSeries->hasDataLabelsAtSeries() ) { OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) + "=" ); aSeriesSubContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle, aChildParticle ) ); diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx index 18d7a16e24d6..8795e691fbd7 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx @@ -52,7 +52,7 @@ bool isDataLabelVisible(const rtl::Reference<::chart::ChartModel>& xModel, std:: if (!xSeries.is()) return false; - return DataSeriesHelper::hasDataLabelsAtSeries(xSeries); + return xSeries->hasDataLabelsAtSeries(); } void setDataLabelVisible(const rtl::Reference<::chart::ChartModel>& xModel, std::u16string_view rCID, bool bVisible) @@ -64,9 +64,9 @@ void setDataLabelVisible(const rtl::Reference<::chart::ChartModel>& xModel, std: return; if (bVisible) - DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints(xSeries); + xSeries->insertDataLabelsToSeriesAndAllPoints(); else - DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints(xSeries); + xSeries->deleteDataLabelsFromSeriesAndAllPoints(); } struct LabelPlacementMap diff --git a/chart2/source/inc/DataSeries.hxx b/chart2/source/inc/DataSeries.hxx index 1715b7376a49..9387b723e263 100644 --- a/chart2/source/inc/DataSeries.hxx +++ b/chart2/source/inc/DataSeries.hxx @@ -180,6 +180,16 @@ public: const OUString& rPropertyName, const css::uno::Any& rPropertyValue ); + bool hasDataLabelsAtSeries(); + + bool hasDataLabelsAtPoints(); + + bool hasDataLabelAtPoint( sal_Int32 nPointIndex ); + + void insertDataLabelsToSeriesAndAllPoints(); + + void deleteDataLabelsFromSeriesAndAllPoints(); + private: // late initialization to call after copy-constructing @@ -199,6 +209,8 @@ private: void fireModifyEvent(); + void impl_insertOrDeleteDataLabelsToSeriesAndAllPoints( bool bInsert ); + tDataSequenceContainer m_aDataSequences; typedef std::map< sal_Int32, diff --git a/chart2/source/inc/DataSeriesHelper.hxx b/chart2/source/inc/DataSeriesHelper.hxx index 48198dc1db37..e458f2652b0c 100644 --- a/chart2/source/inc/DataSeriesHelper.hxx +++ b/chart2/source/inc/DataSeriesHelper.hxx @@ -117,18 +117,8 @@ void deleteSeries( sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nClippedIndex, const css::uno::Reference< css::chart2::data::XDataSequence >& xDataSequence, bool bTranslate ); -bool hasDataLabelsAtSeries( const rtl::Reference< ::chart::DataSeries >& xSeries ); - -bool hasDataLabelsAtPoints( const rtl::Reference< ::chart::DataSeries >& xSeries ); - -bool hasDataLabelAtPoint( const rtl::Reference< ::chart::DataSeries >& xSeries, sal_Int32 nPointIndex ); - -void insertDataLabelsToSeriesAndAllPoints( const rtl::Reference< ::chart::DataSeries >& xSeries ); - void insertDataLabelToPoint( const css::uno::Reference< css::beans::XPropertySet >& xPointPropertySet ); -void deleteDataLabelsFromSeriesAndAllPoints( const rtl::Reference< ::chart::DataSeries >& xSeries ); - void deleteDataLabelsFromPoint( const css::uno::Reference< css::beans::XPropertySet >& xPointPropertySet ); sal_Int32 getExplicitNumberFormatKeyForDataLabel( diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx index 081eb2b7227b..ea84e3202f0a 100644 --- a/chart2/source/model/main/DataSeries.cxx +++ b/chart2/source/model/main/DataSeries.cxx @@ -27,6 +27,8 @@ #include <CloneHelper.hxx> #include <RegressionCurveModel.hxx> #include <ModifyListenerHelper.hxx> +#include <unonames.hxx> +#include <com/sun/star/chart2/DataPointLabel.hpp> #include <com/sun/star/chart2/Symbol.hpp> #include <com/sun/star/chart2/data/XTextualDataSequence.hpp> #include <com/sun/star/container/NoSuchElementException.hpp> @@ -863,6 +865,144 @@ bool DataSeries::hasAttributedDataPointDifferentValue( return false; } +bool DataSeries::hasDataLabelsAtSeries() +{ + bool bRet = false; + try + { + chart2::DataPointLabel aLabel; + if( getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) + bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName + || aLabel.ShowSeriesName; + } + catch(const uno::Exception &) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); + } + return bRet; +} + +bool DataSeries::hasDataLabelsAtPoints() +{ + bool bRet = false; + try + { + std::vector<sal_Int32> aAttributedDataPointIndexList; + { + MutexGuard aGuard( m_aMutex ); + aAttributedDataPointIndexList.reserve(m_aAttributedDataPoints.size()); + for (const auto & rPair : m_aAttributedDataPoints) + aAttributedDataPointIndexList.push_back(rPair.first); + } + for(sal_Int32 nIdx : aAttributedDataPointIndexList) + { + Reference< beans::XPropertySet > xPointProp( getDataPointByIndex(nIdx) ); + if( xPointProp.is() ) + { + chart2::DataPointLabel aLabel; + if( xPointProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) + bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent + || aLabel.ShowCategoryName || aLabel.ShowCustomLabel + || aLabel.ShowSeriesName; + if( bRet ) + break; + } + } + } + catch(const uno::Exception &) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); + } + return bRet; +} + +bool DataSeries::hasDataLabelAtPoint( sal_Int32 nPointIndex ) +{ + bool bRet = false; + try + { + Reference< beans::XPropertySet > xProp; + bool bFound = false; + { + MutexGuard aGuard( m_aMutex ); + bFound = m_aAttributedDataPoints.find(nPointIndex) != m_aAttributedDataPoints.end(); + } + if (bFound) + xProp = getDataPointByIndex(nPointIndex); + else + xProp = this; + if( xProp.is() ) + { + chart2::DataPointLabel aLabel; + if( xProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) + bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent + || aLabel.ShowCategoryName || aLabel.ShowCustomLabel + || aLabel.ShowSeriesName; + } + } + catch(const uno::Exception &) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); + } + return bRet; +} + +void DataSeries::insertDataLabelsToSeriesAndAllPoints() +{ + impl_insertOrDeleteDataLabelsToSeriesAndAllPoints( true /*bInsert*/ ); +} + +void DataSeries::deleteDataLabelsFromSeriesAndAllPoints() +{ + impl_insertOrDeleteDataLabelsToSeriesAndAllPoints( false /*bInsert*/ ); +} + +void DataSeries::impl_insertOrDeleteDataLabelsToSeriesAndAllPoints( bool bInsert ) +{ + try + { + chart2::DataPointLabel aLabelAtSeries; + getPropertyValue(CHART_UNONAME_LABEL) >>= aLabelAtSeries; + aLabelAtSeries.ShowNumber = bInsert; + if( !bInsert ) + { + aLabelAtSeries.ShowNumberInPercent = false; + aLabelAtSeries.ShowCategoryName = false; + } + setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabelAtSeries)); + std::vector<sal_Int32> aAttributedDataPointIndexList; + { + MutexGuard aGuard( m_aMutex ); + aAttributedDataPointIndexList.reserve(m_aAttributedDataPoints.size()); + for (const auto & rPair : m_aAttributedDataPoints) + aAttributedDataPointIndexList.push_back(rPair.first); + } + for(sal_Int32 nIdx : aAttributedDataPointIndexList) + { + Reference< beans::XPropertySet > xPointProp( getDataPointByIndex(nIdx) ); + if( xPointProp.is() ) + { + chart2::DataPointLabel aLabel; + xPointProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel; + aLabel.ShowNumber = bInsert; + if( !bInsert ) + { + aLabel.ShowNumberInPercent = false; + aLabel.ShowCategoryName = false; + aLabel.ShowCustomLabel = false; + aLabel.ShowSeriesName = false; + } + xPointProp->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel)); + xPointProp->setPropertyValue(CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any()); + } + } + } + catch(const uno::Exception &) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); + } +} + } // 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 0d87b5912478..a7096df64699 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -110,52 +110,6 @@ void lcl_getCooSysAndChartTypeOfSeries( } } -void lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( const rtl::Reference< ::chart::DataSeries >& xSeries, bool bInsert ) -{ - try - { - if( xSeries.is() ) - { - DataPointLabel aLabelAtSeries; - xSeries->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabelAtSeries; - aLabelAtSeries.ShowNumber = bInsert; - if( !bInsert ) - { - aLabelAtSeries.ShowNumberInPercent = false; - aLabelAtSeries.ShowCategoryName = false; - } - xSeries->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabelAtSeries)); - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - // "AttributedDataPoints" - if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList ) - { - for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) - { - Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]) ); - if( xPointProp.is() ) - { - DataPointLabel aLabel; - xPointProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel; - aLabel.ShowNumber = bInsert; - if( !bInsert ) - { - aLabel.ShowNumberInPercent = false; - aLabel.ShowCategoryName = false; - aLabel.ShowCustomLabel = false; - aLabel.ShowSeriesName = false; - } - xPointProp->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel)); - xPointProp->setPropertyValue(CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any()); - } - } - } - } - } - catch(const uno::Exception &) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } -} } // anonymous namespace @@ -408,106 +362,6 @@ sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nIndex, const Refere return nIndex; } -bool hasDataLabelsAtSeries( const rtl::Reference< DataSeries >& xSeries ) -{ - bool bRet = false; - try - { - if( xSeries.is() ) - { - DataPointLabel aLabel; - if( xSeries->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) - bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName - || aLabel.ShowSeriesName; - } - } - catch(const uno::Exception &) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } - return bRet; -} - -bool hasDataLabelsAtPoints( const rtl::Reference< DataSeries >& xSeries ) -{ - bool bRet = false; - try - { - if( xSeries.is() ) - { - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - // "AttributedDataPoints" - if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList ) - { - for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) - { - Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]) ); - if( xPointProp.is() ) - { - DataPointLabel aLabel; - if( xPointProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) - bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent - || aLabel.ShowCategoryName || aLabel.ShowCustomLabel - || aLabel.ShowSeriesName; - if( bRet ) - break; - } - } - } - } - } - catch(const uno::Exception &) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } - return bRet; -} - -bool hasDataLabelAtPoint( const rtl::Reference< DataSeries >& xSeries, sal_Int32 nPointIndex ) -{ - bool bRet = false; - try - { - Reference< beans::XPropertySet > xProp; - if( xSeries.is() ) - { - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - // "AttributedDataPoints" - if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList ) - { - auto aIt = std::find( aAttributedDataPointIndexList.begin(), aAttributedDataPointIndexList.end(), nPointIndex ); - if (aIt != aAttributedDataPointIndexList.end()) - xProp = xSeries->getDataPointByIndex(nPointIndex); - else - xProp = xSeries; - } - if( xProp.is() ) - { - DataPointLabel aLabel; - if( xProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) - bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent - || aLabel.ShowCategoryName || aLabel.ShowCustomLabel - || aLabel.ShowSeriesName; - } - } - } - catch(const uno::Exception &) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } - return bRet; -} - -void insertDataLabelsToSeriesAndAllPoints( const rtl::Reference< DataSeries >& xSeries ) -{ - lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( xSeries, true /*bInsert*/ ); -} - -void deleteDataLabelsFromSeriesAndAllPoints( const rtl::Reference< DataSeries >& xSeries ) -{ - lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( xSeries, false /*bInsert*/ ); -} - void insertDataLabelToPoint( const Reference< beans::XPropertySet >& xPointProp ) { try commit 1aa34c45b6622942983c872d9d307d5768b68246 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Apr 11 19:24:54 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Sat Apr 12 19:48:26 2025 +0200 fold DataSeriesHelper functions into DataSeries Where it better belongs, and where we can do a much better implementation. Change-Id: Iec0c932b40512819bd6cc10afa3e2da93fa1e1b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184069 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index 1337ee3337e5..a078fe9fc1fe 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -134,9 +134,9 @@ bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSe { rtl::Reference< DataSeries > xSeries( dynamic_cast<DataSeries*>(xPropertySet.get()) ); if( aValue != aOldValue || - ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) ) + xSeries->hasAttributedDataPointDifferentValue( aPropertyName, aOldValue ) ) { - ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aValue ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( aPropertyName, aValue ); bChanged = true; } } @@ -182,9 +182,9 @@ bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxIte { rtl::Reference< DataSeries > xSeries( dynamic_cast<DataSeries*>(xPropertySet.get()) ); if( aNewValue != aOldValue || - ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) ) + xSeries->hasAttributedDataPointDifferentValue( aPropertyName, aOldValue ) ) { - ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aNewValue ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( aPropertyName, aNewValue ); bChanged = true; } } @@ -343,10 +343,10 @@ bool DataPointItemConverter::ApplySpecialItem( { rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if( bOldValue != bool(rValue) || - DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, CHART_UNONAME_LABEL , aOldValue ) ) + xSeries->hasAttributedDataPointDifferentValue( CHART_UNONAME_LABEL , aOldValue ) ) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_LABEL , uno::Any( aLabel ) ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any() ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( CHART_UNONAME_LABEL , uno::Any( aLabel ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any() ); bChanged = true; } } @@ -384,9 +384,9 @@ bool DataPointItemConverter::ApplySpecialItem( { rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if( aOldValue != aNewValue || - DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, u"LabelSeparator"_ustr , uno::Any( aOldValue ) ) ) + xSeries->hasAttributedDataPointDifferentValue( u"LabelSeparator"_ustr , uno::Any( aOldValue ) ) ) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"LabelSeparator"_ustr , uno::Any( aNewValue ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"LabelSeparator"_ustr , uno::Any( aNewValue ) ); bChanged = true; } } @@ -415,9 +415,9 @@ bool DataPointItemConverter::ApplySpecialItem( { rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if( bOld!=bNew || - DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, u"TextWordWrap"_ustr, uno::Any( bOld ) ) ) + xSeries->hasAttributedDataPointDifferentValue( u"TextWordWrap"_ustr, uno::Any( bOld ) ) ) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"TextWordWrap"_ustr, uno::Any( bNew ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"TextWordWrap"_ustr, uno::Any( bNew ) ); bChanged = true; } } @@ -447,9 +447,9 @@ bool DataPointItemConverter::ApplySpecialItem( { rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if( nOld!=nNew || - DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, u"LabelPlacement"_ustr , uno::Any( nOld ) ) ) + xSeries->hasAttributedDataPointDifferentValue( u"LabelPlacement"_ustr , uno::Any( nOld ) ) ) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"LabelPlacement"_ustr , uno::Any( nNew ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"LabelPlacement"_ustr , uno::Any( nNew ) ); bChanged = true; } } @@ -637,8 +637,8 @@ void DataPointItemConverter::FillSpecialItem( if( m_bOverwriteLabelsForAttributedDataPointsAlso ) { - if( DataSeriesHelper::hasAttributedDataPointDifferentValue( - dynamic_cast<DataSeries*>(GetPropertySet().get()), CHART_UNONAME_LABEL , uno::Any(aLabel) ) ) + if( dynamic_cast<DataSeries*>(GetPropertySet().get())->hasAttributedDataPointDifferentValue( + CHART_UNONAME_LABEL , uno::Any(aLabel) ) ) { rOutItemSet.InvalidateItem(nWhichId); } diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx index 182e50050f6f..9597caab2f68 100644 --- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx @@ -128,9 +128,9 @@ bool numberFormatFromItemToPropertySet( { rtl::Reference<DataSeries> xSeries( dynamic_cast<DataSeries*>(xPropertySet.get()) ); if (aValue != aOldValue || - ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, aPropertyName, aOldValue)) + xSeries->hasAttributedDataPointDifferentValue(aPropertyName, aOldValue)) { - ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, aPropertyName, aValue); + xSeries->setPropertyAlsoToAllAttributedDataPoints(aPropertyName, aValue); bChanged = true; } } @@ -178,9 +178,9 @@ bool useSourceFormatFromItemToPropertySet( { rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(xPropertySet.get())); if (aNewValue != aOldValue || - ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, aPropertyName, aOldValue)) + xSeries->hasAttributedDataPointDifferentValue(aPropertyName, aOldValue)) { - ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, aPropertyName, aNewValue); + xSeries->setPropertyAlsoToAllAttributedDataPoints(aPropertyName, aNewValue); bChanged = true; } } @@ -290,10 +290,10 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte { rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if (bOldValue != bool(rValue) || - DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, CHART_UNONAME_LABEL, aOldValue)) + xSeries->hasAttributedDataPointDifferentValue(CHART_UNONAME_LABEL, aOldValue)) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, CHART_UNONAME_LABEL, uno::Any(aLabel)); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any()); + xSeries->setPropertyAlsoToAllAttributedDataPoints(CHART_UNONAME_LABEL, uno::Any(aLabel)); + xSeries->setPropertyAlsoToAllAttributedDataPoints(CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any()); bChanged = true; } } @@ -328,9 +328,9 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte { rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if (aOldValue != aNewValue || - DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, u"LabelSeparator"_ustr, uno::Any(aOldValue))) + xSeries->hasAttributedDataPointDifferentValue(u"LabelSeparator"_ustr, uno::Any(aOldValue))) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, u"LabelSeparator"_ustr, uno::Any(aNewValue)); + xSeries->setPropertyAlsoToAllAttributedDataPoints(u"LabelSeparator"_ustr, uno::Any(aNewValue)); bChanged = true; } } @@ -358,9 +358,9 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte { rtl::Reference< DataSeries > xSeries( dynamic_cast<DataSeries*>(GetPropertySet().get()) ); if( bOld!=bNew || - DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, u"TextWordWrap"_ustr, uno::Any( bOld ) ) ) + xSeries->hasAttributedDataPointDifferentValue( u"TextWordWrap"_ustr, uno::Any( bOld ) ) ) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"TextWordWrap"_ustr, uno::Any( bNew ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"TextWordWrap"_ustr, uno::Any( bNew ) ); bChanged = true; } } @@ -388,9 +388,9 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte { rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if (nOld != nNew || - DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, u"LabelPlacement"_ustr, uno::Any(nOld))) + xSeries->hasAttributedDataPointDifferentValue(u"LabelPlacement"_ustr, uno::Any(nOld))) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, u"LabelPlacement"_ustr, uno::Any(nNew)); + xSeries->setPropertyAlsoToAllAttributedDataPoints(u"LabelPlacement"_ustr, uno::Any(nNew)); bChanged = true; } } @@ -552,8 +552,8 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r if (mbDataSeries) { - if (DataSeriesHelper::hasAttributedDataPointDifferentValue( - dynamic_cast<DataSeries*>(GetPropertySet().get()), CHART_UNONAME_LABEL, uno::Any(aLabel))) + if (dynamic_cast<DataSeries*>(GetPropertySet().get())->hasAttributedDataPointDifferentValue( + CHART_UNONAME_LABEL, uno::Any(aLabel))) { rOutItemSet.InvalidateItem(nWhichId); } diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 7f42ec25f959..b2d37e3a1024 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -779,8 +779,8 @@ bool ChartController::executeDispatch_Delete() if( aObjectType == OBJECTTYPE_DATA_LABELS ) { rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( aCID, getChartModel() ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_LABEL, uno::Any(aLabel) ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any() ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( CHART_UNONAME_LABEL, uno::Any(aLabel) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any() ); } else { diff --git a/chart2/source/inc/DataSeries.hxx b/chart2/source/inc/DataSeries.hxx index 2327bf671753..1715b7376a49 100644 --- a/chart2/source/inc/DataSeries.hxx +++ b/chart2/source/inc/DataSeries.hxx @@ -172,6 +172,14 @@ public: void makeLinesThickOrThin( bool bThick ); + bool hasAttributedDataPointDifferentValue( + const OUString& rPropertyName, + const css::uno::Any& rPropertyValue ); + + void setPropertyAlsoToAllAttributedDataPoints( + const OUString& rPropertyName, + const css::uno::Any& rPropertyValue ); + private: // late initialization to call after copy-constructing diff --git a/chart2/source/inc/DataSeriesHelper.hxx b/chart2/source/inc/DataSeriesHelper.hxx index 9bc91b49f645..48198dc1db37 100644 --- a/chart2/source/inc/DataSeriesHelper.hxx +++ b/chart2/source/inc/DataSeriesHelper.hxx @@ -114,17 +114,6 @@ void deleteSeries( const rtl::Reference< ::chart::DataSeries > & xSeries, const rtl::Reference< ::chart::ChartType > & xChartType ); -void setPropertyAlsoToAllAttributedDataPoints( - const rtl::Reference< ::chart::DataSeries >& xSeries, - const OUString& rPropertyName, - const css::uno::Any& rPropertyValue ); - - -bool hasAttributedDataPointDifferentValue( - const rtl::Reference< ::chart::DataSeries >& xSeries, - const OUString& rPropertyName, - const css::uno::Any& rPropertyValue ); - sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nClippedIndex, const css::uno::Reference< css::chart2::data::XDataSequence >& xDataSequence, bool bTranslate ); diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx index 83e3e2e9a273..081eb2b7227b 100644 --- a/chart2/source/model/main/DataSeries.cxx +++ b/chart2/source/model/main/DataSeries.cxx @@ -813,6 +813,55 @@ void DataSeries::makeLinesThickOrThin( bool bThick ) } } +void DataSeries::setPropertyAlsoToAllAttributedDataPoints( const OUString& rPropertyName, const uno::Any& rPropertyValue ) +{ + setPropertyValue( rPropertyName, rPropertyValue ); + + std::vector<sal_Int32> aAttributedDataPointIndexList; + { + MutexGuard aGuard( m_aMutex ); + aAttributedDataPointIndexList.reserve(m_aAttributedDataPoints.size()); + for (const auto & rPair : m_aAttributedDataPoints) + aAttributedDataPointIndexList.push_back(rPair.first); + } + + for(sal_Int32 nIdx : aAttributedDataPointIndexList) + { + Reference< beans::XPropertySet > xPointProp( getDataPointByIndex(nIdx) ); + if(!xPointProp.is()) + continue; + xPointProp->setPropertyValue( rPropertyName, rPropertyValue ); + if( rPropertyName == "LabelPlacement" ) + { + xPointProp->setPropertyValue(u"CustomLabelPosition"_ustr, uno::Any()); + xPointProp->setPropertyValue(u"CustomLabelSize"_ustr, uno::Any()); + } + } +} + +bool DataSeries::hasAttributedDataPointDifferentValue( + const OUString& rPropertyName, const uno::Any& rPropertyValue ) +{ + std::vector<sal_Int32> aAttributedDataPointIndexList; + { + MutexGuard aGuard( m_aMutex ); + aAttributedDataPointIndexList.reserve(m_aAttributedDataPoints.size()); + for (const auto & rPair : m_aAttributedDataPoints) + aAttributedDataPointIndexList.push_back(rPair.first); + } + + for(sal_Int32 nIdx : aAttributedDataPointIndexList) + { + Reference< beans::XPropertySet > xPointProp( getDataPointByIndex(nIdx) ); + if(!xPointProp.is()) + continue; + uno::Any aPointValue( xPointProp->getPropertyValue( rPropertyName ) ); + if( rPropertyValue != aPointValue ) + return true; + } + + return false; +} } // namespace chart diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index b8ce37d2579f..14055929f786 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -906,8 +906,8 @@ void Diagram::setGeometry3D( sal_Int32 nNewGeometry ) for (auto const& series : aSeriesVec) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( - series, u"Geometry3D"_ustr, uno::Any( nNewGeometry )); + series->setPropertyAlsoToAllAttributedDataPoints( + u"Geometry3D"_ustr, uno::Any( nNewGeometry )); } } diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx b/chart2/source/model/template/AreaChartTypeTemplate.cxx index 71bbac8b3a19..c71fb5fb126f 100644 --- a/chart2/source/model/template/AreaChartTypeTemplate.cxx +++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx @@ -148,7 +148,7 @@ void AreaChartTypeTemplate::applyStyle2( ::sal_Int32 nSeriesCount ) { ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); } void AreaChartTypeTemplate::resetStyles2( const rtl::Reference< ::chart::Diagram >& xDiagram ) diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx index 1c37019509d1..e1d380fc8f85 100644 --- a/chart2/source/model/template/BarChartTypeTemplate.cxx +++ b/chart2/source/model/template/BarChartTypeTemplate.cxx @@ -200,7 +200,7 @@ void BarChartTypeTemplate::applyStyle2( ::sal_Int32 nSeriesCount ) { ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); if( getDimension() != 3 ) return; @@ -209,7 +209,7 @@ void BarChartTypeTemplate::applyStyle2( //apply Geometry3D uno::Any aAGeometry3D; getFastPropertyValue( aAGeometry3D, PROP_BAR_TEMPLATE_GEOMETRY3D ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"Geometry3D"_ustr, aAGeometry3D ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"Geometry3D"_ustr, aAGeometry3D ); } catch( const uno::Exception & ) { diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.cxx b/chart2/source/model/template/BubbleChartTypeTemplate.cxx index 00baa80a35f6..f72515eefd87 100644 --- a/chart2/source/model/template/BubbleChartTypeTemplate.cxx +++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx @@ -107,7 +107,7 @@ void BubbleChartTypeTemplate::applyStyle2( ::sal_Int32 nSeriesCount ) { ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); } // ____ XChartTypeTemplate ____ diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx index 1cfa6d1f258f..d45ca516af2c 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx @@ -211,7 +211,7 @@ void ColumnLineChartTypeTemplate::applyStyle2( if( nChartTypeIndex==0 ) // columns { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); } else if( nChartTypeIndex==1 ) // lines { diff --git a/chart2/source/model/template/HistogramChartTypeTemplate.cxx b/chart2/source/model/template/HistogramChartTypeTemplate.cxx index 97dc001d9550..b30d1205c429 100644 --- a/chart2/source/model/template/HistogramChartTypeTemplate.cxx +++ b/chart2/source/model/template/HistogramChartTypeTemplate.cxx @@ -124,8 +124,8 @@ void HistogramChartTypeTemplate::applyStyle2(const rtl::Reference<DataSeries>& x ::sal_Int32 nSeriesCount) { ChartTypeTemplate::applyStyle2(xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, "BorderStyle", - uno::Any(drawing::LineStyle_NONE)); + xSeries->setPropertyAlsoToAllAttributedDataPoints("BorderStyle", + uno::Any(drawing::LineStyle_NONE)); } void HistogramChartTypeTemplate::resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx index 0cdeb48ecfce..25d6d9c6ffe6 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.cxx +++ b/chart2/source/model/template/PieChartTypeTemplate.cxx @@ -520,7 +520,7 @@ void PieChartTypeTemplate::applyStyle2( } // line style - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); // vary colors by point xSeries->setFastPropertyValue( PROP_DATASERIES_VARY_COLORS_BY_POINT, uno::Any( true )); // "VaryColorsByPoint" diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx b/chart2/source/model/template/ScatterChartTypeTemplate.cxx index 80e8cc4bb924..5ba115af253c 100644 --- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx +++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx @@ -179,7 +179,7 @@ void ScatterChartTypeTemplate::applyStyle2( xSeries->switchLinesOnOrOff( m_bHasLines ); xSeries->makeLinesThickOrThin( m_nDim==2 ); if( m_nDim==3 ) - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); } catch( const uno::Exception & ) { diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx index 0c1f4ebcee3c..b9f141831d08 100644 --- a/chart2/source/model/template/StockChartTypeTemplate.cxx +++ b/chart2/source/model/template/StockChartTypeTemplate.cxx @@ -204,7 +204,7 @@ void StockChartTypeTemplate::applyStyle2( if( bHasVolume && nChartTypeIndex==0 ) { //switch lines off for volume bars - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); } else { diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index 80a314051dab..0d87b5912478 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -373,59 +373,6 @@ void deleteSeries( } } -void setPropertyAlsoToAllAttributedDataPoints( const rtl::Reference< ::chart::DataSeries >& xSeries, - const OUString& rPropertyName, const uno::Any& rPropertyValue ) -{ - if( !xSeries.is() ) - return; - - xSeries->setPropertyValue( rPropertyName, rPropertyValue ); - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - // "AttributedDataPoints" - if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList ) - { - for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) - { - Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]) ); - if(!xPointProp.is()) - continue; - xPointProp->setPropertyValue( rPropertyName, rPropertyValue ); - if( rPropertyName == "LabelPlacement" ) - { - xPointProp->setPropertyValue(u"CustomLabelPosition"_ustr, uno::Any()); - xPointProp->setPropertyValue(u"CustomLabelSize"_ustr, uno::Any()); - } - } - } -} - -bool hasAttributedDataPointDifferentValue( const rtl::Reference< DataSeries >& xSeries, - const OUString& rPropertyName, const uno::Any& rPropertyValue ) -{ - if( !xSeries.is() ) - return false; - - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - // "AttributedDataPoints" - if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList ) - { - for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) - { - Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]) ); - if(!xPointProp.is()) - continue; - uno::Any aPointValue( xPointProp->getPropertyValue( rPropertyName ) ); - if( rPropertyValue != aPointValue ) - return true; - } - } - return false; -} - -namespace -{ - -} sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nIndex, const Reference< chart2::data::XDataSequence >& xDataSequence, bool bTranslate ) { diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx index df3ab62d082c..b14ed61d385a 100644 --- a/chart2/source/tools/ThreeDHelper.cxx +++ b/chart2/source/tools/ThreeDHelper.cxx @@ -681,8 +681,8 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines( xSeries->getPropertyValue( aPercentDiagonalPropertyName ) >>= nPercentDiagonal; rnRoundedEdges = static_cast< sal_Int32 >( nPercentDiagonal ); - if( DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries - , aPercentDiagonalPropertyName, uno::Any(nPercentDiagonal) ) ) + if( xSeries->hasAttributedDataPointDifferentValue( + aPercentDiagonalPropertyName, uno::Any(nPercentDiagonal) ) ) bDifferentRoundedEdges = true; } catch( const uno::Exception& ) @@ -694,8 +694,8 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines( { xSeries->getPropertyValue( aBorderStylePropertyName ) >>= aLineStyle; - if( DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries - , aBorderStylePropertyName, uno::Any(aLineStyle) ) ) + if( xSeries->hasAttributedDataPointDifferentValue( + aBorderStylePropertyName, uno::Any(aLineStyle) ) ) bDifferentObjectLines = true; } catch( const uno::Exception& ) @@ -712,8 +712,8 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines( xSeries->getPropertyValue( aPercentDiagonalPropertyName ) >>= nPercentDiagonal; sal_Int32 nCurrentRoundedEdges = static_cast< sal_Int32 >( nPercentDiagonal ); if(nCurrentRoundedEdges!=rnRoundedEdges - || DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries - , aPercentDiagonalPropertyName, uno::Any( static_cast< sal_Int16 >(rnRoundedEdges) ) ) ) + || xSeries->hasAttributedDataPointDifferentValue( + aPercentDiagonalPropertyName, uno::Any( static_cast< sal_Int16 >(rnRoundedEdges) ) ) ) { bDifferentRoundedEdges = true; } @@ -724,8 +724,8 @@ void ThreeDHelper::getRoundedEdgesAndObjectLines( drawing::LineStyle aCurrentLineStyle; xSeries->getPropertyValue( aBorderStylePropertyName ) >>= aCurrentLineStyle; if(aCurrentLineStyle!=aLineStyle - || DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries - , aBorderStylePropertyName, uno::Any(aLineStyle) ) ) + || xSeries->hasAttributedDataPointDifferentValue( + aBorderStylePropertyName, uno::Any(aLineStyle) ) ) bDifferentObjectLines = true; } } @@ -765,10 +765,10 @@ void ThreeDHelper::setRoundedEdgesAndObjectLines( for( auto const& xSeries : aSeriesList) { if( nRoundedEdges>=0 && nRoundedEdges<=100 ) - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"PercentDiagonal"_ustr, aARoundedEdges ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"PercentDiagonal"_ustr, aARoundedEdges ); if( nObjectLines==0 || nObjectLines==1 ) - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"BorderStyle"_ustr, aALineStyle ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, aALineStyle ); } }