sc/source/core/data/column3.cxx |   27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

New commits:
commit f8e055c5f719630123608fa0e6b59fc505192139
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Nov 1 10:14:23 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Nov 4 08:52:16 2024 +0100

    fix GetBackColorFilterEntries missing colors
    
    Because the bCondBackColor var is outside the loop, once it is set to
    true, it stays true for the remainder of the loop, which means we might
    miss picking up a new background color.
    
    ever since
        commit 8b2369236dea7d6863c2df3d4ce5e356c9c8010c
        Author: Henry Castro <hcas...@collabora.com>
        Date:   Thu Nov 23 11:49:15 2023 -0400
        sc: fix back color filter entries
    
    Change-Id: I85625941fcd67fac7aabc24d43b2a56999e337db
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175896
    Tested-by: Jenkins
    Reviewed-by: Henry Castro <hcas...@collabora.com>
    (cherry picked from commit 6768924eebc3e6bc731c69e9a3a53781e0cb6f8f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175913
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 26fcd36de0ba..e0f5006f0d63 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2717,35 +2717,30 @@ void ScColumn::GetFilterEntries(
 
 void ScColumn::GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, 
ScFilterEntries& rFilterEntries)
 {
-    Color aBackColor;
-    bool bCondBackColor = false;
-    ScAddress aCell(GetCol(), 0, GetTab());
-    ScConditionalFormat* pCondFormat = nullptr;
-
-    const SfxItemSet* pCondSet = nullptr;
-    const SvxBrushItem* pBrush = nullptr;
-    const ScPatternAttr* pPattern = nullptr;
-    const ScColorScaleFormat* pColFormat = nullptr;
-
     if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2))
         return;
 
+    ScAddress aCell(GetCol(), 0, GetTab());
     while (nRow1 <= nRow2)
     {
         aCell.SetRow(nRow1);
-        pPattern = GetDoc().GetPattern(aCell.Col(), aCell.Row(), aCell.Tab());
+
+        Color aBackColor;
+        bool bCondBackColor = false;
+
+        const ScPatternAttr* pPattern = GetDoc().GetPattern(aCell.Col(), 
aCell.Row(), aCell.Tab());
         if (pPattern)
         {
             if 
(!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty())
             {
-                pCondSet = GetDoc().GetCondResult(GetCol(), nRow1, GetTab());
-                pBrush = &pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
+                const SfxItemSet* pCondSet = GetDoc().GetCondResult(GetCol(), 
nRow1, GetTab());
+                const SvxBrushItem* pBrush = 
&pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
                 aBackColor = pBrush->GetColor();
                 bCondBackColor = true;
             }
         }
 
-        pCondFormat = GetDoc().GetCondFormat(aCell.Col(), aCell.Row(), 
aCell.Tab());
+        ScConditionalFormat* pCondFormat = GetDoc().GetCondFormat(aCell.Col(), 
aCell.Row(), aCell.Tab());
         if (pCondFormat)
         {
             for (size_t nFormat = 0; nFormat < pCondFormat->size(); nFormat++)
@@ -2753,7 +2748,7 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, 
SCROW nRow2, ScFilterEntri
                 auto aEntry = pCondFormat->GetEntry(nFormat);
                 if (aEntry->GetType() == ScFormatEntry::Type::Colorscale)
                 {
-                    pColFormat = static_cast<const 
ScColorScaleFormat*>(aEntry);
+                    const ScColorScaleFormat* pColFormat = static_cast<const 
ScColorScaleFormat*>(aEntry);
                     std::optional<Color> oColor = pColFormat->GetColor(aCell);
                     if (oColor)
                     {
@@ -2766,7 +2761,7 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, 
SCROW nRow2, ScFilterEntri
 
         if (!bCondBackColor)
         {
-            pBrush = GetDoc().GetAttr(aCell, ATTR_BACKGROUND);
+            const SvxBrushItem* pBrush = GetDoc().GetAttr(aCell, 
ATTR_BACKGROUND);
             aBackColor = pBrush->GetColor();
         }
 

Reply via email to