comphelper/source/misc/dispatchcommand.cxx |   19 +++++++++++++++++--
 include/comphelper/dispatchcommand.hxx     |   20 ++++++++++++++++++--
 starmath/source/SmPropertiesPanel.cxx      |    1 +
 3 files changed, 36 insertions(+), 4 deletions(-)

New commits:
commit 98cda0d2e447711f4a612c389cd50b0bbd32526b
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Jul 10 12:03:33 2025 +0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Jul 11 08:32:51 2025 +0200

    Limit comphelper::dispatchCommand argument types to clarify the use
    
    Allows to avoid confusion wrt. what is expected to be passed there.
    See 
https://gerrit.libreoffice.org/c/core/+/187358/3#message-5f3135d37a68cbe64db7dd08e46695a970d4b35c
    
    Change-Id: Ice900dd90c8eb7e5e2ad373dfdb4c4c3e40d2aec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187607
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 653a309f9e416d55781a8f38aefc53d47c0e5e00)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187612
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/comphelper/source/misc/dispatchcommand.cxx 
b/comphelper/source/misc/dispatchcommand.cxx
index 2ea452c18ead..274e4234b6f6 100644
--- a/comphelper/source/misc/dispatchcommand.cxx
+++ b/comphelper/source/misc/dispatchcommand.cxx
@@ -32,11 +32,10 @@ using namespace css;
 namespace comphelper {
 
 bool dispatchCommand(const OUString& rCommand,
-                     const uno::Reference<uno::XInterface>& xDispatchSource,
+                     const uno::Reference<frame::XDispatchProvider>& 
xDispatchProvider,
                      const uno::Sequence<beans::PropertyValue>& rArguments,
                      const uno::Reference<frame::XDispatchResultListener>& 
rListener)
 {
-    uno::Reference<frame::XDispatchProvider> 
xDispatchProvider(xDispatchSource, uno::UNO_QUERY);
     if (!xDispatchProvider.is())
         return false;
 
@@ -66,6 +65,22 @@ bool dispatchCommand(const OUString& rCommand,
     return true;
 }
 
+bool dispatchCommand(const OUString& rCommand,
+                     const uno::Reference<frame::XFrame>& xFrame,
+                     const uno::Sequence<beans::PropertyValue>& rArguments,
+                     const uno::Reference<frame::XDispatchResultListener>& 
rListener)
+{
+    return dispatchCommand(rCommand, xFrame.query<frame::XDispatchProvider>(), 
rArguments, rListener);
+}
+
+bool dispatchCommand(const OUString& rCommand,
+                     const uno::Reference<frame::XController>& xController,
+                     const uno::Sequence<beans::PropertyValue>& rArguments,
+                     const uno::Reference<frame::XDispatchResultListener>& 
rListener)
+{
+    return dispatchCommand(rCommand, 
xController.query<frame::XDispatchProvider>(), rArguments, rListener);
+}
+
 bool dispatchCommand(const OUString& rCommand, const 
css::uno::Sequence<css::beans::PropertyValue>& rArguments, const 
uno::Reference<css::frame::XDispatchResultListener>& rListener)
 {
     // Target where we will execute the .uno: command
diff --git a/include/comphelper/dispatchcommand.hxx 
b/include/comphelper/dispatchcommand.hxx
index 0e127d526108..1630e8573ef0 100644
--- a/include/comphelper/dispatchcommand.hxx
+++ b/include/comphelper/dispatchcommand.hxx
@@ -15,7 +15,13 @@
 #include <com/sun/star/uno/Reference.hxx>
 
 namespace com::sun::star::beans { struct PropertyValue; }
-namespace com::sun::star::frame { class XDispatchResultListener; }
+namespace com::sun::star::frame
+{
+class XDispatchResultListener;
+class XDispatchProvider;
+class XFrame;
+class XController;
+}
 namespace com::sun::star::uno { template <typename > class Sequence; }
 
 namespace comphelper
@@ -32,7 +38,17 @@ COMPHELPER_DLLPUBLIC bool dispatchCommand(const OUString& 
rCommand,
         const css::uno::Reference<css::frame::XDispatchResultListener>& 
rListener = css::uno::Reference<css::frame::XDispatchResultListener>());
 
 COMPHELPER_DLLPUBLIC bool dispatchCommand(const OUString& rCommand,
-        const css::uno::Reference<css::uno::XInterface>& xDispatchSource,
+        const css::uno::Reference<css::frame::XDispatchProvider>& 
xDispatchProvider,
+        const css::uno::Sequence<css::beans::PropertyValue>& rArguments,
+        const css::uno::Reference<css::frame::XDispatchResultListener>& 
rListener = css::uno::Reference<css::frame::XDispatchResultListener>());
+
+COMPHELPER_DLLPUBLIC bool dispatchCommand(const OUString& rCommand,
+        const css::uno::Reference<css::frame::XFrame>& xFrame,
+        const css::uno::Sequence<css::beans::PropertyValue>& rArguments,
+        const css::uno::Reference<css::frame::XDispatchResultListener>& 
rListener = css::uno::Reference<css::frame::XDispatchResultListener>());
+
+COMPHELPER_DLLPUBLIC bool dispatchCommand(const OUString& rCommand,
+        const css::uno::Reference<css::frame::XController>& xController,
         const css::uno::Sequence<css::beans::PropertyValue>& rArguments,
         const css::uno::Reference<css::frame::XDispatchResultListener>& 
rListener = css::uno::Reference<css::frame::XDispatchResultListener>());
 
diff --git a/starmath/source/SmPropertiesPanel.cxx 
b/starmath/source/SmPropertiesPanel.cxx
index 7f7108911b4f..736f2bc011a4 100644
--- a/starmath/source/SmPropertiesPanel.cxx
+++ b/starmath/source/SmPropertiesPanel.cxx
@@ -21,6 +21,7 @@
 
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/frame/theUICommandDescription.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/uno/Sequence.hxx>
 
 #include <comphelper/dispatchcommand.hxx>

Reply via email to