]> git.lyx.org Git - lyx.git/blobdiff - src/Layout.cpp
Implement auto-nesting.
[lyx.git] / src / Layout.cpp
index ec23e57f1eadcbda44d8d2ac2533bc97601b017f..0a783d0aad1542fb5e2124be8c62521dd2716b3c 100644 (file)
@@ -40,6 +40,8 @@ enum LayoutTags {
        LT_ALIGN = 1,
        LT_ALIGNPOSSIBLE,
        LT_ARGUMENT,
+       LT_AUTONESTS,
+       LT_AUTONESTEDBY,
        LT_MARGIN,
        LT_BOTTOMSEP,
        LT_CATEGORY,
@@ -191,6 +193,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                { "align",          LT_ALIGN },
                { "alignpossible",  LT_ALIGNPOSSIBLE },
                { "argument",       LT_ARGUMENT },
+               { "autonests",      LT_AUTONESTS },
                { "babelpreamble",  LT_BABELPREAMBLE },
                { "bottomsep",      LT_BOTTOMSEP },
                { "category",       LT_CATEGORY },
@@ -217,6 +220,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                { "innertag",       LT_INNERTAG },
                { "inpreamble",     LT_INPREAMBLE },
                { "intitle",        LT_INTITLE },
+               { "isautonestedby", LT_AUTONESTEDBY },
                { "istoccaption",   LT_ISTOCCAPTION },
                { "itemcommand",    LT_ITEMCOMMAND },
                { "itemsep",        LT_ITEMSEP },
@@ -592,6 +596,30 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                        break;
                }
 
+               case LT_AUTONESTS: {
+                       docstring const autonest =
+                               subst(subst(subst(lex.getLongString(from_ascii("EndAutoNests")),
+                                                 from_ascii("\n"), docstring()),
+                                           from_ascii(" "), docstring()),
+                                     from_ascii("\t"), docstring());
+                       vector<docstring> const autonests =
+                               getVectorFromString(autonest);
+                       autonests_.insert(autonests.begin(), autonests.end());
+                       break;
+               }
+
+               case LT_AUTONESTEDBY: {
+                       docstring const autonest =
+                               subst(subst(subst(lex.getLongString(from_ascii("EndIsAutoNestedBy")),
+                                                 from_ascii("\n"), docstring()),
+                                           from_ascii(" "), docstring()),
+                                     from_ascii("\t"), docstring());
+                       vector<docstring> const autonests =
+                               getVectorFromString(autonest);
+                       autonested_by_.insert(autonests.begin(), autonests.end());
+                       break;
+               }
+
                case LT_REFPREFIX: {
                        docstring arg;
                        lex >> arg;
@@ -1387,6 +1415,26 @@ void Layout::write(ostream & os) const
                }
                os << '\n';
        }
+       if (!autonests_.empty()) {
+               os << "\tAutoNests\n\t";
+               for (set<docstring>::const_iterator it = autonests_.begin();
+                    it != autonests_.end(); ++it) {
+                       if (it != autonests_.begin())
+                               os << ',';
+                       os << to_utf8(*it);
+               }
+               os << "\n\tEndAutoNests\n";
+       }
+       if (!autonested_by_.empty()) {
+               os << "\tIsAutoNestedBy\n\t";
+               for (set<docstring>::const_iterator it = autonested_by_.begin();
+                    it != autonested_by_.end(); ++it) {
+                       if (it != autonested_by_.begin())
+                               os << ',';
+                       os << to_utf8(*it);
+               }
+               os << "\n\tIsAutoNestedBy\n";
+       }
        if (refprefix.empty())
                os << "\tRefPrefix OFF\n";
        else