X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferParams.cpp;h=9302a35c294e43881eeebd47bbbf8816bbb004f9;hb=700af7e7011f102d92222744791638ff2db18f94;hp=3f14e3a7b0f0c754c7453c3a32772da11523aff9;hpb=0f9a8fcad4104542ff1c94dd384e602b543f15f6;p=lyx.git diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 3f14e3a7b0..9302a35c29 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -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; @@ -1959,7 +1986,7 @@ string const BufferParams::loadFonts(string const & rm, else if (tt == "courier" ) os << "\\usepackage{" << tt << "}\n"; // Computer Modern, Latin Modern, CM Bright - else if (tt != "default") + else if (tt != "default") os << "\\renewcommand{\\ttdefault}{" << tt << "}\n"; return os.str(); @@ -1969,14 +1996,13 @@ string const BufferParams::loadFonts(string const & rm, Encoding const & BufferParams::encoding() const { if (inputenc == "auto" || inputenc == "default") - return *(language->encoding()); - Encoding const * const enc = - encodings.getFromLaTeXName(inputenc); + return *language->encoding(); + Encoding const * const enc = encodings.fromLaTeXName(inputenc); if (enc) return *enc; - lyxerr << "Unknown inputenc value `" << inputenc - << "'. Using `auto' instead." << endl; - return *(language->encoding()); + LYXERR0("Unknown inputenc value `" << inputenc + << "'. Using `auto' instead."); + return *language->encoding(); }