svx/source/dialog/langbox.cxx |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

New commits:
commit a1a1d8edb9d4a62b747aa7069b3026e2ba75704d
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Feb 27 01:13:32 2024 +0600
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Feb 27 01:57:35 2024 +0100

    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.kagan...@collabora.com>

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
     }
 

Reply via email to