diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-19 14:50:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-20 15:25:11 +0100 |
commit | 2b29217c586ca38bd8e8c360fb4b73c2ce81495f (patch) | |
tree | c524fb5de3ada75eda96d05d617976e25523c15d /sfx2/source | |
parent | 9b3387f57d4a762f681ab5276aff8764426c6aa4 (diff) |
clean up HelpLocaleString
to make it easier to read.
And fix the last two fall back cases, where it was assigning a different
value to aLocaleStr than it was returning, which means that it would
return a different value on the second invocation.
Change-Id: I6cac1ddd23b0a6a9e4ae8a0b9e7d94c0d877de39
Reviewed-on: https://gerrit.libreoffice.org/63642
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/appl/sfxhelp.cxx | 108 |
1 files changed, 53 insertions, 55 deletions
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index 19d08453f1d7..d52f74aa4a96 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -110,7 +110,7 @@ IMPL_STATIC_LINK_NOARG(NoHelpErrorBox, HelpRequestHdl, weld::Widget&, bool) return false; } -static OUString HelpLocaleString(); +static OUString const & HelpLocaleString(); namespace { @@ -205,69 +205,67 @@ bool impl_hasHTMLHelpInstalled() /// Return the locale we prefer for displaying help // static OUString const & HelpLocaleString() -static OUString HelpLocaleString() +static OUString const & HelpLocaleString() { if (comphelper::LibreOfficeKit::isActive()) return comphelper::LibreOfficeKit::getLanguageTag().getBcp47(); static OUString aLocaleStr; - if (aLocaleStr.isEmpty()) - { - const OUString aEnglish("en-US"); - // detect installed locale - aLocaleStr = utl::ConfigManager::getUILocale(); + if (!aLocaleStr.isEmpty()) + return aLocaleStr; - if ( aLocaleStr.isEmpty() ) - aLocaleStr = aEnglish; - else - { - // get fall-back language (country) - OUString sLang = aLocaleStr ; - sal_Int32 nSepPos = sLang.indexOf( '-' ); - if (nSepPos != -1) - { - sLang = sLang.copy( 0, nSepPos ); - } - OUString sHelpPath(""); - sHelpPath = getHelpRootURL() + "/" + utl::ConfigManager::getProductVersion() + "/" + aLocaleStr; - if (impl_checkHelpLocalePath(sHelpPath)) - { - return aLocaleStr; - } - sHelpPath = getHelpRootURL() + "/" + utl::ConfigManager::getProductVersion() + "/" + sLang; - if (impl_checkHelpLocalePath(sHelpPath)) - { - aLocaleStr = sLang; - return aLocaleStr; - } - sHelpPath = getHelpRootURL() + "/" + aLocaleStr; - if (impl_checkHelpLocalePath(sHelpPath)) - { - return aLocaleStr; - } - sHelpPath = getHelpRootURL() + "/" + sLang; - if (impl_checkHelpLocalePath(sHelpPath)) - { - aLocaleStr = sLang; - return aLocaleStr; - } + const OUString aEnglish("en-US"); + // detect installed locale + aLocaleStr = utl::ConfigManager::getUILocale(); - sHelpPath = getHelpRootURL() + "/" + utl::ConfigManager::getProductVersion() + "/" + aEnglish; - if (impl_checkHelpLocalePath(sHelpPath)) - { - return aEnglish; - } - sHelpPath = getHelpRootURL() + "/" + aEnglish; - if (impl_checkHelpLocalePath(sHelpPath)) - { - aLocaleStr = sLang; - return aEnglish; - } - aLocaleStr = utl::ConfigManager::getUILocale(); - return aLocaleStr; - } + if ( aLocaleStr.isEmpty() ) + { + aLocaleStr = aEnglish; + return aLocaleStr; } + // get fall-back language (country) + OUString sLang = aLocaleStr; + sal_Int32 nSepPos = sLang.indexOf( '-' ); + if (nSepPos != -1) + { + sLang = sLang.copy( 0, nSepPos ); + } + OUString sHelpPath(""); + sHelpPath = getHelpRootURL() + "/" + utl::ConfigManager::getProductVersion() + "/" + aLocaleStr; + if (impl_checkHelpLocalePath(sHelpPath)) + { + return aLocaleStr; + } + sHelpPath = getHelpRootURL() + "/" + utl::ConfigManager::getProductVersion() + "/" + sLang; + if (impl_checkHelpLocalePath(sHelpPath)) + { + aLocaleStr = sLang; + return aLocaleStr; + } + sHelpPath = getHelpRootURL() + "/" + aLocaleStr; + if (impl_checkHelpLocalePath(sHelpPath)) + { + return aLocaleStr; + } + sHelpPath = getHelpRootURL() + "/" + sLang; + if (impl_checkHelpLocalePath(sHelpPath)) + { + aLocaleStr = sLang; + return aLocaleStr; + } + sHelpPath = getHelpRootURL() + "/" + utl::ConfigManager::getProductVersion() + "/" + aEnglish; + if (impl_checkHelpLocalePath(sHelpPath)) + { + aLocaleStr = aEnglish; + return aLocaleStr; + } + sHelpPath = getHelpRootURL() + "/" + aEnglish; + if (impl_checkHelpLocalePath(sHelpPath)) + { + aLocaleStr = aEnglish; + return aLocaleStr; + } return aLocaleStr; } |