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.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2025-07-10 12:03:33 +05:00
parent 09337d45f8
commit 653a309f9e
3 changed files with 36 additions and 4 deletions

View File

@ -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

View File

@ -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>());

View File

@ -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>