summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-02-07 20:17:42 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-02-08 12:27:54 +0100
commitd20598d14a95675a436736679ab4a82a8cc3a703 (patch)
treef10cb25a02dd76cff7cabad89373c07679db208b /sc
parentcd50d33fc4af3f2d4ab40de98ecf02f0d832d750 (diff)
optimize ScTabView::SkipCursorVertical() for many hidden rows
The code skips all hidden rows, and it does so one by one, until it encounters the last row, and then it reverses and goes back. With a huge sheet it may spend a noticeable time doing this. Since the RowHidden() function gives a range, use that to skip hidden rows faster. Change-Id: I14a990d288d28e9cab69d7dcc7f0dc9210434859 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129643 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/view/tabview2.cxx24
1 files changed, 20 insertions, 4 deletions
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index bf2f1603815b..b5ca9b40d521 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -840,8 +840,14 @@ void ScTabView::SkipCursorVertical(SCCOL& rCurX, SCROW& rCurY, SCROW nOldY, SCRO
bool bVFlip = false;
do
{
- SCROW nLastRow = -1;
- bSkipCell = rDoc.RowHidden(rCurY, nTab, nullptr, &nLastRow) || rDoc.IsVerOverlapped( rCurX, rCurY, nTab );
+ SCROW nFirstHiddenRow = -1;
+ SCROW nLastHiddenRow = -1;
+ bSkipCell = rDoc.RowHidden(rCurY, nTab, &nFirstHiddenRow, &nLastHiddenRow);
+ if (!bSkipCell)
+ {
+ nFirstHiddenRow = nLastHiddenRow = -1;
+ bSkipCell = rDoc.IsVerOverlapped( rCurX, rCurY, nTab );
+ }
if (bSkipProtected && !bSkipCell)
bSkipCell = rDoc.HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HasAttrFlags::Protected);
if (bSkipUnprotected && !bSkipCell)
@@ -867,10 +873,20 @@ void ScTabView::SkipCursorVertical(SCCOL& rCurX, SCROW& rCurY, SCROW nOldY, SCRO
}
}
else
+ {
+ // nFirstRow/nLastRow are set only if the row is hidden, in which case we always skip,
+ // so as an optimization skip to the first row after the hidden range
if (nMovY > 0)
- ++rCurY;
+ if (nLastHiddenRow >= 0)
+ rCurY = std::min<SCROW>(nLastHiddenRow + 1, rDoc.MaxRow());
+ else
+ ++rCurY;
else
- --rCurY;
+ if (nFirstHiddenRow >= 0)
+ rCurY = std::max<SCROW>(nFirstHiddenRow - 1, 0);
+ else
+ --rCurY;
+ }
}
}
while (bSkipCell);