mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
BaseClassList --> LayoutFileList
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23532 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6fee306f2f
commit
6edb3984bf
@ -30,7 +30,6 @@ TOP_extra_files = Split('''
|
||||
src_header_files = Split('''
|
||||
ASpell_local.h
|
||||
Author.h
|
||||
BaseClassList.h
|
||||
BiblioInfo.h
|
||||
Bidi.h
|
||||
Box.h
|
||||
@ -82,6 +81,7 @@ src_header_files = Split('''
|
||||
Language.h
|
||||
Layout.h
|
||||
LayoutEnums.h
|
||||
LayoutFile.h
|
||||
Length.h
|
||||
Lexer.h
|
||||
LyX.h
|
||||
@ -142,7 +142,6 @@ src_header_files = Split('''
|
||||
|
||||
src_pre_files = Split('''
|
||||
Author.cpp
|
||||
BaseClassList.cpp
|
||||
BiblioInfo.cpp
|
||||
Bidi.cpp
|
||||
BranchList.cpp
|
||||
@ -187,6 +186,7 @@ src_pre_files = Split('''
|
||||
LaTeXFeatures.cpp
|
||||
Language.cpp
|
||||
Layout.cpp
|
||||
LayoutFile.cpp
|
||||
Length.cpp
|
||||
Lexer.cpp
|
||||
LyX.cpp
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "Buffer.h"
|
||||
|
||||
#include "Author.h"
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "BiblioInfo.h"
|
||||
#include "BranchList.h"
|
||||
#include "buffer_funcs.h"
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "BufferParams.h"
|
||||
|
||||
#include "Author.h"
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "BranchList.h"
|
||||
#include "buffer_funcs.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
|
||||
// NOTE: in this case, the textclass (.cls file) is assumed to be available.
|
||||
string tcp;
|
||||
BaseClassList & bcl = BaseClassList::get();
|
||||
LayoutFileList & bcl = LayoutFileList::get();
|
||||
if (!filepath.empty())
|
||||
tcp = bcl.addLayoutFile(classname, filepath.absFilename());
|
||||
if (!tcp.empty())
|
||||
@ -1387,7 +1387,7 @@ void BufferParams::setDocumentClass(DocumentClass const * const tc) {
|
||||
bool BufferParams::setBaseClass(string const & classname)
|
||||
{
|
||||
LYXERR(Debug::TCLASS, "setBaseClass: " << classname);
|
||||
BaseClassList const & bcl = BaseClassList::get();
|
||||
LayoutFileList const & bcl = LayoutFileList::get();
|
||||
if (!bcl.haveClass(classname)) {
|
||||
docstring s =
|
||||
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
|
||||
{
|
||||
if (BaseClassList::get().haveClass(pimpl_->baseClass_))
|
||||
return &(BaseClassList::get()[pimpl_->baseClass_]);
|
||||
if (LayoutFileList::get().haveClass(pimpl_->baseClass_))
|
||||
return &(LayoutFileList::get()[pimpl_->baseClass_]);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file BaseClassList.cpp
|
||||
* \file LayoutFileList.cpp
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "Counters.h"
|
||||
#include "Floating.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;
|
||||
}
|
||||
|
||||
|
||||
bool BaseClassList::haveClass(string const & classname) const
|
||||
bool LayoutFileList::haveClass(string const & classname) const
|
||||
{
|
||||
ClassMap::const_iterator it = classmap_.begin();
|
||||
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));
|
||||
return *classmap_[classname];
|
||||
@ -74,7 +74,7 @@ LayoutFile const & BaseClassList::operator[](string const & classname) const
|
||||
|
||||
|
||||
LayoutFile &
|
||||
BaseClassList::operator[](string const & classname)
|
||||
LayoutFileList::operator[](string const & classname)
|
||||
{
|
||||
BOOST_ASSERT(haveClass(classname));
|
||||
return *classmap_[classname];
|
||||
@ -82,14 +82,14 @@ LayoutFile &
|
||||
|
||||
|
||||
// Reads LyX textclass definitions according to textclass config file
|
||||
bool BaseClassList::read()
|
||||
bool LayoutFileList::read()
|
||||
{
|
||||
Lexer lex(0, 0);
|
||||
FileName const real_file = libFileSearch("", "textclass.lst");
|
||||
LYXERR(Debug::TCLASS, "Reading textclasses from `" << real_file << '\'');
|
||||
|
||||
if (real_file.empty()) {
|
||||
lyxerr << "BaseClassList::Read: unable to find "
|
||||
lyxerr << "LayoutFileList::Read: unable to find "
|
||||
"textclass file `"
|
||||
<< to_utf8(makeDisplayPath(real_file.absFilename(), 1000))
|
||||
<< "'. Exiting." << endl;
|
||||
@ -102,13 +102,13 @@ bool BaseClassList::read()
|
||||
}
|
||||
|
||||
if (!lex.setFile(real_file)) {
|
||||
lyxerr << "BaseClassList::Read: "
|
||||
lyxerr << "LayoutFileList::Read: "
|
||||
"lyxlex was not able to set file: "
|
||||
<< real_file << endl;
|
||||
}
|
||||
|
||||
if (!lex.isOK()) {
|
||||
lyxerr << "BaseClassList::Read: unable to open "
|
||||
lyxerr << "LayoutFileList::Read: unable to open "
|
||||
"textclass file `"
|
||||
<< to_utf8(makeDisplayPath(real_file.absFilename(), 1000))
|
||||
<< "'\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
|
||||
// initial configuration fails. (c.f. bug 2829)
|
||||
if (classmap_.empty())
|
||||
lyxerr << "BaseClassList::Read: no textclasses found!"
|
||||
lyxerr << "LayoutFileList::Read: no textclasses found!"
|
||||
<< endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::vector<LayoutFileIndex> BaseClassList::classList() const
|
||||
std::vector<LayoutFileIndex> LayoutFileList::classList() const
|
||||
{
|
||||
std::vector<LayoutFileIndex> cl;
|
||||
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));
|
||||
LayoutFile * tc = classmap_[classname];
|
||||
LayoutFile * tmpl =
|
||||
@ -185,11 +185,11 @@ void BaseClassList::reset(LayoutFileIndex const & classname) {
|
||||
}
|
||||
|
||||
|
||||
string const BaseClassList::localPrefix = "LOCAL:";
|
||||
string const LayoutFileList::localPrefix = "LOCAL:";
|
||||
|
||||
|
||||
LayoutFileIndex
|
||||
BaseClassList::addLayoutFile(string const & textclass, string const & path)
|
||||
LayoutFileList::addLayoutFile(string const & textclass, string const & path)
|
||||
{
|
||||
// FIXME There is a bug here: 4593
|
||||
//
|
||||
@ -242,11 +242,11 @@ LayoutFileIndex
|
||||
|
||||
LayoutFileIndex defaultBaseclass()
|
||||
{
|
||||
if (BaseClassList::get().haveClass("article"))
|
||||
if (LayoutFileList::get().haveClass("article"))
|
||||
return string("article");
|
||||
if (BaseClassList::get().empty())
|
||||
if (LayoutFileList::get().empty())
|
||||
return string();
|
||||
return BaseClassList::get().classList().front();
|
||||
return LayoutFileList::get().classList().front();
|
||||
}
|
||||
|
||||
|
||||
@ -256,7 +256,7 @@ bool LyXSetStyle()
|
||||
{
|
||||
LYXERR(Debug::TCLASS, "LyXSetStyle: parsing configuration...");
|
||||
|
||||
if (!BaseClassList::get().read()) {
|
||||
if (!LayoutFileList::get().read()) {
|
||||
LYXERR(Debug::TCLASS, "LyXSetStyle: an error occured "
|
||||
"during parsing.\n Exiting.");
|
||||
return false;
|
@ -1,6 +1,6 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file BaseClassList.h
|
||||
* \file LayoutFile.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
@ -29,7 +29,7 @@ class Layout;
|
||||
extern bool LyXSetStyle();
|
||||
|
||||
|
||||
/// Index into BaseClassList. Basically a 'strong typedef'.
|
||||
/// Index into LayoutFileList. Basically a 'strong typedef'.
|
||||
class LayoutFileIndex {
|
||||
public:
|
||||
///
|
||||
@ -58,8 +58,8 @@ private:
|
||||
std::string const & description = std::string(),
|
||||
bool texClassAvail = false);
|
||||
/// The only class that should create a LayoutFile is
|
||||
/// BaseClassList, which calls the private constructor.
|
||||
friend class BaseClassList;
|
||||
/// LayoutFileList, which calls the private constructor.
|
||||
friend class LayoutFileList;
|
||||
/// can't create empty LayoutFile
|
||||
LayoutFile() {};
|
||||
};
|
||||
@ -67,13 +67,13 @@ private:
|
||||
|
||||
/// A list of base document classes (*.layout files).
|
||||
/// This is a singleton class. The sole instance is accessed
|
||||
/// via BaseClassList::get()
|
||||
class BaseClassList {
|
||||
/// via LayoutFileList::get()
|
||||
class LayoutFileList {
|
||||
public:
|
||||
///
|
||||
BaseClassList() {}
|
||||
LayoutFileList() {}
|
||||
/// \return The sole instance of this class.
|
||||
static BaseClassList & get();
|
||||
static LayoutFileList & get();
|
||||
///
|
||||
bool empty() const { return classmap_.empty(); }
|
||||
///
|
||||
@ -99,9 +99,9 @@ private:
|
||||
///
|
||||
typedef std::map<std::string, LayoutFile *> ClassMap;
|
||||
/// noncopyable
|
||||
BaseClassList(BaseClassList const &);
|
||||
LayoutFileList(LayoutFileList const &);
|
||||
/// nonassignable
|
||||
void operator=(BaseClassList const &);
|
||||
void operator=(LayoutFileList const &);
|
||||
///
|
||||
mutable ClassMap classmap_; //FIXME
|
||||
};
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include "LyX.h"
|
||||
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "Buffer.h"
|
||||
#include "BufferList.h"
|
||||
#include "CmdDef.h"
|
||||
@ -576,7 +576,7 @@ void LyX::execBatchCommands()
|
||||
// aknowledged.
|
||||
|
||||
// if reconfiguration is needed.
|
||||
while (BaseClassList::get().empty()) {
|
||||
while (LayoutFileList::get().empty()) {
|
||||
switch (Alert::prompt(
|
||||
_("No textclass is found"),
|
||||
_("LyX cannot continue because no textclass is found. "
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "LyXFunc.h"
|
||||
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "BranchList.h"
|
||||
#include "buffer_funcs.h"
|
||||
#include "Buffer.h"
|
||||
@ -709,14 +709,14 @@ void showPrintError(string const & name)
|
||||
|
||||
bool loadLayoutFile(string const & name, string const & buf_path)
|
||||
{
|
||||
if (!BaseClassList::get().haveClass(name)) {
|
||||
if (!LayoutFileList::get().haveClass(name)) {
|
||||
lyxerr << "Document class \"" << name
|
||||
<< "\" does not exist."
|
||||
<< endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
LayoutFile & tc = BaseClassList::get()[name];
|
||||
LayoutFile & tc = LayoutFileList::get()[name];
|
||||
if (!tc.load(buf_path)) {
|
||||
docstring s = bformat(_("The document class %1$s."
|
||||
"could not be loaded."), from_utf8(name));
|
||||
@ -1583,7 +1583,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
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)
|
||||
// nothing to do
|
||||
@ -1604,7 +1604,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
Buffer * buffer = lyx_view_->buffer();
|
||||
DocumentClass * oldClass = buffer->params().documentClassPtr();
|
||||
LayoutFileIndex bc = buffer->params().baseClassID();
|
||||
BaseClassList::get().reset(bc);
|
||||
LayoutFileList::get().reset(bc);
|
||||
buffer->params().makeDocumentClass();
|
||||
updateLayout(oldClass, buffer);
|
||||
updateFlags = Update::Force | Update::FitCursor;
|
||||
|
@ -76,7 +76,6 @@ endif
|
||||
|
||||
SOURCEFILESCORE = \
|
||||
Author.cpp \
|
||||
BaseClassList.cpp \
|
||||
BiblioInfo.cpp \
|
||||
Bidi.cpp \
|
||||
boost.cpp \
|
||||
@ -123,6 +122,7 @@ SOURCEFILESCORE = \
|
||||
Language.cpp \
|
||||
LaTeX.cpp \
|
||||
LaTeXFeatures.cpp \
|
||||
LayoutFile.cpp \
|
||||
Length.cpp \
|
||||
lengthcommon.cpp \
|
||||
Lexer.cpp \
|
||||
@ -171,7 +171,6 @@ SOURCEFILESCORE = \
|
||||
|
||||
HEADERFILESCORE = \
|
||||
Author.h \
|
||||
BaseClassList.h \
|
||||
BiblioInfo.h \
|
||||
Bidi.h \
|
||||
BranchList.h \
|
||||
@ -223,6 +222,7 @@ HEADERFILESCORE = \
|
||||
LaTeX.h \
|
||||
Layout.h \
|
||||
LayoutEnums.h \
|
||||
LayoutFile.h \
|
||||
Length.h \
|
||||
Lexer.h \
|
||||
lfuns.h \
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//Much of this is borrowed from BaseClassList::read()
|
||||
//Much of this is borrowed from LayoutFileList::read()
|
||||
bool ModuleList::load()
|
||||
{
|
||||
FileName const real_file = libFileSearch("", "lyxmodules.lst");
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "Paragraph.h"
|
||||
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "Changes.h"
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "TextClass.h"
|
||||
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "Color.h"
|
||||
#include "Counters.h"
|
||||
#include "Floating.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "GuiDocument.h"
|
||||
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "BranchList.h"
|
||||
#include "buffer_funcs.h"
|
||||
#include "Buffer.h"
|
||||
@ -152,8 +152,8 @@ public:
|
||||
// Ordering criteria:
|
||||
// 1. Availability of text class
|
||||
// 2. Description (lexicographic)
|
||||
LayoutFile const & tc1 = BaseClassList::get()[lhs];
|
||||
LayoutFile const & tc2 = BaseClassList::get()[rhs];
|
||||
LayoutFile const & tc1 = LayoutFileList::get()[lhs];
|
||||
LayoutFile const & tc2 = LayoutFileList::get()[rhs];
|
||||
return (tc1.isTeXClassAvailable() && !tc2.isTeXClassAvailable()) ||
|
||||
(tc1.isTeXClassAvailable() == tc2.isTeXClassAvailable() &&
|
||||
_(tc1.description()) < _(tc2.description()));
|
||||
@ -902,7 +902,7 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
}
|
||||
// latex classes
|
||||
latexModule->classCO->setModel(&classes_model_);
|
||||
BaseClassList const & bcl = BaseClassList::get();
|
||||
LayoutFileList const & bcl = LayoutFileList::get();
|
||||
vector<LayoutFileIndex> classList = bcl.classList();
|
||||
sort(classList.begin(), classList.end(), less_textclass_avail_desc());
|
||||
|
||||
@ -1243,7 +1243,7 @@ void GuiDocument::classChanged()
|
||||
return;
|
||||
string const classname = classes_model_.getIDString(idx);
|
||||
// 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"),
|
||||
_("The layout file you have selected is a local layout\n"
|
||||
"file, not one in the system or user directory. Your\n"
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "InsetInclude.h"
|
||||
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "Buffer.h"
|
||||
#include "buffer_funcs.h"
|
||||
#include "BufferList.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "InsetInfo.h"
|
||||
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "BufferView.h"
|
||||
@ -200,7 +200,7 @@ void InsetInfo::updateInfo()
|
||||
break;
|
||||
case TEXTCLASS_INFO: {
|
||||
// name_ is the class name
|
||||
setText(BaseClassList::get().haveClass(name_) ? _("yes") : _("no"),
|
||||
setText(LayoutFileList::get().haveClass(name_) ? _("yes") : _("no"),
|
||||
bp.getFont(), false);
|
||||
break;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "tex2lyx.h"
|
||||
|
||||
#include "BaseClassList.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "Layout.h"
|
||||
#include "Lexer.h"
|
||||
#include "TextClass.h"
|
||||
|
Loading…
Reference in New Issue
Block a user