From 57d91a1ba839fde0f2826583ad9740f5ca1e246e Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 21 Dec 2022 11:27:18 +0100 Subject: Use ScCellRangesBase's existing XUnoTunnel Change-Id: I1323a0aad06118397f39eec0f42494491df93f23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144680 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- sc/source/ui/vba/vbachartobjects.cxx | 3 ++- sc/source/ui/vba/vbarange.cxx | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbachartobjects.cxx b/sc/source/ui/vba/vbachartobjects.cxx index a61d9a0da83c..5cc12080c1e4 100644 --- a/sc/source/ui/vba/vbachartobjects.cxx +++ b/sc/source/ui/vba/vbachartobjects.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include using namespace ::com::sun::star; @@ -102,7 +103,7 @@ ScVbaChartObjects::getChartObjectNames() const { // c++ hackery uno::Reference< uno::XInterface > xIf( xDrawPageSupplier, uno::UNO_QUERY_THROW ); - ScCellRangesBase* pUno= dynamic_cast< ScCellRangesBase* >( xIf.get() ); + ScCellRangesBase* pUno= comphelper::getFromUnoTunnel< ScCellRangesBase >( xIf ); ScDocShell* pDocShell = nullptr; if ( !pUno ) throw uno::RuntimeException("Failed to obtain the impl class from the drawpage" ); diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index d2bd37db518d..15a04d480f9e 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -19,6 +19,7 @@ #include "vbarange.hxx" +#include #include #include #include @@ -872,7 +873,8 @@ protected: if ( m_eGrammar != formula::FormulaGrammar::GRAM_API && ( o3tl::starts_with(o3tl::trim(sFormula), u"=") ) ) { uno::Reference< uno::XInterface > xIf( xCell, uno::UNO_QUERY_THROW ); - ScCellRangesBase* pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() ); + ScCellRangesBase* pUnoRangesBase + = comphelper::getFromUnoTunnel< ScCellRangesBase >( xIf ); if ( pUnoRangesBase ) { const ScRangeList& rCellRanges = pUnoRangesBase->GetRangeList(); @@ -920,7 +922,8 @@ public: && m_eGrammar != formula::FormulaGrammar::GRAM_API) { uno::Reference< uno::XInterface > xIf( xCell, uno::UNO_QUERY_THROW ); - ScCellRangesBase* pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() ); + ScCellRangesBase* pUnoRangesBase + = comphelper::getFromUnoTunnel< ScCellRangesBase >( xIf ); if (pUnoRangesBase) { OUString sVal; @@ -1831,11 +1834,12 @@ ScVbaRange::HasFormula() return aResult; } uno::Reference< uno::XInterface > xIf( mxRange, uno::UNO_QUERY_THROW ); - ScCellRangesBase* pThisRanges = dynamic_cast< ScCellRangesBase * > ( xIf.get() ); + ScCellRangesBase* pThisRanges = comphelper::getFromUnoTunnel< ScCellRangesBase > ( xIf ); if ( pThisRanges ) { uno::Reference xRanges( pThisRanges->queryFormulaCells( sheet::FormulaResult::ERROR | sheet::FormulaResult::VALUE | sheet::FormulaResult::STRING ), uno::UNO_QUERY_THROW ); - ScCellRangesBase* pFormulaRanges = dynamic_cast< ScCellRangesBase * > ( xRanges.get() ); + ScCellRangesBase* pFormulaRanges + = comphelper::getFromUnoTunnel< ScCellRangesBase > ( xRanges ); assert(pFormulaRanges); // check if there are no formula cell, return false if ( pFormulaRanges->GetRangeList().empty() ) -- cgit v1.2.3