sc/inc/afmtuno.hxx                   |    5 -----
 sc/inc/cellsuno.hxx                  |   10 +---------
 sc/source/ui/app/transobj.cxx        |   10 ++++------
 sc/source/ui/inc/transobj.hxx        |    4 +++-
 sc/source/ui/unoobj/afmtuno.cxx      |    6 +-----
 sc/source/ui/unoobj/cellsuno.cxx     |   22 +++++++---------------
 sc/source/ui/unoobj/docuno.cxx       |    8 ++++----
 sc/source/ui/unoobj/funcuno.cxx      |    2 +-
 sc/source/ui/unoobj/viewuno.cxx      |    4 ++--
 sc/source/ui/vba/excelvbahelper.cxx  |    2 +-
 sc/source/ui/vba/vbachartobjects.cxx |    2 +-
 sc/source/ui/vba/vbaeventshelper.cxx |    4 ++--
 sc/source/ui/vba/vbaformat.cxx       |    2 +-
 sc/source/ui/vba/vbarange.cxx        |   16 ++++++++--------
 14 files changed, 36 insertions(+), 61 deletions(-)

New commits:
commit 3e7ff2a908c577b52ee0707435fb409765c37545
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sat Jan 21 21:16:21 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jan 23 07:27:51 2023 +0000

    XUnoTunnel->dynamic_cast in ScCellRangesBase
    
    Change-Id: Iac62a8ed51d21cc2ef957b3e4811554b62cdb0d1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145982
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx
index 65784be7ee3d..e64c1065d5c7 100644
--- a/sc/inc/cellsuno.hxx
+++ b/sc/inc/cellsuno.hxx
@@ -81,7 +81,6 @@
 #include <com/sun/star/util/XModifyBroadcaster.hpp>
 #include <com/sun/star/beans/XPropertyState.hpp>
 #include <com/sun/star/beans/XMultiPropertySet.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <com/sun/star/document/XActionLockable.hpp>
 #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
 #include <com/sun/star/sheet/XExternalSheetName.hpp>
@@ -155,7 +154,7 @@ namespace ooo::vba::excel {
     class ScVbaCellRangeAccess;  // Vba Helper class
 }
 
-class SC_DLLPUBLIC ScCellRangesBase :
+class SC_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") ScCellRangesBase :
                          public cppu::WeakImplHelper<
                             css::beans::XPropertySet,
                              css::beans::XMultiPropertySet,
@@ -168,7 +167,6 @@ class SC_DLLPUBLIC ScCellRangesBase :
                              css::util::XReplaceable,
                              css::util::XModifyBroadcaster,
                              css::lang::XServiceInfo,
-                             css::lang::XUnoTunnel,
                              css::beans::XTolerantMultiPropertySet>,
                          public SfxListener
 {
@@ -372,9 +370,6 @@ public:
     virtual OUString SAL_CALL getImplementationName() override;
     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
-
-                            // XUnoTunnel
-    UNO3_GETIMPLEMENTATION_DECL(ScCellRangesBase)
 };
 
 class UNLESS_MERGELIBS(SC_DLLPUBLIC) ScCellRangesObj final : public 
ScCellRangesBase,
@@ -959,9 +954,6 @@ public:
     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
 
-                            // XUnoTunnel
-    UNO3_GETIMPLEMENTATION_DECL(ScTableSheetObj);
-
                             // XTypeProvider
     virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
     virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() 
override;
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 3bba033d28e7..d0fbd02fce43 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -635,9 +635,8 @@ ScDocument* ScTransferObj::GetSourceDocument()
 
 ScDocShell* ScTransferObj::GetSourceDocShell()
 {
-    ScCellRangesBase* pRangesObj = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( m_xDragSourceRanges );
-    if (pRangesObj)
-        return pRangesObj->GetDocShell();
+    if (m_xDragSourceRanges)
+        return m_xDragSourceRanges->GetDocShell();
 
     return nullptr;    // none set
 }
