From 8a728ac6cf7d8d032eb93f486618458b7814d42b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 19 Jan 2022 21:02:51 +0200 Subject: use more concrete types in chart2, ChartType Change-Id: Ibd299e2e8d82169706d810af98c29d684809c320 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128741 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../chartapiwrapper/WrappedGapwidthProperty.cxx | 51 ++++++++++------------ 1 file changed, 22 insertions(+), 29 deletions(-) (limited to 'chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx') diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx index c0f100d335a7..e613161bf10f 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx @@ -19,6 +19,7 @@ #include "WrappedGapwidthProperty.hxx" #include "Chart2ModelContact.hxx" +#include #include #include @@ -72,29 +73,25 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, if( m_nDimensionIndex!=1 ) return; - const Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & chartType : aChartTypeList ) + const std::vector< rtl::Reference< ChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); + for( rtl::Reference< ChartType > const & chartType : aChartTypeList ) { try { - Reference< beans::XPropertySet > xProp( chartType, uno::UNO_QUERY ); - if( xProp.is() ) + Sequence< sal_Int32 > aBarPositionSequence; + chartType->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + + tools::Long nOldLength = aBarPositionSequence.getLength(); + if( nOldLength <= m_nAxisIndex ) + aBarPositionSequence.realloc( m_nAxisIndex+1 ); + auto pBarPositionSequence = aBarPositionSequence.getArray(); + for( sal_Int32 i=nOldLength; i aBarPositionSequence; - xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; - - tools::Long nOldLength = aBarPositionSequence.getLength(); - if( nOldLength <= m_nAxisIndex ) - aBarPositionSequence.realloc( m_nAxisIndex+1 ); - auto pBarPositionSequence = aBarPositionSequence.getArray(); - for( sal_Int32 i=nOldLength; isetPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); + pBarPositionSequence[i] = m_nDefaultValue; } + pBarPositionSequence[m_nAxisIndex] = nNewValue; + + chartType->setPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); } catch( uno::Exception& e ) { @@ -115,21 +112,17 @@ Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::X if( m_nDimensionIndex==1 ) { - Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( sal_Int32 nN = 0; nN < aChartTypeList.getLength() && !bInnerValueDetected; nN++ ) + std::vector< rtl::Reference< ChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); + for( sal_Int32 nN = 0; nN < static_cast(aChartTypeList.size()) && !bInnerValueDetected; nN++ ) { try { - Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY ); - if( xProp.is() ) + Sequence< sal_Int32 > aBarPositionSequence; + aChartTypeList[nN]->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + if( m_nAxisIndex < aBarPositionSequence.getLength() ) { - Sequence< sal_Int32 > aBarPositionSequence; - xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; - if( m_nAxisIndex < aBarPositionSequence.getLength() ) - { - nInnerValue = aBarPositionSequence[m_nAxisIndex]; - bInnerValueDetected = true; - } + nInnerValue = aBarPositionSequence[m_nAxisIndex]; + bInnerValueDetected = true; } } catch( uno::Exception& e ) -- cgit