X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLayoutFile.cpp;h=f70209b3b0a7c7f2d90a7b4146454256ae6a489a;hb=4e69b9bac5e970572b9cf9169e3db9060c47e3b6;hp=a915f7129b8236d91328676ac963bdc454841172;hpb=f9fa189e02ef0271b042cabc32f8cf90e0b54cb3;p=lyx.git diff --git a/src/LayoutFile.cpp b/src/LayoutFile.cpp index a915f7129b..f70209b3b0 100644 --- a/src/LayoutFile.cpp +++ b/src/LayoutFile.cpp @@ -27,8 +27,8 @@ #include "support/lassert.h" #include "support/lstrings.h" -#include -#include +#include "support/bind.h" +#include "support/regex.h" #include @@ -37,9 +37,7 @@ using namespace lyx::support; namespace lyx { -using boost::bind; -using boost::regex; -using boost::smatch; + LayoutFile::LayoutFile(string const & fn, string const & cln, string const & desc, string const & prereq, @@ -105,16 +103,14 @@ bool LayoutFileList::read() LYXERR(Debug::TCLASS, "Reading textclasses from `" << real_file << "'."); if (real_file.empty()) { - LYXERR0("LayoutFileList::Read: unable to find textclass file `" - << makeDisplayPath(real_file.absFilename(), 1000) - << "'."); - success = false; + LYXERR0("LayoutFileList::Read: unable to find textclass file " + << "`textclass.lst'."); } else if (!lex.setFile(real_file)) { LYXERR0("LayoutFileList::Read: lyxlex was not able to set file: " << real_file << '.'); } else if (!lex.isOK()) { LYXERR0("LayoutFileList::Read: unable to open textclass file `" - << makeDisplayPath(real_file.absFilename(), 1000) + << makeDisplayPath(real_file.absFileName(), 1000) << "'\nCheck your installation."); } else { // we have a file we can read. @@ -216,13 +212,13 @@ string layoutpost = LayoutFileIndex LayoutFileList::addEmptyClass(string const & textclass) { - FileName const tempLayout = FileName::tempName(); + FileName const tempLayout = FileName::tempName("basic_layout"); ofstream ofs(tempLayout.toFilesystemEncoding().c_str()); // This writes a very basic class, but it also attempts to include // stdclass.inc. That would give us something moderately usable. ofs << "# This layout is automatically generated\n" "# \\DeclareLaTeXClass{" << textclass << "}\n\n" - "Format 26\n" + "Format " << LAYOUT_FORMAT << "\n" "Input stdclass.inc\n\n" << layoutpost; ofs.close(); @@ -233,18 +229,18 @@ LayoutFileIndex LayoutFileList::addEmptyClass(string const & textclass) LayoutFile * tc = new LayoutFile(textclass, textclass, "Unknown text class " + textclass, textclass + ".cls", true); - if (!tc->load(tempLayout.absFilename())) { + if (!tc->load(tempLayout.absFileName())) { // The only way this happens is because the hardcoded layout file - // aboveis wrong or stdclass.inc cannot be found. So try again - // without stdclass.inc. + // above is wrong or stdclass.inc cannot be found. So try again + // without stdclass.inc and without stdinsets.inc. ofstream ofs2(tempLayout.toFilesystemEncoding().c_str()); ofs2 << "# This layout is automatically generated\n" "# \\DeclareLaTeXClass{" << textclass << "}\n\n" - "Format 26\n" - "Input stdclass.inc\n\n" + "Format " << LAYOUT_FORMAT << "\n" + "Provides stdinsets 1\n" << layoutpost; ofs2.close(); - if (!tc->load(tempLayout.absFilename())) { + if (!tc->load(tempLayout.absFileName())) { // This can only happen if the hardcoded file above is wrong. LASSERT(false, /* */); } @@ -319,13 +315,7 @@ bool LayoutFileList::load(string const & name, string const & buf_path) } 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; + return tc->load(buf_path); }