[Libreoffice-commits] core.git: sfx2/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 20 14:25:36 UTC 2018
sfx2/source/appl/sfxhelp.cxx | 108 +++++++++++++++++++++----------------------
1 file changed, 53 insertions(+), 55 deletions(-)
New commits:
commit 2b29217c586ca38bd8e8c360fb4b73c2ce81495f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Nov 19 14:50:19 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Nov 20 15:25:11 2018 +0100
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 at collabora.co.uk>
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;
}
More information about the Libreoffice-commits
mailing list