[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sc/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Sun Aug 22 20:52:53 UTC 2021
sc/source/ui/view/gridwin4.cxx | 57 +++++++++++++++++++++++++++++++++++------
1 file changed, 50 insertions(+), 7 deletions(-)
New commits:
commit 4d431574c906f7786f1c855eaf4c9781eb4187c4
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Aug 17 16:56:22 2021 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Aug 22 22:52:18 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>
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index c3cfe1f60a54..ea76db2a2723 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -2073,14 +2073,60 @@ void ScGridWindow::GetRectsAnyFor(const ScMarkData &rMarkData,
::std::vector< tools::Rectangle >& rRects,
bool bInPrintTwips) const
{
- ScMarkData aMultiMark( rMarkData );
- aMultiMark.SetMarking( false );
- aMultiMark.MarkToMulti();
ScDocument* pDoc = pViewData->GetDocument();
SCTAB nTab = pViewData->GetTabNo();
-
+ double nPPTX = pViewData->GetPPTX();
+ double nPPTY = pViewData->GetPPTY();
bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
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 ? pViewData->GetPrintTwipsPos(nX1, nY1) :
+ pViewData->GetScrPos(nX1, nY1, eWhich);
+
+ long nStartX = aScrStartPos.X();
+ long nStartY = aScrStartPos.Y();
+
+ Point aScrEndPos = bInPrintTwips ? pViewData->GetPrintTwipsPos(nX2, nY2) :
+ pViewData->GetScrPos(nX2, nY2, eWhich);
+
+ long nWidthTwips = pDoc->GetColWidth(nX2, nTab);
+ const long nWidth = bInPrintTwips ?
+ nWidthTwips : ScViewData::ToPixel(nWidthTwips, nPPTX);
+ long nEndX = aScrEndPos.X() + (nWidth - 1) * nLayoutSign;
+
+ sal_uInt16 nHeightTwips = pDoc->GetRowHeight( nY2, nTab );
+ const long nHeight = bInPrintTwips ?
+ nHeightTwips : ScViewData::ToPixel(nHeightTwips, nPPTY);
+ 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;
@@ -2141,9 +2187,6 @@ void ScGridWindow::GetRectsAnyFor(const ScMarkData &rMarkData,
nY2 = nMaxTiledRow;
}
- double nPPTX = pViewData->GetPPTX();
- double nPPTY = pViewData->GetPPTY();
-
ScInvertMerger aInvert( &rRects );
Point aScrPos = bInPrintTwips ? pViewData->GetPrintTwipsPos(nX1, nY1) :
More information about the Libreoffice-commits
mailing list