17#include <officecfg/Office/Common.hxx>
18#include <officecfg/System.hxx>
20#include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
21#include <rtl/ustring.hxx>
27#include <config_langs.h>
28#include <config_vendor.h>
33 if ( aLang.equalsIgnoreAsciiCase(
"pt")
38 if ( aLang.equalsIgnoreAsciiCase(
"zh") )
57 std::vector<OUString> fallbacks(
LanguageTag(locale).getFallbackStrings(
false));
58 auto pf = std::find_if(fallbacks.begin(), fallbacks.end(),
59 [&installed](
const OUString& rf) { return comphelper::findValue(installed, rf) != -1; });
60 if (pf != fallbacks.end())
69class InstallLangpack :
public Idle
71 std::vector<OUString> m_aPackages;
73 explicit InstallLangpack(std::vector<OUString>&& rPackages)
74 :
Idle(
"install langpack")
75 , m_aPackages(std::move(rPackages))
80 virtual void Invoke()
override
92 using namespace org::freedesktop::PackageKit;
96 catch (
const css::uno::Exception&)
108 OUString wantedLocale(rPreferredLocale);
109 if (wantedLocale.isEmpty())
110 wantedLocale = officecfg::System::L10N::UILocale::get();
114 officecfg::Office::Common::PackageKit::EnableLangpackInstallation::get())
120 std::vector<OUString> aPackages;
121 static constexpr std::u16string_view sAvailableLocales(
u"" WITH_LANG);
122 std::vector<OUString> aAvailable;
131 if (!install.isEmpty() && install !=
"en-US")
133 std::string_view sVendor(OOO_VENDOR);
134 if (sVendor ==
"Red Hat, Inc." || sVendor ==
"The Fedora Project")
139 aPackages.emplace_back(
"libreoffice-langpack-zh-Hans");
141 aPackages.emplace_back(
"libreoffice-langpack-zh-Hant");
142 else if (install ==
"pt")
143 aPackages.emplace_back(
"libreoffice-langpack-pt-PT");
145 aPackages.emplace_back(
"libreoffice-langpack-" + install);
147 else if (sVendor ==
"The Document Foundation/Debian" || sVendor ==
"The Document Foundation, Debian and Ubuntu")
150 aPackages.emplace_back(
"libreoffice-l10n-" + install);
153 if (!aPackages.empty())
160 if (locale.isEmpty())
162 if (locale.isEmpty() && rLocaleElementNames.hasElements())
163 locale = rLocaleElementNames[0];
const LanguageTag & GetUILanguageTag() const
static const AllSettings & GetSettings()
static vcl::Window * GetActiveTopWindow()
static bool IsHeadlessModeEnabled()
static vcl::Window * GetFirstTopLevelWindow()
virtual void Start(bool bStartTimer=true) override
Idle(const char *pDebugName)
LanguageType getLanguageType(bool bResolveSystem=true) const
OUString getLanguage() const
OUString getCountry() const
static bool isTraditionalChinese(LanguageType nLang)
static bool isSimplifiedChinese(LanguageType nLang)
void SetPriority(TaskPriority ePriority)
virtual void Invoke() override
#define TOOLS_INFO_EXCEPTION(area, stream)
OUString getInstalledLocaleForSystemUILanguage(const css::uno::Sequence< OUString > &rLocaleElementNames, bool bRequestInstallIfMissing, const OUString &rPreferredLocale)
OUString getInstalledLocaleForLanguage(css::uno::Sequence< OUString > const &installed, OUString const &locale)
static std::unique_ptr< Idle > xLangpackInstaller
void localizeWebserviceURI(OUString &rURI)
Localize a URI to one of the foundation's webservices.
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Reference< XComponentContext > getProcessComponentContext()
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)