summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2016-02-26 12:47:43 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2016-02-28 09:10:30 +0200
commit010b034cd6195c96a21633c328e9693275d27d72 (patch)
tree5a9cb79e5c68edee741b4dcc79d0fd3ccb240aa0 /sfx2
parent7affe26a1291eef8c77e890228061f13e987bff1 (diff)
tdf#84258 Allow creation of command aliases
We already can use different labels for commands, based on whether they're in a menu, context menu or a toolbar. But in some cases we need different labels for the same type of UI element, or even different icons. One example is page/slide commands in Draw/Impress, as they share same commands, but need different icons/labels. Creating full-fledged duplicate slots just to satisfy the need of UI representation seems like overkill, and isn't flexible enough. The proposed solution is to allow creation of command entries, that do not correspond to real application slots, but instead link to another existing commands. The "real" commands will be used for controller factory and dispatch (execute/status) APIs, thus fully retaining functionality. This can be useful also for giving icons to complex commands (i.e. commands with arguments). Change-Id: I9b261b406ec8fc781cae06cf283963386379d4ad
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/sfxhelp.cxx19
1 files changed, 17 insertions, 2 deletions
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 6fe553f93c5a..4140f8d6d05b 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -53,6 +53,7 @@
#include <osl/file.hxx>
#include <unotools/bootstrap.hxx>
#include <rtl/uri.hxx>
+#include <vcl/commandinfoprovider.hxx>
#include <vcl/layout.hxx>
#include <svtools/ehdl.hxx>
#include <svtools/sfxecode.hxx>
@@ -263,6 +264,13 @@ OUString getDefaultModule_Impl()
return sDefaultModule;
}
+Reference< XFrame > getCurrentFrame()
+{
+ Reference < XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ Reference < XDesktop2 > xDesktop = Desktop::create(xContext);
+ return xDesktop->getCurrentFrame();
+}
+
OUString getCurrentModuleIdentifier_Impl()
{
OUString sIdentifier;
@@ -443,7 +451,8 @@ SfxHelpWindow_Impl* impl_createHelp(Reference< XFrame2 >& rHelpTask ,
OUString SfxHelp::GetHelpText( const OUString& aCommandURL, const vcl::Window* pWindow )
{
OUString sModuleName = GetHelpModuleName_Impl();
- OUString sHelpText = SfxHelp_Impl::GetHelpText( aCommandURL, sModuleName );
+ OUString sRealCommand = vcl::CommandInfoProvider::Instance().GetRealCommandForCommand( aCommandURL, getCurrentFrame() );
+ OUString sHelpText = SfxHelp_Impl::GetHelpText( sRealCommand.isEmpty() ? aCommandURL : sRealCommand, sModuleName );
OString aNewHelpId;
@@ -556,8 +565,14 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const
default:
{
OUString aHelpModuleName( GetHelpModuleName_Impl() );
+ OUString aRealCommand;
+
+ if ( nProtocol == INetProtocol::Uno )
+ // Command can be just an alias to another command.
+ aRealCommand = vcl::CommandInfoProvider::Instance().GetRealCommandForCommand( rURL, getCurrentFrame() );
+
// no URL, just a HelpID (maybe empty in case of keyword search)
- aHelpURL = CreateHelpURL_Impl( rURL, aHelpModuleName );
+ aHelpURL = CreateHelpURL_Impl( aRealCommand.isEmpty() ? rURL : aRealCommand, aHelpModuleName );
if ( impl_hasHelpInstalled() && pWindow && SfxContentHelper::IsHelpErrorDocument( aHelpURL ) )
{