sw/inc/unosett.hxx                       |   10 ++--------
 sw/inc/unosrch.hxx                       |    9 +--------
 sw/source/core/unocore/unocrsrhelper.cxx |    2 +-
 sw/source/core/unocore/unosett.cxx       |   16 ----------------
 sw/source/core/unocore/unosrch.cxx       |   11 -----------
 sw/source/core/unocore/unostyle.cxx      |    6 +++---
 sw/source/uibase/uno/unotxdoc.cxx        |    5 ++---
 sw/source/uibase/utlui/uiitems.cxx       |    2 +-
 8 files changed, 10 insertions(+), 51 deletions(-)

New commits:
commit bc87e206f4201cbd3d4df8f14355fb29643768f7
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Jan 18 15:13:06 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Jan 19 17:56:04 2023 +0000

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

diff --git a/sw/inc/unosrch.hxx b/sw/inc/unosrch.hxx
index ac8623160fa0..169903764377 100644
--- a/sw/inc/unosrch.hxx
+++ b/sw/inc/unosrch.hxx
@@ -21,7 +21,6 @@
 
 #include <com/sun/star/util/XPropertyReplace.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <cppuhelper/implbase.hxx>
 #include <rtl/ustring.hxx>
 #include <memory>
@@ -37,8 +36,7 @@ namespace i18nutil {
 class SwXTextSearch final : public cppu::WeakImplHelper
 <
     css::util::XPropertyReplace,
-    css::lang::XServiceInfo,
-    css::lang::XUnoTunnel
+    css::lang::XServiceInfo
 >
 {
     friend class SwXTextDocument;
@@ -68,11 +66,6 @@ class SwXTextSearch final : public cppu::WeakImplHelper
 public:
     SwXTextSearch();
 
-    static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
-
-    //XUnoTunnel
-    virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< 
sal_Int8 >& aIdentifier ) override;
-
     //XSearchDescriptor
     virtual OUString SAL_CALL getSearchString(  ) override;
     virtual void SAL_CALL setSearchString( const OUString& aString ) override;
diff --git a/sw/source/core/unocore/unosrch.cxx 
b/sw/source/core/unocore/unosrch.cxx
index ee260c077b61..e7684861b5c9 100644
--- a/sw/source/core/unocore/unosrch.cxx
+++ b/sw/source/core/unocore/unosrch.cxx
@@ -346,17 +346,6 @@ namespace
 {
 }
 
-const uno::Sequence< sal_Int8 > & SwXTextSearch::getUnoTunnelId()
-{
-    static const comphelper::UnoIdInit theSwXTextSearchUnoTunnelId;
-    return theSwXTextSearchUnoTunnelId.getSeq();
-}
-
-sal_Int64 SAL_CALL SwXTextSearch::getSomething( const uno::Sequence< sal_Int8 
>& rId )
-{
-    return comphelper::getSomethingImpl(rId, this);
-}
-
 OUString SwXTextSearch::getSearchString()
 {
     SolarMutexGuard aGuard;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 6b5b52d105dd..b19827e1ad74 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -696,9 +696,8 @@ SwUnoCursor* 
SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & x
 sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor 
> & xDesc)
 {
     SolarMutexGuard aGuard;
-    Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY_THROW);
     SwXTextSearch* pSearch;
-    if (!IsValid() || !(pSearch = 
comphelper::getFromUnoTunnel<SwXTextSearch>(xDescTunnel)))
+    if (!IsValid() || !(pSearch = dynamic_cast<SwXTextSearch*>(xDesc.get())))
         throw DisposedException("", static_cast< XTextDocument* >(this));
 
     Reference< XTextCursor >  xCursor;
@@ -770,7 +769,7 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< 
util::XSearchDescriptor >
                                      sal_Int32& nResult,
                                      Reference< XInterface > const & 
xLastResult)
 {
-    const auto pSearch = comphelper::getFromUnoTunnel<SwXTextSearch>(xDesc);
+    const auto pSearch = dynamic_cast<SwXTextSearch*>(xDesc.get());
     if(!IsValid() || !pSearch)
         return nullptr;
 
commit 9ebf0023e663b18f06631dbd4fd5782a626c2458
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Jan 18 12:45:10 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Jan 19 17:55:53 2023 +0000

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

diff --git a/sw/inc/unosett.hxx b/sw/inc/unosett.hxx
index fcaed54b1bfe..590046b97412 100644
--- a/sw/inc/unosett.hxx
+++ b/sw/inc/unosett.hxx
@@ -26,12 +26,11 @@
 #include "swtypes.hxx"
 #include <com/sun/star/text/XTextColumns.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <com/sun/star/container/XIndexReplace.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/container/XNamed.hpp>
 #include <cppuhelper/implbase2.hxx>
-#include <cppuhelper/implbase5.hxx>
+#include <cppuhelper/implbase4.hxx>
 #include "unobaseclass.hxx"
 
 class SwDoc;
@@ -132,10 +131,9 @@ public:
     void            Invalidate() {m_pDoc = nullptr;}
 };
 
