diff options
author | Jan Holesovsky <kendy@collabora.com> | 2018-01-03 17:49:25 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-01-05 09:51:54 +0100 |
commit | 7ca3490d91a1fc4e01b34ea1a2f281968b0b1479 (patch) | |
tree | 04f48387cc631224db3fa3b7b3a2f6fe4afd6c06 | |
parent | 028fd03cdf4d3d8072289a5c4d476435c18f90d0 (diff) |
lokdialog: Use only one of the installed langpacks when setting locale.
Change-Id: I446775b121b7806a549f4dbbaa1f2dcf019d9bc2
Reviewed-on: https://gerrit.libreoffice.org/47386
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | include/sfx2/viewsh.hxx | 2 | ||||
-rw-r--r-- | include/svtools/langhelp.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 8 | ||||
-rw-r--r-- | svtools/source/misc/langhelp.cxx | 7 |
4 files changed, 15 insertions, 4 deletions
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 0c83f5faee15..e7a0f6d7fec1 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -344,7 +344,7 @@ public: virtual vcl::Window* GetEditWindowForActiveOLEObj() const override; /// Set the LibreOfficeKit language of this view. - void SetLOKLanguageTag(const OUString& rBcp47LanguageTag) { maLOKLanguageTag = LanguageTag(rBcp47LanguageTag, true); } + void SetLOKLanguageTag(const OUString& rBcp47LanguageTag); /// Get the LibreOfficeKit language of this view. const LanguageTag& GetLOKLanguageTag() const { return maLOKLanguageTag; } }; diff --git a/include/svtools/langhelp.hxx b/include/svtools/langhelp.hxx index db22bb368367..e3f914c7457e 100644 --- a/include/svtools/langhelp.hxx +++ b/include/svtools/langhelp.hxx @@ -23,7 +23,7 @@ SVT_DLLPUBLIC void localizeWebserviceURI( OUString& io_rURI ); OUString SVT_DLLPUBLIC getInstalledLocaleForLanguage(css::uno::Sequence<OUString> const & installed, OUString const & locale); -OUString SVT_DLLPUBLIC getInstalledLocaleForSystemUILanguage(css::uno::Sequence<OUString> const & installed, bool bRequestInstallIfMissing); +OUString SVT_DLLPUBLIC getInstalledLocaleForSystemUILanguage(css::uno::Sequence<OUString> const & installed, bool bRequestInstallIfMissing, const OUString& rPreferredLocale = OUString()); #endif diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 8060a330f132..7ebc86176495 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -26,6 +26,7 @@ #include <vcl/msgbox.hxx> #include <vcl/toolbox.hxx> #include <svl/intitem.hxx> +#include <svtools/langhelp.hxx> #include <svtools/sfxecode.hxx> #include <svtools/ehdl.hxx> #include <com/sun/star/frame/XLayoutManager.hpp> @@ -57,6 +58,7 @@ #include <vcl/commandinfoprovider.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <officecfg/Setup.hxx> #include <sfx2/app.hxx> #include <sfx2/viewsh.hxx> #include "viewimp.hxx" @@ -1488,6 +1490,12 @@ vcl::Window* SfxViewShell::GetEditWindowForActiveOLEObj() const return pEditWin; } +void SfxViewShell::SetLOKLanguageTag(const OUString& rBcp47LanguageTag) +{ + css::uno::Sequence<OUString> inst(officecfg::Setup::Office::InstalledLocales::get()->getElementNames()); + maLOKLanguageTag = LanguageTag(getInstalledLocaleForSystemUILanguage(inst, /* bRequestInstallIfMissing */ false, rBcp47LanguageTag), true).makeFallback(); +} + void SfxViewShell::NotifyCursor(SfxViewShell* /*pViewShell*/) const { } diff --git a/svtools/source/misc/langhelp.cxx b/svtools/source/misc/langhelp.cxx index e4e64375e4b5..5bbc01172964 100644 --- a/svtools/source/misc/langhelp.cxx +++ b/svtools/source/misc/langhelp.cxx @@ -102,9 +102,12 @@ public: } }; -OUString getInstalledLocaleForSystemUILanguage(const css::uno::Sequence<OUString>& rLocaleElementNames, bool bRequestInstallIfMissing) +OUString getInstalledLocaleForSystemUILanguage(const css::uno::Sequence<OUString>& rLocaleElementNames, bool bRequestInstallIfMissing, const OUString& rPreferredLocale) { - OUString wantedLocale = officecfg::System::L10N::UILocale::get(); + OUString wantedLocale(rPreferredLocale); + if (wantedLocale.isEmpty()) + wantedLocale = officecfg::System::L10N::UILocale::get(); + OUString locale = getInstalledLocaleForLanguage(rLocaleElementNames, wantedLocale); if (bRequestInstallIfMissing && locale.isEmpty() && !wantedLocale.isEmpty() && !Application::IsHeadlessModeEnabled() && officecfg::Office::Common::PackageKit::EnableLangpackInstallation::get()) |