summaryrefslogtreecommitdiff
path: root/sc/source/ui/vba
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-12-21 11:27:18 +0100
committerStephan Bergmann <sbergman@redhat.com>2022-12-21 14:41:27 +0000
commit57d91a1ba839fde0f2826583ad9740f5ca1e246e (patch)
treec080467d072bf0298ff6594125a2cc8b6f0f7b62 /sc/source/ui/vba
parent5940427063f7a6ef914b65cf9e2396eb2cc828ca (diff)
Use ScCellRangesBase's existing XUnoTunnel
Change-Id: I1323a0aad06118397f39eec0f42494491df93f23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144680 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc/source/ui/vba')
-rw-r--r--sc/source/ui/vba/vbachartobjects.cxx3
-rw-r--r--sc/source/ui/vba/vbarange.cxx12
2 files changed, 10 insertions, 5 deletions
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() )