summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-02-18 15:28:14 +0100
committerLuboš Luňák <l.lunak@collabora.com>2021-02-19 10:40:50 +0100
commitb9921adae997579915b4600c688719620f9adaf6 (patch)
treeb26070355b88d56bb1e3665349e6c0e3a531fc96
parentbba3afbd5e5ad65375e832a0e3174fe70d42a6e5 (diff)
"delete" also empty Calc cells if it helps mdds (tdf#139820)
With mixed non-empty and empty cells, deleting a range would normally mean deleting just the non-empty cell ranges, which would make mdds repeatedly move parts of the underlying vector. Including empty cells in the range to delete may result in just one pass. Change-Id: Ia2ebcaba054c6e46f3cf6c964ba883bb600d6ee0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111125 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--sc/source/core/data/column3.cxx35
1 files changed, 34 insertions, 1 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 14d1ebdc09c4..c3eb06afc497 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -812,6 +812,11 @@ class DeleteAreaHandler
bool mbDateTime:1;
ScColumn& mrCol;
+ SCROW mLastToDeleteRow1;
+ SCROW mLastToDeleteRow2;
+ SCROW mLastEmptyRow1;
+ SCROW mLastEmptyRow2;
+
public:
DeleteAreaHandler(ScDocument& rDoc, InsertDeleteFlags nDelFlag, ScColumn& rCol) :
mrDoc(rDoc),
@@ -820,7 +825,12 @@ public:
mbString(nDelFlag & InsertDeleteFlags::STRING),
mbFormula(nDelFlag & InsertDeleteFlags::FORMULA),
mbDateTime(nDelFlag & InsertDeleteFlags::DATETIME),
- mrCol(rCol) {}
+ mrCol(rCol),
+ mLastToDeleteRow1(-1),
+ mLastToDeleteRow2(-1),
+ mLastEmptyRow1(-1),
+ mLastEmptyRow2(-1)
+ {}
void operator() (const sc::CellStoreType::value_type& node, size_t nOffset, size_t nDataSize)
{
@@ -857,6 +867,20 @@ public:
}
break;
case sc::element_type_empty:
+ {
+ // See usage below.
+ if( mLastToDeleteRow1 >= 0 )
+ {
+ SCROW nRow1 = node.position + nOffset;
+ SCROW nRow2 = nRow1 + nDataSize - 1;
+ if( nRow1 == mLastToDeleteRow2 + 1 )
+ {
+ mLastEmptyRow1 = nRow1;
+ mLastEmptyRow2 = nRow2;
+ }
+ }
+ return;
+ }
default:
return;
}
@@ -864,7 +888,16 @@ public:
// Tag these cells for deletion.
SCROW nRow1 = node.position + nOffset;
SCROW nRow2 = nRow1 + nDataSize - 1;
+ // tdf#139820: Decide whether to include 'empty' cells in the range to delete.
+ // This may make sense because if the column contains a mix of empty and non-empty
+ // cells, then deleting a range of those cells would normally make mdds operate
+ // on ranges of such cells, event though it could simply delete them all in one go.
+ if( mLastEmptyRow1 >= 0 && nRow1 == mLastEmptyRow2 + 1 )
+ nRow1 = mLastEmptyRow1;
maDeleteRanges.set(nRow1, nRow2, true);
+ mLastToDeleteRow1 = nRow1;
+ mLastToDeleteRow2 = nRow2;
+ mLastEmptyRow1 = mLastEmptyRow2 = -1;
}
void deleteNumeric(const sc::CellStoreType::value_type& node, size_t nOffset, size_t nDataSize)