summaryrefslogtreecommitdiff
path: root/sc/source
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-09-15 12:57:11 +0200
commitd65e177242f2e7359e17161af5f5092daacc34eb (patch)
treec18009ddeb03f71e6e65f9440286f459cd6d6b47 /sc/source
parent86bcb80eaf5aa5f2e9a476157906bb2e04f18aad (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>
Diffstat (limited to 'sc/source')
-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 65d8e2cf5387..ce6c70b44c01 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -2076,14 +2076,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;
@@ -2144,9 +2190,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) :