summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-08-17 16:56:22 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2021-10-06 11:11:14 +0200
commit57a628d540287c4bfa8251e50279f4879faa184d (patch)
tree4f6e54b6c37f260e290cf7b7f3f908e30877f4a7 /sc
parent8ede76d9accc8e3b1ea2c8e332cbb373a1b4d9cf (diff)
calc: get rects faster for simple selection
In LOK when we select the full row using keyboard shortcut Ctrl + Shift + right arrow we need to receive complete selection so we will avoid requesting it by chunks, slowly moving the view to the right. So - don't clip the selection rects to the visible area. It is needed only for simple selections so to avoid performance issues - use simpler algorithm without loops checking every cell size. Change-Id: I6ab975b6c155f3dde3014a52752ffdc79a93844f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120611 Reviewed-by: Henry Castro <hcastro@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122107 Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123099 Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/view/gridwin4.cxx57
1 files changed, 50 insertions, 7 deletions
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index f810efbb8c19..e37949f7ef23 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -2115,14 +2115,60 @@ void ScGridWindow::GetRectsAnyFor(const ScMarkData &rMarkData,
::std::vector< tools::Rectangle >& rRects,
bool bInPrintTwips) const
{
- ScMarkData aMultiMark( rMarkData );
- aMultiMark.SetMarking( false );
- aMultiMark.MarkToMulti();
ScDocument& rDoc = mrViewData.GetDocument();
SCTAB nTab = mrViewData.GetTabNo();
-
+ double nPPTX = mrViewData.GetPPTX();
+ double nPPTY = mrViewData.GetPPTY();
bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ ScMarkData aMultiMark( rMarkData );
+ aMultiMark.SetMarking( false );
+
+ if (!aMultiMark.IsMultiMarked())
+ {
+ // simple range case - simplify calculation
+ ScRange aSimpleRange;
+ aMultiMark.GetMarkArea( aSimpleRange );
+
+ aMultiMark.MarkToMulti();
+ if ( !aMultiMark.IsMultiMarked() )
+ return;
+
+ SCCOL nX1 = aSimpleRange.aStart.Col();
+ SCROW nY1 = aSimpleRange.aStart.Row();
+ SCCOL nX2 = aSimpleRange.aEnd.Col();
+ SCROW nY2 = aSimpleRange.aEnd.Row();
+
+ PutInOrder( nX1, nX2 );
+ PutInOrder( nY1, nY2 );
+
+ Point aScrStartPos = bInPrintTwips ? mrViewData.GetPrintTwipsPos(nX1, nY1) :
+ mrViewData.GetScrPos(nX1, nY1, eWhich);
+
+ tools::Long nStartX = aScrStartPos.X();
+ tools::Long nStartY = aScrStartPos.Y();
+
+ Point aScrEndPos = bInPrintTwips ? mrViewData.GetPrintTwipsPos(nX2, nY2) :
+ mrViewData.GetScrPos(nX2, nY2, eWhich);
+
+ tools::Long nWidthTwips = rDoc.GetColWidth(nX2, nTab);
+ const tools::Long nWidth = bInPrintTwips ?
+ nWidthTwips : ScViewData::ToPixel(nWidthTwips, nPPTX);
+ tools::Long nEndX = aScrEndPos.X() + (nWidth - 1) * nLayoutSign;
+
+ sal_uInt16 nHeightTwips = rDoc.GetRowHeight( nY2, nTab );
+ const tools::Long nHeight = bInPrintTwips ?
+ nHeightTwips : ScViewData::ToPixel(nHeightTwips, nPPTY);
+ tools::Long nEndY = aScrEndPos.Y() + nHeight - 1;
+
+ ScInvertMerger aInvert( &rRects );
+ aInvert.AddRect( tools::Rectangle( nStartX, nStartY, nEndX, nEndY ) );
+
+ return;
+ }
+
+ aMultiMark.MarkToMulti();
if ( !aMultiMark.IsMultiMarked() )
return;
ScRange aMultiRange;
@@ -2183,9 +2229,6 @@ void ScGridWindow::GetRectsAnyFor(const ScMarkData &rMarkData,
nY2 = nMaxTiledRow;
}
- double nPPTX = mrViewData.GetPPTX();
- double nPPTY = mrViewData.GetPPTY();
-
ScInvertMerger aInvert( &rRects );
Point aScrPos = bInPrintTwips ? mrViewData.GetPrintTwipsPos(nX1, nY1) :