sc/source/ui/view/tabview3.cxx | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-)
New commits: commit 552170c9c8ad6d215aa456ba9d622af01c25d275 Author: Denis Sorotnik <sorot...@gmail.com> AuthorDate: Tue Aug 8 15:19:17 2023 +0600 Commit: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> CommitDate: Wed Aug 16 12:47:50 2023 +0200 tdf#156311 Cycling through tabs in Calc Change-Id: Ieadae5dea642b27a2c91fd8c34049dc5a79bdf6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155449 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org> diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index bb0c4701387d..03a15b4437d9 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -1779,33 +1779,34 @@ void ScTabView::SelectNextTab( short nDir, bool bExtendSelection ) ScDocument& rDoc = aViewData.GetDocument(); SCTAB nTab = aViewData.GetTabNo(); - if (nDir<0) + SCTAB nNextTab = nTab; + if (nDir < 0) { - if (!nTab) - return; - --nTab; - while (!rDoc.IsVisible(nTab)) + do { - if (!nTab) - return; - --nTab; - } + --nNextTab; + if (nNextTab < 0) + nNextTab = rDoc.GetTableCount(); + if (rDoc.IsVisible(nNextTab)) + break; + } while (nNextTab != nTab); } - else + if (nDir > 0) { SCTAB nCount = rDoc.GetTableCount(); - ++nTab; - if (nTab >= nCount) - return; - while (!rDoc.IsVisible(nTab)) + do { - ++nTab; - if (nTab >= nCount) - return; - } + ++nNextTab; + if (nNextTab >= nCount) + nNextTab = 0; + if (rDoc.IsVisible(nNextTab)) + break; + } while (nNextTab != nTab); } + if (nNextTab == nTab) + return; - SetTabNo( nTab, false, bExtendSelection ); + SetTabNo(nNextTab, false, bExtendSelection); PaintExtras(); }