summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-06-05 17:36:32 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-06-06 11:54:09 +0200
commit1ae50dc4f816f37df50bfcb9d97c071fdf1e143f (patch)
tree43f9df48af4da29ffab0185ec18564b5e247cafc
parent1bdc67de20cf3090f07412513dfece356024ef0b (diff)
Sort languages in Edit Modules dialog
After commit e855481ead996a3b8270fae91bd23d6c8d75ef25, these languages are already ordered according to css::lang::Locale sorting implemented there; but this ordering does not follow the UI language sorting rules. TODO: put language without country/variant before respective languages having country/variant. Change-Id: Ic98b50ef4a500c799110611f7c35c74b4a239ed4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152641 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--cui/source/options/optlingu.cxx10
-rw-r--r--include/svx/langbox.hxx3
-rw-r--r--svx/source/dialog/langbox.cxx20
3 files changed, 21 insertions, 12 deletions
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index 6097f307038f..d13ca464bbe0 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -1603,11 +1603,11 @@ SvxEditModulesDlg::SvxEditModulesDlg(weld::Window* pParent, SvxLinguData_Impl& r
//fill language box
const auto& rLoc = rLinguData.GetAllSupportedLocales();
- for (Locale const & locale : rLoc)
- {
- LanguageType nLang = LanguageTag::convertToLanguageType( locale );
- m_xLanguageLB->InsertLanguage(nLang);
- }
+ std::vector<LanguageType> aLanguages;
+ aLanguages.reserve(rLoc.size());
+ std::transform(rLoc.begin(), rLoc.end(), std::back_inserter(aLanguages),
+ [](Locale const& locale) { return LanguageTag::convertToLanguageType(locale); });
+ m_xLanguageLB->InsertLanguages(aLanguages);
LanguageType eSysLang = MsLangId::getConfiguredSystemLanguage();
m_xLanguageLB->set_active_id( eSysLang );
if (m_xLanguageLB->get_active_id() != eSysLang)
diff --git a/include/svx/langbox.hxx b/include/svx/langbox.hxx
index 08893e8e1ce4..1ab9c478d805 100644
--- a/include/svx/langbox.hxx
+++ b/include/svx/langbox.hxx
@@ -69,7 +69,7 @@ private:
SVX_DLLPRIVATE weld::ComboBoxEntry BuildEntry(const LanguageType nLangType, sal_Int16 nType = css::i18n::ScriptType::WEAK);
SVX_DLLPRIVATE void AddLanguages(const std::vector< LanguageType >& rLanguageTypes, SvxLanguageListFlags nLangList,
- std::vector<weld::ComboBoxEntry>& rEntries);
+ std::vector<weld::ComboBoxEntry>& rEntries, bool requireSublang);
DECL_DLLPRIVATE_LINK(ChangeHdl, weld::ComboBox&, void);
public:
@@ -80,6 +80,7 @@ public:
LanguageType eDefaultLangType = LANGUAGE_NONE,
sal_Int16 nDefaultType = 0 );
void InsertLanguage(const LanguageType nLangType);
+ void InsertLanguages(const std::vector<LanguageType>& rLanguageTypes);
EditedAndValid GetEditedAndValid() const { return m_eEditedAndValid;}
SvxLanguageBox* SaveEditedAsEntry( SvxLanguageBox* ppBoxes[3] /* convention: Western, Asian, Complex */ );
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index 8142f0425687..6ce694ca0cc5 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -88,7 +88,7 @@ static bool lcl_SeqHasLang( const Sequence< sal_Int16 > & rLangSeq, sal_Int16 nL
namespace {
-bool lcl_isPrerequisite( LanguageType nLangType )
+bool lcl_isPrerequisite(LanguageType nLangType, bool requireSublang)
{
return
nLangType != LANGUAGE_DONTKNOW &&
@@ -96,7 +96,7 @@ bool lcl_isPrerequisite( LanguageType nLangType )
nLangType != LANGUAGE_NONE &&
nLangType != LANGUAGE_USER_KEYID &&
!MsLangId::isLegacy( nLangType) &&
- MsLangId::getSubLanguage( nLangType);
+ (!requireSublang || MsLangId::getSubLanguage( nLangType));
}
bool lcl_isScriptTypeRequested( LanguageType nLangType, SvxLanguageListFlags nLangList )
@@ -167,11 +167,11 @@ void SvxLanguageBox::set_active_id(const LanguageType eLangType)
}
void SvxLanguageBox::AddLanguages(const std::vector< LanguageType >& rLanguageTypes,
- SvxLanguageListFlags nLangList, std::vector<weld::ComboBoxEntry>& rEntries)
+ SvxLanguageListFlags nLangList, std::vector<weld::ComboBoxEntry>& rEntries, bool requireSublang)
{
for ( auto const & nLangType : rLanguageTypes )
{
- if (lcl_isPrerequisite( nLangType ))
+ if (lcl_isPrerequisite(nLangType, requireSublang))
{
LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType );
if (lcl_isScriptTypeRequested( nLang, nLangList))
@@ -280,7 +280,7 @@ void SvxLanguageBox::SetLanguageList(SvxLanguageListFlags nLangList, bool bHasLa
nLangType = aKnown[i];
else
nLangType = SvtLanguageTable::GetLanguageTypeAtIndex( i );
- if ( lcl_isPrerequisite( nLangType ) &&
+ if ( lcl_isPrerequisite( nLangType, true ) &&
(lcl_isScriptTypeRequested( nLangType, nLangList) ||
(bool(nLangList & SvxLanguageListFlags::FBD_CHARS) &&
MsLangId::hasForbiddenCharacters(nLangType)) ||
@@ -298,7 +298,7 @@ void SvxLanguageBox::SetLanguageList(SvxLanguageListFlags nLangList, bool bHasLa
{
// Spell checkers, hyphenators and thesauri may add language tags
// unknown so far.
- AddLanguages(aAvailLang, nLangList, aEntries);
+ AddLanguages(aAvailLang, nLangList, aEntries, true);
}
SortLanguages(aEntries);
@@ -315,6 +315,14 @@ void SvxLanguageBox::InsertLanguage(const LanguageType nLangType)
m_xControl->append(aEntry);
}
+void SvxLanguageBox::InsertLanguages(const std::vector<LanguageType>& rLanguageTypes)
+{
+ std::vector<weld::ComboBoxEntry> entries;
+ AddLanguages(rLanguageTypes, SvxLanguageListFlags::ALL, entries, false);
+ SortLanguages(entries);
+ m_xControl->insert_vector(entries, true);
+}
+
weld::ComboBoxEntry SvxLanguageBox::BuildEntry(const LanguageType nLangType, sal_Int16 nType)
{
LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage(nLangType);