sc/source/ui/view/tabview.cxx |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit eeffa4b2a85751fd0153503520f6fc49b3510d86
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Thu Mar 10 16:40:26 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Fri Mar 11 08:19:13 2022 +0100

    optimize searching for last visible row
    
    If all the remaining rows until the end of the sheet are hidden
    (which apparently some users do to make the sheet look "nicer"),
    don't search all the rows one by one.
    
    Change-Id: I5f7ef61ece62f7858d4d8cfdf53bb514daa5b504
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131323
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 5862d87a8fa0..523044c7531a 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1330,15 +1330,15 @@ namespace
 
 SCROW lcl_LastVisible( const ScViewData& rViewData )
 {
-    // If many rows are hidden at end of the document (what kind of idiot does 
that?),
+    // If many rows are hidden at end of the document,
     // then there should not be a switch to wide row headers because of this
-    //! as a member to the document???
     ScDocument& rDoc = rViewData.GetDocument();
     SCTAB nTab = rViewData.GetTabNo();
 
     SCROW nVis = rDoc.MaxRow();
-    while ( nVis > 0 && rDoc.GetRowHeight( nVis, nTab ) == 0 )
-        --nVis;
+    SCROW startRow;
+    while ( nVis > 0 && rDoc.GetRowHeight( nVis, nTab, &startRow, nullptr ) == 
0 )
+        nVis = std::max<SCROW>( startRow - 1, 0 );
     return nVis;
 }
 

Reply via email to