sfx2/inc/unoctitm.hxx | 7 +------ sfx2/source/control/bindings.cxx | 11 +++-------- sfx2/source/control/sfxstatuslistener.cxx | 3 +-- sfx2/source/control/statcach.cxx | 3 +-- sfx2/source/control/unoctitm.cxx | 14 -------------- sfx2/source/statbar/stbitem.cxx | 3 +-- sfx2/source/toolbox/tbxitem.cxx | 3 +-- 7 files changed, 8 insertions(+), 36 deletions(-)
New commits: commit 3fdfee3268aeae5c9a06527c0f973d258c2188c6 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jan 17 09:48:10 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 17 16:10:45 2023 +0000 XUnoTunnel->dynamic_cast in SfxOfficeDispatch Change-Id: Ie1aa51a873d1e80a15cddf6220f23a6cf4d090c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145671 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sfx2/inc/unoctitm.hxx b/sfx2/inc/unoctitm.hxx index 812dbce7077d..d23b8c9fd714 100644 --- a/sfx2/inc/unoctitm.hxx +++ b/sfx2/inc/unoctitm.hxx @@ -20,7 +20,6 @@ #include <memory> #include <com/sun/star/frame/XNotifyingDispatch.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <comphelper/multiinterfacecontainer4.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/weakref.hxx> @@ -67,7 +66,7 @@ public: class SfxSlotServer; class SfxDispatchController_Impl; -class SfxOfficeDispatch final : public cppu::ImplInheritanceHelper<SfxStatusDispatcher, css::lang::XUnoTunnel> +class SfxOfficeDispatch final : public cppu::ImplInheritanceHelper<SfxStatusDispatcher> { friend class SfxDispatchController_Impl; std::unique_ptr<SfxDispatchController_Impl> pImpl; @@ -89,10 +88,6 @@ public: virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) override; - // XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override ; - static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); - static bool IsMasterUnoCommand( const css::util::URL& aURL ); static OUString GetMasterUnoCommand( const css::util::URL& aURL ); diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 4ea06231562a..51d6b36d237f 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -1529,7 +1529,7 @@ SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, std::unique_ptr<SfxPoolI if ( xDisp.is() ) { - if (!comphelper::getFromUnoTunnel<SfxOfficeDispatch>(xDisp)) + if (!dynamic_cast<SfxOfficeDispatch*>(xDisp.get())) { bool bDeleteCache = false; if ( !pCache ) @@ -1648,15 +1648,10 @@ sal_uInt16 SfxBindings::QuerySlotId( const util::URL& aURL ) if (!xDispatch.is()) return 0; - css::uno::Reference<css::lang::XUnoTunnel> xTunnel(xDispatch, css::uno::UNO_QUERY); - if (!xTunnel.is()) + SfxOfficeDispatch* pDispatch = dynamic_cast<SfxOfficeDispatch*>(xDispatch.get()); + if (!pDispatch) return 0; - sal_Int64 nHandle = xTunnel->getSomething(SfxOfficeDispatch::getUnoTunnelId()); - if (!nHandle) - return 0; - - SfxOfficeDispatch* pDispatch = reinterpret_cast<SfxOfficeDispatch*>(sal::static_int_cast<sal_IntPtr>(nHandle)); return pDispatch->GetId(); } diff --git a/sfx2/source/control/sfxstatuslistener.cxx b/sfx2/source/control/sfxstatuslistener.cxx index 5ee3d471f21a..7cc4e8dd688b 100644 --- a/sfx2/source/control/sfxstatuslistener.cxx +++ b/sfx2/source/control/sfxstatuslistener.cxx @@ -142,8 +142,7 @@ void SAL_CALL SfxStatusListener::statusChanged( const FeatureStateEvent& rEvent) SfxViewFrame* pViewFrame = nullptr; if ( m_xDispatch.is() ) { - Reference< XUnoTunnel > xTunnel( m_xDispatch, UNO_QUERY ); - if (auto pDisp = comphelper::getFromUnoTunnel<SfxOfficeDispatch>(xTunnel)) + if (auto pDisp = dynamic_cast<SfxOfficeDispatch*>(m_xDispatch.get())) pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame(); } diff --git a/sfx2/source/control/statcach.cxx b/sfx2/source/control/statcach.cxx index 3360ebbabfdf..ee20d38c5d81 100644 --- a/sfx2/source/control/statcach.cxx +++ b/sfx2/source/control/statcach.cxx @@ -263,8 +263,7 @@ const SfxSlotServer* SfxStateCache::GetSlotServer( SfxDispatcher &rDispat , cons if ( xDisp.is() ) { // test the dispatch object if it is just a wrapper for a SfxDispatcher - css::uno::Reference< css::lang::XUnoTunnel > xTunnel( xDisp, css::uno::UNO_QUERY ); - if (auto pDisp = comphelper::getFromUnoTunnel<SfxOfficeDispatch>(xTunnel)) + if (auto pDisp = dynamic_cast<SfxOfficeDispatch*>(xDisp.get())) { // The intercepting object is an SFX component // If this dispatch object does not use the wanted dispatcher or the AppDispatcher, it's treated like any other UNO component diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 20934ecf8f56..bcee2360e268 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -173,12 +173,6 @@ void SAL_CALL SfxStatusDispatcher::removeStatusListener( const css::uno::Referen } -// XUnoTunnel -sal_Int64 SAL_CALL SfxOfficeDispatch::getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) -{ - return comphelper::getSomethingImpl(aIdentifier, this); -} - SfxOfficeDispatch::SfxOfficeDispatch( SfxBindings& rBindings, SfxDispatcher* pDispat, const SfxSlot* pSlot, const css::util::URL& rURL ) : pImpl( new SfxDispatchController_Impl( this, &rBindings, pDispat, pSlot, rURL )) { @@ -206,14 +200,6 @@ SfxOfficeDispatch::~SfxOfficeDispatch() } } -const css::uno::Sequence< sal_Int8 >& SfxOfficeDispatch::getUnoTunnelId() -{ - // {38 57 CA 80 09 36 11 d4 83 FE 00 50 04 52 6B 21} - static const sal_uInt8 pGUID[16] = { 0x38, 0x57, 0xCA, 0x80, 0x09, 0x36, 0x11, 0xd4, 0x83, 0xFE, 0x00, 0x50, 0x04, 0x52, 0x6B, 0x21 }; - static css::uno::Sequence< sal_Int8 > seqID(reinterpret_cast<const sal_Int8*>(pGUID), 16) ; - return seqID ; -} - #if HAVE_FEATURE_JAVA // The JavaContext contains an interaction handler which is used when // the creation of a Java Virtual Machine fails. There shall only be one diff --git a/sfx2/source/statbar/stbitem.cxx b/sfx2/source/statbar/stbitem.cxx index c48fc970efa7..d1b1ed58b905 100644 --- a/sfx2/source/statbar/stbitem.cxx +++ b/sfx2/source/statbar/stbitem.cxx @@ -184,8 +184,7 @@ void SAL_CALL SfxStatusBarControl::statusChanged( const frame::FeatureStateEvent uno::Reference < frame::XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, OUString(), 0 ); if ( xDisp.is() ) { - uno::Reference< lang::XUnoTunnel > xTunnel( xDisp, uno::UNO_QUERY ); - if (auto pDisp = comphelper::getFromUnoTunnel<SfxOfficeDispatch>(xTunnel)) + if (auto pDisp = dynamic_cast<SfxOfficeDispatch*>(xDisp.get())) pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame(); } } diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index e61503f94bab..70bd2b2762de 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -293,8 +293,7 @@ void SAL_CALL SfxToolBoxControl::statusChanged( const FeatureStateEvent& rEvent Reference < XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, OUString(), 0 ); if ( xDisp.is() ) { - Reference< XUnoTunnel > xTunnel( xDisp, UNO_QUERY ); - if (auto pDisp = comphelper::getFromUnoTunnel<SfxOfficeDispatch>(xTunnel)) + if (auto pDisp = dynamic_cast<SfxOfficeDispatch*>(xDisp.get())) pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame(); } }