From 3f30fe74216802003df9f18b2dfe7ccddcb006e5 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Mon, 26 Nov 2007 15:45:54 +0000 Subject: [PATCH] If there exists a local layout file, use the local copy instead of the system one. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21800 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferParams.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index a713f84c52..8c30839cd7 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -469,20 +469,24 @@ string const BufferParams::readToken(Lexer & lex, string const & token) if (token == "\\textclass") { lex.next(); string const classname = lex.getString(); - pair pp = - textclasslist.numberOfClass(classname); - if (pp.first) { + // if there exists a local layout file, ignore the system one + // NOTE: in this case, the textclass (.cls file) is assumed to be available. + pair pp = textclasslist.addTextClass(classname, filepath); + if (pp.first) setBaseClass(pp.second); - } else { - // if text class does not exist, try to load it from filepath - pp = textclasslist.addTextClass(classname, filepath); - if (pp.first) { + else { + pp = textclasslist.numberOfClass(classname); + if (pp.first) setBaseClass(pp.second); - } else { + else { + // a warning will be given for unknown class setBaseClass(defaultTextclass()); return classname; } } + // 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()) { docstring const msg = bformat(_("The layout file requested by this document,\n"