@@ -645,10 +644,9 @@ ScDocShell* ScTransferObj::GetSourceDocShell()
 ScMarkData ScTransferObj::GetSourceMarkData() const
 {
     ScMarkData aMarkData(m_pDoc->GetSheetLimits());
-    ScCellRangesBase* pRangesObj = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( m_xDragSourceRanges );
-    if (pRangesObj)
+    if (m_xDragSourceRanges)
     {
-        const ScRangeList& rRanges = pRangesObj->GetRangeList();
+        const ScRangeList& rRanges = m_xDragSourceRanges->GetRangeList();
         aMarkData.MarkFromRangeList( rRanges, false );
     }
     return aMarkData;
diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx
index 3a597669e8b1..1c81610e6fc9 100644
--- a/sc/source/ui/inc/transobj.hxx
+++ b/sc/source/ui/inc/transobj.hxx
@@ -22,12 +22,14 @@
 #include <vcl/transfer.hxx>
 #include <address.hxx>
 #include <document.hxx>
+#include <rtl/ref.hxx>
 #include <sfx2/objsh.hxx>
 
 
 class ScDocShell;
 class ScMarkData;
 enum class ScDragSrc;
+class ScCellRangesBase;
 
 namespace com::sun::star {
     namespace sheet {
@@ -44,7 +46,7 @@ private:
     TransferableObjectDescriptor    m_aObjDesc;
     SfxObjectShellRef               m_aDocShellRef;
     SfxObjectShellRef               m_aDrawPersistRef;
-    css::uno::Reference<css::sheet::XSheetCellRanges> m_xDragSourceRanges;
+    rtl::Reference<ScCellRangesBase> m_xDragSourceRanges;
     SCCOL                           m_nDragHandleX;
     SCROW                           m_nDragHandleY;
     SCCOL                           m_nSourceCursorX;
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 69f4cbd5e61f..3dc012c0acd1 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -3851,7 +3851,7 @@ uno::Reference<uno::XInterface> SAL_CALL 
ScCellRangesBase::findNext(
     SolarMutexGuard aGuard;
     if ( xStartAt.is() )
     {
-        ScCellRangesBase* pRangesImp = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xStartAt );
+        ScCellRangesBase* pRangesImp = dynamic_cast<ScCellRangesBase*>( 
xStartAt.get() );
         if ( pRangesImp && pRangesImp->GetDocShell() == pDocShell )
         {
             const ScRangeList& rStartRanges = pRangesImp->GetRangeList();
@@ -3955,10 +3955,6 @@ sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const 
uno::Reference<util::XSea
     return nReplaced;
 }
 
-// XUnoTunnel
-
-UNO3_GETIMPLEMENTATION_IMPL(ScCellRangesBase);
-
 ScCellRangesObj::ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR)
     : ScCellRangesBase(pDocSh, rR)
 {
@@ -4196,7 +4192,7 @@ void SAL_CALL ScCellRangesObj::insertByName( const 
OUString& aName, const uno::A
     uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
     if ( pDocSh && xInterface.is() )
     {
-        ScCellRangesBase* pRangesImp = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xInterface );
+        ScCellRangesBase* pRangesImp = dynamic_cast<ScCellRangesBase*>( 
xInterface.get() );
         if ( pRangesImp && pRangesImp->GetDocShell() == pDocSh )
         {
             //  if explicit name is given and already existing, throw exception
@@ -4821,7 +4817,7 @@ void ScCellRangeObj::SetArrayFormula_Impl(const OUString& 
rFormula,
 
     if ( !rFormula.isEmpty() )
     {
-        if ( comphelper::getFromUnoTunnel<ScTableSheetObj>( 
static_cast<cppu::OWeakObject*>(this) ) )
+        if ( dynamic_cast<ScTableSheetObj*>( this ) )
         {
             //  don't set array formula for sheet object
             throw uno::RuntimeException();
@@ -4890,7 +4886,7 @@ void SAL_CALL ScCellRangeObj::setArrayTokens( const 
uno::Sequence<sheet::Formula
 
     if ( rTokens.hasElements() )
     {
-        if ( comphelper::getFromUnoTunnel<ScTableSheetObj>( 
static_cast<cppu::OWeakObject*>(this) ) )
+        if ( dynamic_cast<ScTableSheetObj*>( this ) )
         {
             throw uno::RuntimeException();
         }
@@ -4920,7 +4916,7 @@ uno::Sequence< uno::Sequence<uno::Any> > SAL_CALL 
ScCellRangeObj::getDataArray()
 {
     SolarMutexGuard aGuard;
 
-    if ( comphelper::getFromUnoTunnel<ScTableSheetObj>( 
static_cast<cppu::OWeakObject*>(this) ) )
+    if ( dynamic_cast<ScTableSheetObj*>( this ) )
     {
         //  don't create a data array for the sheet
         throw uno::RuntimeException();
@@ -4965,7 +4961,7 @@ uno::Sequence< uno::Sequence<OUString> > SAL_CALL 
ScCellRangeObj::getFormulaArra
 {
     SolarMutexGuard aGuard;
 
-    if ( comphelper::getFromUnoTunnel<ScTableSheetObj>( 
static_cast<cppu::OWeakObject*>(this) ) )
+    if ( dynamic_cast<ScTableSheetObj*>( this ) )
     {
         //  don't create a data array for the sheet
         throw uno::RuntimeException();
@@ -6707,7 +6703,7 @@ uno::Reference<sheet::XSheetCellCursor> SAL_CALL 
ScTableSheetObj::createCursorBy
     ScDocShell* pDocSh = GetDocShell();
     if ( pDocSh && xCellRange.is() )
     {
-        ScCellRangesBase* pRangesImp = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xCellRange );
+        ScCellRangesBase* pRangesImp = dynamic_cast<ScCellRangesBase*>( 
xCellRange.get() );
         if (pRangesImp)
         {
             const ScRangeList& rRanges = pRangesImp->GetRangeList();
@@ -8261,10 +8257,6 @@ uno::Sequence<OUString> SAL_CALL 
ScTableSheetObj::getSupportedServiceNames()
             SCLINKTARGET_SERVICE};
 }
 
-// XUnoTunnel
-
-UNO3_GETIMPLEMENTATION2_IMPL(ScTableSheetObj, ScCellRangeObj);
-
 ScTableColumnObj::ScTableColumnObj( ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab 
) :
     ScCellRangeObj( pDocSh, ScRange(nCol,0,nTab, nCol, 
pDocSh->GetDocument().MaxRow(),nTab) ),
     pColPropSet(lcl_GetColumnPropertySet())
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 0fbfc7d12157..2246e1db58ec 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1620,11 +1620,11 @@ bool ScModelObj::FillRenderMarkData( const uno::Any& 
aSelection,
     uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
     if ( xInterface.is() )
     {
-        ScCellRangesBase* pSelObj = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xInterface );
+        ScCellRangesBase* pSelObj = dynamic_cast<ScCellRangesBase*>( 
xInterface.get() );
         uno::Reference< drawing::XShapes > xShapes( xInterface, uno::UNO_QUERY 
);
         if ( pSelObj && pSelObj->GetDocShell() == pDocShell )
         {
-            bool bSheet = ( comphelper::getFromUnoTunnel<ScTableSheetObj>( 
xInterface ) != nullptr );
+            bool bSheet = ( dynamic_cast<ScTableSheetObj*>( pSelObj ) != 
nullptr );
             bool bCursor = pSelObj->IsCursorOnly();
             const ScRangeList& rRanges = pSelObj->GetRangeList();
 
@@ -3795,7 +3795,7 @@ void SAL_CALL ScTableSheetsObj::insertByName( const 
OUString& aName, const uno::
         uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
         if ( xInterface.is() )
         {
-            ScTableSheetObj* pSheetObj = 
comphelper::getFromUnoTunnel<ScTableSheetObj>( xInterface );
+            ScTableSheetObj* pSheetObj = dynamic_cast<ScTableSheetObj*>( 
xInterface.get() );
             if ( pSheetObj && !pSheetObj->GetDocShell() )   // not inserted 
yet?
             {
                 ScDocument& rDoc = pDocShell->GetDocument();
@@ -3841,7 +3841,7 @@ void SAL_CALL ScTableSheetsObj::replaceByName( const 
OUString& aName, const uno:
         uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
         if ( xInterface.is() )
         {
-            ScTableSheetObj* pSheetObj = 
comphelper::getFromUnoTunnel<ScTableSheetObj>( xInterface );
+            ScTableSheetObj* pSheetObj = dynamic_cast<ScTableSheetObj*>( 
xInterface.get() );
             if ( pSheetObj && !pSheetObj->GetDocShell() )   // not inserted 
yet?
             {
                 SCTAB nPosition;
diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx
index e0d18a7a2ab0..8b5ef69aca66 100644
--- a/sc/source/ui/unoobj/funcuno.cxx
+++ b/sc/source/ui/unoobj/funcuno.cxx
@@ -550,7 +550,7 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const 
OUString& aName,
             // currently, only our own cell ranges are supported
 
             uno::Reference<table::XCellRange> xRange(rArg, uno::UNO_QUERY);
-            ScCellRangesBase* pImpl = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xRange );
+            ScCellRangesBase* pImpl = dynamic_cast<ScCellRangesBase*>( 
xRange.get() );
             if ( pImpl )
             {
                 ScDocument* pSrcDoc = pImpl->GetDocument();
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index c600a01114b8..3a67c7686c20 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -679,7 +679,7 @@ sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& 
aSelection )
     if (bRet)
         return bRet;
 
-    ScCellRangesBase* pRangesImp = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xInterface );
+    ScCellRangesBase* pRangesImp = dynamic_cast<ScCellRangesBase*>( 
xInterface.get() );
     uno::Reference<drawing::XShapes> xShapeColl( xInterface, uno::UNO_QUERY );
     uno::Reference<drawing::XShape> xShapeSel( xInterface, uno::UNO_QUERY );
     SvxShape* pShapeImp = comphelper::getFromUnoTunnel<SvxShape>( xShapeSel );
@@ -1057,7 +1057,7 @@ void SAL_CALL ScTabViewObj::setActiveSheet( const 
uno::Reference<sheet::XSpreads
 
     //  XSpreadsheet and ScCellRangesBase -> has to be the same sheet
 
-    ScCellRangesBase* pRangesImp = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xActiveSheet );
+    ScCellRangesBase* pRangesImp = dynamic_cast<ScCellRangesBase*>( 
xActiveSheet.get() );
     if ( pRangesImp && pViewSh->GetViewData().GetDocShell() == 
pRangesImp->GetDocShell() )
     {
         const ScRangeList& rRanges = pRangesImp->GetRangeList();
diff --git a/sc/source/ui/vba/excelvbahelper.cxx 
b/sc/source/ui/vba/excelvbahelper.cxx
index f752234943c5..06661e45ca74 100644
--- a/sc/source/ui/vba/excelvbahelper.cxx
+++ b/sc/source/ui/vba/excelvbahelper.cxx
@@ -83,7 +83,7 @@ GetAutoFiltRange( const ScDocShell* pShell, sal_Int16 nSheet )
 
 ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& 
xRange )
 {
-    ScCellRangesBase* pScCellRangesBase = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xRange );
+    ScCellRangesBase* pScCellRangesBase = dynamic_cast<ScCellRangesBase*>( 
xRange.get() );
     if ( !pScCellRangesBase )
     {
         throw uno::RuntimeException("Failed to access underlying doc shell uno 
range object" );
diff --git a/sc/source/ui/vba/vbachartobjects.cxx 
b/sc/source/ui/vba/vbachartobjects.cxx
index cdc1d3d48362..968bae6878ea 100644
--- a/sc/source/ui/vba/vbachartobjects.cxx
+++ b/sc/source/ui/vba/vbachartobjects.cxx
@@ -103,7 +103,7 @@ ScVbaChartObjects::getChartObjectNames() const
     {
         // c++ hackery
         uno::Reference< uno::XInterface > xIf( xDrawPageSupplier, 
uno::UNO_QUERY_THROW );
-        ScCellRangesBase* pUno= comphelper::getFromUnoTunnel< ScCellRangesBase 
>( xIf );
+        ScCellRangesBase* pUno = dynamic_cast< ScCellRangesBase* >( xIf.get() 
);
         ScDocShell* pDocShell = nullptr;
         if ( !pUno )
             throw uno::RuntimeException("Failed to obtain the impl class from 
the drawpage" );
diff --git a/sc/source/ui/vba/vbaeventshelper.cxx 
b/sc/source/ui/vba/vbaeventshelper.cxx
index d412af36b466..199c5493ef0b 100644
--- a/sc/source/ui/vba/vbaeventshelper.cxx
+++ b/sc/source/ui/vba/vbaeventshelper.cxx
@@ -831,8 +831,8 @@ bool ScVbaEventsHelper::isSelectionChanged( const 
uno::Sequence< uno::Any >& rAr
 {
     uno::Reference< uno::XInterface > xOldSelection( maOldSelection, 
uno::UNO_QUERY );
     uno::Reference< uno::XInterface > xNewSelection = getXSomethingFromArgs< 
uno::XInterface >( rArgs, nIndex, false );
-    ScCellRangesBase* pOldCellRanges = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xOldSelection );
-    ScCellRangesBase* pNewCellRanges = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xNewSelection );
+    ScCellRangesBase* pOldCellRanges = dynamic_cast<ScCellRangesBase*>( 
xOldSelection.get() );
+    ScCellRangesBase* pNewCellRanges = dynamic_cast<ScCellRangesBase*>( 
xNewSelection.get() );
     bool bChanged = !pOldCellRanges || !pNewCellRanges || lclSelectionChanged( 
pOldCellRanges->GetRangeList(), pNewCellRanges->GetRangeList() );
     maOldSelection <<= xNewSelection;
     return bChanged;
diff --git a/sc/source/ui/vba/vbaformat.cxx b/sc/source/ui/vba/vbaformat.cxx
index 2de02da98d04..dfbc4d706c4c 100644
--- a/sc/source/ui/vba/vbaformat.cxx
+++ b/sc/source/ui/vba/vbaformat.cxx
@@ -796,7 +796,7 @@ template< typename... Ifc >
 ScCellRangesBase*
 ScVbaFormat< Ifc... >::getCellRangesBase()
 {
-    return comphelper::getFromUnoTunnel<ScCellRangesBase>( mxPropertySet );
+    return dynamic_cast<ScCellRangesBase*>( mxPropertySet.get() );
 }
 
 template< typename... Ifc >
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 4998942084ce..16d6d1456b3d 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -230,9 +230,9 @@ static uno::Reference< excel::XRange > 
lcl_makeXRangeFromSheetCellRanges( const
 ScCellRangesBase* ScVbaRange::getCellRangesBase()
 {
     if( mxRanges.is() )
-        return comphelper::getFromUnoTunnel<ScCellRangesBase>( mxRanges );
+        return dynamic_cast<ScCellRangesBase*>( mxRanges.get() );
     if( mxRange.is() )
-        return comphelper::getFromUnoTunnel<ScCellRangesBase>( mxRange );
+        return dynamic_cast<ScCellRangesBase*>( mxRange.get() );
     throw uno::RuntimeException("General Error creating range - Unknown" );
 }
 
@@ -366,7 +366,7 @@ ScVbaRangeAreas::createCollectionObject( const uno::Any& 
aSource )
 static ScDocShell*
 getDocShellFromIf( const uno::Reference< uno::XInterface >& xIf )
 {
-    ScCellRangesBase* pUno = comphelper::getFromUnoTunnel<ScCellRangesBase>( 
xIf );
+    ScCellRangesBase* pUno = dynamic_cast<ScCellRangesBase*>( xIf.get() );
     if ( !pUno )
             throw uno::RuntimeException("Failed to access underlying uno range 
object"  );
     return pUno->GetDocShell();
@@ -513,7 +513,7 @@ public:
     OUString getNumberFormatString()
     {
         uno::Reference< uno::XInterface > xIf( mxRangeProps, 
uno::UNO_QUERY_THROW );
-        ScCellRangesBase* pUnoCellRange = 
comphelper::getFromUnoTunnel<ScCellRangesBase>( xIf );
+        ScCellRangesBase* pUnoCellRange = dynamic_cast<ScCellRangesBase*>( 
xIf.get() );
         if ( pUnoCellRange )
         {
 
@@ -874,7 +874,7 @@ protected:
             {
                 uno::Reference< uno::XInterface > xIf( xCell, 
uno::UNO_QUERY_THROW );
                 ScCellRangesBase* pUnoRangesBase
-                    = comphelper::getFromUnoTunnel< ScCellRangesBase >( xIf );
+                    = dynamic_cast< ScCellRangesBase* >( xIf.get() );
                 if ( pUnoRangesBase )
                 {
                     const ScRangeList& rCellRanges = 
pUnoRangesBase->GetRangeList();
@@ -923,7 +923,7 @@ public:
         {
             uno::Reference< uno::XInterface > xIf( xCell, uno::UNO_QUERY_THROW 
);
             ScCellRangesBase* pUnoRangesBase
-                = comphelper::getFromUnoTunnel< ScCellRangesBase >( xIf );
+                = dynamic_cast< ScCellRangesBase* >( xIf.get() );
             if (pUnoRangesBase)
             {
                 OUString sVal;
@@ -1833,12 +1833,12 @@ ScVbaRange::HasFormula()
         return aResult;
     }
     uno::Reference< uno::XInterface > xIf( mxRange, uno::UNO_QUERY_THROW );
-    ScCellRangesBase* pThisRanges = comphelper::getFromUnoTunnel< 
ScCellRangesBase > ( xIf );
+    ScCellRangesBase* pThisRanges = dynamic_cast< ScCellRangesBase* > ( 
xIf.get() );
     if ( pThisRanges )
     {
         uno::Reference<uno::XInterface>  xRanges( 
pThisRanges->queryFormulaCells( sheet::FormulaResult::ERROR | 
sheet::FormulaResult::VALUE | sheet::FormulaResult::STRING ), 
uno::UNO_QUERY_THROW );
         ScCellRangesBase* pFormulaRanges
-            = comphelper::getFromUnoTunnel< ScCellRangesBase > ( xRanges );
+            = dynamic_cast< ScCellRangesBase* > ( xRanges.get() );
         assert(pFormulaRanges);
         // check if there are no formula cell, return false
         if ( pFormulaRanges->GetRangeList().empty() )
commit c04434a58407f76ab378b6a991b23f1aaf534f86
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sat Jan 21 20:57:23 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jan 23 07:27:43 2023 +0000

    XUnoTunnel->dynamic_cast in ScAutoFormatObj
    
    Change-Id: Id0910149f89e77de8b50b3892fccee789dd7aa2f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145981
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/inc/afmtuno.hxx b/sc/inc/afmtuno.hxx
index ae1b1a9a9330..6434a5073c0e 100644
--- a/sc/inc/afmtuno.hxx
+++ b/sc/inc/afmtuno.hxx
@@ -27,7 +27,6 @@
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/container/XNamed.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <comphelper/servicehelper.hxx>
 #include <cppuhelper/implbase.hxx>
 
@@ -89,7 +88,6 @@ class ScAutoFormatObj final : public ::cppu::WeakImplHelper<
                             css::container::XEnumerationAccess,
                             css::container::XNamed,
                             css::beans::XPropertySet,
-                            css::lang::XUnoTunnel,
                             css::lang::XServiceInfo >
 {
 private:
@@ -146,9 +144,6 @@ public:
     virtual OUString SAL_CALL getImplementationName() override;
     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
-
-                            // XUnoTunnel
-    UNO3_GETIMPLEMENTATION_DECL(ScAutoFormatObj)
 };
 
 class ScAutoFormatFieldObj final : public ::cppu::WeakImplHelper<
diff --git a/sc/source/ui/unoobj/afmtuno.cxx b/sc/source/ui/unoobj/afmtuno.cxx
index b26e38cd81b0..cc4fd1fe53ce 100644
--- a/sc/source/ui/unoobj/afmtuno.cxx
+++ b/sc/source/ui/unoobj/afmtuno.cxx
@@ -190,7 +190,7 @@ void SAL_CALL ScAutoFormatsObj::insertByName( const 
OUString& aName, const uno::
     uno::Reference< uno::XInterface > xInterface(aElement, uno::UNO_QUERY);
     if ( xInterface.is() )
     {
-        ScAutoFormatObj* pFormatObj = 
comphelper::getFromUnoTunnel<ScAutoFormatObj>( xInterface );
+        ScAutoFormatObj* pFormatObj = dynamic_cast<ScAutoFormatObj*>( 
xInterface.get() );
         if ( pFormatObj && !pFormatObj->IsInserted() )
         {
             ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
@@ -353,10 +353,6 @@ void ScAutoFormatObj::InitFormat( sal_uInt16 nNewIndex )
     nFormatIndex = nNewIndex;
 }
 
-// XUnoTunnel
-
-UNO3_GETIMPLEMENTATION_IMPL(ScAutoFormatObj);
-
 // XTableAutoFormat
 
 rtl::Reference<ScAutoFormatFieldObj> 
ScAutoFormatObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)

Reply via email to