X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferParams.cpp;h=6355dbcc6729d3f5a439c50f33936d5c6a260963;hb=0362c6aae73c293d1c20277c12d362acfe0b2ef6;hp=147fe8e10f6ef6252c2398b4f8b01ea0b7df945e;hpb=f62fbd05d2c5f8c4476ffcf3a465122fb7f80850;p=lyx.git diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 147fe8e10f..6355dbcc67 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -482,7 +482,7 @@ string const BufferParams::readToken(Lexer & lex, string const & token, // FIXME: this warning will be given even if there exists a local .cls // file. Even worse, the .lyx file can not be compiled or exported // because the textclass is marked as unavilable. - if (!getTextClass().isTeXClassAvailable()) { + if (!textClass().isTeXClassAvailable()) { docstring const msg = bformat(_("The layout file requested by this document,\n" "%1$s.layout,\n" @@ -529,7 +529,11 @@ string const BufferParams::readToken(Lexer & lex, string const & token, paragraph_separation = parseptranslator().find(parsep); } else if (token == "\\defskip") { lex.next(); - pimpl_->defskip = VSpace(lex.getString()); + string defskip = lex.getString(); + if (defskip == "defskip") + // this is invalid + defskip = "medskip"; + pimpl_->defskip = VSpace(defskip); } else if (token == "\\quotes_language") { string quotes_lang; lex >> quotes_lang; @@ -615,6 +619,8 @@ string const BufferParams::readToken(Lexer & lex, string const & token, lex >> headsep; } else if (token == "\\footskip") { lex >> footskip; + } else if (token == "\\columnsep") { + lex >> columnsep; } else if (token == "\\paperfontsize") { lex >> fontsize; } else if (token == "\\papercolumns") { @@ -764,6 +770,9 @@ void BufferParams::writeFile(ostream & os) const if (!footskip.empty()) os << "\\footskip " << VSpace(footskip).asLyXCommand() << '\n'; + if (!columnsep.empty()) + os << "\\columnsep " + << VSpace(columnsep).asLyXCommand() << '\n'; os << "\\secnumdepth " << secnumdepth << "\n\\tocdepth " << tocdepth << "\n\\paragraph_separation " @@ -810,13 +819,7 @@ void BufferParams::writeFile(ostream & os) const void BufferParams::validate(LaTeXFeatures & features) const { - if (!getTextClass().requires().empty()) { - vector req = getTextClass().requires(); - for (vector::const_iterator it = req.begin(); - it != req.end(); ++it) { - features.require(*it); - } - } + features.require(textClass().requires()); if (outputChanges) { bool dvipost = LaTeXFeatures::isAvailable("dvipost"); @@ -858,7 +861,7 @@ void BufferParams::validate(LaTeXFeatures & features) const // AMS Style is at document level if (use_amsmath == package_on - || getTextClass().provides("amsmath")) + || textClass().provides("amsmath")) features.require("amsmath"); if (use_esint == package_on) features.require("esint"); @@ -899,7 +902,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, { os << "\\documentclass"; - TextClass const & tclass = getTextClass(); + TextClass const & tclass = textClass(); ostringstream clsoptions; // the document class options. @@ -1141,6 +1144,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, os << ",headsep=" << from_ascii(Length(headsep).asLatexString()); if (!footskip.empty()) os << ",footskip=" << from_ascii(Length(footskip).asLatexString()); + if (!columnsep.empty()) + os << ",columnsep=" << from_ascii(Length(columnsep).asLatexString()); os << "}\n"; texrow.newline(); } @@ -1238,7 +1243,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, // hyperref, see // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html if (language->lang() == "japanese-plain" && - !getTextClass().provides("japanese")) { + !textClass().provides("japanese")) { //load babel in case it was not loaded due to an empty language list if (language_options.str().empty()) lyxpreamble += "\\usepackage{babel}\n"; @@ -1256,7 +1261,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, // use hyperref explicitely when it is required if (features.isRequired("hyperref")) { odocstringstream oss; - pdfoptions().writeLaTeX(oss, getTextClass().provides("hyperref")); + pdfoptions().writeLaTeX(oss, textClass().provides("hyperref")); lyxpreamble += oss.str(); } @@ -1365,13 +1370,13 @@ bool BufferParams::hasClassDefaults() const } -TextClass const & BufferParams::getTextClass() const +TextClass const & BufferParams::textClass() const { return *textClass_; } -TextClassPtr BufferParams::getTextClassPtr() const { +TextClassPtr BufferParams::textClassPtr() const { return textClass_; } @@ -1434,7 +1439,11 @@ void BufferParams::makeTextClass() frontend::Alert::warning(_("Package not available"), msg); } FileName layout_file = libFileSearch("layouts", lm->getFilename()); - textClass_->read(layout_file, TextClass::MODULE); + if (!textClass_->read(layout_file, TextClass::MODULE)) { + docstring const msg = + bformat(_("Error reading module %1$s\n"), from_utf8(modName)); + frontend::Alert::warning(_("Read Error"), msg); + } } } @@ -1466,7 +1475,7 @@ void BufferParams::clearLayoutModules() { Font const BufferParams::getFont() const { - FontInfo f = getTextClass().defaultfont(); + FontInfo f = textClass().defaultfont(); if (fontsDefaultFamily == "rmdefault") f.setFamily(ROMAN_FAMILY); else if (fontsDefaultFamily == "sfdefault") @@ -1913,7 +1922,7 @@ biblio::CiteEngine BufferParams::getEngine() const { // FIXME the class should provide the numerical/ // authoryear choice - if (getTextClass().provides("natbib") + if (textClass().provides("natbib") && cite_engine_ != biblio::ENGINE_NATBIB_NUMERICAL) return biblio::ENGINE_NATBIB_AUTHORYEAR; return cite_engine_;