From d833992e7e06f7d385fca6ffe35ce66b79360a63 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Thu, 7 Nov 2024 02:27:54 +0500 Subject: Avoid checking exact interface type of Any value Change-Id: Ic883c3a9fd8eb87469aec6b6570a39aadf575c3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176184 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- chart2/source/controller/main/ChartController_Window.cxx | 8 +++----- chart2/source/tools/ObjectIdentifier.cxx | 5 ++--- chart2/source/tools/RangeHighlighter.cxx | 7 ++----- 3 files changed, 7 insertions(+), 13 deletions(-) (limited to 'chart2/source') diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index a4e54a5fd13e..b0fbf6a25cb4 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -1644,8 +1644,7 @@ sal_Bool SAL_CALL ChartController::select( const uno::Any& rSelection ) if ( rSelection.hasValue() ) { - const uno::Type& rType = rSelection.getValueType(); - if ( rType == cppu::UnoType< OUString >::get() ) + if (rSelection.getValueType() == cppu::UnoType::get()) { OUString aNewCID; if ( ( rSelection >>= aNewCID ) && m_aSelection.setSelection( aNewCID ) ) @@ -1653,10 +1652,9 @@ sal_Bool SAL_CALL ChartController::select( const uno::Any& rSelection ) bSuccess = true; } } - else if ( rType == cppu::UnoType::get() ) + else if (uno::Reference xShape; rSelection >>= xShape) { - uno::Reference< drawing::XShape > xShape; - if ( ( rSelection >>= xShape ) && m_aSelection.setSelection( xShape ) ) + if (m_aSelection.setSelection(xShape)) { bSuccess = true; } diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index 1e4e2764d063..7e6314b15c69 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -239,12 +239,11 @@ ObjectIdentifier::ObjectIdentifier( const Reference< drawing::XShape >& rxShape ObjectIdentifier::ObjectIdentifier( const Any& rAny ) { - const uno::Type& rType = rAny.getValueType(); - if ( rType == cppu::UnoType::get() ) + if (rAny.getValueType() == cppu::UnoType::get()) { rAny >>= m_aObjectCID; } - else if ( rType == cppu::UnoType< drawing::XShape >::get() ) + else { rAny >>= m_xAdditionalShape; } diff --git a/chart2/source/tools/RangeHighlighter.cxx b/chart2/source/tools/RangeHighlighter.cxx index eb3dffb2bdcc..63c8809be081 100644 --- a/chart2/source/tools/RangeHighlighter.cxx +++ b/chart2/source/tools/RangeHighlighter.cxx @@ -100,9 +100,8 @@ void RangeHighlighter::determineRanges() m_bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( m_xChartModel ); uno::Any aSelection( m_xSelectionSupplier->getSelection()); - const uno::Type& rType = aSelection.getValueType(); - if ( rType == cppu::UnoType::get() ) + if (aSelection.getValueType() == cppu::UnoType::get()) { // @todo??: maybe getSelection() should return a model object rather than a CID @@ -169,11 +168,9 @@ void RangeHighlighter::determineRanges() } } } - else if ( rType == cppu::UnoType< drawing::XShape >::get() ) + else if (Reference xShape; aSelection >>= xShape) { // #i12587# support for shapes in chart - Reference< drawing::XShape > xShape; - aSelection >>= xShape; if ( xShape.is() ) { return; -- cgit