diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-02-27 01:13:32 +0600 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-02-27 01:57:35 +0100 |
commit | a1a1d8edb9d4a62b747aa7069b3026e2ba75704d (patch) | |
tree | f1a65db468d664f61187efbf931dc55804f6eb35 | |
parent | c279cad9484cce44cf11473478c6059d69013fd2 (diff) |
Another attempt to ensure strict weak ordering when sorting
The failure that Stephan noticed turns out to show a problem in the
data - the use of the special LANGUAGE_USER_SYSTEM_CONFIG language
type value. It should not appear in the sorted part of the list; if
needed, it should be added explicitly, like the "default" entry is
handled in SvxLanguageBox::SetLanguageList.
So simplify the shortcut in GenericFirst::operator() again, and
drop the special entries before sorting.
Change-Id: If08e0ddbc5b597795e129fa4a2315c54205dab90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163964
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | svx/source/dialog/langbox.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx index e8b82e3ac63c..8699a6798d59 100644 --- a/svx/source/dialog/langbox.cxx +++ b/svx/source/dialog/langbox.cxx @@ -219,8 +219,8 @@ static void SortLanguages(std::vector<weld::ComboBoxEntry>& rEntries) bool operator()(const EntryData& e1, const EntryData& e2) const { assert(e1.tag.getLanguage() == e2.tag.getLanguage()); - if (e1.entry.sId == e2.entry.sId || e1.tag.equals(e2.tag)) - return false; // shortcut; make sure to also compare tags, to resolve system locale + if (e1.entry.sId == e2.entry.sId) + return false; // shortcut // Make sure that e.g. generic 'Spanish {es}' goes before 'Spanish (Argentina)'. // We can't depend on MsLangId::getPrimaryLanguage/getSubLanguage, because e.g. @@ -267,7 +267,11 @@ static void SortLanguages(std::vector<weld::ComboBoxEntry>& rEntries) for (const auto& entry : rEntries) { - LanguageTag tag(LanguageType(entry.sId.toInt32())); + LanguageType languageType(entry.sId.toInt32()); + // Remove LANGUAGE_USER_SYSTEM_CONFIG special entry and friends from the list + if (languageType >= LanguageType(0xFFE0)) + continue; + LanguageTag tag(languageType); langToEntriesMap[tag.getLanguage()].insert({ tag, entry }); // also makes unique } |