include/sfx2/bindings.hxx | 2 ++ sfx2/inc/unoctitm.hxx | 2 ++ sfx2/source/control/bindings.cxx | 22 ++++++++++++++++++++++ sfx2/source/control/unoctitm.cxx | 5 +++++ 4 files changed, 31 insertions(+)
New commits: commit 470448227dc3e26190e68ea6c58551d7e3993dbb Author: Henry Castro <hcas...@collabora.com> AuthorDate: Mon Oct 4 14:14:32 2021 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Fri Feb 18 11:29:36 2022 +0100 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.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129464 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/include/sfx2/bindings.hxx b/include/sfx2/bindings.hxx index 47b904d6d113..38104105088d 100644 --- a/include/sfx2/bindings.hxx +++ b/include/sfx2/bindings.hxx @@ -144,6 +144,8 @@ public: void QueryControlState ( sal_uInt16 nSID, boost::property_tree::ptree& rState ); + sal_uInt16 QuerySlotId( const css::util::URL& aURL ); + const SfxPoolItem* ExecuteSynchron( sal_uInt16 nSlot, const SfxPoolItem **pArgs = nullptr); bool Execute( sal_uInt16 nSlot, 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 )