sw/inc/unotextrange.hxx                         |   10 +---------
 sw/source/core/inc/unobookmark.hxx              |   10 +---------
 sw/source/core/unocore/unobkm.cxx               |   20 +++-----------------
 sw/source/core/unocore/unocontentcontrol.cxx    |    3 +--
 sw/source/core/unocore/unocrsrhelper.cxx        |    4 ++--
 sw/source/core/unocore/unodraw.cxx              |    2 +-
 sw/source/core/unocore/unofield.cxx             |    3 +--
 sw/source/core/unocore/unoframe.cxx             |    3 +--
 sw/source/core/unocore/unoftn.cxx               |    8 ++------
 sw/source/core/unocore/unoidx.cxx               |    7 ++-----
 sw/source/core/unocore/unoobj.cxx               |    3 +--
 sw/source/core/unocore/unoobj2.cxx              |   15 +--------------
 sw/source/core/unocore/unorefmk.cxx             |    7 ++-----
 sw/source/core/unocore/unosect.cxx              |    3 +--
 sw/source/core/unocore/unotbl.cxx               |    3 +--
 sw/source/core/unocore/unotext.cxx              |   24 +++++++-----------------
 sw/source/core/unocore/unotextmarkup.cxx        |    4 +---
 sw/source/filter/xml/XMLRedlineImportHelper.cxx |    6 ++----
 sw/source/uibase/uno/unoatxt.cxx                |   10 ++++------
 sw/source/uibase/uno/unotxdoc.cxx               |    3 +--
 sw/source/uibase/uno/unotxvw.cxx                |    3 +--
 21 files changed, 37 insertions(+), 114 deletions(-)

New commits:
commit 048dd914c251ef62d7cebf4d35ded3549bf42110
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Jan 19 10:12:30 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Jan 20 08:20:29 2023 +0000

    XUnoTunnel->dynamic_cast in SwXBookmark
    
    Change-Id: Iaf544314d0c47209b254c3bb40d35c03e6556f5a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145858
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sw/source/core/inc/unobookmark.hxx 
b/sw/source/core/inc/unobookmark.hxx
index aa3ef430387a..d1d800d9a28e 100644
--- a/sw/source/core/inc/unobookmark.hxx
+++ b/sw/source/core/inc/unobookmark.hxx
@@ -19,7 +19,6 @@
 
 #pragma once
 
-#include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/container/XNamed.hpp>
@@ -40,7 +39,6 @@ class SwXTextRange;
 
 typedef ::cppu::ImplInheritanceHelper
 <   ::sfx2::MetadatableMixin
-,   css::lang::XUnoTunnel
 ,   css::lang::XServiceInfo
 ,   css::beans::XPropertySet
 ,   css::container::XNamed
@@ -91,18 +89,12 @@ public:
 
     /// @return IMark for this, but only if it lives in pDoc
     static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc,
-            const css::uno::Reference<css::lang::XUnoTunnel> & xUT);
+            const css::uno::Reference<css::uno::XInterface> & xUT);
 
     // MetadatableMixin
     virtual ::sfx2::Metadatable* GetCoreObject() override;
     virtual css::uno::Reference< css::frame::XModel > GetModel() override;
 
