summaryrefslogtreecommitdiff
path: root/sc/source/core/data/column3.cxx
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-11-23 11:49:15 -0400
committerAron Budea <aron.budea@collabora.com>2023-12-09 21:30:04 +1030
commit55179934c0fb48e43ef16172e85b2d7af360fee4 (patch)
tree8f968f6566685408b3848ee60f2f3910ce09f1c9 /sc/source/core/data/column3.cxx
parent4a3cb6b1c27173df5e8e4aac62d25079f7b59505 (diff)
sc: fix back color filter entries mimo-7.3.7.2.M8
The function "GetFilterEntries" iterates only that contains cell data value entries, the background color filter feature requires to iterate background color attribute which is not stored in multi type vector cells. Signed-off-by: Henry Castro <hcastro@collabora.com> Change-Id: I372db48d2399f62712f642eefdbfea8885b09f58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159864 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> (cherry picked from commit 826eae46095b2184554565bab1792e96964a720f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159905 Tested-by: Jenkins (cherry picked from commit 8b2369236dea7d6863c2df3d4ce5e356c9c8010c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160038 (cherry picked from commit 6b1d35b9af28e9f54306112203fa98961cd3e567)
Diffstat (limited to 'sc/source/core/data/column3.cxx')
-rw-r--r--sc/source/core/data/column3.cxx60
1 files changed, 60 insertions, 0 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 69a32eaad433..ebec09e581ef 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2720,6 +2720,66 @@ void ScColumn::GetFilterEntries(
sc::ParseAll(rBlockPos.miCellPos, maCells, nStartRow, nEndRow, aFunc, aFunc);
}
+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;
+
+ while (nRow1 <= nRow2)
+ {
+ aCell.SetRow(nRow1);
+ 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);
+ aBackColor = pBrush->GetColor();
+ bCondBackColor = true;
+ }
+ }
+
+ pCondFormat = GetDoc().GetCondFormat(aCell.Col(), aCell.Row(), aCell.Tab());
+ if (pCondFormat)
+ {
+ for (size_t nFormat = 0; nFormat < pCondFormat->size(); nFormat++)
+ {
+ auto aEntry = pCondFormat->GetEntry(nFormat);
+ if (aEntry->GetType() == ScFormatEntry::Type::Colorscale)
+ {
+ pColFormat = static_cast<const ScColorScaleFormat*>(aEntry);
+ std::optional<Color> oColor = pColFormat->GetColor(aCell);
+ if (oColor)
+ {
+ aBackColor = *oColor;
+ bCondBackColor = true;
+ }
+ }
+ }
+ }
+
+ if (!bCondBackColor)
+ {
+ pBrush = GetDoc().GetAttr(aCell, ATTR_BACKGROUND);
+ aBackColor = pBrush->GetColor();
+ }
+
+ rFilterEntries.addBackgroundColor(aBackColor);
+ nRow1++;
+ }
+}
+
namespace {
/**