summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-10-17 16:36:23 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-10-18 09:35:01 +0200
commitac859a4c6a7fce4efee9cdd45821a0c9e40e9e9a (patch)
tree6e7d452d038e92eb122ab3f3d94304bf43fde71e
parentaa70820a79152830a32070eb722311b8531945a4 (diff)
tdf#147842 shrink selection to data area when applying to entire sheet
This takes the time to apply the formating from "who knows how long" to about 500ms on my machine. Change-Id: I202d023c58ea191bf080ef3a85068e8acab52dec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141463 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/source/ui/view/viewfunc.cxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 423c66abef2b..8b7adf0c0f19 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1171,6 +1171,34 @@ void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem
StartFormatArea();
}
+static void ShrinkToDataArea(ScMarkData& rFuncMark, ScDocument& rDoc)
+{
+ // tdf#147842 if the marked area is the entire sheet, then shrink it to the data area.
+ // Otherwise ctrl-A, perform-action, will take a very long time as it tries to modify
+ // cells then we are not using.
+ if (rFuncMark.IsMultiMarked())
+ return;
+ ScRange aMarkArea = rFuncMark.GetMarkArea();
+ const ScSheetLimits& rLimits = rDoc.GetSheetLimits();
+ if (aMarkArea.aStart.Row() != 0 || aMarkArea.aStart.Col() != 0)
+ return;
+ if (aMarkArea.aEnd.Row() != rLimits.MaxRow() || aMarkArea.aEnd.Col() != rLimits.MaxCol())
+ return;
+ if (aMarkArea.aStart.Tab() != aMarkArea.aEnd.Tab())
+ return;
+ SCCOL nStartCol = aMarkArea.aStart.Col();
+ SCROW nStartRow = aMarkArea.aStart.Row();
+ SCCOL nEndCol = aMarkArea.aEnd.Col();
+ SCROW nEndRow = aMarkArea.aEnd.Row();
+ rDoc.ShrinkToDataArea(aMarkArea.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow);
+ aMarkArea.aStart.SetCol(nStartCol);
+ aMarkArea.aStart.SetRow(nStartRow);
+ aMarkArea.aEnd.SetCol(nEndCol);
+ aMarkArea.aEnd.SetRow(nEndRow);
+ rFuncMark.ResetMark();
+ rFuncMark.SetMarkArea(aMarkArea);
+}
+
// pattern only
void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursorOnly )
@@ -1179,6 +1207,7 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursor
ScDocShell* pDocSh = rViewData.GetDocShell();
ScDocument& rDoc = pDocSh->GetDocument();
ScMarkData aFuncMark( rViewData.GetMarkData() ); // local copy for UnmarkFiltered
+ ShrinkToDataArea( aFuncMark, rDoc );
ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
bool bRecord = true;