summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-11-06 07:18:48 -0400
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-11-11 20:27:29 +0100
commit4abe6c83e76f825319e8b2a0c0b8b8e92177da65 (patch)
tree59d02535ed3a2b8d60027f3e3864040375260278 /sc/source/core
parent76de80f512967379f809d3744c71cf5e7e095e87 (diff)
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 <hcastro@collabora.com> Change-Id: I341c602247e7f71e3c9665e1b594177d8f5553b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158991 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 768433f07873eb608837630f85e7e1b375239fca) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159238 Tested-by: Jenkins
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/document.cxx7
-rw-r--r--sc/source/core/data/table4.cxx34
-rw-r--r--sc/source/core/tool/dbdata.cxx17
3 files changed, 58 insertions, 0 deletions
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 6225e92781b9..0b4ae5ca0da8 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1081,6 +1081,13 @@ void ScDocument::GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
pTable->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<SCTAB> (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 d8a4cf584132..62b9dbb9e006 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -23,6 +23,7 @@
#include <editeng/editeng.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/escapementitem.hxx>
+#include <editeng/brushitem.hxx>
#include <svl/numformat.hxx>
#include <svl/zforlist.hxx>
#include <vcl/keycodes.hxx>
@@ -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 = &rDocument.GetPool()->GetDefaultItem(ATTR_BACKGROUND);
+
+ rStartCol = std::min<SCCOL>(rStartCol, aCol.size() - 1);
+ rEndCol = std::min<SCCOL>(rEndCol, aCol.size() - 1);
+
+ do
+ {
+ bExtend = false;
+
+ if (rEndRow < rDocument.MaxRow())
+ {
+ for (SCCOL nCol = rStartCol; nCol <= rEndCol; ++nCol)
+ {
+ const ScPatternAttr* pPattern = ColumnData(nCol).GetPattern(rEndRow + 1);
+ const SvxBrushItem* pBackground = &pPattern->GetItem(ATTR_BACKGROUND);
+ if (!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty() ||
+ pBackground != pDefBackground)
+ {
+ bExtend = true;
+ break;
+ }
+ }
+
+ if (bExtend)
+ ++rEndRow;
+ }
+ } while (bExtend);
+}
+
OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY )
{
OUString aValue;
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index d6f2a91b2256..4b24110658c3 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -665,6 +665,23 @@ void ScDBData::ExtendDataArea(const ScDocument& rDoc)
}
}
+void ScDBData::ExtendBackColorArea(const ScDocument& rDoc)
+{
+ // Extend the DB area to include data rows immediately below.
+ SCCOL nOldCol1 = nStartCol, nOldCol2 = nEndCol;
+ SCROW nOldEndRow = nEndRow;
+ rDoc.GetBackColorArea(nTable, nStartCol, nStartRow, nEndCol, nEndRow);
+
+ if (nOldEndRow < rDoc.MaxRow() && nEndRow < nOldEndRow)
+ nEndRow = nOldEndRow;
+
+ if (nStartCol != nOldCol1 || nEndCol != nOldCol2)
+ {
+ SAL_WARN_IF( !maTableColumnNames.empty(), "sc.core", "ScDBData::ExtendBackColorArea - invalidating column names/offsets");
+ InvalidateTableColumnNames( true);
+ }
+}
+
void ScDBData::StartTableColumnNamesListener()
{
if (mpContainer && bHasHeader)