sc/source/ui/view/viewfunc.cxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
New commits: commit ac859a4c6a7fce4efee9cdd45821a0c9e40e9e9a Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Oct 17 16:36:23 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Oct 18 09:35:01 2022 +0200 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.gran...@collabora.co.uk> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> 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;