sc/source/core/data/column3.cxx | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-)
New commits: commit 6768924eebc3e6bc731c69e9a3a53781e0cb6f8f Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Nov 1 10:14:23 2024 +0200 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Fri Nov 1 11:36:50 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> diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index ab8b434a1e9d..442d9f023557 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2719,35 +2719,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++) @@ -2755,7 +2750,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) { @@ -2768,7 +2763,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(); }