ElyTable: under LOK an AutoFilter range keeps its rows through list, apply, toggle, undo and reopen (R2.9)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 03:20:07 -04:00
1 parent f4c1a1665b
commit 0ce468a3ad
5 files changed
+141 -120

No files matched your search

@@ -1,110 +0,0 @@
LOK Calc: an AutoFilter on marked rows keeps to those rows
Each time the filter list opens, GetFilterEntries grows an unnamed
filter range to the data rows right under it (ExtendDataArea and
ExtendBackColorArea), so appended rows join. It cannot tell them from
a totals row that was there when the user marked the block: the
total joined the filter, showed in its list and hid with the data.
Under LOK, an AutoFilter set on a marked block that spans rows keeps
that block: ScDBData remembers it (not saved) and never extends.
diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index 6d80216b4..54515b138 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -119,6 +119,7 @@ private:
sal_uInt16 nIndex; ///< unique index formulas
bool bAutoFilter; ///< AutoFilter? (not saved)
+ bool bMarkedRows; ///< rows were marked; never extend (not saved)
bool bModified; ///< is set/cleared for/by(?) UpdateReference
::std::vector< OUString > maTableColumnNames; ///< names of table columns
@@ -244,6 +245,9 @@ public:
bool HasAutoFilter() const { return bAutoFilter; }
void SetAutoFilter(bool bSet) { bAutoFilter = bSet; }
+ bool HasMarkedRows() const { return bMarkedRows; }
+ void SetMarkedRows(bool bSet) { bMarkedRows = bSet; }
+
bool IsModified() const { return bModified; }
void SetModified(bool bMod) { bModified = bMod; }
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index b1d714c55..e7c5a16c1 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -75,6 +75,7 @@ ScDBData::ScDBData( const OUString& rName,
bDBSelection(false),
nIndex (0),
bAutoFilter (false),
+ bMarkedRows (false),
bModified (false),
mbTableColumnNamesDirty(true),
nFilteredRowCount(SCSIZE_MAX)
@@ -110,6 +111,7 @@ ScDBData::ScDBData( const ScDBData& rData ) :
bDBSelection (rData.bDBSelection),
nIndex (rData.nIndex),
bAutoFilter (rData.bAutoFilter),
+ bMarkedRows (rData.bMarkedRows),
bModified (rData.bModified),
maTableColumnNames (rData.maTableColumnNames),
maTableColumnAttributes(rData.maTableColumnAttributes),
@@ -146,6 +148,7 @@ ScDBData::ScDBData( const OUString& rName, const ScDBData& rData ) :
bDBSelection (rData.bDBSelection),
nIndex (rData.nIndex),
bAutoFilter (rData.bAutoFilter),
+ bMarkedRows (rData.bMarkedRows),
bModified (rData.bModified),
maTableColumnNames (rData.maTableColumnNames),
maTableColumnAttributes(rData.maTableColumnAttributes),
@@ -192,6 +195,7 @@ ScDBData& ScDBData::operator= (const ScDBData& rData)
bDBSelection = rData.bDBSelection;
nIndex = rData.nIndex;
bAutoFilter = rData.bAutoFilter;
+ bMarkedRows = rData.bMarkedRows;
nFilteredRowCount = rData.nFilteredRowCount;
if (bHeaderRangeDiffers)
@@ -646,6 +650,8 @@ bool ScDBData::UpdateReference(const ScDocument& rDoc, UpdateRefMode eUpdateRefM
void ScDBData::ExtendDataArea(const ScDocument& rDoc)
{
+ if (bMarkedRows)
+ return;
// Extend the DB area to include data rows immediately below.
SCCOL nOldCol1 = nStartCol, nOldCol2 = nEndCol;
SCROW nOldEndRow = nEndRow;
@@ -665,6 +671,8 @@ void ScDBData::ExtendDataArea(const ScDocument& rDoc)
void ScDBData::ExtendBackColorArea(const ScDocument& rDoc)
{
+ if (bMarkedRows)
+ return;
// Extend the DB area to include data rows immediately below.
SCCOL nOldCol1 = nStartCol, nOldCol2 = nEndCol;
SCROW nOldEndRow = nEndRow;
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
index db3d23d86..8140ce4d0 100644
--- a/sc/source/ui/view/dbfunc.cxx
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -18,6 +18,7 @@
*/
#include <scitems.hxx>
+#include <comphelper/lok.hxx>
#include <sfx2/bindings.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
@@ -286,6 +287,11 @@ void ScDBFunc::ToggleAutoFilter()
return;
pDBData->SetByRow( true ); //! undo, retrieve beforehand ??
+ // LOK: marked rows are the range, as in Excel.
+ ScRange aMarked;
+ pDBData->SetMarkedRows(comphelper::LibreOfficeKit::isActive()
+ && rViewData.GetSimpleArea(aMarked) == SC_MARK_SIMPLE
+ && aMarked.aStart.Row() != aMarked.aEnd.Row());
pDBData->GetQueryParam( aParam );
SCCOL nCol;
@@ -0,0 +1,65 @@
LOK Calc: an AutoFilter range keeps its rows
Calc regrows an unnamed AutoFilter range from the data around it: each
time the filter list opens (ExtendDataArea, ExtendBackColorArea, so
appended rows join) and whenever a command finds it from a single cell
(ScDocShell::GetDBData, so applying a condition, toggling it off, and
its undo). A totals row right under a marked block joined the filter,
showed in its list and hid with the data; a saved range reopened grew
the same way. Under LOK the range keeps the rows it was set on, as in
Excel. A single cell still takes the data area when the filter is set.
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index b1d714c55..9a01847ee 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -19,6 +19,7 @@
#include <sal/config.h>
#include <sal/log.hxx>
+#include <comphelper/lok.hxx>
#include <o3tl/safeint.hxx>
#include <unotools/transliterationwrapper.hxx>
@@ -646,6 +647,9 @@ bool ScDBData::UpdateReference(const ScDocument& rDoc, UpdateRefMode eUpdateRefM
void ScDBData::ExtendDataArea(const ScDocument& rDoc)
{
+ // LOK: an AutoFilter range keeps its rows, as in Excel.
+ if (comphelper::LibreOfficeKit::isActive() && bAutoFilter)
+ return;
// Extend the DB area to include data rows immediately below.
SCCOL nOldCol1 = nStartCol, nOldCol2 = nEndCol;
SCROW nOldEndRow = nEndRow;
@@ -665,6 +669,8 @@ void ScDBData::ExtendDataArea(const ScDocument& rDoc)
void ScDBData::ExtendBackColorArea(const ScDocument& rDoc)
{
+ if (comphelper::LibreOfficeKit::isActive() && bAutoFilter)
+ return;
// Extend the DB area to include data rows immediately below.
SCCOL nOldCol1 = nStartCol, nOldCol2 = nEndCol;
SCROW nOldEndRow = nEndRow;
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index d154597c3..54a2344af 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -19,6 +19,7 @@
#include <memory>
#include <sal/config.h>
+#include <comphelper/lok.hxx>
#include <cassert>
@@ -147,7 +148,9 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe
if (!bSelected)
{
bUseThis = true;
- if ( bIsNoName && (eMode == SC_DB_MAKE || eMode == SC_DB_AUTOFILTER) )
+ // LOK: an AutoFilter range keeps its rows, as in Excel.
+ const bool bKeep = comphelper::LibreOfficeKit::isActive() && pData->HasAutoFilter();
+ if ( bIsNoName && !bKeep && (eMode == SC_DB_MAKE || eMode == SC_DB_AUTOFILTER) )
{
// If nothing marked or only one row marked, adapt
// "unnamed" to contiguous area.