-class SwXNumberingRules : public cppu::WeakAggImplHelper5
+class SwXNumberingRules : public cppu::WeakAggImplHelper4
 <
     css::container::XIndexReplace,
-    css::lang::XUnoTunnel,
     css::beans::XPropertySet,
     css::container::XNamed,
     css::lang::XServiceInfo
@@ -161,10 +159,6 @@ public:
     SwXNumberingRules(const SwNumRule& rRule, SwDoc* doc = nullptr); // 
NumRule for paragraphs, numbering styles
     SwXNumberingRules(SwDoc& rDoc); //create a new instance
 
-    static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
-
-    virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< 
sal_Int8 >& aIdentifier ) override;
-
     //XIndexReplace
     virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const 
css::uno::Any& Element ) override;
 
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx 
b/sw/source/core/unocore/unocrsrhelper.cxx
index 18e8ddb54dd6..830b53f4be39 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -834,7 +834,7 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam)
     uno::Reference<XIndexReplace> xIndexReplace;
     if(rValue >>= xIndexReplace)
     {
-        auto pSwNum = 
comphelper::getFromUnoTunnel<SwXNumberingRules>(xIndexReplace);
+        auto pSwNum = dynamic_cast<SwXNumberingRules*>(xIndexReplace.get());
         if(pSwNum)
         {
             SwDoc& rDoc = rPam.GetDoc();
diff --git a/sw/source/core/unocore/unosett.cxx 
b/sw/source/core/unocore/unosett.cxx
index de51da9b3e9d..43dd2cbe2ffa 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -996,22 +996,6 @@ bool SwXNumberingRules::isInvalidStyle(std::u16string_view 
rName)
     return rName == aInvalidStyle;
 }
 
-namespace
-{
-}
-
-const uno::Sequence< sal_Int8 > & SwXNumberingRules::getUnoTunnelId()
-{
-    static const comphelper::UnoIdInit theSwXNumberingRulesUnoTunnelId;
-    return theSwXNumberingRulesUnoTunnelId.getSeq();
-}
-
-// return implementation specific data
-sal_Int64 SwXNumberingRules::getSomething( const uno::Sequence< sal_Int8 > & 
rId )
-{
-    return comphelper::getSomethingImpl(rId, this);
-}
-
 OUString SwXNumberingRules::getImplementationName()
 {
     return "SwXNumberingRules";
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index f77f72bdf2e7..8de642fcc034 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1701,10 +1701,10 @@ void 
SwXStyle::SetPropertyValue<sal_uInt16(RES_PAPER_BIN)>(const SfxItemProperty
 template<>
 void SwXStyle::SetPropertyValue<FN_UNO_NUM_RULES>(const 
SfxItemPropertyMapEntry&, const SfxItemPropertySet&, const uno::Any& rValue, 
SwStyleBase_Impl& o_rStyleBase)
 {
-    if(!rValue.has<uno::Reference<container::XIndexReplace>>() || 
!rValue.has<uno::Reference<lang::XUnoTunnel>>())
+    auto xNumberTunnel(rValue.get<uno::Reference<container::XIndexReplace>>());
+    if(!xNumberTunnel)
         throw lang::IllegalArgumentException();
-    auto xNumberTunnel(rValue.get<uno::Reference<lang::XUnoTunnel>>());
-    SwXNumberingRules* pSwXRules = 
comphelper::getFromUnoTunnel<SwXNumberingRules>(xNumberTunnel);
+    SwXNumberingRules* pSwXRules = 
dynamic_cast<SwXNumberingRules*>(xNumberTunnel.get());
     if(!pSwXRules)
         return;
     SwNumRule aSetRule(*pSwXRules->GetNumRule());
diff --git a/sw/source/uibase/utlui/uiitems.cxx 
b/sw/source/uibase/utlui/uiitems.cxx
index 492e8eb6ce23..b88751abdddb 100644
--- a/sw/source/uibase/utlui/uiitems.cxx
+++ b/sw/source/uibase/utlui/uiitems.cxx
@@ -248,7 +248,7 @@ bool SwUINumRuleItem::PutValue( const uno::Any& rVal, 
sal_uInt8 /*nMemberId*/ )
     uno::Reference< container::XIndexReplace> xRulesRef;
     if(rVal >>= xRulesRef)
     {
-        auto pSwXRules = 
comphelper::getFromUnoTunnel<SwXNumberingRules>(xRulesRef);
+        auto pSwXRules = dynamic_cast<SwXNumberingRules*>(xRulesRef.get());
         if(pSwXRules)
         {
             *m_pRule = *pSwXRules->GetNumRule();

Reply via email to