#include "Lexer.h"
#include "TextClass.h"
-#include "support/lassert.h"
+#include "frontends/alert.h"
+
#include "support/debug.h"
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/gettext.h"
+#include "support/lassert.h"
+#include "support/lstrings.h"
#include <boost/bind.hpp>
#include <boost/regex.hpp>
default:
string const fname = lex.getString();
LYXERR(Debug::TCLASS, "Fname: " << fname);
- if (lex.next()) {
- string const clname = lex.getString();
- LYXERR(Debug::TCLASS, "Clname: " << clname);
- if (lex.next()) {
- string const desc = lex.getString();
- LYXERR(Debug::TCLASS, "Desc: " << desc);
- if (lex.next()) {
- bool avail = lex.getBool();
- LYXERR(Debug::TCLASS, "Avail: " << avail);
- // This code is run when we have
- // fname, clname, desc, and avail
- LayoutFile * tmpl = new LayoutFile(fname, clname, desc, avail);
- if (lyxerr.debugging(Debug::TCLASS)) {
- // only system layout files are loaded here so no
- // buffer path is needed.
- tmpl->load();
- }
- classmap_[fname] = tmpl;
- }
- }
+ if (!lex.next())
+ break;
+ string const clname = lex.getString();
+ LYXERR(Debug::TCLASS, "Clname: " << clname);
+ if (!lex.next())
+ break;
+ string const desc = lex.getString();
+ LYXERR(Debug::TCLASS, "Desc: " << desc);
+ if (!lex.next())
+ break;
+ bool avail = lex.getBool();
+ LYXERR(Debug::TCLASS, "Avail: " << avail);
+ // This code is run when we have
+ // fname, clname, desc, and avail
+ LayoutFile * tmpl = new LayoutFile(fname, clname, desc, avail);
+ if (lyxerr.debugging(Debug::TCLASS)) {
+ // only system layout files are loaded here so no
+ // buffer path is needed.
+ tmpl->load();
}
+ classmap_[fname] = tmpl;
}
}
LYXERR(Debug::TCLASS, "End of parsing of textclass.lst");
}
+bool LayoutFileList::load(string const & name, string const & buf_path)
+{
+ if (!haveClass(name)) {
+ LYXERR0("Document class \"" << name << "\" does not exist.");
+ return false;
+ }
+
+ LayoutFile * tc = classmap_[name];
+ if (!tc->load(buf_path)) {
+ docstring s = bformat(_("The document class %1$s "
+ "could not be loaded."), from_utf8(name));
+ frontend::Alert::error(_("Could not load class"), s);
+ return false;
+ }
+ return true;
+}
+
+
LayoutFileIndex defaultBaseclass()
{
if (LayoutFileList::get().haveClass("article"))