From 721cef392f301321a632a1d9286d57cd45335649 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 11 Jul 2019 11:08:13 +0200 Subject: Deduplicate URL tooltip creation Change-Id: I94eb40ff4d727029ad764a381df300beee90481c Reviewed-on: https://gerrit.libreoffice.org/75409 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- sfx2/source/appl/sfxhelp.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sfx2/source/appl/sfxhelp.cxx') diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index 8fbdad1fc794..d6fac42bd6de 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -65,8 +65,11 @@ #include #include #include +#include +#include #include #include +#include #include #include #include @@ -680,6 +683,25 @@ OUString SfxHelp::GetHelpText(const OUString& aCommandURL, const weld::Widget* p return sHelpText; } +OUString SfxHelp::GetURLHelpText(const OUString& aURL) +{ + SvtSecurityOptions aSecOpt; + bool bCtrlClickHlink = aSecOpt.IsOptionSet(SvtSecurityOptions::EOption::CtrlClickHyperlink); + + // "ctrl-click to follow link:" for not MacOS + // "⌘-click to follow link:" for MacOs + vcl::KeyCode aCode(KEY_SPACE); + vcl::KeyCode aModifiedCode(KEY_SPACE, KEY_MOD1); + OUString aModStr(aModifiedCode.GetName()); + aModStr = aModStr.replaceFirst(aCode.GetName(), ""); + aModStr = aModStr.replaceAll("+", ""); + OUString aHelpStr + = bCtrlClickHlink ? SfxResId(STR_CTRLCLICKHYPERLINK) : SfxResId(STR_CLICKHYPERLINK); + aHelpStr = aHelpStr.replaceFirst("%{key}", aModStr); + aHelpStr = aHelpStr.replaceFirst("%{link}", aURL); + return aHelpStr; +} + void SfxHelp::SearchKeyword( const OUString& rKeyword ) { Start_Impl(OUString(), static_cast(nullptr), rKeyword); -- cgit