]> git.lyx.org Git - features.git/commitdiff
Let OUTLINE functions jump from section to part if there is no chapter
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 21 Oct 2023 11:48:50 +0000 (13:48 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 21 Oct 2023 11:48:50 +0000 (13:48 +0200)
Fixes #12938

src/Text.cpp

index ef5dd26615b415907ada36b9575f6136f056ef4b..820b755511e4e15049db5dbc403b67fc7fee94be 100644 (file)
@@ -3903,8 +3903,20 @@ void outline(OutlineOp mode, Cursor & cur, bool local)
                                        continue;
 
                                DocumentClass const & tc = buf.params().documentClass();
-                               int const newtoclevel =
-                                       (mode == OutlineIn ? toclevel + 1 : toclevel - 1);
+                               int newtoclevel = -1;
+                               if (mode == OutlineIn) {
+                                       if (toclevel == -1 && tc.getTOCLayout().toclevel > 0)
+                                               // we are at part but don't have a chapter
+                                               newtoclevel = tc.getTOCLayout().toclevel;
+                                       else
+                                               newtoclevel = toclevel + 1;
+                               } else {
+                                       if (tc.getTOCLayout().toclevel == toclevel && tc.min_toclevel() < toclevel)
+                                               // we are at highest level, but there is still part
+                                               newtoclevel = tc.min_toclevel();
+                                       else
+                                               newtoclevel = toclevel - 1;
+                               }
 
                                bool found = false;
                                for (auto const & lay : tc) {
@@ -3939,8 +3951,20 @@ void outline(OutlineOp mode, Cursor & cur, bool local)
                                        continue;
 
                                DocumentClass const & tc = buf.params().documentClass();
-                               int const newtoclevel =
-                                       (mode == OutlineIn ? toclevel + 1 : toclevel - 1);
+                               int newtoclevel = -1;
+                               if (mode == OutlineIn) {
+                                       if (toclevel == -1 && tc.getTOCLayout().toclevel > 0)
+                                               // we are at part but don't have a chapter
+                                               newtoclevel = tc.getTOCLayout().toclevel;
+                                       else
+                                               newtoclevel = toclevel + 1;
+                               } else {
+                                       if (tc.getTOCLayout().toclevel == toclevel && tc.min_toclevel() < toclevel)
+                                               // we are at highest level, but there is still part
+                                               newtoclevel = tc.min_toclevel();
+                                       else
+                                               newtoclevel = toclevel - 1;
+                               }
 
                                for (auto const & lay : tc) {
                                        if (lay.toclevel == newtoclevel