sc/source/ui/view/cellsh1.cxx |   33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

New commits:
commit 26246b2fb202e1fe8045dd69ff771588a845764a
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Jan 20 15:59:21 2025 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Jan 20 18:14:11 2025 +0100

    Simplify a bit
    
    No need to skip the loop explicitly when there's no element in the 
container.
    No need to take integers (the elements in the container) by reference.
    
    Change-Id: I15f7ccdeaafaa5a766ae36b31e49f41daebf86b5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180518
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 3c2719e162b9..e45afab83c00 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2242,28 +2242,23 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 // try to find an existing conditional format
                 const ScPatternAttr* pPattern = rDoc.GetPattern(aPos.Col(), 
aPos.Row(), aPos.Tab());
                 ScConditionalFormatList* pList = 
rDoc.GetCondFormList(aPos.Tab());
-                const ScCondFormatIndexes& rCondFormats = 
pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
-                bool bContainsCondFormat = !rCondFormats.empty();
+                bool bContainsCondFormat = false;
                 bool bCondFormatDlg = false;
-                if(bContainsCondFormat)
+                for (auto nKey : 
pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData())
                 {
-                    bContainsCondFormat = false; // maybe all nullptrs?
-                    for (const auto& rCondFormat : rCondFormats)
+                    // check if at least one existing conditional format has 
the same range
+                    const ScConditionalFormat* pCondFormat = 
pList->GetFormat(nKey);
+                    if(!pCondFormat)
+                        continue;
+
+                    bContainsCondFormat = true; // found at least one format
+                    const ScRangeList& rCondFormatRange = 
pCondFormat->GetRange();
+                    if(rCondFormatRange == aRangeList)
                     {
-                        // check if at least one existing conditional format 
has the same range
-                        const ScConditionalFormat* pCondFormat = 
pList->GetFormat(rCondFormat);
-                        if(!pCondFormat)
-                            continue;
-
-                        bContainsCondFormat = true; // found at least one 
format
-                        const ScRangeList& rCondFormatRange = 
pCondFormat->GetRange();
-                        if(rCondFormatRange == aRangeList)
-                        {
-                            // found a matching range, edit this conditional 
format
-                            bCondFormatDlg = true;
-                            nIndex = pCondFormat->GetKey();
-                            break;
-                        }
+                        // found a matching range, edit this conditional format
+                        bCondFormatDlg = true;
+                        nIndex = pCondFormat->GetKey();
+                        break;
                     }
                 }
 

Reply via email to