diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2015-11-16 12:23:25 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2015-11-16 14:48:47 +0000 |
commit | 40fa83871e18bf7ff54f853e6b665f207ee8fb78 (patch) | |
tree | 01d9d3c2a627e1b38ed7451d0be89cb045692de7 | |
parent | 396b5f411f7ecc7d600efdc0bb2381a7d1ed6d88 (diff) |
Move CommandInfoProvider to vcl and use it from there
Change-Id: If7e3ef81cad8974bc54f359096e3ecc700fa62d6
Reviewed-on: https://gerrit.libreoffice.org/19984
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r-- | compilerplugins/clang/store/deletedspecial.cxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/toolbarmanager.cxx | 8 | ||||
-rw-r--r-- | include/vcl/commandinfoprovider.hxx (renamed from include/svtools/commandinfoprovider.hxx) | 18 | ||||
-rw-r--r-- | sfx2/inc/pch/precompiled_sfx.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/sidebar/ControllerFactory.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/sidebar/ControllerItem.cxx | 4 | ||||
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | vcl/Library_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/source/helper/commandinfoprovider.cxx (renamed from svtools/source/misc/commandinfoprovider.cxx) | 27 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 40 | ||||
-rw-r--r-- | vcl/source/window/toolbox2.cxx | 5 |
11 files changed, 47 insertions, 65 deletions
diff --git a/compilerplugins/clang/store/deletedspecial.cxx b/compilerplugins/clang/store/deletedspecial.cxx index ff82f7eefedb..79393f2130f9 100644 --- a/compilerplugins/clang/store/deletedspecial.cxx +++ b/compilerplugins/clang/store/deletedspecial.cxx @@ -118,7 +118,7 @@ bool DeletedSpecial::VisitCXXMethodDecl(CXXMethodDecl const * decl) { || whitelist(decl, "sd::IconCache", "sd/source/ui/inc/tools/IconCache.hxx") || whitelist(decl, "sd::RemoteServer", "sd/source/ui/inc/RemoteServer.hxx") || whitelist(decl, "sd::slidesorter::cache::PageCacheManager", "sd/source/ui/slidesorter/inc/cache/SlsPageCacheManager.hxx") - || whitelist(decl, "svt::CommandInfoProvider", "include/svt/commandinfoprovider.hxx") + || whitelist(decl, "framework::CommandInfoProvider", "include/framework/commandinfoprovider.hxx") || whitelist(decl, "vcl::SettingsConfigItem", "include/vcl/configsettings.hxx") || whitelist(decl, "writerfilter::ooxml::OOXMLFactory", "writerfilter/source/ooxml/OOXMLFactory.hxx")) { diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index ee792f73b567..40bf7d5b06b9 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -68,8 +68,8 @@ #include <vcl/taskpanelist.hxx> #include <vcl/toolbox.hxx> #include <vcl/settings.hxx> +#include <vcl/commandinfoprovider.hxx> -#include <svtools/commandinfoprovider.hxx> #include <svtools/menuoptions.hxx> #include <boost/bind.hpp> @@ -1272,8 +1272,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine if (( nType == css::ui::ItemType::DEFAULT ) && !aCommandURL.isEmpty() ) { - OUString aString(svt::CommandInfoProvider::Instance().GetLabelForCommand(aCommandURL, m_xFrame)); - OUString aTooltipFromCommand(svt::CommandInfoProvider::Instance().GetTooltipForCommand(aCommandURL, m_xFrame, false)); + OUString aString(vcl::CommandInfoProvider::Instance().GetLabelForCommand(aCommandURL, m_xFrame)); + OUString aTooltipFromCommand(vcl::CommandInfoProvider::Instance().GetTooltipForCommand(aCommandURL, m_xFrame, false)); ToolBoxItemBits nItemBits = ConvertStyleToToolboxItemBits( nStyle ); if ( aMenuDesc.is() ) @@ -1289,7 +1289,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine sQuickHelp = aTooltip; else if ( !aTooltipFromCommand.isEmpty() ) // Tooltip from uno command (TooltipLabel) sQuickHelp = aTooltipFromCommand; - OUString sShortCut = svt::CommandInfoProvider::Instance().GetCommandShortcut(aCommandURL, m_xFrame); + OUString sShortCut = vcl::CommandInfoProvider::Instance().GetCommandShortcut(aCommandURL, m_xFrame); if( !sShortCut.isEmpty() ) { sQuickHelp += " ("; diff --git a/include/svtools/commandinfoprovider.hxx b/include/vcl/commandinfoprovider.hxx index 6c0431bf7d7c..91d98b7c5fb0 100644 --- a/include/svtools/commandinfoprovider.hxx +++ b/include/vcl/commandinfoprovider.hxx @@ -16,22 +16,23 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_COMPHELPER_COMMANDINFOPROVIDER_HXX -#define INCLUDED_COMPHELPER_COMMANDINFOPROVIDER_HXX +#ifndef INCLUDED_VCL_COMMANDINFOPROVIDER_HXX +#define INCLUDED_VCL_COMMANDINFOPROVIDER_HXX -#include <svtools/svtdllapi.h> +#include <vcl/dllapi.h> +#include <vcl/keycod.hxx> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/ui/XAcceleratorConfiguration.hpp> -namespace svt { +namespace vcl { -/** Provide information about UNO commands like tooltip text with +/** Provides information about UNO commands like tooltip text with keyboard accelerator. */ -class SVT_DLLPUBLIC CommandInfoProvider +class VCL_DLLPUBLIC CommandInfoProvider { public: /** Return the singleton instance. @@ -103,10 +104,11 @@ public: static OUString RetrieveShortcutsFromConfiguration( const css::uno::Reference<css::ui::XAcceleratorConfiguration>& rxConfiguration, const OUString& rsCommandName); + static vcl::KeyCode AWTKey2VCLKey(const css::awt::KeyEvent& aAWTKey); }; -} // end of namespace svt +} // end of namespace vcl -#endif // INCLUDED_COMPHELPER_COMMANDINFOPROVIDER_HXX +#endif // INCLUDED_VCL_COMMANDINFOPROVIDER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx index 6c8c6588724c..d599a0dc1f89 100644 --- a/sfx2/inc/pch/precompiled_sfx.hxx +++ b/sfx2/inc/pch/precompiled_sfx.hxx @@ -503,7 +503,7 @@ #include <sfx2/sfxresid.hxx> #include <sfx2/sfxuno.hxx> #include <sfx2/sidebar/Accessible.hxx> -#include <svtools/commandinfoprovider.hxx> +#include <vcl/CommandInfoProvider.hxx> #include <sfx2/sidebar/Context.hxx> #include <sfx2/sidebar/ControllerFactory.hxx> #include <sfx2/sidebar/Deck.hxx> diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx index 65590377019a..7de15515b482 100644 --- a/sfx2/source/sidebar/ControllerFactory.cxx +++ b/sfx2/source/sidebar/ControllerFactory.cxx @@ -26,8 +26,8 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <framework/sfxhelperfunctions.hxx> +#include <vcl/commandinfoprovider.hxx> #include <svtools/generictoolboxcontroller.hxx> -#include <svtools/commandinfoprovider.hxx> #include <comphelper/processfactory.hxx> #include <toolkit/helper/vclunohelper.hxx> @@ -123,7 +123,7 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController( // Add tooltip. if (xController.is()) { - const OUString sTooltip (svt::CommandInfoProvider::Instance().GetTooltipForCommand( + const OUString sTooltip (vcl::CommandInfoProvider::Instance().GetTooltipForCommand( rsCommandName, rxFrame)); pToolBox->SetQuickHelpText(nItemId, sTooltip); diff --git a/sfx2/source/sidebar/ControllerItem.cxx b/sfx2/source/sidebar/ControllerItem.cxx index cf24c3441c73..5ee79cc30062 100644 --- a/sfx2/source/sidebar/ControllerItem.cxx +++ b/sfx2/source/sidebar/ControllerItem.cxx @@ -23,7 +23,7 @@ #include <sfx2/imagemgr.hxx> #include <sfx2/bindings.hxx> #include <unotools/cmdoptions.hxx> -#include <svtools/commandinfoprovider.hxx> +#include <vcl/commandinfoprovider.hxx> #include <vcl/svapp.hxx> #include <vcl/toolbox.hxx> #include <vcl/help.hxx> @@ -204,7 +204,7 @@ ControllerItem::ItemUpdateReceiverInterface::~ItemUpdateReceiverInterface() void ControllerItem::SetupToolBoxItem (ToolBox& rToolBox, const sal_uInt16 nIndex) { - rToolBox.SetQuickHelpText(nIndex,svt::CommandInfoProvider::Instance().GetTooltipForCommand(".uno:" + msCommandName, mxFrame)); + rToolBox.SetQuickHelpText(nIndex, vcl::CommandInfoProvider::Instance().GetTooltipForCommand(".uno:" + msCommandName, mxFrame)); rToolBox.SetHelpText(nIndex, GetHelpText()); rToolBox.SetItemImage(nIndex, GetIcon()); } diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 19779cb24d76..9e30e77037a6 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -172,7 +172,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/misc/acceleratorexecute \ svtools/source/misc/bindablecontrolhelper \ svtools/source/misc/cliplistener \ - svtools/source/misc/commandinfoprovider \ svtools/source/misc/dialogclosedlistener \ svtools/source/misc/dialogcontrolling \ svtools/source/misc/ehdl \ diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 7592860fd2ba..e9933d187290 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -330,6 +330,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/bitmap/checksum \ vcl/source/helper/canvasbitmap \ vcl/source/helper/canvastools \ + vcl/source/helper/commandinfoprovider \ vcl/source/helper/evntpost \ vcl/source/helper/lazydelete \ vcl/source/helper/strhelper \ diff --git a/svtools/source/misc/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx index 3536ba47e794..5d5ac771c08b 100644 --- a/svtools/source/misc/commandinfoprovider.cxx +++ b/vcl/source/helper/commandinfoprovider.cxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <svtools/commandinfoprovider.hxx> -#include <svtools/acceleratorexecute.hxx> +#include <vcl/commandinfoprovider.hxx> #include <comphelper/processfactory.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/basemutex.hxx> @@ -28,6 +27,8 @@ #include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp> #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp> +#include <com/sun/star/awt/KeyModifier.hpp> + using namespace css; using namespace css::uno; @@ -43,7 +44,7 @@ namespace public FrameListenerInterfaceBase { public: - FrameListener (svt::CommandInfoProvider& rInfoProvider, const Reference<frame::XFrame>& rxFrame) + FrameListener (vcl::CommandInfoProvider& rInfoProvider, const Reference<frame::XFrame>& rxFrame) : FrameListenerInterfaceBase(m_aMutex), mrInfoProvider(rInfoProvider), mxFrame(rxFrame) @@ -68,12 +69,12 @@ namespace } private: - svt::CommandInfoProvider& mrInfoProvider; + vcl::CommandInfoProvider& mrInfoProvider; Reference<frame::XFrame> mxFrame; }; } -namespace svt { +namespace vcl { CommandInfoProvider& CommandInfoProvider::Instance() { @@ -264,7 +265,7 @@ OUString CommandInfoProvider::RetrieveShortcutsFromConfiguration( css::awt::KeyEvent aKeyEvent; if (aKeyCodes[0] >>= aKeyEvent) { - return svt::AcceleratorExecute::st_AWTKey2VCLKey(aKeyEvent).GetName(); + return AWTKey2VCLKey(aKeyEvent).GetName(); } } } @@ -312,6 +313,18 @@ OUString CommandInfoProvider::GetCommandProperty(const OUString& rsProperty, con return OUString(); } -} // end of namespace svt +vcl::KeyCode CommandInfoProvider::AWTKey2VCLKey(const css::awt::KeyEvent& aAWTKey) +{ + bool bShift = ((aAWTKey.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT ); + bool bMod1 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 ); + bool bMod2 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 ); + bool bMod3 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD3 ) == css::awt::KeyModifier::MOD3 ); + sal_uInt16 nKey = (sal_uInt16)aAWTKey.KeyCode; + + return vcl::KeyCode(nKey, bShift, bMod1, bMod2, bMod3); +} + + +} // end of namespace vcl /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 09ed49e6fa64..40036983126b 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -43,6 +43,7 @@ #include <vcl/vclmedit.hxx> #include <vcl/settings.hxx> #include <vcl/slider.hxx> +#include <vcl/commandinfoprovider.hxx> #include <svdata.hxx> #include <svids.hrc> #include <window.h> @@ -892,11 +893,11 @@ namespace uno::Reference<frame::XModuleManager2> xModuleManager(frame::ModuleManager::create(xContext)); OUString aModuleId(xModuleManager->identify(rFrame)); - OUString aLabel(VclBuilder::getCommandProperty("Label", aCommand, xContext, aModuleId)); + OUString aLabel(vcl::CommandInfoProvider::Instance().GetLabelForCommand(aCommand, rFrame)); if (!aLabel.isEmpty()) pButton->SetText(aLabel); - OUString aTooltip(VclBuilder::getCommandProperty("Tooltip", aCommand, xContext, aModuleId)); + OUString aTooltip(vcl::CommandInfoProvider::Instance().GetTooltipForCommand(aCommand, rFrame)); if (!aTooltip.isEmpty()) pButton->SetQuickHelpText(aTooltip); @@ -2168,41 +2169,6 @@ void VclBuilder::reorderWithinParent(std::vector<vcl::Window*>& rChilds, bool bI } } -OUString VclBuilder::getCommandProperty(const OUString& rProperty, const OUString& rCommand, - const uno::Reference<uno::XComponentContext>& rContext, const OUString& rModuleId) -{ - if (rCommand.isEmpty()) - return OUString(); - - try - { - uno::Reference<container::XNameAccess> xUICommandLabels; - uno::Reference<container::XNameAccess> xUICommandDescription(frame::theUICommandDescription::get(rContext)); - - if ((xUICommandDescription->getByName(rModuleId) >>= xUICommandLabels) && xUICommandLabels.is()) - { - uno::Sequence<beans::PropertyValue> aProperties; - if (xUICommandLabels->getByName(rCommand) >>= aProperties) - { - for ( sal_Int32 i = 0; i < aProperties.getLength(); i++ ) - { - if (aProperties[i].Name == rProperty) - { - OUString aLabel; - if (aProperties[i].Value >>= aLabel) - return aLabel; - } - } - } - } - } - catch (uno::Exception&) - { - } - - return OUString(); -} - Image VclBuilder::getCommandImage(const OUString& rCommand, bool bLarge, const uno::Reference<uno::XComponentContext>& rContext, const uno::Reference<frame::XFrame>& rFrame, const OUString& rModuleId) diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 0efb1f8cfa85..5bb123aa4742 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -32,6 +32,7 @@ #include <vcl/menu.hxx> #include <vcl/settings.hxx> #include <vcl/IconThemeInfo.hxx> +#include <vcl/commandinfoprovider.hxx> #include <svdata.hxx> #include <brdwin.hxx> @@ -606,8 +607,8 @@ void ToolBox::InsertItem(const OUString& rCommand, const uno::Reference<frame::X uno::Reference<frame::XModuleManager2> xModuleManager(frame::ModuleManager::create(xContext)); OUString aModuleId(xModuleManager->identify(rFrame)); - OUString aLabel(VclBuilder::getCommandProperty("Label", rCommand, xContext, aModuleId)); - OUString aTooltip(VclBuilder::getCommandProperty("TooltipLabel", rCommand, xContext, aModuleId)); + OUString aLabel(vcl::CommandInfoProvider::Instance().GetLabelForCommand(rCommand, rFrame)); + OUString aTooltip(vcl::CommandInfoProvider::Instance().GetTooltipForCommand(rCommand, rFrame)); Image aImage(VclBuilder::getCommandImage(rCommand, (GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE), xContext, rFrame, aModuleId)); // let's invent an ItemId |