diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/helper/commandinfoprovider.cxx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx index 234a73eb2949..075fd4e7ced1 100644 --- a/vcl/source/helper/commandinfoprovider.cxx +++ b/vcl/source/helper/commandinfoprovider.cxx @@ -158,6 +158,33 @@ static OUString RetrieveShortcutsFromConfiguration( return OUString(); } +static vcl::KeyCode RetrieveKeyCodeShortcutsFromConfiguration( + const Reference<ui::XAcceleratorConfiguration>& rxConfiguration, + const OUString& rsCommandName) +{ + if (rxConfiguration.is()) + { + try + { + Sequence<OUString> aCommands { rsCommandName }; + + Sequence<Any> aKeyCodes (rxConfiguration->getPreferredKeyEventsForCommandList(aCommands)); + if (aCommands.getLength() == 1) + { + awt::KeyEvent aKeyEvent; + if (aKeyCodes[0] >>= aKeyEvent) + { + return AWTKey2VCLKey(aKeyEvent); + } + } + } + catch (css::lang::IllegalArgumentException&) + { + } + } + return vcl::KeyCode(); +} + static bool ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName, const OUString& rsModuleName) { Sequence< OUString > aSequence; @@ -278,6 +305,25 @@ OUString GetCommandShortcut (const OUString& rsCommandName, return OUString(); } +vcl::KeyCode GetCommandKeyCodeShortcut (const OUString& rsCommandName, const Reference<frame::XFrame>& rxFrame) +{ + vcl::KeyCode aKeyCodeShortcut; + + aKeyCodeShortcut = RetrieveKeyCodeShortcutsFromConfiguration(GetDocumentAcceleratorConfiguration(rxFrame), rsCommandName); + if (aKeyCodeShortcut.GetCode()) + return aKeyCodeShortcut; + + aKeyCodeShortcut = RetrieveKeyCodeShortcutsFromConfiguration(GetModuleAcceleratorConfiguration(rxFrame), rsCommandName); + if (aKeyCodeShortcut.GetCode()) + return aKeyCodeShortcut; + + aKeyCodeShortcut = RetrieveKeyCodeShortcutsFromConfiguration(GetGlobalAcceleratorConfiguration(), rsCommandName); + if (aKeyCodeShortcut.GetCode()) + return aKeyCodeShortcut; + + return vcl::KeyCode(); +} + OUString GetRealCommandForCommand(const css::uno::Sequence<css::beans::PropertyValue>& rProperties) { return GetCommandProperty("TargetURL", rProperties); |