sc/source/core/data/stlpool.cxx  |   10 ++++--
 sc/source/core/tool/interpr2.cxx |   64 ++++++++++++++++++---------------------
 2 files changed, 39 insertions(+), 35 deletions(-)

New commits:
commit 2844670d2a47c606cbebb99f73389f30154a3c5e
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Feb 10 16:44:37 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Feb 10 16:12:35 2023 +0000

    Flatten ScInterpreter::ScStyle
    
    Change-Id: I64c622d2c2cacccc7eda02e8739657fe345f9be8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146777
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 707d9c66cb3d..c8015598891f 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2592,48 +2592,46 @@ void ScInterpreter::ScCurrent()
 void ScInterpreter::ScStyle()
 {
     sal_uInt8 nParamCount = GetByte();
-    if (nParamCount >= 1 && nParamCount <= 3)
-    {
-        OUString aStyle2;                           // Template after timer
-        if (nParamCount >= 3)
-            aStyle2 = GetString().getString();
-        tools::Long nTimeOut = 0;                          // timeout
-        if (nParamCount >= 2)
-            nTimeOut = static_cast<tools::Long>(GetDouble()*1000.0);
-        OUString aStyle1 = GetString().getString(); // Template for immediate
+    if (!MustHaveParamCount(nParamCount, 1, 3))
+        return;
 
-        if (nTimeOut < 0)
-            nTimeOut = 0;
+    OUString aStyle2;                           // Template after timer
+    if (nParamCount >= 3)
+        aStyle2 = GetString().getString();
+    tools::Long nTimeOut = 0;                          // timeout
+    if (nParamCount >= 2)
+        nTimeOut = static_cast<tools::Long>(GetDouble()*1000.0);
+    OUString aStyle1 = GetString().getString(); // Template for immediate
 
-        // Execute request to apply template
-        if ( !mrDoc.IsClipOrUndo() )
+    if (nTimeOut < 0)
+        nTimeOut = 0;
+
+    // Execute request to apply template
+    if ( !mrDoc.IsClipOrUndo() )
+    {
+        SfxObjectShell* pShell = mrDoc.GetDocumentShell();
+        if (pShell)
         {
-            SfxObjectShell* pShell = mrDoc.GetDocumentShell();
-            if (pShell)
+            // notify object shell directly!
+            bool bNotify = true;
+            if (aStyle2.isEmpty())
             {
-                // notify object shell directly!
-                bool bNotify = true;
-                if (aStyle2.isEmpty())
-                {
-                    const ScStyleSheet* pStyle = mrDoc.GetStyle(aPos.Col(), 
aPos.Row(), aPos.Tab());
+                const ScStyleSheet* pStyle = mrDoc.GetStyle(aPos.Col(), 
aPos.Row(), aPos.Tab());
 
-                    if (pStyle && pStyle->GetName() == aStyle1)
-                        bNotify = false;
-                }
+                if (pStyle && pStyle->GetName() == aStyle1)
+                    bNotify = false;
+            }
 
-                if (bNotify)
-                {
-                    ScRange aRange(aPos);
-                    ScAutoStyleHint aHint( aRange, aStyle1, nTimeOut, aStyle2 
);
-                    pShell->Broadcast( aHint );
-                }
+            if (bNotify)
+            {
+                ScRange aRange(aPos);
+                ScAutoStyleHint aHint( aRange, aStyle1, nTimeOut, aStyle2 );
+                pShell->Broadcast( aHint );
             }
         }
-
-        PushDouble(0.0);
     }
-    else
-        PushIllegalParameter();
+
+    PushDouble(0.0);
 }
 
 static ScDdeLink* lcl_GetDdeLink( const sfx2::LinkManager* pLinkMgr,
commit 2a984c77ccb1aa77d9bbd02218d4dc76aaff4a9e
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Feb 10 13:25:53 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Feb 10 16:12:28 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>

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