[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - include/sfx2 sfx2/inc sfx2/source

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 8 06:07:57 UTC 2021


 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 3d5cd0cf6019972a3eb7a0a38791023d29a8d20b
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Mon Oct 4 14:14:32 2021 -0400
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Oct 8 08:07:22 2021 +0200

    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 at collabora.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/sfx2/bindings.hxx b/include/sfx2/bindings.hxx
index 3eb756ebb18d..058755d35a30 100644
--- a/include/sfx2/bindings.hxx
+++ b/include/sfx2/bindings.hxx
@@ -143,6 +143,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 7f6bf815e1f9..263958e9e56c 100644
--- a/sfx2/inc/unoctitm.hxx
+++ b/sfx2/inc/unoctitm.hxx
@@ -100,6 +100,8 @@ public:
     void                    SetMasterUnoCommand( bool bSet );
 
     SfxDispatcher*          GetDispatcher_Impl();
+
+    sal_uInt16              GetId() const;
 };
 
 class SfxDispatchController_Impl
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 1792e330f5c4..48480207ea01 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -1642,6 +1642,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::impl_getStaticIdentifier());
+    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 cad127e1c89d..752bdf99ead1 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -260,6 +260,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 )


More information about the Libreoffice-commits mailing list