]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Add support for document-local layout information. GUI is to follow.
[lyx.git] / src / BufferParams.cpp
index 5eda910e937e576276236ea7131135579145cf23..9302a35c294e43881eeebd47bbbf8816bbb004f9 100644 (file)
@@ -506,6 +506,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                
        } else if (token == "\\begin_preamble") {
                readPreamble(lex);
+       } else if (token == "\\begin_local_layout") {
+               readLocalLayout(lex);
        } else if (token == "\\begin_modules") {
                readModules(lex);
        } else if (token == "\\options") {
@@ -722,6 +724,15 @@ void BufferParams::writeFile(ostream & os) const
                os << "\\end_modules" << '\n';
        }
 
+       // local layout information
+       if (!local_layout.empty()) {
+               // remove '\n' from the end 
+               string const tmplocal = rtrim(local_layout, "\n");
+               os << "\\begin_local_layout\n"
+                  << tmplocal
+                  << "\n\\end_local_layout\n";
+       }
+
        // then the text parameters
        if (language != ignore_language)
                os << "\\language " << language->lang() << '\n';
@@ -1501,6 +1512,12 @@ void BufferParams::makeDocumentClass()
                        frontend::Alert::warning(_("Read Error"), msg);
                }
        }
+       if (!local_layout.empty()) {
+               if (!doc_class_->read(local_layout, TextClass::MODULE)) {
+                       docstring const msg = _("Error reading internal layout information");
+                       frontend::Alert::warning(_("Read Error"), msg);
+               }
+       }
 }
 
 
@@ -1555,6 +1572,16 @@ void BufferParams::readPreamble(Lexer & lex)
 }
 
 
+void BufferParams::readLocalLayout(Lexer & lex)
+{
+       if (lex.getString() != "\\begin_local_layout")
+               lyxerr << "Error (BufferParams::readLocalLayout):"
+                       "consistency check failed." << endl;
+
+       local_layout = lex.getLongString("\\end_local_layout");
+}
+
+
 void BufferParams::readLanguage(Lexer & lex)
 {
        if (!lex.next()) return;