sc/source/ui/view/tabview2.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit ee57936475064b409565490022f414220656e12c
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Wed Apr 27 18:36:56 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Thu Apr 28 05:51:31 2022 +0200

    fix horizontal Calc cursor skipping
    
    UITest_calc_tests' columns.CalcColumns.test_column_hide_show fails
    with INITIALCOLCOUNT being 1 because column C was hidden, but
    searching only up to the first allocated column + 1 searched only
    up to column B. Whether an entire column is hidden is not part
    of ScColumn, it's stored in ScTable.
    
    Change-Id: Ib1befe5cd0db8d50a6196bc6621fb1b0967e6209
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133524
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 654590a74152..400ea89b6106 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -739,8 +739,16 @@ void ScTabView::SkipCursorHorizontal(SCCOL& rCurX, SCROW& 
rCurY, SCCOL nOldX, SC
 
     bool bSkipCell = false;
     bool bHFlip = false;
-    // search also the first unallocated column (all unallocated columns share 
a set of attrs)
-    SCCOL nMaxCol = std::min<SCCOL>( rDoc.GetAllocatedColumnsCount(nTab) + 1, 
rDoc.MaxCol());
+    // If a number of last columns are hidden, search up to and including the 
first of them,
+    // because after it nothing changes.
+    SCCOL nMaxCol;
+    if(rDoc.ColHidden(rDoc.MaxCol(), nTab, &nMaxCol))
+        ++nMaxCol;
+    else
+        nMaxCol = rDoc.MaxCol();
+    // Search also at least up to and including the first unallocated column 
(all unallocated columns
+    // share a set of attrs).
+    nMaxCol = std::max( nMaxCol, std::min<SCCOL>( 
rDoc.GetAllocatedColumnsCount(nTab) + 1, rDoc.MaxCol()));
     do
     {
         bSkipCell = rDoc.ColHidden(rCurX, nTab) || rDoc.IsHorOverlapped(rCurX, 
rCurY, nTab);

Reply via email to