framework/source/uielement/generictoolbarcontroller.cxx | 8 ++++- svtools/source/uno/toolboxcontroller.cxx | 25 ++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-)
New commits: commit 5533bf8642cf753d3176b6a4c027473b2f4b197a Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Nov 10 11:33:03 2021 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Mon Nov 15 08:53:38 2021 +0100 Handle UNO command aliases in ToolBoxes This allows to use ".uno:InsertSlide" which is an alias for ".uno:InsertPage" in the notebookbar. Change-Id: Ia52488b65e308a62b686e77b38cba3675deece73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124952 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125048 Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx index a657efd3cc88..aa35a1511b48 100644 --- a/framework/source/uielement/generictoolbarcontroller.cxx +++ b/framework/source/uielement/generictoolbarcontroller.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/frame/ControlCommand.hpp> #include <svtools/toolboxcontroller.hxx> +#include <vcl/commandinfoprovider.hxx> #include <vcl/svapp.hxx> #include <vcl/mnemonic.hxx> #include <vcl/toolbox.hxx> @@ -151,7 +152,12 @@ void SAL_CALL GenericToolbarController::execute( sal_Int16 KeyModifier ) aArgs[0].Name = "KeyModifier"; aArgs[0].Value <<= KeyModifier; - aTargetURL.Complete = aCommandURL; + // handle also command aliases + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(m_aCommandURL, + vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame)); + OUString sRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand(aProperties); + + aTargetURL.Complete = sRealCommand.isEmpty() ? aCommandURL : sRealCommand; if ( m_xUrlTransformer.is() ) m_xUrlTransformer->parseStrict( aTargetURL ); diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx index 8bd9d94f2366..5193979f36d2 100644 --- a/svtools/source/uno/toolboxcontroller.cxx +++ b/svtools/source/uno/toolboxcontroller.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/util/URLTransformer.hpp> +#include <vcl/commandinfoprovider.hxx> #include <vcl/svapp.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/toolbox.hxx> @@ -501,6 +502,30 @@ void ToolboxController::bindListener() catch ( Exception& ) { } + + // it may be a command alias + if (!xDispatch.is()) + { + try + { + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(listener.first, + vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame)); + OUString sRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand(aProperties); + + if (!sRealCommand.isEmpty()) + { + aTargetURL.Complete = sRealCommand; + if ( m_xUrlTransformer.is() ) + m_xUrlTransformer->parseStrict( aTargetURL ); + + xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ); + } + } + catch ( Exception& ) + { + } + } + listener.second = xDispatch; Listener aListener( aTargetURL, xDispatch );