sc/source/core/data/stlpool.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit b8efa9e460f358d42662e385ef5101cca053d8c7
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Feb 10 13:25:53 2023 +0300
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Mon Feb 13 00:02:23 2023 +0000

    tdf#153514: try to find exact match, even when searching case-insensitively
    
    Change-Id: Ib3bec382ef80a9078ffde8612c395cb0154fd476
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146747
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 2a984c77ccb1aa77d9bbd02218d4dc76aaff4a9e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146763
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx
index 5ca89c37a510..b08b6c2203c9 100644
--- a/sc/source/core/data/stlpool.cxx
+++ b/sc/source/core/data/stlpool.cxx
@@ -408,14 +408,20 @@ ScStyleSheet* ScStyleSheetPool::FindCaseIns( const 
OUString& rName, SfxStyleFami
     CaseInsensitiveNamePredicate aPredicate(rName, eFam);
     std::vector<sal_Int32> aFoundPositions = 
GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate);
 
+    ScStyleSheet* first = nullptr; // first case insensitive match found
     for (const auto& rPos : aFoundPositions)
     {
         SfxStyleSheetBase *pFound = GetStyleSheetByPositionInIndex(rPos);
         // we do not know what kind of sheets we have.
         if (pFound->isScStyleSheet())
-            return static_cast<ScStyleSheet*>(pFound);
+        {
+            if (pFound->GetName() == rName) // exact case sensitive match
+                return static_cast<ScStyleSheet*>(pFound);
+            if (!first)
+                first = static_cast<ScStyleSheet*>(pFound);
+        }
     }
-    return nullptr;
+    return first;
 }
 
 void ScStyleSheetPool::setAllParaStandard()

Reply via email to