[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - sc/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 15 10:57:45 UTC 2021
sc/source/ui/view/gridwin4.cxx | 57 +++++++++++++++++++++++++++++++++++------
1 file changed, 50 insertions(+), 7 deletions(-)
New commits:
commit d65e177242f2e7359e17161af5f5092daacc34eb
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Aug 17 16:56:22 2021 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Sep 15 12:57:11 2021 +0200
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 at collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122107
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
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) :
More information about the Libreoffice-commits
mailing list