sc/source/ui/view/cellsh1.cxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 9916469fa9ff48340cfe317269f259b50e4ecd21
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Jan 20 17:26:24 2025 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Jan 20 15:04:35 2025 +0100

    tdf#164722: fix the "contains conditional format" condition
    
    In commit a06a44c3b342648139e7fa0ff850a4176df60538 (one more fix for
    fdo#58686, 2012-12-25), the code was adjusted for possible nullptrs
    in the conditional format list. The new bContainsExistingCondFormat
    variable meant "there is at least one non-nullptr element in list",
    and was used as a condition for deciding which dialog to show (and
    the pre-existing bContainsCondFormat variable was used to decide if
    iterating the list is necessary).
    
    But the two similar variables resulted in confusion; eventually, in
    commit 2b5915da481990fd6ea272104215d82b6fbf5dbb (tdf#60573 Conditional
    formatting does not allow scrolling, 2015-05-12), bContainsCondFormat
    was misused in a condition to show the dialog.
    
    Commit c492de66a077f3a2a960209b0b8b278b3901f361 (tdf#160149: save
    and restore the whole set of tab's conditional formats, 2024-03-17),
    nullptrs became possible in one more scenario (which is OK), but
    that uncovered the wrong variable use here.
    
    To avoid further confusion, merge the two variables into one, i.e.
    update bContainsCondFormat in the loop over the list - so that we
    only have one "contains conditional format" variable with up-to-date
    information.
    
    Change-Id: I567dc97551fba748bf6f2242d4650442f4753cc8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180507
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 99f5075f6b3a..3c2719e162b9 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2245,9 +2245,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 const ScCondFormatIndexes& rCondFormats = 
pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
                 bool bContainsCondFormat = !rCondFormats.empty();
                 bool bCondFormatDlg = false;
-                bool bContainsExistingCondFormat = false;
                 if(bContainsCondFormat)
                 {
+                    bContainsCondFormat = false; // maybe all nullptrs?
                     for (const auto& rCondFormat : rCondFormats)
                     {
                         // check if at least one existing conditional format 
has the same range
@@ -2255,7 +2255,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                         if(!pCondFormat)
                             continue;
 
-                        bContainsExistingCondFormat = true;
+                        bContainsCondFormat = true; // found at least one 
format
                         const ScRangeList& rCondFormatRange = 
pCondFormat->GetRange();
                         if(rCondFormatRange == aRangeList)
                         {
@@ -2426,7 +2426,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 
                 // if not found a conditional format ask whether we should 
edit one of the existing
                 // or should create a new overlapping conditional format
-                if(bContainsCondFormat && !bCondFormatDlg && 
bContainsExistingCondFormat)
+                if (bContainsCondFormat && !bCondFormatDlg)
                 {
                     std::shared_ptr<weld::MessageDialog> 
xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
                                                                    
VclMessageType::Question, VclButtonsType::YesNo,

Reply via email to