sc/source/ui/vba/vbachartobjects.cxx | 3 ++- sc/source/ui/vba/vbarange.cxx | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-)
New commits: commit 57d91a1ba839fde0f2826583ad9740f5ca1e246e Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Dec 21 11:27:18 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Dec 21 14:41:27 2022 +0000 Use ScCellRangesBase's existing XUnoTunnel Change-Id: I1323a0aad06118397f39eec0f42494491df93f23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144680 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> 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 <vector> #include <basic/sberrors.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/servicehelper.hxx> #include <comphelper/diagnose_ex.hxx> 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 <comphelper/servicehelper.hxx> #include <comphelper/types.hxx> #include <cppuhelper/exc_hlp.hxx> #include <o3tl/any.hxx> @@ -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<uno::XInterface> 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() )