[Libreoffice-commits] core.git: Branch 'distro/mimo/mimo-7-5' - sc/inc sc/source

2023-11-29 Thread Henry Castro (via logerrit)
 sc/inc/column.hxx   |2 +
 sc/source/core/data/column3.cxx |   60 
 sc/source/core/data/table3.cxx  |6 
 3 files changed, 68 insertions(+)

New commits:
commit 6b1d35b9af28e9f54306112203fa98961cd3e567
Author: Henry Castro 
AuthorDate: Thu Nov 23 11:49:15 2023 -0400
Commit: Henry Castro 
CommitDate: Wed Nov 29 20:57:08 2023 +0100

sc: fix back color filter entries

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 
Change-Id: I372db48d2399f62712f642eefdbfea8885b09f58
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159864
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
(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

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 87d3dc730a9f..9fb3e9557bb0 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -598,6 +598,8 @@ public:
 sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW 
nEndRow,
 ScFilterEntries& rFilterEntries, bool bFiltering, bool bFilteredRow );
 
+void GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, ScFilterEntries& 
rFilterEntries );
+
 bool GetDataEntries( SCROW nRow, std::set& rStrings) const;
 
 void UpdateInsertTabAbs(SCTAB nNewPos);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index ca16c49d8de8..2ef0f9aee3df 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2753,6 +2753,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 = >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(aEntry);
+std::optional 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 {
 
 /**
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index bdf16a69aad4..77b66ec0b750 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2963,6 +2963,12 @@ void ScTable::GetFilterEntries( SCCOL nCol, SCROW nRow1, 
SCROW nRow2, ScFilterEn
 sc::ColumnBlockConstPosition aBlockPos;
 aCol[nCol].InitBlockPosition(aBlockPos);
 aCol[nCol].GetFilterEntries(aBlockPos, nRow1, nRow2, rFilterEntries, 
bFiltering, false /*bFilteredRow*/);
+
+SCROW nLastRow = aBlockPos.miCellPos->position;
+if (nLastRow < nRow2)
+{
+aCol[nCol].GetBackColorFilterEntries(nLastRow, nRow2, rFilterEntries);
+}
 }
 
 void ScTable::GetFilteredFilterEntries(


[Libreoffice-commits] core.git: Branch 'distro/mimo/mimo-7-5' - sc/inc sc/source

2023-11-14 Thread Henry Castro (via logerrit)
 sc/inc/dbdata.hxx|1 +
 sc/inc/document.hxx  |7 +++
 sc/inc/table.hxx |3 +++
 sc/source/core/data/document.cxx |7 +++
 sc/source/core/data/table4.cxx   |   34 ++
 sc/source/core/tool/dbdata.cxx   |   17 +
 sc/source/ui/view/gridwin.cxx|1 +
 sc/source/ui/view/tabvwshc.cxx   |1 +
 8 files changed, 71 insertions(+)

New commits:
commit 64a4011951f54f8b86205798b968b20b532ea703
Author: Henry Castro 
AuthorDate: Mon Nov 6 07:18:48 2023 -0400
Commit: Henry Castro 
CommitDate: Tue Nov 14 16:59:24 2023 +0100

sc: extend backcolor area

If the filter background color is selected,
the automatic selection area should include,
the attribute of background cell color too.

Signed-off-by: Henry Castro 
Change-Id: I341c602247e7f71e3c9665e1b594177d8f5553b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158991
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 768433f07873eb608837630f85e7e1b375239fca)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159238
Tested-by: Jenkins
(cherry picked from commit 4abe6c83e76f825319e8b2a0c0b8b8e92177da65)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159249

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index 482c55bc6aa4..df235ec52619 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -221,6 +221,7 @@ public:
 SCCOL nDx, SCROW nDy, SCTAB nDz);
 
 void ExtendDataArea(const ScDocument& rDoc);
+void ExtendBackColorArea(const ScDocument& rDoc);
 void CalcSaveFilteredCount(SCSIZE nNonFilteredRowCount);
 void GetFilterSelCount(SCSIZE& nSelected, SCSIZE& nTotal);
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 97b47ee94d00..aeb277ec4f3a 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1506,6 +1506,13 @@ public:
  SCCOL& rEndCol, SCROW& rEndRow,
  bool bIncludeOld, bool bOnlyDown 
) const;
 
+/**
+ * Return the extended area containing at least all contiguous cells
+ * having background color.
+ */
+SC_DLLPUBLIC void GetBackColorArea( SCTAB nTab, SCCOL& rStartCol, SCROW& 
rStartRow,
+SCCOL& rEndCol, SCROW& rEndRow ) const;
+
 /**
  * Returns true if there is a non-empty subrange in the range given as 
input.
  * In that case it also modifies rRange to largest subrange that does not
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 3367af129c19..4f7407809115 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -627,6 +627,9 @@ public:
 voidGetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& 
rEndCol, SCROW& rEndRow,
  bool bIncludeOld, bool bOnlyDown ) const;
 
+voidGetBackColorArea( SCCOL& rStartCol, SCROW& rStartRow,
+  SCCOL& rEndCol, SCROW& rEndRow ) const;
+
 boolGetDataAreaSubrange( ScRange& rRange ) const;
 
 boolShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, 
SCROW& rStartRow,
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 79ce684d87be..e80d56203351 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1104,6 +1104,13 @@ void ScDocument::GetDataArea( SCTAB nTab, SCCOL& 
rStartCol, SCROW& rStartRow,
 maTabs[nTab]->GetDataArea( rStartCol, rStartRow, rEndCol, rEndRow, 
bIncludeOld, bOnlyDown );
 }
 
+void ScDocument::GetBackColorArea( SCTAB nTab, SCCOL& rStartCol, SCROW& 
rStartRow,
+   SCCOL& rEndCol, SCROW& rEndRow ) const
+{
+if (ValidTab(nTab) && nTab < static_cast (maTabs.size()) && 
maTabs[nTab])
+maTabs[nTab]->GetBackColorArea( rStartCol, rStartRow, rEndCol, rEndRow 
);
+}
+
 bool ScDocument::GetDataAreaSubrange(ScRange& rRange) const
 {
 SCTAB nTab = rRange.aStart.Tab();
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 9c6852990efe..3ec8dc5aeab7 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1293,6 +1294,39 @@ void  ScTable::FillSparkline(bool bVertical, SCCOLROW 
nFixed,
 }
 }
 
+void ScTable::GetBackColorArea(SCCOL& rStartCol, SCROW& /*rStartRow*/,
+   SCCOL& rEndCol, SCROW& rEndRow ) const
+{
+bool bExtend;
+const SvxBrushItem* pDefBackground = 
()->GetDefaultItem(ATTR_BACKGROUND);
+
+rStartCol = std::min(rStartCol, aCol.size() - 1);
+rEndCol = std::min(rEndCol, aCol.size() - 1);
+
+do
+{
+bExtend = false;
+
+if (rEndRow < rDocument.MaxRow())
+{
+