-    static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
-
-    // XUnoTunnel
-    virtual sal_Int64 SAL_CALL getSomething(
-            const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
-
     // XServiceInfo
     virtual OUString SAL_CALL getImplementationName() override;
     virtual sal_Bool SAL_CALL supportsService(
diff --git a/sw/source/core/unocore/unobkm.cxx 
b/sw/source/core/unocore/unobkm.cxx
index 7eb1f4d05480..ed99a076244a 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -182,10 +182,9 @@ rtl::Reference<SwXBookmark> SwXBookmark::CreateXBookmark(
 }
 
 ::sw::mark::IMark const* SwXBookmark::GetBookmarkInDoc(SwDoc const*const pDoc,
-        const uno::Reference< lang::XUnoTunnel> & xUT)
+        const uno::Reference<uno::XInterface> & xUT)
 {
-    SwXBookmark *const pXBkm(
-            comphelper::getFromUnoTunnel<SwXBookmark>(xUT));
+    SwXBookmark *const pXBkm = dynamic_cast<SwXBookmark*>(xUT.get());
     if (pXBkm && (pDoc == pXBkm->m_pImpl->m_pDoc))
     {
         return pXBkm->m_pImpl->m_pRegisteredBookmark;
@@ -193,17 +192,6 @@ rtl::Reference<SwXBookmark> SwXBookmark::CreateXBookmark(
     return nullptr;
 }
 
-const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId()
-{
-    static const comphelper::UnoIdInit theSwXBookmarkUnoTunnelId;
-    return theSwXBookmarkUnoTunnelId.getSeq();
-}
-
-sal_Int64 SAL_CALL SwXBookmark::getSomething( const uno::Sequence< sal_Int8 >& 
rId )
-{
-    return comphelper::getSomethingImpl<SwXBookmark>(rId, this);
-}
-
 void SwXBookmark::attachToRangeEx(
     const uno::Reference< text::XTextRange > & xTextRange,
     IDocumentMarkAccess::MarkType eType,
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx 
b/sw/source/core/unocore/unocrsrhelper.cxx
index df73ee184c04..1e37c4015b1d 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -256,8 +256,8 @@ void GetSelectableFromAny(uno::Reference<uno::XInterface> 
const& xIfc,
         return;
     }
 
-    ::sw::mark::IMark const*const pMark(
-            SwXBookmark::GetBookmarkInDoc(& rTargetDoc, xTunnel));
+    ::sw::mark::IMark const*const pMark =
+            SwXBookmark::GetBookmarkInDoc(& rTargetDoc, xIfc);
     if (pMark)
     {
         o_rpMark = pMark;
diff --git a/sw/source/core/unocore/unotext.cxx 
b/sw/source/core/unocore/unotext.cxx
index 7193fe333843..81f731ba3026 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -573,7 +573,7 @@ SwXText::insertTextContent(
     SwXTextSection *const pSection =
         comphelper::getFromUnoTunnel<SwXTextSection>(xContentTunnel);
     SwXBookmark *const pBookmark =
-        comphelper::getFromUnoTunnel<SwXBookmark>(xContentTunnel);
+        dynamic_cast<SwXBookmark*>(xContent.get());
     SwXReferenceMark *const pReferenceMark =
         comphelper::getFromUnoTunnel<SwXReferenceMark>(xContentTunnel);
     SwXMeta *const pMeta =
commit 635448a996714a81cb15b41ac4bb0c73cabfb74f
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Jan 18 15:49:41 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Jan 20 08:20:20 2023 +0000

    XUnoTunnel->dynamic_cast in SwXTextRange
    
    Change-Id: I87e635f371278132be9da4e6a60ba90180d25522
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145857
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx
index b64712b5ba5a..a234d1092805 100644
--- a/sw/inc/unotextrange.hxx
+++ b/sw/inc/unotextrange.hxx
@@ -20,7 +20,6 @@
 #ifndef INCLUDED_SW_INC_UNOTEXTRANGE_HXX
 #define INCLUDED_SW_INC_UNOTEXTRANGE_HXX
 
-#include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/beans/XPropertyState.hpp>
@@ -76,8 +75,7 @@ namespace sw {
 } // namespace sw
 
 typedef ::cppu::WeakImplHelper
-<   css::lang::XUnoTunnel
-,   css::lang::XServiceInfo
+<   css::lang::XServiceInfo
 ,   css::beans::XPropertySet
 ,   css::beans::XPropertyState
 ,   css::container::XEnumerationAccess
@@ -133,12 +131,6 @@ public:
             SwDoc & rDoc,
             const SwPosition& rPos, const SwPosition *const pMark);
 
-    static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
-
-    // XUnoTunnel
-    virtual sal_Int64 SAL_CALL getSomething(
-            const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
-
     // XServiceInfo
     virtual OUString SAL_CALL getImplementationName() override;
     virtual sal_Bool SAL_CALL supportsService(
diff --git a/sw/source/core/unocore/unobkm.cxx 
b/sw/source/core/unocore/unobkm.cxx
index 6faab283f787..7eb1f4d05480 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -214,9 +214,7 @@ void SwXBookmark::attachToRangeEx(
         throw uno::RuntimeException();
     }
 
-    const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
-            xTextRange, uno::UNO_QUERY);
-    SwXTextRange* pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+    SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
     OTextCursorHelper* pCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
 
     SwDoc *const pDoc =
diff --git a/sw/source/core/unocore/unocontentcontrol.cxx 
b/sw/source/core/unocore/unocontentcontrol.cxx
index 6d07645df66a..ceb7a2933dd5 100644
--- a/sw/source/core/unocore/unocontentcontrol.cxx
+++ b/sw/source/core/unocore/unocontentcontrol.cxx
@@ -437,8 +437,7 @@ void SwXContentControl::AttachImpl(const 
uno::Reference<text::XTextRange>& xText
                                     static_cast<::cppu::OWeakObject*>(this));
     }
 
-    uno::Reference<lang::XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
-    SwXTextRange* pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+    SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
     OTextCursorHelper* pCursor
         = pRange ? nullptr : 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
     if (!pRange && !pCursor)
diff --git a/sw/source/core/unocore/unodraw.cxx 
b/sw/source/core/unocore/unodraw.cxx
index a11dff3a87cc..add34e200e7b 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1987,7 +1987,7 @@ void SwXShape::attach(const uno::Reference< 
text::XTextRange > & xTextRange)
     // (see also SwXTextRange::XTextRangeToSwPaM)
     const SwDoc* pDoc = nullptr;
     uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
-    if (auto pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel))
+    if (auto pRange = dynamic_cast<SwXTextRange*>(xTextRange.get()))
         pDoc = &pRange->GetDoc();
     else if (auto pText = dynamic_cast<SwXText*>(xTextRange.get()))
         pDoc = pText->GetDoc();
diff --git a/sw/source/core/unocore/unofield.cxx 
b/sw/source/core/unocore/unofield.cxx
index abbde27a3d69..ffb0fa8bd9f8 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1350,8 +1350,7 @@ void SAL_CALL SwXTextField::attach(
     SolarMutexGuard aGuard;
     if (m_pImpl->IsDescriptor())
     {
-        uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, 
uno::UNO_QUERY);
-        SwXTextRange* pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+        SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
         OTextCursorHelper* pCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
 
         SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() 
: nullptr;
diff --git a/sw/source/core/unocore/unoframe.cxx 
b/sw/source/core/unocore/unoframe.cxx
index b81ba90f40d9..908f85a33e73 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -2724,8 +2724,7 @@ void 
SwXFrame::attachToRange(uno::Reference<text::XTextRange> const& xTextRange,
     SolarMutexGuard aGuard;
     if(!IsDescriptor())
         throw uno::RuntimeException();
-    uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
-    SwXTextRange* pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+    SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
     OTextCursorHelper* pCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
 
     SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : 
nullptr;
diff --git a/sw/source/core/unocore/unoftn.cxx 
b/sw/source/core/unocore/unoftn.cxx
index f27b8aa5ca80..c4ff75fec2f8 100644
--- a/sw/source/core/unocore/unoftn.cxx
+++ b/sw/source/core/unocore/unoftn.cxx
@@ -278,12 +278,8 @@ SwXFootnote::attach(const uno::Reference< text::XTextRange 
> & xTextRange)
     {
         throw uno::RuntimeException();
     }
-    const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
-            xTextRange, uno::UNO_QUERY);
-    SwXTextRange *const pRange =
-        comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
-    OTextCursorHelper *const pCursor =
-        dynamic_cast<OTextCursorHelper*>(xTextRange.get());
+    SwXTextRange *const pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
+    OTextCursorHelper *const pCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
     SwDoc *const pNewDoc =
         pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr);
     if (!pNewDoc)
diff --git a/sw/source/core/unocore/unoidx.cxx 
b/sw/source/core/unocore/unoidx.cxx
index c03227062e69..736f25200022 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -1288,9 +1288,7 @@ SwXDocumentIndex::attach(const uno::Reference< 
text::XTextRange > & xTextRange)
     {
         throw uno::RuntimeException();
     }
-    const uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
-    SwXTextRange *const pRange =
-        comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+    SwXTextRange *const pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
     OTextCursorHelper *const pCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
 
     SwDoc *const pDoc =
@@ -1756,9 +1754,8 @@ SwXDocumentIndexMark::attach(
         throw uno::RuntimeException();
     }
 
-    const uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
     SwXTextRange *const pRange =
-        comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+        dynamic_cast<SwXTextRange*>(xTextRange.get());
     OTextCursorHelper *const pCursor =
         dynamic_cast<OTextCursorHelper*>(xTextRange.get());
     SwDoc *const pDoc =
diff --git a/sw/source/core/unocore/unoobj.cxx 
b/sw/source/core/unocore/unoobj.cxx
index 4d50250341bf..7ef11b9462ab 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -1192,8 +1192,7 @@ SwXTextCursor::gotoRange(
 
     SwUnoCursor & rOwnCursor( GetCursorOrThrow() );
 
-    uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
-    SwXTextRange* pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+    SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xRange.get());
     OTextCursorHelper* pCursor = 
dynamic_cast<OTextCursorHelper*>(xRange.get());
 
     if (!pRange && !pCursor)
diff --git a/sw/source/core/unocore/unoobj2.cxx 
b/sw/source/core/unocore/unoobj2.cxx
index 75461d29f549..6983704ac2d2 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -901,19 +901,6 @@ void SwXTextRange::DeleteAndInsert(
     m_pImpl->m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
 }
 
-const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId()
-{
-    static const comphelper::UnoIdInit theSwXTextRangeUnoTunnelId;
-    return theSwXTextRangeUnoTunnelId.getSeq();
-}
-
-// XUnoTunnel
-sal_Int64 SAL_CALL
-SwXTextRange::getSomething(const uno::Sequence< sal_Int8 >& rId)
-{
-    return comphelper::getSomethingImpl<SwXTextRange>(rId, this);
-}
-
 OUString SAL_CALL
 SwXTextRange::getImplementationName()
 {
@@ -1107,7 +1094,7 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill,
     bool bRet = false;
 
     uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
-    SwXTextRange* pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+    SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
     OTextCursorHelper* pCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
     SwXTextPortion* pPortion = 
comphelper::getFromUnoTunnel<SwXTextPortion>(xRangeTunnel);
     SwXText* pText = dynamic_cast<SwXText*>(xTextRange.get());
diff --git a/sw/source/core/unocore/unorefmk.cxx 
b/sw/source/core/unocore/unorefmk.cxx
index 623710f3e374..d2af2e8eaf3f 100644
--- a/sw/source/core/unocore/unorefmk.cxx
+++ b/sw/source/core/unocore/unorefmk.cxx
@@ -270,8 +270,7 @@ SwXReferenceMark::attach(const uno::Reference< 
text::XTextRange > & xTextRange)
     {
         throw uno::RuntimeException();
     }
-    uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
-    SwXTextRange* pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+    SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
     OTextCursorHelper* pCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
     SwDoc *const pDocument =
         pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr);
@@ -936,9 +935,7 @@ SwXMeta::AttachImpl(const uno::Reference< text::XTextRange 
> & i_xTextRange,
             static_cast< ::cppu::OWeakObject* >(this));
     }
 
-    uno::Reference<lang::XUnoTunnel> xRangeTunnel(i_xTextRange, 
uno::UNO_QUERY);
-    SwXTextRange *const pRange(
-            comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel));
+    SwXTextRange *const 
pRange(dynamic_cast<SwXTextRange*>(i_xTextRange.get()));
     OTextCursorHelper *const 
pCursor(dynamic_cast<OTextCursorHelper*>(i_xTextRange.get()));
     if (!pRange && !pCursor)
     {
diff --git a/sw/source/core/unocore/unosect.cxx 
b/sw/source/core/unocore/unosect.cxx
index 990c561800ef..5bb3ff0c119d 100644
--- a/sw/source/core/unocore/unosect.cxx
+++ b/sw/source/core/unocore/unosect.cxx
@@ -279,8 +279,7 @@ SwXTextSection::attach(const uno::Reference< 
text::XTextRange > & xTextRange)
         throw uno::RuntimeException();
     }
 
-    uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
-    SwXTextRange* pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+    SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
     OTextCursorHelper* pCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
 
     SwDoc *const pDoc =
diff --git a/sw/source/core/unocore/unotbl.cxx 
b/sw/source/core/unocore/unotbl.cxx
index 0aaedfa8b8d3..acf41120f3ce 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2060,8 +2060,7 @@ SwXTextTable::attach(const 
uno::Reference<text::XTextRange> & xTextRange)
     if (!m_pImpl->IsDescriptor())  /* already attached ? */
         throw uno::RuntimeException("SwXTextTable: already attached to 
range.", static_cast<cppu::OWeakObject*>(this));
 
-    uno::Reference<lang::XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
-    SwXTextRange* 
pRange(comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel));
+    SwXTextRange* pRange(dynamic_cast<SwXTextRange*>(xTextRange.get()));
     OTextCursorHelper* 
pCursor(dynamic_cast<OTextCursorHelper*>(xTextRange.get()));
     SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : 
nullptr;
     if (!pDoc || !m_pImpl->m_nRows || !m_pImpl->m_nColumns)
diff --git a/sw/source/core/unocore/unotext.cxx 
b/sw/source/core/unocore/unotext.cxx
index 52df5295dea7..7193fe333843 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -293,10 +293,7 @@ SwXText::insertString(const uno::Reference< 
text::XTextRange >& xTextRange,
     {
         throw uno::RuntimeException();
     }
-    const uno::Reference<lang::XUnoTunnel> xRangeTunnel(xTextRange,
-            uno::UNO_QUERY);
-    SwXTextRange *const pRange =
-        comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+    SwXTextRange *const pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
     OTextCursorHelper *const pCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
     if ((!pRange  || &pRange ->GetDoc() != GetDoc()) &&
         (!pCursor || pCursor->GetDoc() != GetDoc()))
@@ -432,10 +429,8 @@ SwXText::insertControlCharacter(
             m_pImpl->m_pDoc->ClearBoxNumAttrs(aPam.GetPoint()->GetNode());
             
m_pImpl->m_pDoc->getIDocumentContentOperations().AppendTextNode(*aPam.GetPoint());
 
-            const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
-                    xTextRange, uno::UNO_QUERY);
             SwXTextRange *const pRange =
-                comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+                dynamic_cast<SwXTextRange*>(xTextRange.get());
             OTextCursorHelper *const pCursor =
                 dynamic_cast<OTextCursorHelper*>(xTextRange.get());
             if (pRange)
@@ -464,10 +459,8 @@ SwXText::insertControlCharacter(
     if (!bAbsorb)
         return;
 
-    const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
-            xTextRange, uno::UNO_QUERY);
     SwXTextRange *const pRange =
-        comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+        dynamic_cast<SwXTextRange*>(xTextRange.get());
     OTextCursorHelper *const pCursor =
         dynamic_cast<OTextCursorHelper*>(xTextRange.get());
 
@@ -596,8 +589,7 @@ SwXText::insertTextContent(
 
     if (bAbsorb && !bAttribute)
     {
-        uno::Reference<lang::XUnoTunnel> const xRangeTunnel(xRange, 
uno::UNO_QUERY);
-        if (SwXTextRange *const pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel))
+        if (SwXTextRange *const pRange = 
dynamic_cast<SwXTextRange*>(xRange.get()))
         {
             pRange->DeleteAndInsert(u"", 
::sw::DeleteAndInsertMode::ForceReplace
                 | (bForceExpandHints ? 
::sw::DeleteAndInsertMode::ForceExpandHints : 
::sw::DeleteAndInsertMode::Default));
@@ -1550,10 +1542,8 @@ SwXText::convertToTextFrame(
     }
     pTempStartPam.reset();
 
-    SwXTextRange *const pStartRange =
-        comphelper::getFromUnoTunnel<SwXTextRange>(xStart);
-    SwXTextRange *const pEndRange   =
-        comphelper::getFromUnoTunnel<SwXTextRange>(xEnd);
+    SwXTextRange *const pStartRange = 
dynamic_cast<SwXTextRange*>(xStart.get());
+    SwXTextRange *const pEndRange   = dynamic_cast<SwXTextRange*>(xEnd.get());
     // bookmarks have to be removed before the referenced text node
     // is deleted in DelFullPara
     if (pStartRange)
diff --git a/sw/source/core/unocore/unotextmarkup.cxx 
b/sw/source/core/unocore/unotextmarkup.cxx
index 2aa8aef7322f..4bbc8601608d 100644
--- a/sw/source/core/unocore/unotextmarkup.cxx
+++ b/sw/source/core/unocore/unotextmarkup.cxx
@@ -99,9 +99,7 @@ void SAL_CALL 
SwXTextMarkup::commitTextRangeMarkup(::sal_Int32 nType, const OUSt
 {
     SolarMutexGuard aGuard;
 
-    uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
-
-    if (auto pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel))
+    if (auto pRange = dynamic_cast<SwXTextRange*>(xRange.get()))
     {
         SwDoc& rDoc = pRange->GetDoc();
 
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx 
b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
index d5848ea4e65a..a78a7e484e1a 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
@@ -68,10 +68,8 @@ static SwDoc* lcl_GetDocViaTunnel( Reference<XTextCursor> 
const & rCursor )
 
 static SwDoc* lcl_GetDocViaTunnel( Reference<XTextRange> const & rRange )
 {
-    Reference<XUnoTunnel> xTunnel(rRange, UNO_QUERY);
-    OSL_ENSURE(xTunnel.is(), "missing XUnoTunnel for XTextRange");
-    SwXTextRange *const pXRange =
-        comphelper::getFromUnoTunnel<SwXTextRange>(xTunnel);
+    SwXTextRange *const pXRange = dynamic_cast<SwXTextRange*>(rRange.get());
+    OSL_ENSURE(pXRange, "missing SwXTextRange for XTextRange");
     // #i115174#: this may be a SvxUnoTextRange
     // OSL_ENSURE( pXRange, "SwXTextRange missing" );
     return pXRange ? &pXRange->GetDoc() : nullptr;
diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx
index f1358df6b4d8..a3960425ad29 100644
--- a/sw/source/uibase/uno/unoatxt.cxx
+++ b/sw/source/uibase/uno/unoatxt.cxx
@@ -329,8 +329,7 @@ uno::Reference< text::XAutoTextEntry >  
SwXAutoTextGroup::insertNewByName(const
     const OUString& sLongName(aTitle);
     if (pGlosGroup && !pGlosGroup->GetError())
     {
-        uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, 
uno::UNO_QUERY);
-        SwXTextRange* pxRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+        SwXTextRange* pxRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
         OTextCursorHelper* pxCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
 
         OUString sOnlyText;
@@ -850,10 +849,9 @@ void SwXAutoTextEntry::applyTo(const uno::Reference< 
text::XTextRange > & xTextR
 
     // The reference to xKeepAlive is needed during the whole call, likely 
because it could be a
     // different object, not xTextRange itself, and the reference guards it 
from preliminary death
-    uno::Reference<text::XTextRange> xKeepAlive( xTextRange );
-    uno::Reference<lang::XUnoTunnel> xTunnel( xTextRange, uno::UNO_QUERY);
-    SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xTunnel);
-    OTextCursorHelper* pCursor = 
dynamic_cast<OTextCursorHelper*>(xKeepAlive.get());
+    auto xKeepAlive( xTextRange );
+    SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
+    OTextCursorHelper* pCursor = 
dynamic_cast<OTextCursorHelper*>(xTextRange.get());
     SwXText *pText = dynamic_cast<SwXText*>(xTextRange.get());
 
     SwDoc* pDoc = nullptr;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index b19827e1ad74..abc6fb9bbc80 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -787,8 +787,7 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< 
util::XSearchDescriptor >
         }
         else
         {
-            Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY);
-            SwXTextRange* pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xCursorTunnel);
+            SwXTextRange* pRange = 
dynamic_cast<SwXTextRange*>(xLastResult.get());
             if(!pRange)
                 return nullptr;
             pRange->GetPositions(*pUnoCursor);
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index 953b430a4314..ec07edbf16ae 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -988,8 +988,7 @@ void SwXTextViewCursor::gotoRange(
         *aOwnPaM.GetMark() = *pShellCursor->GetMark();
     }
 
-    uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
-    SwXTextRange* pRange = 
comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
+    SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xRange.get());
     SwXParagraph* pPara = dynamic_cast<SwXParagraph*>(xRange.get());
     OTextCursorHelper* pCursor = 
dynamic_cast<OTextCursorHelper*>(xRange.get());
 

Reply via email to