officecfg/registry/schema/org/openoffice/Office/Calc.xcs |    7 +++++
 sc/source/ui/view/tabview3.cxx                           |   18 +++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

New commits:
commit 5daac16a03c84f5908808be446c705e19445c150
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Oct 9 23:19:20 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Oct 10 07:49:59 2024 +0200

    tdf#160580: make cycling from first to last tab configurable
    
    This introduces Office/Calc/Input/CycleNextPrevSheetTab
    boolean property, that controls the behavior implemented
    in commit 552170c9c8ad6d215aa456ba9d622af01c25d275
    (tdf#156311 Cycling through tabs in Calc, 2023-08-16).
    
    Change-Id: I0510743b4ab6d92488ba73a7b8d5b83be9586b2f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174745
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 770b31e7a5fd..656747e782be 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -721,6 +721,13 @@
         </info>
         <value>true</value>
       </prop>
+      <prop oor:name="WrapNextPrevSheetTab" oor:type="xs:boolean" 
oor:nillable="false">
+        <info>
+          <desc>When switching to next / previous sheet, wrap from last to 
first tab (and vice versa)</desc>
+          <label>When switching to next / previous sheet, wrap from last to 
first tab (and vice versa)</label>
+        </info>
+        <value>true</value>
+      </prop>
       <prop oor:name="LastFunctions" oor:type="oor:int-list" 
oor:nillable="false">
         <info>
           <desc>Specifies the functions last used.</desc>
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index dd4495653d5b..7c32cee3c7bf 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1834,25 +1834,35 @@ void ScTabView::SelectNextTab( short nDir, bool 
bExtendSelection )
     ScDocument& rDoc = aViewData.GetDocument();
     SCTAB nTab = aViewData.GetTabNo();
     SCTAB nNextTab = nTab;
+    SCTAB nCount = rDoc.GetTableCount();
     if (nDir < 0)
     {
         do
         {
             --nNextTab;
             if (nNextTab < 0)
-                nNextTab = rDoc.GetTableCount();
+            {
+                if 
(officecfg::Office::Calc::Input::WrapNextPrevSheetTab::get())
+                    nNextTab = nCount;
+                else
+                    return;
+            }
             if (rDoc.IsVisible(nNextTab))
                 break;
         } while (nNextTab != nTab);
     }
-    if (nDir > 0)
+    else // nDir > 0
     {
-        SCTAB nCount = rDoc.GetTableCount();
         do
         {
             ++nNextTab;
             if (nNextTab >= nCount)
-                nNextTab = 0;
+            {
+                if 
(officecfg::Office::Calc::Input::WrapNextPrevSheetTab::get())
+                    nNextTab = 0;
+                else
+                    return;
+            }
             if (rDoc.IsVisible(nNextTab))
                 break;
         } while (nNextTab != nTab);

Reply via email to