2003-08-22 09:44:59 +00:00
|
|
|
|
/**
|
2007-04-29 19:53:54 +00:00
|
|
|
|
* \file TextClass.cpp
|
2003-08-22 09:44:59 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-22 09:44:59 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
2003-08-22 09:44:59 +00:00
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-22 09:44:59 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-12-28 13:26:54 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
#include "TextClass.h"
|
2007-10-25 12:41:02 +00:00
|
|
|
|
|
|
|
|
|
#include "Color.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Counters.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/debug.h"
|
|
|
|
|
#include "support/gettext.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "Floating.h"
|
2002-09-11 07:39:55 +00:00
|
|
|
|
#include "FloatList.h"
|
2007-10-25 12:41:02 +00:00
|
|
|
|
#include "Layout.h"
|
|
|
|
|
#include "Lexer.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2007-07-11 13:39:08 +00:00
|
|
|
|
#include "frontends/alert.h"
|
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2005-10-21 16:11:36 +00:00
|
|
|
|
#include "support/lyxlib.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
#include "support/filetools.h"
|
2006-06-30 13:54:01 +00:00
|
|
|
|
#include "support/os.h"
|
|
|
|
|
|
2005-10-21 16:11:36 +00:00
|
|
|
|
#include <sstream>
|
|
|
|
|
|
2007-10-28 18:51:54 +00:00
|
|
|
|
using std::endl;
|
|
|
|
|
using std::find_if;
|
|
|
|
|
using std::remove_if;
|
|
|
|
|
using std::string;
|
|
|
|
|
using std::ostream;
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2006-11-26 21:30:39 +00:00
|
|
|
|
using support::FileName;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
using support::libFileSearch;
|
|
|
|
|
using support::makeDisplayPath;
|
|
|
|
|
using support::quoteName;
|
|
|
|
|
using support::rtrim;
|
|
|
|
|
using support::subst;
|
|
|
|
|
using support::addName;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2007-11-01 06:25:47 +00:00
|
|
|
|
extern FontInfo lyxRead(Lexer &, FontInfo const & fi = sane_font);
|
2007-11-25 19:25:05 +00:00
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2004-01-31 15:30:24 +00:00
|
|
|
|
namespace {
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2007-08-23 19:59:07 +00:00
|
|
|
|
class LayoutNamesEqual : public std::unary_function<LayoutPtr, bool> {
|
2004-01-31 15:30:24 +00:00
|
|
|
|
public:
|
2007-07-11 13:39:08 +00:00
|
|
|
|
LayoutNamesEqual(docstring const & name)
|
2003-03-14 11:57:12 +00:00
|
|
|
|
: name_(name)
|
|
|
|
|
{}
|
2007-08-23 19:59:07 +00:00
|
|
|
|
bool operator()(LayoutPtr const & c) const
|
2003-03-14 11:57:12 +00:00
|
|
|
|
{
|
2002-06-24 20:28:12 +00:00
|
|
|
|
return c->name() == name_;
|
|
|
|
|
}
|
2004-01-31 15:30:24 +00:00
|
|
|
|
private:
|
2007-07-11 13:39:08 +00:00
|
|
|
|
docstring name_;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
};
|
|
|
|
|
|
2005-10-21 16:11:36 +00:00
|
|
|
|
|
2007-08-22 14:36:07 +00:00
|
|
|
|
int const FORMAT = 5;
|
2005-10-21 16:11:36 +00:00
|
|
|
|
|
|
|
|
|
|
2006-11-26 21:30:39 +00:00
|
|
|
|
bool layout2layout(FileName const & filename, FileName const & tempfile)
|
2005-10-21 16:11:36 +00:00
|
|
|
|
{
|
2006-11-26 21:30:39 +00:00
|
|
|
|
FileName const script = libFileSearch("scripts", "layout2layout.py");
|
2005-10-21 16:11:36 +00:00
|
|
|
|
if (script.empty()) {
|
|
|
|
|
lyxerr << "Could not find layout conversion "
|
2006-04-05 23:56:29 +00:00
|
|
|
|
"script layout2layout.py." << endl;
|
2005-10-21 16:11:36 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::ostringstream command;
|
2006-11-26 21:30:39 +00:00
|
|
|
|
command << support::os::python() << ' ' << quoteName(script.toFilesystemEncoding())
|
|
|
|
|
<< ' ' << quoteName(filename.toFilesystemEncoding())
|
|
|
|
|
<< ' ' << quoteName(tempfile.toFilesystemEncoding());
|
2005-10-21 16:11:36 +00:00
|
|
|
|
string const command_str = command.str();
|
|
|
|
|
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Running `" << command_str << '\'');
|
2005-10-21 16:11:36 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
support::cmd_ret const ret =
|
|
|
|
|
support::runCommand(command_str);
|
2005-10-21 16:11:36 +00:00
|
|
|
|
if (ret.first != 0) {
|
|
|
|
|
lyxerr << "Could not run layout conversion "
|
2006-04-05 23:56:29 +00:00
|
|
|
|
"script layout2layout.py." << endl;
|
2005-10-21 16:11:36 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-31 15:30:24 +00:00
|
|
|
|
} // namespace anon
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
TextClass::TextClass(string const & fn, string const & cln,
|
2003-05-03 19:24:36 +00:00
|
|
|
|
string const & desc, bool texClassAvail )
|
2002-09-11 07:39:55 +00:00
|
|
|
|
: name_(fn), latexname_(cln), description_(desc),
|
2007-08-16 15:26:00 +00:00
|
|
|
|
floatlist_(new FloatList), counters_(new Counters),
|
2004-01-31 15:30:24 +00:00
|
|
|
|
texClassAvail_(texClassAvail)
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
modular_ = false;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
outputType_ = LATEX;
|
|
|
|
|
columns_ = 1;
|
|
|
|
|
sides_ = OneSide;
|
|
|
|
|
secnumdepth_ = 3;
|
|
|
|
|
tocdepth_ = 3;
|
|
|
|
|
pagestyle_ = "default";
|
2007-10-28 18:51:54 +00:00
|
|
|
|
defaultfont_ = sane_font;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
opt_fontsize_ = "10|11|12";
|
|
|
|
|
opt_pagestyle_ = "empty|plain|headings|fancy";
|
2003-02-13 17:49:09 +00:00
|
|
|
|
titletype_ = TITLE_COMMAND_AFTER;
|
|
|
|
|
titlename_ = "maketitle";
|
2004-03-30 16:19:50 +00:00
|
|
|
|
loaded_ = false;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
bool TextClass::isTeXClassAvailable() const
|
2003-05-03 19:24:36 +00:00
|
|
|
|
{
|
|
|
|
|
return texClassAvail_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-04 09:51:26 +00:00
|
|
|
|
bool TextClass::readStyle(Lexer & lexrc, Layout & lay)
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Reading style " << to_utf8(lay.name()));
|
2006-04-09 00:26:19 +00:00
|
|
|
|
if (!lay.read(lexrc, *this)) {
|
2002-02-26 10:50:48 +00:00
|
|
|
|
// Resolve fonts
|
2001-12-28 13:26:54 +00:00
|
|
|
|
lay.resfont = lay.font;
|
|
|
|
|
lay.resfont.realize(defaultfont());
|
|
|
|
|
lay.reslabelfont = lay.labelfont;
|
|
|
|
|
lay.reslabelfont.realize(defaultfont());
|
|
|
|
|
return false; // no errors
|
2002-03-21 17:27:08 +00:00
|
|
|
|
}
|
2007-07-11 13:39:08 +00:00
|
|
|
|
lyxerr << "Error parsing style `" << to_utf8(lay.name()) << '\'' << endl;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum TextClassTags {
|
|
|
|
|
TC_OUTPUTTYPE = 1,
|
|
|
|
|
TC_INPUT,
|
|
|
|
|
TC_STYLE,
|
2002-03-02 16:39:54 +00:00
|
|
|
|
TC_DEFAULTSTYLE,
|
2007-08-13 12:13:17 +00:00
|
|
|
|
TC_INSETLAYOUT,
|
2003-03-21 12:48:20 +00:00
|
|
|
|
TC_ENVIRONMENT,
|
2001-12-28 13:26:54 +00:00
|
|
|
|
TC_NOSTYLE,
|
|
|
|
|
TC_COLUMNS,
|
|
|
|
|
TC_SIDES,
|
|
|
|
|
TC_PAGESTYLE,
|
|
|
|
|
TC_DEFAULTFONT,
|
|
|
|
|
TC_SECNUMDEPTH,
|
|
|
|
|
TC_TOCDEPTH,
|
|
|
|
|
TC_CLASSOPTIONS,
|
|
|
|
|
TC_PREAMBLE,
|
2007-04-06 09:02:23 +00:00
|
|
|
|
TC_PROVIDES,
|
2001-12-28 13:26:54 +00:00
|
|
|
|
TC_LEFTMARGIN,
|
2002-09-04 06:52:26 +00:00
|
|
|
|
TC_RIGHTMARGIN,
|
2002-09-06 14:48:01 +00:00
|
|
|
|
TC_FLOAT,
|
2002-09-11 07:39:55 +00:00
|
|
|
|
TC_COUNTER,
|
2003-02-13 17:49:09 +00:00
|
|
|
|
TC_NOFLOAT,
|
|
|
|
|
TC_TITLELATEXNAME,
|
2005-10-21 16:11:36 +00:00
|
|
|
|
TC_TITLELATEXTYPE,
|
|
|
|
|
TC_FORMAT
|
2001-12-28 13:26:54 +00:00
|
|
|
|
};
|
|
|
|
|
|
2005-10-21 16:11:36 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
// Reads a textclass structure from file.
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
bool TextClass::read(FileName const & filename, ReadType rt)
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
2007-11-25 11:18:16 +00:00
|
|
|
|
if (!filename.isReadableFile()) {
|
2005-10-21 16:11:36 +00:00
|
|
|
|
lyxerr << "Cannot read layout file `" << filename << "'."
|
|
|
|
|
<< endl;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
keyword_item textClassTags[] = {
|
|
|
|
|
{ "classoptions", TC_CLASSOPTIONS },
|
|
|
|
|
{ "columns", TC_COLUMNS },
|
2002-09-06 14:48:01 +00:00
|
|
|
|
{ "counter", TC_COUNTER },
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{ "defaultfont", TC_DEFAULTFONT },
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{ "defaultstyle", TC_DEFAULTSTYLE },
|
2003-03-21 12:48:20 +00:00
|
|
|
|
{ "environment", TC_ENVIRONMENT },
|
2002-09-04 06:52:26 +00:00
|
|
|
|
{ "float", TC_FLOAT },
|
2005-10-21 16:11:36 +00:00
|
|
|
|
{ "format", TC_FORMAT },
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{ "input", TC_INPUT },
|
2007-08-13 12:13:17 +00:00
|
|
|
|
{ "insetlayout", TC_INSETLAYOUT },
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{ "leftmargin", TC_LEFTMARGIN },
|
2002-09-11 07:39:55 +00:00
|
|
|
|
{ "nofloat", TC_NOFLOAT },
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{ "nostyle", TC_NOSTYLE },
|
|
|
|
|
{ "outputtype", TC_OUTPUTTYPE },
|
|
|
|
|
{ "pagestyle", TC_PAGESTYLE },
|
|
|
|
|
{ "preamble", TC_PREAMBLE },
|
2007-04-06 09:02:23 +00:00
|
|
|
|
{ "provides", TC_PROVIDES },
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{ "rightmargin", TC_RIGHTMARGIN },
|
|
|
|
|
{ "secnumdepth", TC_SECNUMDEPTH },
|
|
|
|
|
{ "sides", TC_SIDES },
|
|
|
|
|
{ "style", TC_STYLE },
|
2003-02-13 17:49:09 +00:00
|
|
|
|
{ "titlelatexname", TC_TITLELATEXNAME },
|
|
|
|
|
{ "titlelatextype", TC_TITLELATEXTYPE },
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{ "tocdepth", TC_TOCDEPTH }
|
|
|
|
|
};
|
|
|
|
|
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
switch (rt) {
|
|
|
|
|
case BASECLASS:
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Reading textclass ");
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
break;
|
|
|
|
|
case MERGE:
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Reading input file ");
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
break;
|
|
|
|
|
case MODULE:
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Reading module file ");
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
BOOST_ASSERT(false);
|
|
|
|
|
}
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, to_utf8(makeDisplayPath(filename.absFilename())));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
Lexer lexrc(textClassTags,
|
2003-03-21 12:48:20 +00:00
|
|
|
|
sizeof(textClassTags) / sizeof(textClassTags[0]));
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
lexrc.setFile(filename);
|
2005-10-21 16:11:36 +00:00
|
|
|
|
bool error = !lexrc.isOK();
|
|
|
|
|
|
|
|
|
|
// Format of files before the 'Format' tag was introduced
|
|
|
|
|
int format = 1;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
|
|
// parsing
|
|
|
|
|
while (lexrc.isOK() && !error) {
|
|
|
|
|
int le = lexrc.lex();
|
2003-03-14 12:08:15 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
switch (le) {
|
2007-04-26 11:30:54 +00:00
|
|
|
|
case Lexer::LEX_FEOF:
|
2002-03-21 17:27:08 +00:00
|
|
|
|
continue;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
case Lexer::LEX_UNDEF:
|
2001-12-28 13:26:54 +00:00
|
|
|
|
lexrc.printError("Unknown TextClass tag `$$Token'");
|
|
|
|
|
error = true;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
continue;
|
2003-03-14 12:08:15 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
}
|
2003-03-14 12:08:15 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
switch (static_cast<TextClassTags>(le)) {
|
2003-03-14 12:08:15 +00:00
|
|
|
|
|
2005-10-21 16:11:36 +00:00
|
|
|
|
case TC_FORMAT:
|
|
|
|
|
if (lexrc.next())
|
|
|
|
|
format = lexrc.getInteger();
|
|
|
|
|
break;
|
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
case TC_OUTPUTTYPE: // output type definition
|
|
|
|
|
readOutputType(lexrc);
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
case TC_INPUT: // Include file
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (lexrc.next()) {
|
2006-10-04 16:22:38 +00:00
|
|
|
|
string const inc = lexrc.getString();
|
2006-11-26 21:30:39 +00:00
|
|
|
|
FileName tmp = libFileSearch("layouts", inc,
|
2001-12-28 13:26:54 +00:00
|
|
|
|
"layout");
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-10-04 16:22:38 +00:00
|
|
|
|
if (tmp.empty()) {
|
|
|
|
|
lexrc.printError("Could not find input"
|
2007-05-28 22:27:45 +00:00
|
|
|
|
"file: " + inc);
|
2006-10-04 16:22:38 +00:00
|
|
|
|
error = true;
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
} else if (read(tmp, MERGE)) {
|
2001-12-28 13:26:54 +00:00
|
|
|
|
lexrc.printError("Error reading input"
|
2006-11-26 21:30:39 +00:00
|
|
|
|
"file: " + tmp.absFilename());
|
2001-12-28 13:26:54 +00:00
|
|
|
|
error = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
|
case TC_DEFAULTSTYLE:
|
|
|
|
|
if (lexrc.next()) {
|
2007-07-11 13:39:08 +00:00
|
|
|
|
docstring const name = from_utf8(subst(lexrc.getString(),
|
|
|
|
|
'_', ' '));
|
2002-03-02 16:39:54 +00:00
|
|
|
|
defaultlayout_ = name;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-05-19 07:12:09 +00:00
|
|
|
|
case TC_ENVIRONMENT:
|
2001-12-28 13:26:54 +00:00
|
|
|
|
case TC_STYLE:
|
|
|
|
|
if (lexrc.next()) {
|
2007-07-11 13:39:08 +00:00
|
|
|
|
docstring const name = from_utf8(subst(lexrc.getString(),
|
|
|
|
|
'_', ' '));
|
|
|
|
|
if (name.empty()) {
|
|
|
|
|
string s = "Could not read name for style: `$$Token' "
|
|
|
|
|
+ lexrc.getString() + " is probably not valid UTF-8!";
|
|
|
|
|
lexrc.printError(s.c_str());
|
|
|
|
|
Layout lay;
|
2007-11-04 09:51:26 +00:00
|
|
|
|
error = readStyle(lexrc, lay);
|
2007-07-11 13:39:08 +00:00
|
|
|
|
} else if (hasLayout(name)) {
|
2007-04-29 18:58:28 +00:00
|
|
|
|
Layout * lay = operator[](name).get();
|
2007-11-04 09:51:26 +00:00
|
|
|
|
error = readStyle(lexrc, *lay);
|
2001-12-28 13:26:54 +00:00
|
|
|
|
} else {
|
2007-04-29 18:58:28 +00:00
|
|
|
|
Layout lay;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
lay.setName(name);
|
2003-05-19 07:12:09 +00:00
|
|
|
|
if (le == TC_ENVIRONMENT)
|
|
|
|
|
lay.is_environment = true;
|
2007-11-04 09:51:26 +00:00
|
|
|
|
error = readStyle(lexrc, lay);
|
2005-11-02 20:11:36 +00:00
|
|
|
|
if (!error)
|
2003-11-03 17:47:28 +00:00
|
|
|
|
layoutlist_.push_back(
|
2007-04-29 18:58:28 +00:00
|
|
|
|
boost::shared_ptr<Layout>(new Layout(lay))
|
2003-11-03 17:47:28 +00:00
|
|
|
|
);
|
|
|
|
|
|
2002-03-03 20:25:07 +00:00
|
|
|
|
if (defaultlayout_.empty()) {
|
|
|
|
|
// We do not have a default
|
|
|
|
|
// layout yet, so we choose
|
|
|
|
|
// the first layout we
|
|
|
|
|
// encounter.
|
|
|
|
|
defaultlayout_ = name;
|
|
|
|
|
}
|
2001-12-28 13:26:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
lexrc.printError("No name given for style: `$$Token'.");
|
|
|
|
|
error = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TC_NOSTYLE:
|
|
|
|
|
if (lexrc.next()) {
|
2007-07-11 13:39:08 +00:00
|
|
|
|
docstring const style = from_utf8(subst(lexrc.getString(),
|
|
|
|
|
'_', ' '));
|
2007-11-04 09:51:26 +00:00
|
|
|
|
if (!deleteLayout(style))
|
2002-11-27 10:30:28 +00:00
|
|
|
|
lyxerr << "Cannot delete style `"
|
2007-07-11 13:39:08 +00:00
|
|
|
|
<< to_utf8(style) << '\'' << endl;
|
2002-03-02 16:39:54 +00:00
|
|
|
|
// lexrc.printError("Cannot delete style"
|
|
|
|
|
// " `$$Token'");
|
2001-12-28 13:26:54 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TC_COLUMNS:
|
|
|
|
|
if (lexrc.next())
|
|
|
|
|
columns_ = lexrc.getInteger();
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
case TC_SIDES:
|
|
|
|
|
if (lexrc.next()) {
|
|
|
|
|
switch (lexrc.getInteger()) {
|
|
|
|
|
case 1: sides_ = OneSide; break;
|
|
|
|
|
case 2: sides_ = TwoSides; break;
|
|
|
|
|
default:
|
|
|
|
|
lyxerr << "Impossible number of page"
|
|
|
|
|
" sides, setting to one."
|
|
|
|
|
<< endl;
|
|
|
|
|
sides_ = OneSide;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
case TC_PAGESTYLE:
|
2002-03-21 17:27:08 +00:00
|
|
|
|
lexrc.next();
|
2002-07-28 22:50:13 +00:00
|
|
|
|
pagestyle_ = rtrim(lexrc.getString());
|
2001-12-28 13:26:54 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
case TC_DEFAULTFONT:
|
2007-11-01 09:57:38 +00:00
|
|
|
|
defaultfont_ = lyxRead(lexrc);
|
2001-12-28 13:26:54 +00:00
|
|
|
|
if (!defaultfont_.resolved()) {
|
|
|
|
|
lexrc.printError("Warning: defaultfont should "
|
|
|
|
|
"be fully instantiated!");
|
2007-10-28 18:51:54 +00:00
|
|
|
|
defaultfont_.realize(sane_font);
|
2001-12-28 13:26:54 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TC_SECNUMDEPTH:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
secnumdepth_ = lexrc.getInteger();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TC_TOCDEPTH:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
tocdepth_ = lexrc.getInteger();
|
|
|
|
|
break;
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
// First step to support options
|
|
|
|
|
case TC_CLASSOPTIONS:
|
2001-12-28 13:26:54 +00:00
|
|
|
|
readClassOptions(lexrc);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
break;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
|
|
case TC_PREAMBLE:
|
2006-11-08 17:22:44 +00:00
|
|
|
|
preamble_ = from_utf8(lexrc.getLongString("EndPreamble"));
|
2001-12-28 13:26:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
|
case TC_PROVIDES: {
|
|
|
|
|
lexrc.next();
|
|
|
|
|
string const feature = lexrc.getString();
|
|
|
|
|
lexrc.next();
|
|
|
|
|
if (lexrc.getInteger())
|
|
|
|
|
provides_.insert(feature);
|
|
|
|
|
else
|
|
|
|
|
provides_.erase(feature);
|
2001-12-28 13:26:54 +00:00
|
|
|
|
break;
|
2007-04-06 09:02:23 +00:00
|
|
|
|
}
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
|
|
case TC_LEFTMARGIN: // left margin type
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (lexrc.next())
|
2007-08-18 13:21:12 +00:00
|
|
|
|
leftmargin_ = lexrc.getDocString();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
break;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
|
|
case TC_RIGHTMARGIN: // right margin type
|
|
|
|
|
if (lexrc.next())
|
2007-08-18 13:21:12 +00:00
|
|
|
|
rightmargin_ = lexrc.getDocString();
|
2001-12-28 13:26:54 +00:00
|
|
|
|
break;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
case TC_INSETLAYOUT:
|
|
|
|
|
if (lexrc.next()) {
|
|
|
|
|
docstring const name = subst(lexrc.getDocString(), '_', ' ');
|
|
|
|
|
readInsetLayout(lexrc, name);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-09-04 06:52:26 +00:00
|
|
|
|
case TC_FLOAT:
|
|
|
|
|
readFloat(lexrc);
|
|
|
|
|
break;
|
2002-09-06 14:48:01 +00:00
|
|
|
|
case TC_COUNTER:
|
|
|
|
|
readCounter(lexrc);
|
|
|
|
|
break;
|
2003-02-13 17:49:09 +00:00
|
|
|
|
case TC_TITLELATEXTYPE:
|
|
|
|
|
readTitleType(lexrc);
|
|
|
|
|
break;
|
|
|
|
|
case TC_TITLELATEXNAME:
|
|
|
|
|
if (lexrc.next())
|
|
|
|
|
titlename_ = lexrc.getString();
|
|
|
|
|
break;
|
2002-09-11 07:39:55 +00:00
|
|
|
|
case TC_NOFLOAT:
|
|
|
|
|
if (lexrc.next()) {
|
|
|
|
|
string const nofloat = lexrc.getString();
|
|
|
|
|
floatlist_->erase(nofloat);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
}
|
2005-10-21 16:11:36 +00:00
|
|
|
|
if (format != FORMAT)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (format != FORMAT) {
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Converting layout file from format "
|
|
|
|
|
<< format << " to " << FORMAT);
|
2006-11-26 21:30:39 +00:00
|
|
|
|
FileName const tempfile(support::tempName());
|
2005-10-21 16:11:36 +00:00
|
|
|
|
error = !layout2layout(filename, tempfile);
|
|
|
|
|
if (!error)
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
error = read(tempfile, rt);
|
2007-11-28 09:01:49 +00:00
|
|
|
|
tempfile.removeFile();
|
2005-10-21 16:11:36 +00:00
|
|
|
|
return error;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
}
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
if (rt == MODULE)
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Finished reading module file "
|
|
|
|
|
<< to_utf8(makeDisplayPath(filename.absFilename())));
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
else if (rt == MERGE)
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Finished reading input file "
|
|
|
|
|
<< to_utf8(makeDisplayPath(filename.absFilename())));
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
else { // we are at top level here.
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Finished reading textclass "
|
|
|
|
|
<< to_utf8(makeDisplayPath(filename.absFilename())));
|
2002-03-02 16:39:54 +00:00
|
|
|
|
if (defaultlayout_.empty()) {
|
|
|
|
|
lyxerr << "Error: Textclass '" << name_
|
|
|
|
|
<< "' is missing a defaultstyle." << endl;
|
|
|
|
|
error = true;
|
|
|
|
|
}
|
2005-05-12 10:16:04 +00:00
|
|
|
|
|
2007-04-29 18:58:28 +00:00
|
|
|
|
min_toclevel_ = Layout::NOT_IN_TOC;
|
|
|
|
|
max_toclevel_ = Layout::NOT_IN_TOC;
|
2005-05-12 10:16:04 +00:00
|
|
|
|
const_iterator cit = begin();
|
|
|
|
|
const_iterator the_end = end();
|
|
|
|
|
for ( ; cit != the_end ; ++cit) {
|
|
|
|
|
int const toclevel = (*cit)->toclevel;
|
2007-04-29 18:58:28 +00:00
|
|
|
|
if (toclevel != Layout::NOT_IN_TOC) {
|
|
|
|
|
if (min_toclevel_ == Layout::NOT_IN_TOC)
|
2005-05-12 10:16:04 +00:00
|
|
|
|
min_toclevel_ = toclevel;
|
|
|
|
|
else
|
2005-06-09 09:58:08 +00:00
|
|
|
|
min_toclevel_ = std::min(min_toclevel_,
|
2005-05-12 10:16:04 +00:00
|
|
|
|
toclevel);
|
2005-06-09 09:58:08 +00:00
|
|
|
|
max_toclevel_ = std::max(max_toclevel_,
|
2005-05-12 10:16:04 +00:00
|
|
|
|
toclevel);
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Minimum TocLevel is " << min_toclevel_
|
|
|
|
|
<< ", maximum is " << max_toclevel_);
|
2005-06-09 09:58:08 +00:00
|
|
|
|
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
}
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
void TextClass::readTitleType(Lexer & lexrc)
|
2003-02-13 17:49:09 +00:00
|
|
|
|
{
|
|
|
|
|
keyword_item titleTypeTags[] = {
|
|
|
|
|
{ "commandafter", TITLE_COMMAND_AFTER },
|
|
|
|
|
{ "environment", TITLE_ENVIRONMENT }
|
|
|
|
|
};
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
PushPopHelper pph(lexrc, titleTypeTags, TITLE_ENVIRONMENT);
|
2003-02-13 17:49:09 +00:00
|
|
|
|
|
|
|
|
|
int le = lexrc.lex();
|
|
|
|
|
switch (le) {
|
2007-04-26 11:30:54 +00:00
|
|
|
|
case Lexer::LEX_UNDEF:
|
2003-02-13 17:49:09 +00:00
|
|
|
|
lexrc.printError("Unknown output type `$$Token'");
|
|
|
|
|
return;
|
|
|
|
|
case TITLE_COMMAND_AFTER:
|
|
|
|
|
case TITLE_ENVIRONMENT:
|
2007-09-29 20:02:32 +00:00
|
|
|
|
titletype_ = static_cast<TitleLatexType>(le);
|
2003-02-13 17:49:09 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
lyxerr << "Unhandled value " << le
|
2007-04-29 19:53:54 +00:00
|
|
|
|
<< " in TextClass::readTitleType." << endl;
|
2003-02-13 17:49:09 +00:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
void TextClass::readOutputType(Lexer & lexrc)
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
|
|
|
|
keyword_item outputTypeTags[] = {
|
|
|
|
|
{ "docbook", DOCBOOK },
|
|
|
|
|
{ "latex", LATEX },
|
|
|
|
|
{ "literate", LITERATE }
|
|
|
|
|
};
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
PushPopHelper pph(lexrc, outputTypeTags, LITERATE);
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
|
|
int le = lexrc.lex();
|
|
|
|
|
switch (le) {
|
2007-04-26 11:30:54 +00:00
|
|
|
|
case Lexer::LEX_UNDEF:
|
2001-12-28 13:26:54 +00:00
|
|
|
|
lexrc.printError("Unknown output type `$$Token'");
|
|
|
|
|
return;
|
|
|
|
|
case LATEX:
|
|
|
|
|
case DOCBOOK:
|
|
|
|
|
case LITERATE:
|
|
|
|
|
outputType_ = static_cast<OutputType>(le);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
lyxerr << "Unhandled value " << le
|
2007-04-29 19:53:54 +00:00
|
|
|
|
<< " in TextClass::readOutputType." << endl;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum ClassOptionsTags {
|
|
|
|
|
CO_FONTSIZE = 1,
|
|
|
|
|
CO_PAGESTYLE,
|
|
|
|
|
CO_OTHER,
|
2003-11-27 16:57:12 +00:00
|
|
|
|
CO_HEADER,
|
2001-12-28 13:26:54 +00:00
|
|
|
|
CO_END
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
void TextClass::readClassOptions(Lexer & lexrc)
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
|
|
|
|
keyword_item classOptionsTags[] = {
|
|
|
|
|
{"end", CO_END },
|
|
|
|
|
{"fontsize", CO_FONTSIZE },
|
2003-11-27 16:57:12 +00:00
|
|
|
|
{"header", CO_HEADER },
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{"other", CO_OTHER },
|
|
|
|
|
{"pagestyle", CO_PAGESTYLE }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
lexrc.pushTable(classOptionsTags, CO_END);
|
|
|
|
|
bool getout = false;
|
|
|
|
|
while (!getout && lexrc.isOK()) {
|
|
|
|
|
int le = lexrc.lex();
|
|
|
|
|
switch (le) {
|
2007-04-26 11:30:54 +00:00
|
|
|
|
case Lexer::LEX_UNDEF:
|
2001-12-28 13:26:54 +00:00
|
|
|
|
lexrc.printError("Unknown ClassOption tag `$$Token'");
|
2002-03-21 17:27:08 +00:00
|
|
|
|
continue;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
switch (static_cast<ClassOptionsTags>(le)) {
|
|
|
|
|
case CO_FONTSIZE:
|
|
|
|
|
lexrc.next();
|
2002-07-28 22:50:13 +00:00
|
|
|
|
opt_fontsize_ = rtrim(lexrc.getString());
|
2001-12-28 13:26:54 +00:00
|
|
|
|
break;
|
|
|
|
|
case CO_PAGESTYLE:
|
|
|
|
|
lexrc.next();
|
2002-07-28 22:50:13 +00:00
|
|
|
|
opt_pagestyle_ = rtrim(lexrc.getString());
|
2001-12-28 13:26:54 +00:00
|
|
|
|
break;
|
|
|
|
|
case CO_OTHER:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
options_ = lexrc.getString();
|
|
|
|
|
break;
|
2003-11-27 16:57:12 +00:00
|
|
|
|
case CO_HEADER:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
class_header_ = subst(lexrc.getString(), """, "\"");
|
|
|
|
|
break;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
case CO_END:
|
|
|
|
|
getout = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
lexrc.popTable();
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
2007-08-13 12:13:17 +00:00
|
|
|
|
enum InsetLayoutTags {
|
|
|
|
|
IL_FONT = 1,
|
2007-08-26 20:32:58 +00:00
|
|
|
|
IL_BGCOLOR,
|
2007-08-25 09:57:32 +00:00
|
|
|
|
IL_DECORATION,
|
2007-10-25 09:19:26 +00:00
|
|
|
|
IL_FREESPACING,
|
2007-10-29 14:39:29 +00:00
|
|
|
|
IL_FORCELTR,
|
2007-08-13 12:13:17 +00:00
|
|
|
|
IL_LABELFONT,
|
|
|
|
|
IL_LABELSTRING,
|
|
|
|
|
IL_LATEXNAME,
|
|
|
|
|
IL_LATEXPARAM,
|
2007-08-22 14:36:07 +00:00
|
|
|
|
IL_LATEXTYPE,
|
|
|
|
|
IL_LYXTYPE,
|
2007-10-25 09:19:26 +00:00
|
|
|
|
IL_KEEPEMPTY,
|
2007-10-09 17:07:24 +00:00
|
|
|
|
IL_MULTIPAR,
|
2007-10-25 09:19:26 +00:00
|
|
|
|
IL_NEEDPROTECT,
|
|
|
|
|
IL_PASSTHRU,
|
2007-08-13 12:13:17 +00:00
|
|
|
|
IL_PREAMBLE,
|
|
|
|
|
IL_END
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
|
|
|
|
|
{
|
|
|
|
|
keyword_item elementTags[] = {
|
2007-08-26 20:32:58 +00:00
|
|
|
|
{ "bgcolor", IL_BGCOLOR },
|
2007-08-25 09:57:32 +00:00
|
|
|
|
{ "decoration", IL_DECORATION },
|
2007-08-13 12:13:17 +00:00
|
|
|
|
{ "end", IL_END },
|
|
|
|
|
{ "font", IL_FONT },
|
2007-10-29 14:39:29 +00:00
|
|
|
|
{ "forceltr", IL_FORCELTR },
|
2007-10-25 09:19:26 +00:00
|
|
|
|
{ "freespacing", IL_FREESPACING },
|
|
|
|
|
{ "keepempty", IL_KEEPEMPTY },
|
2007-08-13 12:13:17 +00:00
|
|
|
|
{ "labelfont", IL_LABELFONT },
|
|
|
|
|
{ "labelstring", IL_LABELSTRING },
|
|
|
|
|
{ "latexname", IL_LATEXNAME },
|
|
|
|
|
{ "latexparam", IL_LATEXPARAM },
|
|
|
|
|
{ "latextype", IL_LATEXTYPE },
|
2007-08-17 15:38:58 +00:00
|
|
|
|
{ "lyxtype", IL_LYXTYPE },
|
2007-10-09 17:07:24 +00:00
|
|
|
|
{ "multipar", IL_MULTIPAR },
|
2007-10-25 09:19:26 +00:00
|
|
|
|
{ "needprotect", IL_NEEDPROTECT },
|
|
|
|
|
{ "passthru", IL_PASSTHRU },
|
|
|
|
|
{ "preamble", IL_PREAMBLE }
|
2007-08-13 12:13:17 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
lexrc.pushTable(elementTags, IL_END);
|
|
|
|
|
|
2007-08-17 15:38:58 +00:00
|
|
|
|
string lyxtype;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
docstring labelstring;
|
|
|
|
|
string latextype;
|
2007-08-25 09:57:32 +00:00
|
|
|
|
string decoration;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
string latexname;
|
|
|
|
|
string latexparam;
|
2007-11-01 06:25:47 +00:00
|
|
|
|
FontInfo font = inherit_font;
|
|
|
|
|
FontInfo labelfont = inherit_font;
|
2007-10-25 12:41:02 +00:00
|
|
|
|
ColorCode bgcolor(Color_background);
|
2007-08-13 12:13:17 +00:00
|
|
|
|
string preamble;
|
2007-11-01 06:25:47 +00:00
|
|
|
|
bool multipar = false;
|
|
|
|
|
bool passthru = false;
|
|
|
|
|
bool needprotect = false;
|
|
|
|
|
bool keepempty = false;
|
|
|
|
|
bool freespacing = false;
|
|
|
|
|
bool forceltr = false;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
|
|
|
|
|
bool getout = false;
|
|
|
|
|
while (!getout && lexrc.isOK()) {
|
|
|
|
|
int le = lexrc.lex();
|
|
|
|
|
switch (le) {
|
|
|
|
|
case Lexer::LEX_UNDEF:
|
|
|
|
|
lexrc.printError("Unknown ClassOption tag `$$Token'");
|
|
|
|
|
continue;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
switch (static_cast<InsetLayoutTags>(le)) {
|
2007-08-17 15:38:58 +00:00
|
|
|
|
case IL_LYXTYPE:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
lyxtype = lexrc.getString();
|
|
|
|
|
break;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
case IL_LATEXTYPE:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
latextype = lexrc.getString();
|
|
|
|
|
break;
|
|
|
|
|
case IL_LABELSTRING:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
labelstring = lexrc.getDocString();
|
|
|
|
|
break;
|
2007-08-25 09:57:32 +00:00
|
|
|
|
case IL_DECORATION:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
decoration = lexrc.getString();
|
|
|
|
|
break;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
case IL_LATEXNAME:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
latexname = lexrc.getString();
|
|
|
|
|
break;
|
|
|
|
|
case IL_LATEXPARAM:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
latexparam = subst(lexrc.getString(), """, "\"");
|
|
|
|
|
break;
|
|
|
|
|
case IL_LABELFONT:
|
2007-11-01 06:25:47 +00:00
|
|
|
|
labelfont = lyxRead(lexrc, inherit_font);
|
2007-08-13 12:13:17 +00:00
|
|
|
|
break;
|
2007-10-29 14:39:29 +00:00
|
|
|
|
case IL_FORCELTR:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
forceltr = lexrc.getBool();
|
|
|
|
|
break;
|
2007-10-09 17:07:24 +00:00
|
|
|
|
case IL_MULTIPAR:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
multipar = lexrc.getBool();
|
|
|
|
|
break;
|
2007-10-25 09:19:26 +00:00
|
|
|
|
case IL_PASSTHRU:
|
2007-10-20 17:07:08 +00:00
|
|
|
|
lexrc.next();
|
2007-10-25 09:19:26 +00:00
|
|
|
|
passthru = lexrc.getBool();
|
|
|
|
|
break;
|
|
|
|
|
case IL_KEEPEMPTY:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
keepempty = lexrc.getBool();
|
|
|
|
|
break;
|
|
|
|
|
case IL_FREESPACING:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
freespacing = lexrc.getBool();
|
|
|
|
|
break;
|
|
|
|
|
case IL_NEEDPROTECT:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
needprotect = lexrc.getBool();
|
2007-10-20 17:07:08 +00:00
|
|
|
|
break;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
case IL_FONT:
|
2007-11-01 06:25:47 +00:00
|
|
|
|
font = lyxRead(lexrc, inherit_font);
|
2007-09-05 15:29:04 +00:00
|
|
|
|
// So: define font before labelfont
|
2007-08-13 12:13:17 +00:00
|
|
|
|
labelfont = font;
|
|
|
|
|
break;
|
2007-08-26 20:32:58 +00:00
|
|
|
|
case IL_BGCOLOR: {
|
|
|
|
|
lexrc.next();
|
|
|
|
|
string const token = lexrc.getString();
|
|
|
|
|
bgcolor = lcolor.getFromLyXName(token);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2007-08-13 12:13:17 +00:00
|
|
|
|
case IL_PREAMBLE:
|
|
|
|
|
preamble = lexrc.getLongString("EndPreamble");
|
|
|
|
|
break;
|
|
|
|
|
case IL_END:
|
|
|
|
|
getout = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Here add element to list if getout == true
|
|
|
|
|
if (getout) {
|
|
|
|
|
InsetLayout il;
|
2007-08-17 15:38:58 +00:00
|
|
|
|
il.name = to_ascii(name);
|
|
|
|
|
il.lyxtype = lyxtype;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
il.labelstring = labelstring;
|
2007-08-25 09:57:32 +00:00
|
|
|
|
il.decoration = decoration;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
il.latextype = latextype;
|
|
|
|
|
il.latexname = latexname;
|
|
|
|
|
il.latexparam = latexparam;
|
2007-10-09 17:07:24 +00:00
|
|
|
|
il.multipar = multipar;
|
2007-10-25 09:19:26 +00:00
|
|
|
|
il.passthru = passthru;
|
|
|
|
|
il.needprotect = needprotect;
|
|
|
|
|
il.freespacing = freespacing;
|
2007-10-29 14:39:29 +00:00
|
|
|
|
il.forceltr = forceltr;
|
2007-10-25 09:19:26 +00:00
|
|
|
|
il.keepempty = keepempty;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
il.font = font;
|
2007-11-03 01:41:27 +00:00
|
|
|
|
// The label font is generally used as-is without
|
|
|
|
|
// any realization against a given context.
|
|
|
|
|
labelfont.realize(sane_font);
|
2007-08-13 12:13:17 +00:00
|
|
|
|
il.labelfont = labelfont;
|
2007-08-26 20:32:58 +00:00
|
|
|
|
il.bgcolor = bgcolor;
|
2007-08-22 14:36:07 +00:00
|
|
|
|
il.preamble = preamble;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
insetlayoutlist_[name] = il;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lexrc.popTable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-09-04 06:52:26 +00:00
|
|
|
|
enum FloatTags {
|
|
|
|
|
FT_TYPE = 1,
|
|
|
|
|
FT_NAME,
|
|
|
|
|
FT_PLACEMENT,
|
|
|
|
|
FT_EXT,
|
|
|
|
|
FT_WITHIN,
|
|
|
|
|
FT_STYLE,
|
|
|
|
|
FT_LISTNAME,
|
|
|
|
|
FT_BUILTIN,
|
|
|
|
|
FT_END
|
|
|
|
|
};
|
|
|
|
|
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
void TextClass::readFloat(Lexer & lexrc)
|
2002-09-04 06:52:26 +00:00
|
|
|
|
{
|
|
|
|
|
keyword_item floatTags[] = {
|
|
|
|
|
{ "end", FT_END },
|
|
|
|
|
{ "extension", FT_EXT },
|
|
|
|
|
{ "guiname", FT_NAME },
|
|
|
|
|
{ "latexbuiltin", FT_BUILTIN },
|
|
|
|
|
{ "listname", FT_LISTNAME },
|
|
|
|
|
{ "numberwithin", FT_WITHIN },
|
|
|
|
|
{ "placement", FT_PLACEMENT },
|
|
|
|
|
{ "style", FT_STYLE },
|
|
|
|
|
{ "type", FT_TYPE }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
lexrc.pushTable(floatTags, FT_END);
|
|
|
|
|
|
|
|
|
|
string type;
|
|
|
|
|
string placement;
|
|
|
|
|
string ext;
|
|
|
|
|
string within;
|
|
|
|
|
string style;
|
|
|
|
|
string name;
|
2007-08-16 11:07:00 +00:00
|
|
|
|
string listName;
|
2002-09-04 06:52:26 +00:00
|
|
|
|
bool builtin = false;
|
|
|
|
|
|
|
|
|
|
bool getout = false;
|
|
|
|
|
while (!getout && lexrc.isOK()) {
|
|
|
|
|
int le = lexrc.lex();
|
|
|
|
|
switch (le) {
|
2007-04-26 11:30:54 +00:00
|
|
|
|
case Lexer::LEX_UNDEF:
|
2002-09-04 06:52:26 +00:00
|
|
|
|
lexrc.printError("Unknown ClassOption tag `$$Token'");
|
|
|
|
|
continue;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
switch (static_cast<FloatTags>(le)) {
|
|
|
|
|
case FT_TYPE:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
type = lexrc.getString();
|
2007-08-16 11:07:00 +00:00
|
|
|
|
if (floatlist_->typeExist(type)) {
|
|
|
|
|
Floating const & fl = floatlist_->getType(type);
|
|
|
|
|
placement = fl.placement();
|
|
|
|
|
ext = fl.ext();
|
|
|
|
|
within = fl.within();
|
|
|
|
|
style = fl.style();
|
|
|
|
|
name = fl.name();
|
|
|
|
|
listName = fl.listName();
|
|
|
|
|
builtin = fl.builtin();
|
|
|
|
|
}
|
2002-09-04 06:52:26 +00:00
|
|
|
|
break;
|
|
|
|
|
case FT_NAME:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
name = lexrc.getString();
|
|
|
|
|
break;
|
|
|
|
|
case FT_PLACEMENT:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
placement = lexrc.getString();
|
|
|
|
|
break;
|
|
|
|
|
case FT_EXT:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
ext = lexrc.getString();
|
|
|
|
|
break;
|
|
|
|
|
case FT_WITHIN:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
within = lexrc.getString();
|
|
|
|
|
if (within == "none")
|
|
|
|
|
within.erase();
|
|
|
|
|
break;
|
|
|
|
|
case FT_STYLE:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
style = lexrc.getString();
|
|
|
|
|
break;
|
|
|
|
|
case FT_LISTNAME:
|
|
|
|
|
lexrc.next();
|
2007-08-16 11:07:00 +00:00
|
|
|
|
listName = lexrc.getString();
|
2002-09-04 06:52:26 +00:00
|
|
|
|
break;
|
|
|
|
|
case FT_BUILTIN:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
builtin = lexrc.getBool();
|
|
|
|
|
break;
|
|
|
|
|
case FT_END:
|
|
|
|
|
getout = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Here if have a full float if getout == true
|
|
|
|
|
if (getout) {
|
2007-08-16 11:07:00 +00:00
|
|
|
|
Floating fl(type, placement, ext, within,
|
|
|
|
|
style, name, listName, builtin);
|
|
|
|
|
floatlist_->newFloat(fl);
|
|
|
|
|
// each float has its own counter
|
2007-08-16 15:26:00 +00:00
|
|
|
|
counters_->newCounter(from_ascii(type), from_ascii(within),
|
|
|
|
|
docstring(), docstring());
|
2002-09-04 06:52:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lexrc.popTable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-09-06 14:48:01 +00:00
|
|
|
|
enum CounterTags {
|
|
|
|
|
CT_NAME = 1,
|
|
|
|
|
CT_WITHIN,
|
2007-08-16 11:07:00 +00:00
|
|
|
|
CT_LABELSTRING,
|
|
|
|
|
CT_LABELSTRING_APPENDIX,
|
2002-09-06 14:48:01 +00:00
|
|
|
|
CT_END
|
|
|
|
|
};
|
|
|
|
|
|
2007-11-15 20:04:51 +00:00
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
void TextClass::readCounter(Lexer & lexrc)
|
2002-09-06 14:48:01 +00:00
|
|
|
|
{
|
|
|
|
|
keyword_item counterTags[] = {
|
|
|
|
|
{ "end", CT_END },
|
2007-08-16 11:07:00 +00:00
|
|
|
|
{ "labelstring", CT_LABELSTRING },
|
|
|
|
|
{ "labelstringappendix", CT_LABELSTRING_APPENDIX },
|
2002-09-06 14:48:01 +00:00
|
|
|
|
{ "name", CT_NAME },
|
|
|
|
|
{ "within", CT_WITHIN }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
lexrc.pushTable(counterTags, CT_END);
|
|
|
|
|
|
2006-10-20 22:17:16 +00:00
|
|
|
|
docstring name;
|
|
|
|
|
docstring within;
|
2007-08-16 11:07:00 +00:00
|
|
|
|
docstring labelstring;
|
|
|
|
|
docstring labelstring_appendix;
|
2002-09-06 14:48:01 +00:00
|
|
|
|
|
|
|
|
|
bool getout = false;
|
|
|
|
|
while (!getout && lexrc.isOK()) {
|
|
|
|
|
int le = lexrc.lex();
|
|
|
|
|
switch (le) {
|
2007-04-26 11:30:54 +00:00
|
|
|
|
case Lexer::LEX_UNDEF:
|
2002-09-06 14:48:01 +00:00
|
|
|
|
lexrc.printError("Unknown ClassOption tag `$$Token'");
|
|
|
|
|
continue;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
switch (static_cast<CounterTags>(le)) {
|
|
|
|
|
case CT_NAME:
|
|
|
|
|
lexrc.next();
|
2007-08-16 11:07:00 +00:00
|
|
|
|
name = lexrc.getDocString();
|
2007-08-16 15:26:00 +00:00
|
|
|
|
if (counters_->hasCounter(name))
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Reading existing counter " << to_utf8(name));
|
2007-08-16 11:07:00 +00:00
|
|
|
|
else
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::TCLASS, "Reading new counter " << to_utf8(name));
|
2002-09-06 14:48:01 +00:00
|
|
|
|
break;
|
|
|
|
|
case CT_WITHIN:
|
|
|
|
|
lexrc.next();
|
2007-08-16 11:07:00 +00:00
|
|
|
|
within = lexrc.getDocString();
|
2006-12-21 19:02:17 +00:00
|
|
|
|
if (within == "none")
|
2002-09-06 14:48:01 +00:00
|
|
|
|
within.erase();
|
|
|
|
|
break;
|
2007-08-16 11:07:00 +00:00
|
|
|
|
case CT_LABELSTRING:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
labelstring = lexrc.getDocString();
|
|
|
|
|
labelstring_appendix = labelstring;
|
|
|
|
|
break;
|
|
|
|
|
case CT_LABELSTRING_APPENDIX:
|
|
|
|
|
lexrc.next();
|
|
|
|
|
labelstring_appendix = lexrc.getDocString();
|
|
|
|
|
break;
|
2002-09-06 14:48:01 +00:00
|
|
|
|
case CT_END:
|
|
|
|
|
getout = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-12 17:13:22 +00:00
|
|
|
|
// Here if have a full counter if getout == true
|
2007-08-16 11:07:00 +00:00
|
|
|
|
if (getout)
|
2007-08-16 15:26:00 +00:00
|
|
|
|
counters_->newCounter(name, within,
|
|
|
|
|
labelstring, labelstring_appendix);
|
2002-09-06 14:48:01 +00:00
|
|
|
|
|
|
|
|
|
lexrc.popTable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-28 18:51:54 +00:00
|
|
|
|
FontInfo const & TextClass::defaultfont() const
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
|
|
|
|
return defaultfont_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-18 13:21:12 +00:00
|
|
|
|
docstring const & TextClass::leftmargin() const
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
|
|
|
|
return leftmargin_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-18 13:21:12 +00:00
|
|
|
|
docstring const & TextClass::rightmargin() const
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
|
|
|
|
return rightmargin_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-07-11 13:39:08 +00:00
|
|
|
|
bool TextClass::hasLayout(docstring const & n) const
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
2007-07-11 13:39:08 +00:00
|
|
|
|
docstring const name = n.empty() ? defaultLayoutName() : n;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-08-27 15:51:19 +00:00
|
|
|
|
return find_if(layoutlist_.begin(), layoutlist_.end(),
|
2004-01-31 15:30:24 +00:00
|
|
|
|
LayoutNamesEqual(name))
|
2002-08-27 15:51:19 +00:00
|
|
|
|
!= layoutlist_.end();
|
2001-12-28 13:26:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-19 07:12:09 +00:00
|
|
|
|
|
2007-08-23 19:59:07 +00:00
|
|
|
|
LayoutPtr const & TextClass::operator[](docstring const & name) const
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(!name.empty());
|
2002-03-12 18:11:49 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
LayoutList::const_iterator cit =
|
2002-08-27 15:51:19 +00:00
|
|
|
|
find_if(layoutlist_.begin(),
|
|
|
|
|
layoutlist_.end(),
|
2004-01-31 15:30:24 +00:00
|
|
|
|
LayoutNamesEqual(name));
|
2002-03-02 16:39:54 +00:00
|
|
|
|
|
2002-08-27 15:51:19 +00:00
|
|
|
|
if (cit == layoutlist_.end()) {
|
2007-07-11 13:39:08 +00:00
|
|
|
|
lyxerr << "We failed to find the layout '" << to_utf8(name)
|
2002-03-02 16:39:54 +00:00
|
|
|
|
<< "' in the layout list. You MUST investigate!"
|
|
|
|
|
<< endl;
|
2003-05-19 07:12:09 +00:00
|
|
|
|
for (LayoutList::const_iterator it = layoutlist_.begin();
|
2006-04-05 23:56:29 +00:00
|
|
|
|
it != layoutlist_.end(); ++it)
|
2007-07-11 13:39:08 +00:00
|
|
|
|
lyxerr << " " << to_utf8(it->get()->name()) << endl;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
|
// we require the name to exist
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(false);
|
2002-03-02 16:39:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-04 09:51:26 +00:00
|
|
|
|
return *cit;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-04 09:51:26 +00:00
|
|
|
|
bool TextClass::deleteLayout(docstring const & name)
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
2002-03-02 16:39:54 +00:00
|
|
|
|
if (name == defaultLayoutName())
|
|
|
|
|
return false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
LayoutList::iterator it =
|
2002-08-27 15:51:19 +00:00
|
|
|
|
remove_if(layoutlist_.begin(), layoutlist_.end(),
|
2004-01-31 15:30:24 +00:00
|
|
|
|
LayoutNamesEqual(name));
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2002-08-27 15:51:19 +00:00
|
|
|
|
LayoutList::iterator end = layoutlist_.end();
|
2001-12-28 13:26:54 +00:00
|
|
|
|
bool const ret = (it != end);
|
2002-08-27 15:51:19 +00:00
|
|
|
|
layoutlist_.erase(it, end);
|
2001-12-28 13:26:54 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Load textclass info if not loaded yet
|
2007-04-29 19:53:54 +00:00
|
|
|
|
bool TextClass::load(string const & path) const
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
2004-03-30 16:19:50 +00:00
|
|
|
|
if (loaded_)
|
2002-03-02 16:39:54 +00:00
|
|
|
|
return true;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2006-05-04 02:38:11 +00:00
|
|
|
|
// Read style-file, provided path is searched before the system ones
|
2006-11-26 21:30:39 +00:00
|
|
|
|
FileName layout_file;
|
2006-05-04 02:38:11 +00:00
|
|
|
|
if (!path.empty())
|
2006-11-26 21:30:39 +00:00
|
|
|
|
layout_file = FileName(addName(path, name_ + ".layout"));
|
2007-10-18 19:29:32 +00:00
|
|
|
|
if (layout_file.empty() || !layout_file.exists())
|
2006-05-04 02:38:11 +00:00
|
|
|
|
layout_file = libFileSearch("layouts", name_, "layout");
|
2007-04-29 19:53:54 +00:00
|
|
|
|
loaded_ = const_cast<TextClass*>(this)->read(layout_file) == 0;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2004-03-31 09:44:40 +00:00
|
|
|
|
if (!loaded_) {
|
2001-12-28 13:26:54 +00:00
|
|
|
|
lyxerr << "Error reading `"
|
2006-11-26 21:30:39 +00:00
|
|
|
|
<< to_utf8(makeDisplayPath(layout_file.absFilename()))
|
2001-12-28 13:26:54 +00:00
|
|
|
|
<< "'\n(Check `" << name_
|
|
|
|
|
<< "')\nCheck your installation and "
|
|
|
|
|
"try Options/Reconfigure..." << endl;
|
|
|
|
|
}
|
2004-03-31 09:44:40 +00:00
|
|
|
|
|
2004-03-30 16:19:50 +00:00
|
|
|
|
return loaded_;
|
2002-03-02 16:39:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
FloatList & TextClass::floats()
|
2002-08-27 15:51:19 +00:00
|
|
|
|
{
|
2002-09-11 07:39:55 +00:00
|
|
|
|
return *floatlist_.get();
|
2002-08-27 15:51:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
FloatList const & TextClass::floats() const
|
2002-08-27 15:51:19 +00:00
|
|
|
|
{
|
2002-09-11 07:39:55 +00:00
|
|
|
|
return *floatlist_.get();
|
2002-08-27 15:51:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
Counters & TextClass::counters() const
|
2002-09-06 14:48:01 +00:00
|
|
|
|
{
|
2007-08-16 15:26:00 +00:00
|
|
|
|
return *counters_.get();
|
2002-09-06 14:48:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-25 14:43:59 +00:00
|
|
|
|
|
|
|
|
|
// Return the layout object of an inset given by name. If the name
|
|
|
|
|
// is not found as such, the part after the ':' is stripped off, and
|
|
|
|
|
// searched again. In this way, an error fallback can be provided:
|
|
|
|
|
// An erroneous 'CharStyle:badname' (e.g., after a documentclass switch)
|
|
|
|
|
// will invoke the layout object defined by name = 'CharStyle'.
|
|
|
|
|
// If that doesn't work either, an empty object returns (shouldn't
|
|
|
|
|
// happen). -- Idea JMarc, comment MV
|
2007-08-13 12:13:17 +00:00
|
|
|
|
InsetLayout const & TextClass::insetlayout(docstring const & name) const
|
|
|
|
|
{
|
2007-08-17 15:38:58 +00:00
|
|
|
|
docstring n = name;
|
|
|
|
|
while (!n.empty()) {
|
2007-08-18 11:48:53 +00:00
|
|
|
|
if (insetlayoutlist_.count(n) > 0)
|
2007-08-17 15:38:58 +00:00
|
|
|
|
return insetlayoutlist_[n];
|
|
|
|
|
docstring::size_type i = n.find(':');
|
|
|
|
|
if (i == string::npos)
|
|
|
|
|
break;
|
|
|
|
|
n = n.substr(0,i);
|
|
|
|
|
}
|
2007-08-25 14:43:59 +00:00
|
|
|
|
static InsetLayout empty;
|
|
|
|
|
empty.labelstring = from_utf8("UNDEFINED");
|
2007-11-03 01:41:27 +00:00
|
|
|
|
empty.labelfont = sane_font;
|
|
|
|
|
empty.labelfont.setColor(Color_error);
|
2007-10-25 12:41:02 +00:00
|
|
|
|
empty.bgcolor = Color_error;
|
2007-08-17 15:38:58 +00:00
|
|
|
|
return empty;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-06 14:48:01 +00:00
|
|
|
|
|
2007-07-11 13:39:08 +00:00
|
|
|
|
docstring const & TextClass::defaultLayoutName() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
// This really should come from the actual layout... (Lgb)
|
|
|
|
|
return defaultlayout_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-23 19:59:07 +00:00
|
|
|
|
LayoutPtr const & TextClass::defaultLayout() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return operator[](defaultLayoutName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
string const & TextClass::name() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
string const & TextClass::latexname() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
2007-04-29 19:53:54 +00:00
|
|
|
|
const_cast<TextClass*>(this)->load();
|
2002-03-02 16:39:54 +00:00
|
|
|
|
return latexname_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
string const & TextClass::description() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return description_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
string const & TextClass::opt_fontsize() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return opt_fontsize_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
string const & TextClass::opt_pagestyle() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return opt_pagestyle_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
string const & TextClass::options() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return options_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
string const & TextClass::class_header() const
|
2003-11-27 16:57:12 +00:00
|
|
|
|
{
|
|
|
|
|
return class_header_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
string const & TextClass::pagestyle() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return pagestyle_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
docstring const & TextClass::preamble() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return preamble_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-07 23:25:08 +00:00
|
|
|
|
PageSides TextClass::sides() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return sides_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
int TextClass::secnumdepth() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return secnumdepth_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
int TextClass::tocdepth() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return tocdepth_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
OutputType TextClass::outputType() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return outputType_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
bool TextClass::provides(string const & p) const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
2007-04-06 09:02:23 +00:00
|
|
|
|
return provides_.find(p) != provides_.end();
|
2002-03-02 16:39:54 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
unsigned int TextClass::columns() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return columns_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-29 20:02:32 +00:00
|
|
|
|
TitleLatexType TextClass::titletype() const
|
2003-02-13 17:49:09 +00:00
|
|
|
|
{
|
|
|
|
|
return titletype_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
string const & TextClass::titlename() const
|
2003-02-13 17:49:09 +00:00
|
|
|
|
{
|
|
|
|
|
return titlename_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
int TextClass::size() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
2002-08-27 15:51:19 +00:00
|
|
|
|
return layoutlist_.size();
|
2001-12-28 13:26:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
int TextClass::min_toclevel() const
|
2005-05-12 10:16:04 +00:00
|
|
|
|
{
|
|
|
|
|
return min_toclevel_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
int TextClass::max_toclevel() const
|
2005-05-12 10:16:04 +00:00
|
|
|
|
{
|
|
|
|
|
return max_toclevel_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
bool TextClass::hasTocLevels() const
|
2006-03-24 11:57:19 +00:00
|
|
|
|
{
|
2007-04-29 18:58:28 +00:00
|
|
|
|
return min_toclevel_ != Layout::NOT_IN_TOC;
|
2006-03-24 11:57:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-07 23:25:08 +00:00
|
|
|
|
ostream & operator<<(ostream & os, PageSides p)
|
2001-12-28 13:26:54 +00:00
|
|
|
|
{
|
|
|
|
|
switch (p) {
|
2007-11-07 23:25:08 +00:00
|
|
|
|
case OneSide:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '1';
|
2001-12-28 13:26:54 +00:00
|
|
|
|
break;
|
2007-11-07 23:25:08 +00:00
|
|
|
|
case TwoSides:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '2';
|
2001-12-28 13:26:54 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return os;
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|