BaseClassList --> LayoutFileList

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23532 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-03-07 03:53:21 +00:00
parent 6fee306f2f
commit 6edb3984bf
15 changed files with 59 additions and 59 deletions

View File

@ -30,7 +30,6 @@ TOP_extra_files = Split('''
src_header_files = Split(''' src_header_files = Split('''
ASpell_local.h ASpell_local.h
Author.h Author.h
BaseClassList.h
BiblioInfo.h BiblioInfo.h
Bidi.h Bidi.h
Box.h Box.h
@ -82,6 +81,7 @@ src_header_files = Split('''
Language.h Language.h
Layout.h Layout.h
LayoutEnums.h LayoutEnums.h
LayoutFile.h
Length.h Length.h
Lexer.h Lexer.h
LyX.h LyX.h
@ -142,7 +142,6 @@ src_header_files = Split('''
src_pre_files = Split(''' src_pre_files = Split('''
Author.cpp Author.cpp
BaseClassList.cpp
BiblioInfo.cpp BiblioInfo.cpp
Bidi.cpp Bidi.cpp
BranchList.cpp BranchList.cpp
@ -187,6 +186,7 @@ src_pre_files = Split('''
LaTeXFeatures.cpp LaTeXFeatures.cpp
Language.cpp Language.cpp
Layout.cpp Layout.cpp
LayoutFile.cpp
Length.cpp Length.cpp
Lexer.cpp Lexer.cpp
LyX.cpp LyX.cpp

View File

@ -14,7 +14,7 @@
#include "Buffer.h" #include "Buffer.h"
#include "Author.h" #include "Author.h"
#include "BaseClassList.h" #include "LayoutFile.h"
#include "BiblioInfo.h" #include "BiblioInfo.h"
#include "BranchList.h" #include "BranchList.h"
#include "buffer_funcs.h" #include "buffer_funcs.h"

View File

@ -18,7 +18,7 @@
#include "BufferParams.h" #include "BufferParams.h"
#include "Author.h" #include "Author.h"
#include "BaseClassList.h" #include "LayoutFile.h"
#include "BranchList.h" #include "BranchList.h"
#include "buffer_funcs.h" #include "buffer_funcs.h"
#include "Bullet.h" #include "Bullet.h"
@ -464,7 +464,7 @@ string const BufferParams::readToken(Lexer & lex, string const & token,
// if there exists a local layout file, ignore the system one // if there exists a local layout file, ignore the system one
// NOTE: in this case, the textclass (.cls file) is assumed to be available. // NOTE: in this case, the textclass (.cls file) is assumed to be available.
string tcp; string tcp;
BaseClassList & bcl = BaseClassList::get(); LayoutFileList & bcl = LayoutFileList::get();
if (!filepath.empty()) if (!filepath.empty())
tcp = bcl.addLayoutFile(classname, filepath.absFilename()); tcp = bcl.addLayoutFile(classname, filepath.absFilename());
if (!tcp.empty()) if (!tcp.empty())
@ -1387,7 +1387,7 @@ void BufferParams::setDocumentClass(DocumentClass const * const tc) {
bool BufferParams::setBaseClass(string const & classname) bool BufferParams::setBaseClass(string const & classname)
{ {
LYXERR(Debug::TCLASS, "setBaseClass: " << classname); LYXERR(Debug::TCLASS, "setBaseClass: " << classname);
BaseClassList const & bcl = BaseClassList::get(); LayoutFileList const & bcl = LayoutFileList::get();
if (!bcl.haveClass(classname)) { if (!bcl.haveClass(classname)) {
docstring s = docstring s =
bformat(_("The document class %1$s could not be found."), bformat(_("The document class %1$s could not be found."),
@ -1411,8 +1411,8 @@ bool BufferParams::setBaseClass(string const & classname)
LayoutFile const * BufferParams::baseClass() const LayoutFile const * BufferParams::baseClass() const
{ {
if (BaseClassList::get().haveClass(pimpl_->baseClass_)) if (LayoutFileList::get().haveClass(pimpl_->baseClass_))
return &(BaseClassList::get()[pimpl_->baseClass_]); return &(LayoutFileList::get()[pimpl_->baseClass_]);
else else
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
/** /**
* \file BaseClassList.cpp * \file LayoutFileList.cpp
* This file is part of LyX, the document processor. * This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING. * Licence details can be found in the file COPYING.
* *
@ -11,7 +11,7 @@
#include <config.h> #include <config.h>
#include "BaseClassList.h" #include "LayoutFile.h"
#include "Counters.h" #include "Counters.h"
#include "Floating.h" #include "Floating.h"
#include "FloatList.h" #include "FloatList.h"
@ -47,14 +47,14 @@ LayoutFile::LayoutFile(string const & fn, string const & cln,
} }
BaseClassList & BaseClassList::get() LayoutFileList & LayoutFileList::get()
{ {
static BaseClassList baseclasslist; static LayoutFileList baseclasslist;
return baseclasslist; return baseclasslist;
} }
bool BaseClassList::haveClass(string const & classname) const bool LayoutFileList::haveClass(string const & classname) const
{ {
ClassMap::const_iterator it = classmap_.begin(); ClassMap::const_iterator it = classmap_.begin();
ClassMap::const_iterator en = classmap_.end(); ClassMap::const_iterator en = classmap_.end();
@ -66,7 +66,7 @@ bool BaseClassList::haveClass(string const & classname) const
} }
LayoutFile const & BaseClassList::operator[](string const & classname) const LayoutFile const & LayoutFileList::operator[](string const & classname) const
{ {
BOOST_ASSERT(haveClass(classname)); BOOST_ASSERT(haveClass(classname));
return *classmap_[classname]; return *classmap_[classname];
@ -74,7 +74,7 @@ LayoutFile const & BaseClassList::operator[](string const & classname) const
LayoutFile & LayoutFile &
BaseClassList::operator[](string const & classname) LayoutFileList::operator[](string const & classname)
{ {
BOOST_ASSERT(haveClass(classname)); BOOST_ASSERT(haveClass(classname));
return *classmap_[classname]; return *classmap_[classname];
@ -82,14 +82,14 @@ LayoutFile &
// Reads LyX textclass definitions according to textclass config file // Reads LyX textclass definitions according to textclass config file
bool BaseClassList::read() bool LayoutFileList::read()
{ {
Lexer lex(0, 0); Lexer lex(0, 0);
FileName const real_file = libFileSearch("", "textclass.lst"); FileName const real_file = libFileSearch("", "textclass.lst");
LYXERR(Debug::TCLASS, "Reading textclasses from `" << real_file << '\''); LYXERR(Debug::TCLASS, "Reading textclasses from `" << real_file << '\'');
if (real_file.empty()) { if (real_file.empty()) {
lyxerr << "BaseClassList::Read: unable to find " lyxerr << "LayoutFileList::Read: unable to find "
"textclass file `" "textclass file `"
<< to_utf8(makeDisplayPath(real_file.absFilename(), 1000)) << to_utf8(makeDisplayPath(real_file.absFilename(), 1000))
<< "'. Exiting." << endl; << "'. Exiting." << endl;
@ -102,13 +102,13 @@ bool BaseClassList::read()
} }
if (!lex.setFile(real_file)) { if (!lex.setFile(real_file)) {
lyxerr << "BaseClassList::Read: " lyxerr << "LayoutFileList::Read: "
"lyxlex was not able to set file: " "lyxlex was not able to set file: "
<< real_file << endl; << real_file << endl;
} }
if (!lex.isOK()) { if (!lex.isOK()) {
lyxerr << "BaseClassList::Read: unable to open " lyxerr << "LayoutFileList::Read: unable to open "
"textclass file `" "textclass file `"
<< to_utf8(makeDisplayPath(real_file.absFilename(), 1000)) << to_utf8(makeDisplayPath(real_file.absFilename(), 1000))
<< "'\nCheck your installation. LyX can't continue." << "'\nCheck your installation. LyX can't continue."
@ -157,13 +157,13 @@ bool BaseClassList::read()
// in this case. This gives users a second chance to configure lyx if // in this case. This gives users a second chance to configure lyx if
// initial configuration fails. (c.f. bug 2829) // initial configuration fails. (c.f. bug 2829)
if (classmap_.empty()) if (classmap_.empty())
lyxerr << "BaseClassList::Read: no textclasses found!" lyxerr << "LayoutFileList::Read: no textclasses found!"
<< endl; << endl;
return true; return true;
} }
std::vector<LayoutFileIndex> BaseClassList::classList() const std::vector<LayoutFileIndex> LayoutFileList::classList() const
{ {
std::vector<LayoutFileIndex> cl; std::vector<LayoutFileIndex> cl;
ClassMap::const_iterator it = classmap_.begin(); ClassMap::const_iterator it = classmap_.begin();
@ -174,7 +174,7 @@ std::vector<LayoutFileIndex> BaseClassList::classList() const
} }
void BaseClassList::reset(LayoutFileIndex const & classname) { void LayoutFileList::reset(LayoutFileIndex const & classname) {
BOOST_ASSERT(haveClass(classname)); BOOST_ASSERT(haveClass(classname));
LayoutFile * tc = classmap_[classname]; LayoutFile * tc = classmap_[classname];
LayoutFile * tmpl = LayoutFile * tmpl =
@ -185,11 +185,11 @@ void BaseClassList::reset(LayoutFileIndex const & classname) {
} }
string const BaseClassList::localPrefix = "LOCAL:"; string const LayoutFileList::localPrefix = "LOCAL:";
LayoutFileIndex LayoutFileIndex
BaseClassList::addLayoutFile(string const & textclass, string const & path) LayoutFileList::addLayoutFile(string const & textclass, string const & path)
{ {
// FIXME There is a bug here: 4593 // FIXME There is a bug here: 4593
// //
@ -242,11 +242,11 @@ LayoutFileIndex
LayoutFileIndex defaultBaseclass() LayoutFileIndex defaultBaseclass()
{ {
if (BaseClassList::get().haveClass("article")) if (LayoutFileList::get().haveClass("article"))
return string("article"); return string("article");
if (BaseClassList::get().empty()) if (LayoutFileList::get().empty())
return string(); return string();
return BaseClassList::get().classList().front(); return LayoutFileList::get().classList().front();
} }
@ -256,7 +256,7 @@ bool LyXSetStyle()
{ {
LYXERR(Debug::TCLASS, "LyXSetStyle: parsing configuration..."); LYXERR(Debug::TCLASS, "LyXSetStyle: parsing configuration...");
if (!BaseClassList::get().read()) { if (!LayoutFileList::get().read()) {
LYXERR(Debug::TCLASS, "LyXSetStyle: an error occured " LYXERR(Debug::TCLASS, "LyXSetStyle: an error occured "
"during parsing.\n Exiting."); "during parsing.\n Exiting.");
return false; return false;

View File

@ -1,6 +1,6 @@
// -*- C++ -*- // -*- C++ -*-
/** /**
* \file BaseClassList.h * \file LayoutFile.h
* This file is part of LyX, the document processor. * This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING. * Licence details can be found in the file COPYING.
* *
@ -29,7 +29,7 @@ class Layout;
extern bool LyXSetStyle(); extern bool LyXSetStyle();
/// Index into BaseClassList. Basically a 'strong typedef'. /// Index into LayoutFileList. Basically a 'strong typedef'.
class LayoutFileIndex { class LayoutFileIndex {
public: public:
/// ///
@ -58,8 +58,8 @@ private:
std::string const & description = std::string(), std::string const & description = std::string(),
bool texClassAvail = false); bool texClassAvail = false);
/// The only class that should create a LayoutFile is /// The only class that should create a LayoutFile is
/// BaseClassList, which calls the private constructor. /// LayoutFileList, which calls the private constructor.
friend class BaseClassList; friend class LayoutFileList;
/// can't create empty LayoutFile /// can't create empty LayoutFile
LayoutFile() {}; LayoutFile() {};
}; };
@ -67,13 +67,13 @@ private:
/// A list of base document classes (*.layout files). /// A list of base document classes (*.layout files).
/// This is a singleton class. The sole instance is accessed /// This is a singleton class. The sole instance is accessed
/// via BaseClassList::get() /// via LayoutFileList::get()
class BaseClassList { class LayoutFileList {
public: public:
/// ///
BaseClassList() {} LayoutFileList() {}
/// \return The sole instance of this class. /// \return The sole instance of this class.
static BaseClassList & get(); static LayoutFileList & get();
/// ///
bool empty() const { return classmap_.empty(); } bool empty() const { return classmap_.empty(); }
/// ///
@ -99,9 +99,9 @@ private:
/// ///
typedef std::map<std::string, LayoutFile *> ClassMap; typedef std::map<std::string, LayoutFile *> ClassMap;
/// noncopyable /// noncopyable
BaseClassList(BaseClassList const &); LayoutFileList(LayoutFileList const &);
/// nonassignable /// nonassignable
void operator=(BaseClassList const &); void operator=(LayoutFileList const &);
/// ///
mutable ClassMap classmap_; //FIXME mutable ClassMap classmap_; //FIXME
}; };

View File

@ -17,7 +17,7 @@
#include "LyX.h" #include "LyX.h"
#include "BaseClassList.h" #include "LayoutFile.h"
#include "Buffer.h" #include "Buffer.h"
#include "BufferList.h" #include "BufferList.h"
#include "CmdDef.h" #include "CmdDef.h"
@ -576,7 +576,7 @@ void LyX::execBatchCommands()
// aknowledged. // aknowledged.
// if reconfiguration is needed. // if reconfiguration is needed.
while (BaseClassList::get().empty()) { while (LayoutFileList::get().empty()) {
switch (Alert::prompt( switch (Alert::prompt(
_("No textclass is found"), _("No textclass is found"),
_("LyX cannot continue because no textclass is found. " _("LyX cannot continue because no textclass is found. "

View File

@ -21,7 +21,7 @@
#include "LyXFunc.h" #include "LyXFunc.h"
#include "BaseClassList.h" #include "LayoutFile.h"
#include "BranchList.h" #include "BranchList.h"
#include "buffer_funcs.h" #include "buffer_funcs.h"
#include "Buffer.h" #include "Buffer.h"
@ -709,14 +709,14 @@ void showPrintError(string const & name)
bool loadLayoutFile(string const & name, string const & buf_path) bool loadLayoutFile(string const & name, string const & buf_path)
{ {
if (!BaseClassList::get().haveClass(name)) { if (!LayoutFileList::get().haveClass(name)) {
lyxerr << "Document class \"" << name lyxerr << "Document class \"" << name
<< "\" does not exist." << "\" does not exist."
<< endl; << endl;
return false; return false;
} }
LayoutFile & tc = BaseClassList::get()[name]; LayoutFile & tc = LayoutFileList::get()[name];
if (!tc.load(buf_path)) { if (!tc.load(buf_path)) {
docstring s = bformat(_("The document class %1$s." docstring s = bformat(_("The document class %1$s."
"could not be loaded."), from_utf8(name)); "could not be loaded."), from_utf8(name));
@ -1583,7 +1583,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
break; break;
LayoutFile const * old_layout = buffer->params().baseClass(); LayoutFile const * old_layout = buffer->params().baseClass();
LayoutFile const * new_layout = &(BaseClassList::get()[argument]); LayoutFile const * new_layout = &(LayoutFileList::get()[argument]);
if (old_layout == new_layout) if (old_layout == new_layout)
// nothing to do // nothing to do
@ -1604,7 +1604,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
Buffer * buffer = lyx_view_->buffer(); Buffer * buffer = lyx_view_->buffer();
DocumentClass * oldClass = buffer->params().documentClassPtr(); DocumentClass * oldClass = buffer->params().documentClassPtr();
LayoutFileIndex bc = buffer->params().baseClassID(); LayoutFileIndex bc = buffer->params().baseClassID();
BaseClassList::get().reset(bc); LayoutFileList::get().reset(bc);
buffer->params().makeDocumentClass(); buffer->params().makeDocumentClass();
updateLayout(oldClass, buffer); updateLayout(oldClass, buffer);
updateFlags = Update::Force | Update::FitCursor; updateFlags = Update::Force | Update::FitCursor;

View File

@ -76,7 +76,6 @@ endif
SOURCEFILESCORE = \ SOURCEFILESCORE = \
Author.cpp \ Author.cpp \
BaseClassList.cpp \
BiblioInfo.cpp \ BiblioInfo.cpp \
Bidi.cpp \ Bidi.cpp \
boost.cpp \ boost.cpp \
@ -123,6 +122,7 @@ SOURCEFILESCORE = \
Language.cpp \ Language.cpp \
LaTeX.cpp \ LaTeX.cpp \
LaTeXFeatures.cpp \ LaTeXFeatures.cpp \
LayoutFile.cpp \
Length.cpp \ Length.cpp \
lengthcommon.cpp \ lengthcommon.cpp \
Lexer.cpp \ Lexer.cpp \
@ -171,7 +171,6 @@ SOURCEFILESCORE = \
HEADERFILESCORE = \ HEADERFILESCORE = \
Author.h \ Author.h \
BaseClassList.h \
BiblioInfo.h \ BiblioInfo.h \
Bidi.h \ Bidi.h \
BranchList.h \ BranchList.h \
@ -223,6 +222,7 @@ HEADERFILESCORE = \
LaTeX.h \ LaTeX.h \
Layout.h \ Layout.h \
LayoutEnums.h \ LayoutEnums.h \
LayoutFile.h \
Length.h \ Length.h \
Lexer.h \ Lexer.h \
lfuns.h \ lfuns.h \

View File

@ -76,7 +76,7 @@ public:
}; };
//Much of this is borrowed from BaseClassList::read() //Much of this is borrowed from LayoutFileList::read()
bool ModuleList::load() bool ModuleList::load()
{ {
FileName const real_file = libFileSearch("", "lyxmodules.lst"); FileName const real_file = libFileSearch("", "lyxmodules.lst");

View File

@ -19,7 +19,7 @@
#include "Paragraph.h" #include "Paragraph.h"
#include "BaseClassList.h" #include "LayoutFile.h"
#include "Buffer.h" #include "Buffer.h"
#include "BufferParams.h" #include "BufferParams.h"
#include "Changes.h" #include "Changes.h"

View File

@ -16,7 +16,7 @@
#include "TextClass.h" #include "TextClass.h"
#include "BaseClassList.h" #include "LayoutFile.h"
#include "Color.h" #include "Color.h"
#include "Counters.h" #include "Counters.h"
#include "Floating.h" #include "Floating.h"

View File

@ -13,7 +13,7 @@
#include "GuiDocument.h" #include "GuiDocument.h"
#include "BaseClassList.h" #include "LayoutFile.h"
#include "BranchList.h" #include "BranchList.h"
#include "buffer_funcs.h" #include "buffer_funcs.h"
#include "Buffer.h" #include "Buffer.h"
@ -152,8 +152,8 @@ public:
// Ordering criteria: // Ordering criteria:
// 1. Availability of text class // 1. Availability of text class
// 2. Description (lexicographic) // 2. Description (lexicographic)
LayoutFile const & tc1 = BaseClassList::get()[lhs]; LayoutFile const & tc1 = LayoutFileList::get()[lhs];
LayoutFile const & tc2 = BaseClassList::get()[rhs]; LayoutFile const & tc2 = LayoutFileList::get()[rhs];
return (tc1.isTeXClassAvailable() && !tc2.isTeXClassAvailable()) || return (tc1.isTeXClassAvailable() && !tc2.isTeXClassAvailable()) ||
(tc1.isTeXClassAvailable() == tc2.isTeXClassAvailable() && (tc1.isTeXClassAvailable() == tc2.isTeXClassAvailable() &&
_(tc1.description()) < _(tc2.description())); _(tc1.description()) < _(tc2.description()));
@ -902,7 +902,7 @@ GuiDocument::GuiDocument(GuiView & lv)
} }
// latex classes // latex classes
latexModule->classCO->setModel(&classes_model_); latexModule->classCO->setModel(&classes_model_);
BaseClassList const & bcl = BaseClassList::get(); LayoutFileList const & bcl = LayoutFileList::get();
vector<LayoutFileIndex> classList = bcl.classList(); vector<LayoutFileIndex> classList = bcl.classList();
sort(classList.begin(), classList.end(), less_textclass_avail_desc()); sort(classList.begin(), classList.end(), less_textclass_avail_desc());
@ -1243,7 +1243,7 @@ void GuiDocument::classChanged()
return; return;
string const classname = classes_model_.getIDString(idx); string const classname = classes_model_.getIDString(idx);
// check if this is a local layout file // check if this is a local layout file
if (prefixIs(classname, BaseClassList::localPrefix)) { if (prefixIs(classname, LayoutFileList::localPrefix)) {
int const ret = Alert::prompt(_("Local layout file"), int const ret = Alert::prompt(_("Local layout file"),
_("The layout file you have selected is a local layout\n" _("The layout file you have selected is a local layout\n"
"file, not one in the system or user directory. Your\n" "file, not one in the system or user directory. Your\n"

View File

@ -14,7 +14,7 @@
#include "InsetInclude.h" #include "InsetInclude.h"
#include "BaseClassList.h" #include "LayoutFile.h"
#include "Buffer.h" #include "Buffer.h"
#include "buffer_funcs.h" #include "buffer_funcs.h"
#include "BufferList.h" #include "BufferList.h"

View File

@ -11,7 +11,7 @@
#include "InsetInfo.h" #include "InsetInfo.h"
#include "BaseClassList.h" #include "LayoutFile.h"
#include "Buffer.h" #include "Buffer.h"
#include "BufferParams.h" #include "BufferParams.h"
#include "BufferView.h" #include "BufferView.h"
@ -200,7 +200,7 @@ void InsetInfo::updateInfo()
break; break;
case TEXTCLASS_INFO: { case TEXTCLASS_INFO: {
// name_ is the class name // name_ is the class name
setText(BaseClassList::get().haveClass(name_) ? _("yes") : _("no"), setText(LayoutFileList::get().haveClass(name_) ? _("yes") : _("no"),
bp.getFont(), false); bp.getFont(), false);
break; break;
} }

View File

@ -15,7 +15,7 @@
#include "tex2lyx.h" #include "tex2lyx.h"
#include "BaseClassList.h" #include "LayoutFile.h"
#include "Layout.h" #include "Layout.h"
#include "Lexer.h" #include "Lexer.h"
#include "TextClass.h" #include "TextClass.h"