]> git.lyx.org Git - features.git/commitdiff
Combine OutlineIn and OutlineOut blocks
authorScott Kostyshak <skostysh@lyx.org>
Sat, 7 Jun 2014 04:41:20 +0000 (00:41 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Sun, 8 Jun 2014 07:33:32 +0000 (03:33 -0400)
They differ only by adding/subtracting 1.

src/Text3.cpp

index b78ba15ce98d7b598e25b15f1a18562c5bdff722..ccd8de3c7acdaa95125d93adc7ae75919ead8b12 100644 (file)
@@ -409,7 +409,8 @@ static void outline(OutlineOp mode, Cursor & cur)
                        cur.pit() = newpit - len;
                        break;
                }
-               case OutlineIn: {
+               case OutlineIn:
+               case OutlineOut: {
                        pit_type const len = distance(start, finish);
                        buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
                        for (; start != finish; ++start) {
@@ -419,7 +420,8 @@ static void outline(OutlineOp mode, Cursor & cur)
                                DocumentClass::const_iterator lit = tc.begin();
                                DocumentClass::const_iterator len = tc.end();
                                for (; lit != len; ++lit) {
-                                       if (lit->toclevel == toclevel + 1 &&
+                                       if (lit->toclevel == (mode == OutlineIn ?
+                                                             toclevel + 1 : toclevel - 1) &&
                                            start->layout().labeltype == lit->labeltype) {
                                                start->setLayout(*lit);
                                                break;
@@ -428,25 +430,6 @@ static void outline(OutlineOp mode, Cursor & cur)
                        }
                        break;
                }
-               case OutlineOut: {
-                       pit_type const len = distance(start, finish);
-                       buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
-                       for (; start != finish; ++start) {
-                               toclevel = buf.text().getTocLevel(distance(bgn, start));
-                               if (toclevel == Layout::NOT_IN_TOC)
-                                       continue;
-                               DocumentClass::const_iterator lit = tc.begin();
-                               DocumentClass::const_iterator len = tc.end();
-                               for (; lit != len; ++lit) {
-                                       if (lit->toclevel == toclevel - 1 &&
-                                               start->layout().labeltype == lit->labeltype) {
-                                                       start->setLayout(*lit);
-                                                       break;
-                                       }
-                               }
-                       }
-                       break;
-               }
        }
 }