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.lunak@collabora.com>
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 654590a..400ea89 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);