diff options
author | Henry Castro <hcastro@collabora.com> | 2021-10-04 14:14:32 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-02-20 12:24:37 +0100 |
commit | 72f55df23f3ccccffba597b3a529b7b0a6c1b388 (patch) | |
tree | 5b06c41b3fddc8cad5e2b678541243c6886b43e9 /sfx2 | |
parent | f7d274026fbf6443ce3673432c384ce158ecc355 (diff) |
sfx2: introduce SfxBindings::QuerySlotId
In order to invoke QueryState with the slot id,
which it is easier to invoke UNO command states in unit test.
Change-Id: I36d72a4381ff8386b1f1af33284ce674cf26acd1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123063
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129464
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/unoctitm.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/bindings.cxx | 22 | ||||
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 5 |
3 files changed, 29 insertions, 0 deletions
diff --git a/sfx2/inc/unoctitm.hxx b/sfx2/inc/unoctitm.hxx index a88a64c261ef..5c3926391e90 100644 --- a/sfx2/inc/unoctitm.hxx +++ b/sfx2/inc/unoctitm.hxx @@ -101,6 +101,8 @@ public: void SetMasterUnoCommand( bool bSet ); SfxDispatcher* GetDispatcher_Impl(); + + sal_uInt16 GetId() const; }; class SfxDispatchController_Impl final diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 5f929846107c..4c891e2e86b7 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -1637,6 +1637,28 @@ void SfxBindings::QueryControlState( sal_uInt16 nSlot, boost::property_tree::ptr } } +sal_uInt16 SfxBindings::QuerySlotId( const util::URL& aURL ) +{ + if (!pImpl) + return 0; + + css::uno::Reference<css::frame::XDispatch> xDispatch = + pImpl->xProv->queryDispatch(aURL, OUString(), 0); + if (!xDispatch.is()) + return 0; + + css::uno::Reference<css::lang::XUnoTunnel> xTunnel(xDispatch, css::uno::UNO_QUERY); + if (!xTunnel.is()) + 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(); +} + void SfxBindings::SetSubBindings_Impl( SfxBindings *pSub ) { if ( pImpl->pSubBindings ) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index b01500814bc9..44350d96ab9a 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -286,6 +286,11 @@ SfxDispatcher* SfxOfficeDispatch::GetDispatcher_Impl() return pImpl->GetDispatcher(); } +sal_uInt16 SfxOfficeDispatch::GetId() const +{ + return pImpl ? pImpl->GetId() : 0; +} + void SfxOfficeDispatch::SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame) { if ( pImpl ) |