chart2/source/controller/dialogs/DialogModel.cxx | 2 chart2/source/controller/dialogs/DialogModel.hxx | 2 chart2/source/inc/DataSeries.hxx | 4 chart2/source/inc/DataSeriesHelper.hxx | 17 +--- chart2/source/model/main/DataSeries.cxx | 35 ++++++++ chart2/source/tools/DataSeriesHelper.cxx | 88 +++++---------------- chart2/source/view/main/SeriesPlotterContainer.cxx | 2 7 files changed, 68 insertions(+), 82 deletions(-)
New commits: commit f02ec0d8489404966596cb0e949bf969e8e66fa2 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 22 08:50:15 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Mar 22 17:15:25 2023 +0000 move hasUnhiddenData inside chart2::DataSeries Change-Id: Id8a4daf046f2306a52948c7ed434854b25ee7936 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149283 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/inc/DataSeries.hxx b/chart2/source/inc/DataSeries.hxx index 9e84ac99ab51..86405c19ac8e 100644 --- a/chart2/source/inc/DataSeries.hxx +++ b/chart2/source/inc/DataSeries.hxx @@ -149,6 +149,8 @@ public: */ OUString getLabelForRole( const OUString & rLabelSequenceRole ); + bool hasUnhiddenData(); + private: // late initialization to call after copy-constructing diff --git a/chart2/source/inc/DataSeriesHelper.hxx b/chart2/source/inc/DataSeriesHelper.hxx index c3eb20af90d6..474c49bb8277 100644 --- a/chart2/source/inc/DataSeriesHelper.hxx +++ b/chart2/source/inc/DataSeriesHelper.hxx @@ -160,9 +160,6 @@ OOO_DLLPUBLIC_CHARTTOOLS bool hasAttributedDataPointDifferentValue( const OUString& rPropertyName, const css::uno::Any& rPropertyValue ); -OOO_DLLPUBLIC_CHARTTOOLS bool hasUnhiddenData( const rtl::Reference< - ::chart::DataSeries >& xSeries ); - OOO_DLLPUBLIC_CHARTTOOLS 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 79f51fa8ab2e..8313054f2df2 100644 --- a/chart2/source/model/main/DataSeries.cxx +++ b/chart2/source/model/main/DataSeries.cxx @@ -685,6 +685,41 @@ OUString DataSeries::getLabelForRole( const OUString & rLabelSequenceRole ) return aResult; } +static bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSequence >& xDataSequence ) +{ + uno::Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY ); + if( xProp.is() ) + { + uno::Sequence< sal_Int32 > aHiddenValues; + try + { + xProp->getPropertyValue( "HiddenValues" ) >>= aHiddenValues; + if( !aHiddenValues.hasElements() ) + return true; + } + catch( const uno::Exception& ) + { + return true; + } + } + return xDataSequence->getData().hasElements(); +} + +bool DataSeries::hasUnhiddenData() +{ + MutexGuard aGuard( m_aMutex ); + + for(uno::Reference< chart2::data::XLabeledDataSequence > const & rDataSequence : m_aDataSequences) + { + if( !rDataSequence.is() ) + continue; + if( lcl_SequenceHasUnhiddenData( rDataSequence->getValues() ) ) + return true; + } + return false; +} + + } // 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 07883a1646bf..9935aa0e5fd3 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -526,42 +526,6 @@ bool hasAttributedDataPointDifferentValue( const Reference< chart2::XDataSeries namespace { -bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSequence >& xDataSequence ) -{ - if( !xDataSequence.is() ) - return false; - uno::Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY ); - if( xProp.is() ) - { - uno::Sequence< sal_Int32 > aHiddenValues; - try - { - xProp->getPropertyValue( "HiddenValues" ) >>= aHiddenValues; - if( !aHiddenValues.hasElements() ) - return true; - } - catch( const uno::Exception& ) - { - return true; - } - } - return xDataSequence->getData().hasElements(); -} - -} - -bool hasUnhiddenData( const rtl::Reference< DataSeries >& xSeries ) -{ - uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aDataSequences = xSeries->getDataSequences(); - - for(sal_Int32 nN = aDataSequences.getLength();nN--;) - { - if( !aDataSequences[nN].is() ) - continue; - if( lcl_SequenceHasUnhiddenData( aDataSequences[nN]->getValues() ) ) - return true; - } - return false; } sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nIndex, const Reference< chart2::data::XDataSequence >& xDataSequence, bool bTranslate ) diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx b/chart2/source/view/main/SeriesPlotterContainer.cxx index b965812b6528..30b2ba8edcb5 100644 --- a/chart2/source/view/main/SeriesPlotterContainer.cxx +++ b/chart2/source/view/main/SeriesPlotterContainer.cxx @@ -253,7 +253,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart for (std::size_t nS = 0; nS < aSeriesList.size(); ++nS) { rtl::Reference<DataSeries> const& xDataSeries = aSeriesList[nS]; - if (!bIncludeHiddenCells && !DataSeriesHelper::hasUnhiddenData(xDataSeries)) + if (!bIncludeHiddenCells && !xDataSeries->hasUnhiddenData()) continue; std::unique_ptr<VDataSeries> pSeries(new VDataSeries(xDataSeries)); commit f4cde4406217dd61e8d803eb38e6f5fac84a1f6d Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 22 08:29:26 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Mar 22 17:15:15 2023 +0000 use more concrete type in chart2 Change-Id: I0ed45cf9acd1c9bf702bbe335f8a07b6947fb946 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149282 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index 334fc0b1b0e2..c9084ca8f518 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -581,7 +581,7 @@ rtl::Reference< ::chart::DataSeries > DialogModel::insertSeriesAfter( } void DialogModel::deleteSeries( - const Reference< XDataSeries > & xSeries, + const rtl::Reference< DataSeries > & xSeries, const rtl::Reference< ChartType > & xChartType ) { m_aTimerTriggeredControllerLock.startTimer(); diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx index 576f29c20f4b..325cffe06773 100644 --- a/chart2/source/controller/dialogs/DialogModel.hxx +++ b/chart2/source/controller/dialogs/DialogModel.hxx @@ -115,7 +115,7 @@ public: bool bCreateDataCachedSequences = false ); void deleteSeries( - const css::uno::Reference< css::chart2::XDataSeries > & xSeries, + const rtl::Reference< ::chart::DataSeries > & xSeries, const rtl::Reference< ::chart::ChartType > & xChartType ); css::uno::Reference< css::chart2::data::XLabeledDataSequence > diff --git a/chart2/source/inc/DataSeries.hxx b/chart2/source/inc/DataSeries.hxx index fb8255d10f12..9e84ac99ab51 100644 --- a/chart2/source/inc/DataSeries.hxx +++ b/chart2/source/inc/DataSeries.hxx @@ -86,7 +86,6 @@ public: virtual void SAL_CALL resetDataPoint( sal_Int32 nIndex ) override; virtual void SAL_CALL resetAllDataPoints() override; -private: // ____ XDataSink ____ /// @see css::chart2::data::XDataSink virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > >& aData ) override; @@ -94,7 +93,6 @@ private: // ____ XDataSource ____ /// @see css::chart2::data::XDataSource virtual css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences() override; -public: // ____ OPropertySet ____ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; diff --git a/chart2/source/inc/DataSeriesHelper.hxx b/chart2/source/inc/DataSeriesHelper.hxx index b07ff17b1e08..c3eb20af90d6 100644 --- a/chart2/source/inc/DataSeriesHelper.hxx +++ b/chart2/source/inc/DataSeriesHelper.hxx @@ -127,11 +127,11 @@ rtl::Reference< ::chart::BaseCoordinateSystem > OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference< ::chart::ChartType > getChartTypeOfSeries( - const css::uno::Reference< css::chart2::XDataSeries > & xSeries, + const rtl::Reference< ::chart::DataSeries > & xSeries, const rtl::Reference< ::chart::Diagram > & xDiagram ); OOO_DLLPUBLIC_CHARTTOOLS void deleteSeries( - const css::uno::Reference< css::chart2::XDataSeries > & xSeries, + const rtl::Reference< ::chart::DataSeries > & xSeries, const rtl::Reference< ::chart::ChartType > & xChartType ); OOO_DLLPUBLIC_CHARTTOOLS void switchSymbolsOnOrOff( @@ -160,24 +160,24 @@ OOO_DLLPUBLIC_CHARTTOOLS bool hasAttributedDataPointDifferentValue( const OUString& rPropertyName, const css::uno::Any& rPropertyValue ); -OOO_DLLPUBLIC_CHARTTOOLS bool hasUnhiddenData( const css::uno::Reference< - css::chart2::XDataSeries >& xSeries ); +OOO_DLLPUBLIC_CHARTTOOLS bool hasUnhiddenData( const rtl::Reference< + ::chart::DataSeries >& xSeries ); OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nClippedIndex, const css::uno::Reference< css::chart2::data::XDataSequence >& xDataSequence, bool bTranslate ); -OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtSeries( const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); +OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtSeries( const rtl::Reference< ::chart::DataSeries >& xSeries ); -OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtPoints( const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); +OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtPoints( const rtl::Reference< ::chart::DataSeries >& xSeries ); -OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelAtPoint( const css::uno::Reference< css::chart2::XDataSeries >& xSeries, sal_Int32 nPointIndex ); +OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelAtPoint( const rtl::Reference< ::chart::DataSeries >& xSeries, sal_Int32 nPointIndex ); -OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelsToSeriesAndAllPoints( const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); +OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelsToSeriesAndAllPoints( const rtl::Reference< ::chart::DataSeries >& xSeries ); OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelToPoint( const css::uno::Reference< css::beans::XPropertySet >& xPointPropertySet ); -OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromSeriesAndAllPoints( const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); +OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromSeriesAndAllPoints( const rtl::Reference< ::chart::DataSeries >& xSeries ); OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromPoint( const css::uno::Reference< css::beans::XPropertySet >& xPointPropertySet ); diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index e1212ae1fa72..07883a1646bf 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -112,24 +112,23 @@ void lcl_getCooSysAndChartTypeOfSeries( } } -void lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( const Reference< chart2::XDataSeries >& xSeries, bool bInsert ) +void lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( const rtl::Reference< ::chart::DataSeries >& xSeries, bool bInsert ) { try { - Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY ); - if( xSeriesProperties.is() ) + if( xSeries.is() ) { DataPointLabel aLabelAtSeries; - xSeriesProperties->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabelAtSeries; + xSeries->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabelAtSeries; aLabelAtSeries.ShowNumber = bInsert; if( !bInsert ) { aLabelAtSeries.ShowNumberInPercent = false; aLabelAtSeries.ShowCategoryName = false; } - xSeriesProperties->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabelAtSeries)); + xSeries->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabelAtSeries)); uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) + if( xSeries->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) { for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) { @@ -386,28 +385,24 @@ rtl::Reference< ::chart::BaseCoordinateSystem > getCoordinateSystemOfSeries( } rtl::Reference< ::chart::ChartType > getChartTypeOfSeries( - const Reference< chart2::XDataSeries > & xSeries, + const rtl::Reference< DataSeries > & xSeries, const rtl::Reference< Diagram > & xDiagram ) { rtl::Reference< ::chart::ChartType > xResult; rtl::Reference< ::chart::BaseCoordinateSystem > xDummy; - rtl::Reference< DataSeries> pSeries = dynamic_cast<DataSeries*>(xSeries.get()); - assert(pSeries); - lcl_getCooSysAndChartTypeOfSeries( pSeries, xDiagram, xDummy, xResult ); + lcl_getCooSysAndChartTypeOfSeries( xSeries, xDiagram, xDummy, xResult ); return xResult; } void deleteSeries( - const Reference< chart2::XDataSeries > & xSeries, + const rtl::Reference< ::chart::DataSeries > & xSeries, const rtl::Reference< ::chart::ChartType > & xChartType ) { try { - rtl::Reference<DataSeries> pSeries = dynamic_cast<DataSeries*>(xSeries.get()); - assert(pSeries); std::vector< rtl::Reference< DataSeries > > aSeries = xChartType->getDataSeries2(); - auto aIt = std::find( aSeries.begin(), aSeries.end(), pSeries ); + auto aIt = std::find( aSeries.begin(), aSeries.end(), xSeries ); if( aIt != aSeries.end()) { aSeries.erase( aIt ); @@ -555,11 +550,9 @@ bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSeque } -bool hasUnhiddenData( const uno::Reference< chart2::XDataSeries >& xSeries ) +bool hasUnhiddenData( const rtl::Reference< DataSeries >& xSeries ) { - uno::Reference< chart2::data::XDataSource > xDataSource( xSeries, uno::UNO_QUERY ); - - uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aDataSequences = xDataSource->getDataSequences(); + uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aDataSequences = xSeries->getDataSequences(); for(sal_Int32 nN = aDataSequences.getLength();nN--;) { @@ -605,16 +598,15 @@ sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nIndex, const Refere return nIndex; } -bool hasDataLabelsAtSeries( const Reference< chart2::XDataSeries >& xSeries ) +bool hasDataLabelsAtSeries( const rtl::Reference< DataSeries >& xSeries ) { bool bRet = false; try { - Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY ); - if( xProp.is() ) + if( xSeries.is() ) { DataPointLabel aLabel; - if( xProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) + if( xSeries->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName || aLabel.ShowSeriesName; } @@ -626,16 +618,15 @@ bool hasDataLabelsAtSeries( const Reference< chart2::XDataSeries >& xSeries ) return bRet; } -bool hasDataLabelsAtPoints( const Reference< chart2::XDataSeries >& xSeries ) +bool hasDataLabelsAtPoints( const rtl::Reference< DataSeries >& xSeries ) { bool bRet = false; try { - Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY ); - if( xSeriesProperties.is() ) + if( xSeries.is() ) { uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) + if( xSeries->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) { for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) { @@ -661,23 +652,22 @@ bool hasDataLabelsAtPoints( const Reference< chart2::XDataSeries >& xSeries ) return bRet; } -bool hasDataLabelAtPoint( const Reference< chart2::XDataSeries >& xSeries, sal_Int32 nPointIndex ) +bool hasDataLabelAtPoint( const rtl::Reference< DataSeries >& xSeries, sal_Int32 nPointIndex ) { bool bRet = false; try { Reference< beans::XPropertySet > xProp; - Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY ); - if( xSeriesProperties.is() ) + if( xSeries.is() ) { uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) + if( xSeries->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) { auto aIt = std::find( std::as_const(aAttributedDataPointIndexList).begin(), std::as_const(aAttributedDataPointIndexList).end(), nPointIndex ); if( aIt != std::as_const(aAttributedDataPointIndexList).end()) xProp = xSeries->getDataPointByIndex(nPointIndex); else - xProp = xSeriesProperties; + xProp = xSeries; } if( xProp.is() ) { @@ -696,12 +686,12 @@ bool hasDataLabelAtPoint( const Reference< chart2::XDataSeries >& xSeries, sal_I return bRet; } -void insertDataLabelsToSeriesAndAllPoints( const Reference< chart2::XDataSeries >& xSeries ) +void insertDataLabelsToSeriesAndAllPoints( const rtl::Reference< DataSeries >& xSeries ) { lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( xSeries, true /*bInsert*/ ); } -void deleteDataLabelsFromSeriesAndAllPoints( const Reference< chart2::XDataSeries >& xSeries ) +void deleteDataLabelsFromSeriesAndAllPoints( const rtl::Reference< DataSeries >& xSeries ) { lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( xSeries, false /*bInsert*/ ); }