diff options
author | Henry Castro <hcastro@collabora.com> | 2021-10-04 14:14:32 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2022-02-18 11:29:36 +0100 |
commit | 470448227dc3e26190e68ea6c58551d7e3993dbb (patch) | |
tree | d90068e406dc172e0baebd588e8b168b498d6bb1 /sfx2 | |
parent | 62a8580587aec1c1a3070448b063889c01ac5c11 (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 a021c5379840..85d5f7c82fee 100644 --- a/sfx2/inc/unoctitm.hxx +++ b/sfx2/inc/unoctitm.hxx @@ -102,6 +102,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 87d04d3524a8..ba3d5761d0dc 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -307,6 +307,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 ) |