mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
2001-12-28 Lars Gullik Bj�nnes <larsbj@birdstep.com>
* Makefile.am: added the new files to sources, removed layout.C * layout.C: removed file * layout.h: remove LYX_DUMMY_LAYOUT * lyxtextclasslist.C (NumberOfLayout): do not special case dummy layout. * lyxlayout.[Ch]: * lyxtextclass.[Ch]: * lyxtextclasslist.[Ch]: new files * include order changes to a lot of files, also changes because of the six new files. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3269 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9987ffaee8
commit
b922cdd796
@ -28,6 +28,7 @@
|
||||
#include "gettext.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "undo_funcs.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#include "frontends/Dialogs.h"
|
||||
#include "frontends/Alert.h"
|
||||
@ -70,7 +71,7 @@
|
||||
#include <ctime>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <locale.h>
|
||||
#include <clocale>
|
||||
|
||||
|
||||
extern lyx::layout_type current_layout;
|
||||
|
@ -1,3 +1,21 @@
|
||||
2001-12-28 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* Makefile.am: added the new files to sources, removed layout.C
|
||||
|
||||
* layout.C: removed file
|
||||
|
||||
* layout.h: remove LYX_DUMMY_LAYOUT
|
||||
|
||||
* lyxtextclasslist.C (NumberOfLayout): do not special case dummy
|
||||
layout.
|
||||
|
||||
* lyxlayout.[Ch]:
|
||||
* lyxtextclass.[Ch]:
|
||||
* lyxtextclasslist.[Ch]: new files
|
||||
|
||||
* include order changes to a lot of files, also changes because of
|
||||
the six new files.
|
||||
|
||||
2001-12-27 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* buffer.C (asciiParagraph): more fixes.
|
||||
|
@ -9,19 +9,21 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "CutAndPaste.h"
|
||||
#include "BufferView.h"
|
||||
#include "buffer.h"
|
||||
#include "paragraph.h"
|
||||
#include "insets/inseterror.h"
|
||||
#include "lyx_gui_misc.h"
|
||||
#include "lyxcursor.h"
|
||||
#include "gettext.h"
|
||||
#include "iterators.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
#include "insets/inseterror.h"
|
||||
|
||||
using std::pair;
|
||||
using lyx::pos_type;
|
||||
|
@ -15,9 +15,10 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "layout.h"
|
||||
#include "support/types.h"
|
||||
|
||||
class Paragraph;
|
||||
class BufferParams;
|
||||
|
||||
///
|
||||
class CutAndPaste {
|
||||
@ -25,16 +26,16 @@ public:
|
||||
///
|
||||
static
|
||||
bool cutSelection(Paragraph * startpar, Paragraph ** endpar,
|
||||
int start, int & end, char tc, bool doclear = false,
|
||||
bool realcut = true);
|
||||
int start, int & end, char tc, bool doclear = false,
|
||||
bool realcut = true);
|
||||
///
|
||||
static
|
||||
bool copySelection(Paragraph * startpar, Paragraph * endpar,
|
||||
int start, int end, char tc);
|
||||
int start, int end, char tc);
|
||||
///
|
||||
static
|
||||
bool pasteSelection(Paragraph ** par, Paragraph ** endpar,
|
||||
int & pos, char tc);
|
||||
int & pos, char tc);
|
||||
///
|
||||
static
|
||||
int nrOfParagraphs();
|
||||
|
@ -11,28 +11,29 @@
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "LaTeXFeatures.h"
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "debug.h"
|
||||
#include "lyx_sty.h"
|
||||
#include "lyxrc.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "bufferparams.h"
|
||||
#include "layout.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "FloatList.h"
|
||||
#include "language.h"
|
||||
#include "encoding.h"
|
||||
#include "LString.h"
|
||||
|
||||
using std::endl;
|
||||
using std::set;
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using lyx::layout_type;
|
||||
using lyx::textclass_type;
|
||||
|
||||
using std::endl;
|
||||
using std::set;
|
||||
|
||||
LaTeXFeatures::LaTeXFeatures(BufferParams const & p, layout_type n)
|
||||
: layout(n, false), params(p)
|
||||
{}
|
||||
|
@ -17,12 +17,14 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "support/types.h"
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <list>
|
||||
|
||||
#include "LString.h"
|
||||
#include "layout.h"
|
||||
#include <map>
|
||||
|
||||
class BufferParams;
|
||||
struct Language;
|
||||
@ -41,7 +43,6 @@ struct Language;
|
||||
when you do so.
|
||||
*/
|
||||
class LaTeXFeatures {
|
||||
|
||||
public:
|
||||
///
|
||||
LaTeXFeatures(BufferParams const &, lyx::layout_type n) ;
|
||||
|
@ -135,7 +135,6 @@ lyx_SOURCES = \
|
||||
language.h \
|
||||
lastfiles.C \
|
||||
lastfiles.h \
|
||||
layout.C \
|
||||
layout.h \
|
||||
lengthcommon.C \
|
||||
lengthcommon.h \
|
||||
@ -159,6 +158,8 @@ lyx_SOURCES = \
|
||||
lyxfunc.h \
|
||||
lyxgluelength.C \
|
||||
lyxgluelength.h \
|
||||
lyxlayout.C \
|
||||
lyxlayout.h \
|
||||
lyxlength.C \
|
||||
lyxlength.h \
|
||||
lyxlex.C \
|
||||
@ -175,6 +176,10 @@ lyx_SOURCES = \
|
||||
lyxserver.C \
|
||||
lyxserver.h \
|
||||
lyxtext.h \
|
||||
lyxtextclass.C \
|
||||
lyxtextclass.h \
|
||||
lyxtextclasslist.C \
|
||||
lyxtextclasslist.h \
|
||||
lyxvc.C \
|
||||
lyxvc.h \
|
||||
main.C \
|
||||
|
22
src/buffer.C
22
src/buffer.C
@ -45,6 +45,7 @@
|
||||
#include "BufferView.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "iterators.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#include "mathed/formulamacro.h"
|
||||
#include "mathed/formula.h"
|
||||
@ -460,9 +461,14 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
#endif
|
||||
lex.eatLine();
|
||||
string const layoutname = lex.getString();
|
||||
//lyxerr << "Looking for layout '"
|
||||
// << layoutname << "'!" << endl;
|
||||
|
||||
pair<bool, layout_type> pp
|
||||
= textclasslist.NumberOfLayout(params.textclass, layoutname);
|
||||
|
||||
//lyxerr << "Result: " << pp.first << "/" << pp.second << endl;
|
||||
|
||||
#ifndef NO_COMPABILITY
|
||||
if (compare_no_case(layoutname, "latex") == 0) {
|
||||
ert_comp.active = true;
|
||||
@ -536,6 +542,9 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
} else {
|
||||
// layout not found
|
||||
// use default layout "Standard" (0)
|
||||
//lyxerr << "Layout '" << layoutname
|
||||
// << "' was not found!" << endl;
|
||||
|
||||
par->layout = 0;
|
||||
++unknown_layouts;
|
||||
string const s = _("Layout had to be changed from\n")
|
||||
@ -728,21 +737,25 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
par->params().startOfAppendix(true);
|
||||
} else if (token == "\\paragraph_separation") {
|
||||
int tmpret = lex.findToken(string_paragraph_separation);
|
||||
if (tmpret == -1) ++tmpret;
|
||||
if (tmpret == -1)
|
||||
++tmpret;
|
||||
if (tmpret != LYX_LAYOUT_DEFAULT)
|
||||
params.paragraph_separation =
|
||||
static_cast<BufferParams::PARSEP>(tmpret);
|
||||
} else if (token == "\\defskip") {
|
||||
lex.nextToken();
|
||||
params.defskip = VSpace(lex.getString());
|
||||
#ifndef NO_COMPABILITY
|
||||
} else if (token == "\\epsfig") { // obsolete
|
||||
// Indeed it is obsolete, but we HAVE to be backwards
|
||||
// compatible until 0.14, because otherwise all figures
|
||||
// in existing documents are irretrivably lost. (Asger)
|
||||
params.readGraphicsDriver(lex);
|
||||
#endif
|
||||
} else if (token == "\\quotes_language") {
|
||||
int tmpret = lex.findToken(string_quotes_language);
|
||||
if (tmpret == -1) ++tmpret;
|
||||
if (tmpret == -1)
|
||||
++tmpret;
|
||||
if (tmpret != LYX_LAYOUT_DEFAULT) {
|
||||
InsetQuotes::quote_language tmpl =
|
||||
InsetQuotes::EnglishQ;
|
||||
@ -805,7 +818,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
params.use_numerical_citations = lex.getInteger();
|
||||
} else if (token == "\\paperorientation") {
|
||||
int tmpret = lex.findToken(string_orientation);
|
||||
if (tmpret == -1) ++tmpret;
|
||||
if (tmpret == -1)
|
||||
++tmpret;
|
||||
if (tmpret != LYX_LAYOUT_DEFAULT)
|
||||
params.orientation = static_cast<BufferParams::PAPER_ORIENTATION>(tmpret);
|
||||
} else if (token == "\\paperwidth") {
|
||||
@ -2004,8 +2018,10 @@ void Buffer::writeFileAscii(ostream & ofs, int linelen)
|
||||
ofs << "\n";
|
||||
}
|
||||
|
||||
|
||||
bool use_babel;
|
||||
|
||||
|
||||
void Buffer::makeLaTeXFile(string const & fname,
|
||||
string const & original_path,
|
||||
bool nice, bool only_body)
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "support/lyxfunctional.h"
|
||||
#include "support/LAssert.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
@ -101,7 +101,8 @@ bool BufferList::empty() const
|
||||
}
|
||||
|
||||
|
||||
bool BufferList::qwriteOne(Buffer * buf, string const & fname, string & unsaved_list)
|
||||
bool BufferList::qwriteOne(Buffer * buf, string const & fname,
|
||||
string & unsaved_list)
|
||||
{
|
||||
bool reask = true;
|
||||
while (reask) {
|
||||
@ -137,9 +138,9 @@ bool BufferList::qwriteOne(Buffer * buf, string const & fname, string & unsaved_
|
||||
bool BufferList::qwriteAll()
|
||||
{
|
||||
string unsaved;
|
||||
for (BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it)
|
||||
{
|
||||
BufferStorage::iterator it = bstore.begin();
|
||||
BufferStorage::iterator end = bstore.end();
|
||||
for (; it != end; ++it) {
|
||||
if (!(*it)->isLyxClean()) {
|
||||
string fname;
|
||||
if ((*it)->isUnnamed())
|
||||
@ -182,7 +183,9 @@ bool BufferList::close(Buffer * buf)
|
||||
// Trace back why we need to use buf->getUser here.
|
||||
// Perhaps slight rewrite is in order? (Lgb)
|
||||
|
||||
if (buf->getUser()) buf->getUser()->insetUnlock();
|
||||
if (buf->getUser())
|
||||
buf->getUser()->insetUnlock();
|
||||
|
||||
if (buf->paragraph && !buf->isLyxClean() && !quitting) {
|
||||
if (buf->getUser())
|
||||
buf->getUser()->owner()->prohibitInput();
|
||||
@ -256,9 +259,9 @@ int BufferList::unlockInset(UpdatableInset * inset)
|
||||
{
|
||||
lyx::Assert(inset);
|
||||
|
||||
//if (!inset) return 1;
|
||||
for (BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
BufferStorage::iterator it = bstore.begin();
|
||||
BufferStorage::iterator end = bstore.end();
|
||||
for (; it != end; ++it) {
|
||||
if ((*it)->getUser()
|
||||
&& (*it)->getUser()->theLockingInset() == inset) {
|
||||
(*it)->getUser()->insetUnlock();
|
||||
@ -271,8 +274,9 @@ int BufferList::unlockInset(UpdatableInset * inset)
|
||||
|
||||
void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
|
||||
{
|
||||
for (BufferStorage::iterator it = bstore.begin();
|
||||
it != bstore.end(); ++it) {
|
||||
BufferStorage::iterator it = bstore.begin();
|
||||
BufferStorage::iterator end = bstore.end();
|
||||
for (; it != end; ++it) {
|
||||
if (!(*it)->isDepClean(mastertmpdir)) {
|
||||
string writefile = mastertmpdir;
|
||||
writefile += '/';
|
||||
@ -300,7 +304,8 @@ void BufferList::emergencyWrite(Buffer * buf)
|
||||
|
||||
|
||||
// No need to save if the buffer has not changed.
|
||||
if (buf->isLyxClean()) return;
|
||||
if (buf->isLyxClean())
|
||||
return;
|
||||
|
||||
lyxerr << fmt(_("lyx: Attempting to save document %s as..."),
|
||||
buf->isUnnamed() ? OnlyFilename(buf->fileName()).c_str()
|
||||
@ -354,7 +359,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
|
||||
{
|
||||
Buffer * b = bstore.newBuffer(s, ronly);
|
||||
|
||||
string ts = s;
|
||||
string ts(s);
|
||||
string e = OnlyPath(s);
|
||||
string a = e;
|
||||
// File information about normal file
|
||||
|
@ -9,10 +9,9 @@
|
||||
* ====================================================== */
|
||||
|
||||
#include <config.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "bufferparams.h"
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "bufferparams.h"
|
||||
@ -20,10 +19,14 @@
|
||||
#include "layout.h"
|
||||
#include "vspace.h"
|
||||
#include "debug.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "lyxrc.h"
|
||||
#include "language.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
|
@ -21,8 +21,10 @@
|
||||
#include "vspace.h"
|
||||
#include "Spacing.h"
|
||||
#include "Bullet.h"
|
||||
#include "lyxtextclass.h"
|
||||
|
||||
#include "insets/insetquotes.h"
|
||||
#include "layout.h"
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
|
||||
|
@ -19,15 +19,17 @@
|
||||
#include "BufferView.h"
|
||||
#include "paragraph.h"
|
||||
#include "lyxfont.h"
|
||||
#include "frontends/Alert.h"
|
||||
#include "lyxtext.h"
|
||||
#include "buffer.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "lyx_cb.h"
|
||||
#include "language.h"
|
||||
#include "gettext.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
void emph(BufferView * bv)
|
||||
{
|
||||
|
@ -153,7 +153,8 @@ int lyxfont::width(char const * s, size_t n, LyXFont const & f)
|
||||
|
||||
int lyxfont::signedWidth(string const & s, LyXFont const & f)
|
||||
{
|
||||
if (s.empty()) return 0;
|
||||
if (s.empty())
|
||||
return 0;
|
||||
if (s[0] == '-')
|
||||
return -width(s.substr(1, s.length() - 1), f);
|
||||
else
|
||||
|
@ -18,20 +18,16 @@
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "Alert.h"
|
||||
|
||||
#include "FormDocument.h"
|
||||
#include "form_document.h"
|
||||
#include "Alert.h"
|
||||
#include "Dialogs.h"
|
||||
#include "layout.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "combox.h"
|
||||
#include "tex-strings.h"
|
||||
#include "bufferparams.h"
|
||||
#include "insets/insetquotes.h"
|
||||
#include "vspace.h"
|
||||
#include "bmtable.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "language.h"
|
||||
#include "LyXView.h"
|
||||
#include "lyxfunc.h"
|
||||
@ -47,6 +43,11 @@
|
||||
#include "helper_funcs.h"
|
||||
#include "lyx_main.h" // for user_lyxdir
|
||||
|
||||
#include "insets/insetquotes.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using Liason::setMinibuffer;
|
||||
using SigC::slot;
|
||||
|
||||
|
@ -20,18 +20,20 @@
|
||||
#include "FormParagraph.h"
|
||||
#include "form_paragraph.h"
|
||||
#include "Dialogs.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "Liason.h"
|
||||
#include "LyXView.h"
|
||||
#include "buffer.h"
|
||||
#include "lyxtext.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "BufferView.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "Spacing.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "input_validators.h"
|
||||
#include "helper_funcs.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using Liason::setMinibuffer;
|
||||
using SigC::slot;
|
||||
|
||||
|
@ -26,11 +26,13 @@
|
||||
#include "func_status.h"
|
||||
#include "BufferView.h"
|
||||
#include "buffer.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "LyXAction.h"
|
||||
#include "MathsSymbols.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "gettext.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
@ -42,18 +44,21 @@ const int sepspace = 6; // extra space
|
||||
const int buttonwidth = 30; // the standard button width
|
||||
const int height = 30; // the height of all items in the toolbar
|
||||
|
||||
Toolbar::Pimpl::toolbarItem::toolbarItem() {
|
||||
Toolbar::Pimpl::toolbarItem::toolbarItem()
|
||||
{
|
||||
action = LFUN_NOACTION;
|
||||
icon = 0;
|
||||
}
|
||||
|
||||
|
||||
Toolbar::Pimpl::toolbarItem::~toolbarItem() {
|
||||
Toolbar::Pimpl::toolbarItem::~toolbarItem()
|
||||
{
|
||||
clean();
|
||||
}
|
||||
|
||||
|
||||
void Toolbar::Pimpl::toolbarItem::clean() {
|
||||
void Toolbar::Pimpl::toolbarItem::clean()
|
||||
{
|
||||
if (icon) {
|
||||
fl_delete_object(icon);
|
||||
fl_free_object(icon);
|
||||
@ -63,7 +68,8 @@ void Toolbar::Pimpl::toolbarItem::clean() {
|
||||
|
||||
|
||||
Toolbar::Pimpl::toolbarItem &
|
||||
Toolbar::Pimpl::toolbarItem::operator=(toolbarItem const & ti) {
|
||||
Toolbar::Pimpl::toolbarItem::operator=(toolbarItem const & ti)
|
||||
{
|
||||
// Are we assigning the object onto itself?
|
||||
if (this == &ti)
|
||||
return *this;
|
||||
@ -177,6 +183,7 @@ void Toolbar::Pimpl::deactivate()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Toolbar::Pimpl::update()
|
||||
{
|
||||
ToolbarList::const_iterator p = toollist.begin();
|
||||
@ -239,7 +246,8 @@ void Toolbar::Pimpl::layoutSelected()
|
||||
}
|
||||
|
||||
|
||||
void Toolbar::Pimpl::setLayout(int layout) {
|
||||
void Toolbar::Pimpl::setLayout(int layout)
|
||||
{
|
||||
if (combox) {
|
||||
LyXTextClass const & tc =
|
||||
textclasslist.TextClass(owner->buffer()->
|
||||
@ -313,8 +321,11 @@ extern "C" {
|
||||
}
|
||||
|
||||
|
||||
void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) {
|
||||
string name, arg, xpm_name;
|
||||
void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height)
|
||||
{
|
||||
string name;
|
||||
string arg;
|
||||
string xpm_name;
|
||||
kb_action act;
|
||||
|
||||
if (lyxaction.isPseudoAction(action)) {
|
||||
|
@ -1,27 +1,30 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "frontends/Dialogs.h"
|
||||
#include "insetbib.h"
|
||||
#include "buffer.h"
|
||||
#include "debug.h"
|
||||
#include "BufferView.h"
|
||||
#include "gettext.h"
|
||||
#include "lyxtext.h"
|
||||
#include "lyxrc.h"
|
||||
#include "font.h"
|
||||
#include "LyXView.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#include "frontends/Dialogs.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/path.h"
|
||||
#include "support/os.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "lyxrc.h"
|
||||
#include "font.h"
|
||||
#include "LyXView.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
|
||||
using std::ostream;
|
||||
using std::ifstream;
|
||||
|
@ -18,15 +18,19 @@
|
||||
#include "lyxfont.h"
|
||||
#include "language.h"
|
||||
#include "buffer.h"
|
||||
#include "insets/insettext.h"
|
||||
#include "support/LOstream.h"
|
||||
#include "lyx_gui_misc.h"
|
||||
#include "BufferView.h"
|
||||
#include "LyXView.h"
|
||||
#include "lyxtext.h"
|
||||
#include "debug.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#include "insets/insettext.h"
|
||||
|
||||
#include "frontends/Dialogs.h"
|
||||
#include "frontends/Alert.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "support/LOstream.h"
|
||||
|
||||
using std::ostream;
|
||||
using lyx::pos_type;
|
||||
|
@ -1,27 +1,28 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "frontends/Dialogs.h"
|
||||
|
||||
#include "insetinclude.h"
|
||||
#include "buffer.h"
|
||||
#include "bufferlist.h"
|
||||
#include "BufferView.h"
|
||||
#include "debug.h"
|
||||
#include "support/filetools.h"
|
||||
#include "lyxrc.h"
|
||||
#include "LyXView.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "gettext.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#include "frontends/Dialogs.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "layout.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "Painter.h"
|
||||
#include "font.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxfont.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::max;
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "buffer.h"
|
||||
#include "LyXView.h"
|
||||
#include "BufferView.h"
|
||||
#include "layout.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "Painter.h"
|
||||
#include "lyxtext.h"
|
||||
|
1478
src/layout.C
1478
src/layout.C
File diff suppressed because it is too large
Load Diff
448
src/layout.h
448
src/layout.h
@ -12,32 +12,11 @@
|
||||
#ifndef LAYOUT_H
|
||||
#define LAYOUT_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "lyxfont.h"
|
||||
#include "Spacing.h"
|
||||
#include "support/types.h"
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
class LyXLeX;
|
||||
|
||||
/// Reads the style files
|
||||
extern void LyXSetStyle();
|
||||
|
||||
enum layout_default {
|
||||
///
|
||||
LYX_LAYOUT_DEFAULT = 99
|
||||
};
|
||||
|
||||
// Could this cause confusion that both DUMMY_LAYOUT and LAYOUT_DEFAULT has
|
||||
// the same value? (Lgb)
|
||||
///
|
||||
#define LYX_DUMMY_LAYOUT 99
|
||||
|
||||
|
||||
/// The different output types
|
||||
enum OutputType {
|
||||
@ -184,431 +163,4 @@ enum LYX_END_LABEL_TYPES {
|
||||
*/
|
||||
|
||||
|
||||
// Attributes of a layout/paragraph environment
|
||||
class LyXTextClass;
|
||||
|
||||
///
|
||||
class LyXLayout {
|
||||
public:
|
||||
///
|
||||
LyXLayout ();
|
||||
|
||||
///
|
||||
bool Read (LyXLex &, LyXTextClass const &);
|
||||
///
|
||||
void readAlign(LyXLex &);
|
||||
///
|
||||
void readAlignPossible(LyXLex &);
|
||||
///
|
||||
void readLabelType(LyXLex &);
|
||||
///
|
||||
void readEndLabelType(LyXLex &);
|
||||
///
|
||||
void readMargin(LyXLex &);
|
||||
///
|
||||
void readLatexType(LyXLex &);
|
||||
///
|
||||
void readSpacing(LyXLex &);
|
||||
///
|
||||
string const & name() const { return name_; }
|
||||
///
|
||||
void setName(string const & n) { name_ = n; }
|
||||
///
|
||||
string const & obsoleted_by() const { return obsoleted_by_; }
|
||||
///
|
||||
string const & latexname() const { return latexname_; }
|
||||
///
|
||||
string const & labelstring() const { return labelstring_; }
|
||||
///
|
||||
string const & endlabelstring() const { return endlabelstring_; }
|
||||
///
|
||||
string const & preamble() const { return preamble_; }
|
||||
///
|
||||
string const & latexparam() const { return latexparam_; }
|
||||
///
|
||||
string const & labelstring_appendix() const {
|
||||
return labelstring_appendix_;
|
||||
}
|
||||
/** Default font for this layout/environment.
|
||||
The main font for this kind of environment. If an attribute has
|
||||
LyXFont::INHERITED_*, it means that the value is specified by
|
||||
the defaultfont for the entire layout. If we are nested, the
|
||||
font is inherited from the font in the environment one level
|
||||
up until the font is resolved. The values LyXFont::IGNORE_*
|
||||
and LyXFont::TOGGLE are illegal here.
|
||||
*/
|
||||
LyXFont font;
|
||||
|
||||
/** Default font for labels.
|
||||
Interpretation the same as for font above
|
||||
*/
|
||||
LyXFont labelfont;
|
||||
|
||||
/** Resolved version of the font for this layout/environment.
|
||||
This is a resolved version the default font. The font is resolved
|
||||
against the defaultfont of the entire layout.
|
||||
*/
|
||||
LyXFont resfont;
|
||||
|
||||
/** Resolved version of the font used for labels.
|
||||
This is a resolved version the label font. The font is resolved
|
||||
against the defaultfont of the entire layout.
|
||||
*/
|
||||
LyXFont reslabelfont;
|
||||
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
string leftmargin;
|
||||
|
||||
/// Text that dictates how wide the right margin is on the screen
|
||||
string rightmargin;
|
||||
|
||||
/// Text that dictates how much space to leave after a potential label
|
||||
string labelsep;
|
||||
|
||||
/// Text that dictates how much space to leave before a potential label
|
||||
string labelindent;
|
||||
|
||||
/** Text that dictates the width of the indentation of
|
||||
indented paragraphs.
|
||||
*/
|
||||
string parindent;
|
||||
|
||||
///
|
||||
float parskip;
|
||||
|
||||
///
|
||||
float itemsep;
|
||||
|
||||
///
|
||||
float topsep;
|
||||
|
||||
///
|
||||
float bottomsep;
|
||||
|
||||
///
|
||||
float labelbottomsep;
|
||||
|
||||
///
|
||||
float parsep;
|
||||
|
||||
///
|
||||
Spacing spacing;
|
||||
|
||||
///
|
||||
LyXAlignment align;
|
||||
|
||||
///
|
||||
LyXAlignment alignpossible;
|
||||
|
||||
///
|
||||
char labeltype; // add approp. type
|
||||
|
||||
///
|
||||
LYX_END_LABEL_TYPES endlabeltype;
|
||||
|
||||
///
|
||||
LYX_MARGIN_TYPE margintype;
|
||||
|
||||
///
|
||||
bool fill_top;
|
||||
|
||||
///
|
||||
bool fill_bottom;
|
||||
|
||||
///
|
||||
bool newline_allowed;
|
||||
|
||||
///
|
||||
bool nextnoindent;
|
||||
|
||||
///
|
||||
bool free_spacing;
|
||||
|
||||
///
|
||||
bool pass_thru;
|
||||
|
||||
/** true when the fragile commands in the paragraph need to be
|
||||
\protect'ed. */
|
||||
bool needprotect;
|
||||
/// true when empty paragraphs should be kept.
|
||||
bool keepempty;
|
||||
///
|
||||
bool isParagraph() const {
|
||||
return latextype == LATEX_PARAGRAPH;
|
||||
}
|
||||
///
|
||||
bool isCommand() const {
|
||||
return latextype == LATEX_COMMAND;
|
||||
}
|
||||
///
|
||||
bool isEnvironment() const {
|
||||
return (latextype == LATEX_ENVIRONMENT
|
||||
|| latextype == LATEX_ITEM_ENVIRONMENT
|
||||
|| latextype == LATEX_LIST_ENVIRONMENT);
|
||||
}
|
||||
/// Type of LaTeX object
|
||||
LYX_LATEX_TYPES latextype;
|
||||
/// Does this object belong in the title part of the document?
|
||||
bool intitle;
|
||||
private:
|
||||
/// Name of the layout/paragraph environment
|
||||
string name_;
|
||||
|
||||
/** Name of an layout that has replaced this layout.
|
||||
This is used to rename a layout, while keeping backward
|
||||
compatibility
|
||||
*/
|
||||
string obsoleted_by_;
|
||||
|
||||
/// LaTeX name for environment
|
||||
string latexname_;
|
||||
|
||||
/// Label string. "Abstract", "Reference", "Caption"...
|
||||
string labelstring_;
|
||||
|
||||
///
|
||||
string endlabelstring_;
|
||||
|
||||
/// Label string inside appendix. "Appendix", ...
|
||||
string labelstring_appendix_;
|
||||
|
||||
/// LaTeX parameter for environment
|
||||
string latexparam_;
|
||||
|
||||
/// Macro definitions needed for this layout
|
||||
string preamble_;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
class LyXTextClass {
|
||||
public:
|
||||
///
|
||||
typedef std::vector<LyXLayout> LayoutList;
|
||||
///
|
||||
typedef LayoutList::const_iterator const_iterator;
|
||||
///
|
||||
explicit
|
||||
LyXTextClass (string const & = string(),
|
||||
string const & = string(),
|
||||
string const & = string());
|
||||
|
||||
///
|
||||
const_iterator begin() const { return layoutlist.begin(); }
|
||||
///
|
||||
const_iterator end() const { return layoutlist.end(); }
|
||||
|
||||
///
|
||||
bool Read(string const & filename, bool merge = false);
|
||||
///
|
||||
void readOutputType(LyXLex &);
|
||||
///
|
||||
void readMaxCounter(LyXLex &);
|
||||
///
|
||||
void readClassOptions(LyXLex &);
|
||||
///
|
||||
bool hasLayout(string const & name) const;
|
||||
|
||||
///
|
||||
LyXLayout const & GetLayout(string const & vname) const;
|
||||
|
||||
///
|
||||
LyXLayout & GetLayout(string const & vname);
|
||||
|
||||
/// Sees to that the textclass structure has been loaded
|
||||
void load();
|
||||
|
||||
///
|
||||
string const & name() const { return name_; }
|
||||
///
|
||||
string const & latexname() const { return latexname_; }
|
||||
///
|
||||
string const & description() const { return description_; }
|
||||
///
|
||||
string const & opt_fontsize() const { return opt_fontsize_; }
|
||||
///
|
||||
string const & opt_pagestyle() const { return opt_pagestyle_; }
|
||||
///
|
||||
string const & options() const { return options_; }
|
||||
///
|
||||
string const & pagestyle() const { return pagestyle_; }
|
||||
///
|
||||
string const & preamble() const { return preamble_; }
|
||||
|
||||
/// Packages that are already loaded by the class
|
||||
enum Provides {
|
||||
///
|
||||
nothing = 0,
|
||||
///
|
||||
amsmath = 1,
|
||||
///
|
||||
makeidx = 2,
|
||||
///
|
||||
url = 4
|
||||
};
|
||||
///
|
||||
bool provides(Provides p) const { return provides_ & p; }
|
||||
|
||||
///
|
||||
unsigned int columns() const { return columns_; }
|
||||
///
|
||||
enum PageSides {
|
||||
///
|
||||
OneSide,
|
||||
///
|
||||
TwoSides
|
||||
};
|
||||
///
|
||||
PageSides sides() const { return sides_; }
|
||||
///
|
||||
int secnumdepth() const { return secnumdepth_; }
|
||||
///
|
||||
int tocdepth() const { return tocdepth_; }
|
||||
|
||||
///
|
||||
OutputType outputType() const { return outputType_; }
|
||||
|
||||
///
|
||||
LyXFont const & defaultfont() const { return defaultfont_; }
|
||||
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
string const & leftmargin() const { return leftmargin_; }
|
||||
|
||||
/// Text that dictates how wide the right margin is on the screen
|
||||
string const & rightmargin() const { return rightmargin_; }
|
||||
///
|
||||
int maxcounter() const { return maxcounter_; }
|
||||
///
|
||||
lyx::layout_type numLayouts() const { return layoutlist.size(); }
|
||||
///
|
||||
LyXLayout const & operator[](lyx::layout_type i) const {
|
||||
return layoutlist[i];
|
||||
}
|
||||
private:
|
||||
///
|
||||
bool delete_layout(string const &);
|
||||
///
|
||||
bool do_readStyle(LyXLex &, LyXLayout &);
|
||||
///
|
||||
string name_;
|
||||
///
|
||||
string latexname_;
|
||||
///
|
||||
string description_;
|
||||
/// Specific class options
|
||||
string opt_fontsize_;
|
||||
///
|
||||
string opt_pagestyle_;
|
||||
///
|
||||
string options_;
|
||||
///
|
||||
string pagestyle_;
|
||||
///
|
||||
string preamble_;
|
||||
///
|
||||
Provides provides_;
|
||||
///
|
||||
unsigned int columns_;
|
||||
///
|
||||
PageSides sides_;
|
||||
///
|
||||
int secnumdepth_;
|
||||
///
|
||||
int tocdepth_;
|
||||
///
|
||||
OutputType outputType_;
|
||||
/** Base font. The paragraph and layout fonts are resolved against
|
||||
this font. This has to be fully instantiated. Attributes
|
||||
LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
|
||||
extremely illegal.
|
||||
*/
|
||||
LyXFont defaultfont_;
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
string leftmargin_;
|
||||
|
||||
/// Text that dictates how wide the right margin is on the screen
|
||||
string rightmargin_;
|
||||
///
|
||||
int maxcounter_; // add approp. signedness
|
||||
|
||||
///
|
||||
LayoutList layoutlist;
|
||||
|
||||
/// Has this layout file been loaded yet?
|
||||
bool loaded;
|
||||
};
|
||||
|
||||
///
|
||||
inline
|
||||
void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
|
||||
{
|
||||
p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
|
||||
|
||||
|
||||
///
|
||||
class LyXTextClassList : boost::noncopyable {
|
||||
public:
|
||||
///
|
||||
typedef std::vector<LyXTextClass> ClassList;
|
||||
///
|
||||
typedef ClassList::const_iterator const_iterator;
|
||||
///
|
||||
const_iterator begin() const { return classlist.begin(); }
|
||||
///
|
||||
const_iterator end() const { return classlist.end(); }
|
||||
|
||||
/// Gets layout structure from layout number and textclass number
|
||||
LyXLayout const & Style(lyx::textclass_type textclass,
|
||||
lyx::layout_type layout) const;
|
||||
|
||||
/// Gets layout number from textclass number and layout name
|
||||
std::pair<bool, lyx::layout_type> const
|
||||
NumberOfLayout(lyx::textclass_type textclass, string const & name) const;
|
||||
|
||||
/// Gets a layout name from layout number and textclass number
|
||||
string const &
|
||||
NameOfLayout(lyx::textclass_type textclass, lyx::layout_type layout) const;
|
||||
|
||||
/** Gets textclass number from name.
|
||||
Returns -1 if textclass name does not exist
|
||||
*/
|
||||
std::pair<bool, lyx::textclass_type> const
|
||||
NumberOfClass(string const & textclass) const;
|
||||
|
||||
///
|
||||
string const & NameOfClass(lyx::textclass_type number) const;
|
||||
|
||||
///
|
||||
string const & LatexnameOfClass(lyx::textclass_type number) const;
|
||||
|
||||
///
|
||||
string const & DescOfClass(lyx::textclass_type number) const;
|
||||
|
||||
///
|
||||
LyXTextClass const & TextClass(lyx::textclass_type textclass) const;
|
||||
|
||||
/** Read textclass list.
|
||||
Returns false if this fails
|
||||
*/
|
||||
bool Read();
|
||||
|
||||
/** Load textclass.
|
||||
Returns false if this fails
|
||||
*/
|
||||
bool Load(lyx::textclass_type number) const;
|
||||
private:
|
||||
///
|
||||
mutable ClassList classlist;
|
||||
///
|
||||
void Add (LyXTextClass const &);
|
||||
};
|
||||
|
||||
///
|
||||
extern LyXTextClassList textclasslist;
|
||||
|
||||
#endif
|
||||
|
22
src/lyx_cb.C
22
src/lyx_cb.C
@ -10,11 +10,6 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
|
||||
#include "lyx_cb.h"
|
||||
#include "lyx_main.h"
|
||||
#include "buffer.h"
|
||||
@ -25,17 +20,26 @@
|
||||
#include "LyXView.h"
|
||||
#include "lyxrc.h"
|
||||
#include "lyxtext.h"
|
||||
#include "gettext.h"
|
||||
#include "BufferView.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#include "insets/insetlabel.h"
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
#include "frontends/FileDialog.h"
|
||||
#include "frontends/GUIRunTime.h"
|
||||
#include "insets/insetlabel.h"
|
||||
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/path.h"
|
||||
#include "support/syscall.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "gettext.h"
|
||||
#include "BufferView.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
|
||||
using std::vector;
|
||||
using std::ifstream;
|
||||
@ -159,7 +163,7 @@ bool MenuWrite(BufferView * bv, Buffer * buffer)
|
||||
bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename)
|
||||
{
|
||||
string fname = buffer->fileName();
|
||||
string oldname = fname;
|
||||
string const oldname = fname;
|
||||
|
||||
if (filename.empty()) {
|
||||
|
||||
|
@ -9,8 +9,6 @@
|
||||
* ====================================================== */
|
||||
|
||||
#include <config.h>
|
||||
#include <cstdlib>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
@ -18,9 +16,6 @@
|
||||
|
||||
#include "lyx_gui.h"
|
||||
#include FORMS_H_LOCATION
|
||||
#include "support/filetools.h"
|
||||
#include "support/os.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "figure_form.h"
|
||||
#include "print_form.h"
|
||||
#include "tex-strings.h"
|
||||
@ -39,9 +34,17 @@
|
||||
#endif
|
||||
#include "bufferlist.h"
|
||||
#include "ColorHandler.h"
|
||||
|
||||
#include "frontends/GUIRunTime.h"
|
||||
#include "frontends/xforms/xforms_helpers.h" // for XformColor
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/os.h"
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fcntl.h>
|
||||
|
||||
using std::endl;
|
||||
|
||||
FD_form_sendto * fd_form_sendto;
|
||||
@ -136,25 +139,27 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
|
||||
|
||||
// If width is not set by geometry, check it against monitor width
|
||||
if (!(geometryBitmask & 4)) {
|
||||
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(fl_get_display());
|
||||
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
|
||||
if (WidthOfScreen(scr) - 8 < width)
|
||||
width = WidthOfScreen(scr) - 8;
|
||||
}
|
||||
|
||||
// If height is not set by geometry, check it against monitor height
|
||||
if (!(geometryBitmask & 8)) {
|
||||
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(fl_get_display());
|
||||
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
|
||||
if (HeightOfScreen(scr) - 24 < height)
|
||||
height = HeightOfScreen(scr) - 24;
|
||||
}
|
||||
|
||||
// Recalculate xpos if it's negative
|
||||
if (geometryBitmask & 16)
|
||||
xpos += WidthOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen)) - width; //DefaultScreen(fl_get_display())) - width;
|
||||
xpos += WidthOfScreen(ScreenOfDisplay(fl_get_display(),
|
||||
fl_screen)) - width;
|
||||
|
||||
// Recalculate ypos if it's negative
|
||||
if (geometryBitmask & 32)
|
||||
ypos += HeightOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen)) - height; //DefaultScreen(fl_get_display())) - height;
|
||||
ypos += HeightOfScreen(ScreenOfDisplay(fl_get_display(),
|
||||
fl_screen)) - height;
|
||||
|
||||
// Initialize the LyXColorHandler
|
||||
lyxColorHandler.reset(new LyXColorHandler);
|
||||
@ -291,10 +296,8 @@ void LyXGUI::create_forms()
|
||||
|
||||
// This is probably as good a time as any to map the xform colours,
|
||||
// should a mapping exist.
|
||||
{
|
||||
string filename = AddName(user_lyxdir, "preferences.xform");
|
||||
XformsColor::read( filename );
|
||||
}
|
||||
string const filename = AddName(user_lyxdir, "preferences.xform");
|
||||
XformsColor::read( filename );
|
||||
|
||||
// Show the main & title form
|
||||
int main_placement = FL_PLACE_CENTER | FL_FREE_SIZE;
|
||||
|
@ -9,32 +9,25 @@
|
||||
* ====================================================== */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <csignal>
|
||||
#include <version.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <version.h>
|
||||
#include "lyx_main.h"
|
||||
#include "lyx_gui.h"
|
||||
#include "LyXView.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "frontends/Alert.h"
|
||||
#include "frontends/GUIRunTime.h"
|
||||
#include "lyxrc.h"
|
||||
#include "support/path.h"
|
||||
#include "support/filetools.h"
|
||||
#include "buffer.h"
|
||||
#include "bufferlist.h"
|
||||
#include "debug.h"
|
||||
#include "support/FileInfo.h"
|
||||
#include "lastfiles.h"
|
||||
#include "intl.h"
|
||||
#include "lyxserver.h"
|
||||
#include "layout.h"
|
||||
//#include "layout.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "gettext.h"
|
||||
#include "kbmap.h"
|
||||
#include "MenuBackend.h"
|
||||
@ -43,8 +36,18 @@
|
||||
#include "encoding.h"
|
||||
#include "converter.h"
|
||||
#include "language.h"
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
#include "frontends/GUIRunTime.h"
|
||||
|
||||
#include "support/path.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/os.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <csignal>
|
||||
|
||||
using std::endl;
|
||||
|
||||
#ifndef CXX_GLOBAL_CSTD
|
||||
@ -240,10 +243,9 @@ void LyX::init(bool gui)
|
||||
// Determine path of binary
|
||||
//
|
||||
|
||||
string fullbinpath;
|
||||
string binpath = os::binpath();
|
||||
string binname = os::binname();
|
||||
fullbinpath = binpath;
|
||||
string fullbinpath = binpath;
|
||||
|
||||
if (binpath.empty()) {
|
||||
lyxerr << _("Warning: could not determine path of binary.")
|
||||
@ -413,12 +415,12 @@ void LyX::init(bool gui)
|
||||
//
|
||||
|
||||
// Default template path: system_dir/templates
|
||||
if (lyxrc.template_path.empty()){
|
||||
if (lyxrc.template_path.empty()) {
|
||||
lyxrc.template_path = AddPath(system_lyxdir, "templates");
|
||||
}
|
||||
|
||||
// Default lastfiles file: $HOME/.lyx/lastfiles
|
||||
if (lyxrc.lastfiles.empty()){
|
||||
if (lyxrc.lastfiles.empty()) {
|
||||
lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
|
||||
}
|
||||
|
||||
|
720
src/lyxlayout.C
Normal file
720
src/lyxlayout.C
Normal file
@ -0,0 +1,720 @@
|
||||
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "lyxlayout.h"
|
||||
#include "lyxtextclass.h"
|
||||
#include "lyxlex.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
// The order of the LayoutTags enum is no more important. [asierra300396]
|
||||
// Tags indexes.
|
||||
enum LayoutTags {
|
||||
LT_ALIGN = 1,
|
||||
LT_ALIGNPOSSIBLE,
|
||||
LT_MARGIN,
|
||||
LT_BOTTOMSEP,
|
||||
LT_COPYSTYLE,
|
||||
LT_OBSOLETEDBY,
|
||||
//LT_EMPTY,
|
||||
LT_END,
|
||||
//LT_ENVIRONMENT_DEFAULT,
|
||||
//LT_FANCYHDR,
|
||||
LT_FILL_BOTTOM,
|
||||
LT_FILL_TOP,
|
||||
//LT_FIRST_COUNTER,
|
||||
LT_FONT,
|
||||
LT_FREE_SPACING,
|
||||
LT_PASS_THRU,
|
||||
//LT_HEADINGS,
|
||||
LT_ITEMSEP,
|
||||
LT_KEEPEMPTY,
|
||||
LT_LABEL_BOTTOMSEP,
|
||||
LT_LABELFONT,
|
||||
LT_TEXTFONT,
|
||||
LT_LABELINDENT,
|
||||
LT_LABELSEP,
|
||||
LT_LABELSTRING,
|
||||
LT_LABELSTRING_APPENDIX,
|
||||
LT_LABELTYPE,
|
||||
LT_ENDLABELSTRING,
|
||||
LT_ENDLABELTYPE,
|
||||
LT_LATEXNAME,
|
||||
LT_LATEXPARAM,
|
||||
LT_LATEXTYPE,
|
||||
LT_LEFTMARGIN,
|
||||
LT_NEED_PROTECT,
|
||||
LT_NEWLINE,
|
||||
LT_NEXTNOINDENT,
|
||||
LT_PARINDENT,
|
||||
LT_PARSEP,
|
||||
LT_PARSKIP,
|
||||
//LT_PLAIN,
|
||||
LT_PREAMBLE,
|
||||
LT_RIGHTMARGIN,
|
||||
LT_SPACING,
|
||||
LT_TOPSEP,
|
||||
LT_INTITLE
|
||||
};
|
||||
|
||||
/////////////////////
|
||||
|
||||
// Constructor for layout
|
||||
LyXLayout::LyXLayout ()
|
||||
{
|
||||
margintype = MARGIN_STATIC;
|
||||
latextype = LATEX_PARAGRAPH;
|
||||
intitle = false;
|
||||
needprotect = false;
|
||||
keepempty = false;
|
||||
font = LyXFont(LyXFont::ALL_INHERIT);
|
||||
labelfont = LyXFont(LyXFont::ALL_INHERIT);
|
||||
resfont = LyXFont(LyXFont::ALL_SANE);
|
||||
reslabelfont = LyXFont(LyXFont::ALL_SANE);
|
||||
nextnoindent = false;
|
||||
parskip = 0.0;
|
||||
itemsep = 0;
|
||||
topsep = 0.0;
|
||||
bottomsep = 0.0;
|
||||
labelbottomsep = 0.0;
|
||||
parsep = 0;
|
||||
align = LYX_ALIGN_BLOCK;
|
||||
alignpossible = LYX_ALIGN_BLOCK;
|
||||
labeltype = LABEL_NO_LABEL;
|
||||
endlabeltype = END_LABEL_NO_LABEL;
|
||||
// Should or should not. That is the question.
|
||||
// spacing.set(Spacing::OneHalf);
|
||||
fill_top = false;
|
||||
fill_bottom = false;
|
||||
newline_allowed = true;
|
||||
free_spacing = false;
|
||||
pass_thru = false;
|
||||
}
|
||||
|
||||
|
||||
// Reads a layout definition from file
|
||||
bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
|
||||
{
|
||||
// This table is sorted alphabetically [asierra 30March96]
|
||||
keyword_item layoutTags[] = {
|
||||
{ "align", LT_ALIGN },
|
||||
{ "alignpossible", LT_ALIGNPOSSIBLE },
|
||||
{ "bottomsep", LT_BOTTOMSEP },
|
||||
{ "copystyle", LT_COPYSTYLE },
|
||||
{ "end", LT_END },
|
||||
{ "endlabelstring", LT_ENDLABELSTRING },
|
||||
{ "endlabeltype", LT_ENDLABELTYPE },
|
||||
{ "fill_bottom", LT_FILL_BOTTOM },
|
||||
{ "fill_top", LT_FILL_TOP },
|
||||
{ "font", LT_FONT },
|
||||
{ "freespacing", LT_FREE_SPACING },
|
||||
{ "intitle", LT_INTITLE },
|
||||
{ "itemsep", LT_ITEMSEP },
|
||||
{ "keepempty", LT_KEEPEMPTY },
|
||||
{ "labelbottomsep", LT_LABEL_BOTTOMSEP },
|
||||
{ "labelfont", LT_LABELFONT },
|
||||
{ "labelindent", LT_LABELINDENT },
|
||||
{ "labelsep", LT_LABELSEP },
|
||||
{ "labelstring", LT_LABELSTRING },
|
||||
{ "labelstringappendix", LT_LABELSTRING_APPENDIX },
|
||||
{ "labeltype", LT_LABELTYPE },
|
||||
{ "latexname", LT_LATEXNAME },
|
||||
{ "latexparam", LT_LATEXPARAM },
|
||||
{ "latextype", LT_LATEXTYPE },
|
||||
{ "leftmargin", LT_LEFTMARGIN },
|
||||
{ "margin", LT_MARGIN },
|
||||
{ "needprotect", LT_NEED_PROTECT },
|
||||
{ "newline", LT_NEWLINE },
|
||||
{ "nextnoindent", LT_NEXTNOINDENT },
|
||||
{ "obsoletedby", LT_OBSOLETEDBY },
|
||||
{ "parindent", LT_PARINDENT },
|
||||
{ "parsep", LT_PARSEP },
|
||||
{ "parskip", LT_PARSKIP },
|
||||
{ "passthru", LT_PASS_THRU },
|
||||
{ "preamble", LT_PREAMBLE },
|
||||
{ "rightmargin", LT_RIGHTMARGIN },
|
||||
{ "spacing", LT_SPACING },
|
||||
{ "textfont", LT_TEXTFONT },
|
||||
{ "topsep", LT_TOPSEP }
|
||||
};
|
||||
|
||||
bool error = false;
|
||||
bool finished = false;
|
||||
lexrc.pushTable(layoutTags, LT_INTITLE);
|
||||
// parse style section
|
||||
while (!finished && lexrc.isOK() && !error) {
|
||||
int le = lexrc.lex();
|
||||
// See comment in lyxrc.C.
|
||||
switch (le) {
|
||||
case LyXLex::LEX_FEOF:
|
||||
continue;
|
||||
|
||||
case LyXLex::LEX_UNDEF: // parse error
|
||||
lexrc.printError("Unknown layout tag `$$Token'");
|
||||
error = true;
|
||||
continue;
|
||||
default: break;
|
||||
}
|
||||
switch (static_cast<LayoutTags>(le)) {
|
||||
case LT_END: // end of structure
|
||||
finished = true;
|
||||
break;
|
||||
|
||||
case LT_COPYSTYLE: // initialize with a known style
|
||||
if (lexrc.next()) {
|
||||
if (tclass.hasLayout(lexrc.getString())) {
|
||||
string const tmpname = name_;
|
||||
this->operator= (tclass.GetLayout(lexrc.getString()));
|
||||
name_ = tmpname;
|
||||
} else {
|
||||
lexrc.printError("Cannot copy known "
|
||||
"style `$$Token'");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LT_OBSOLETEDBY: // replace with a known style
|
||||
if (lexrc.next()) {
|
||||
if (tclass.hasLayout(lexrc.getString())) {
|
||||
string const tmpname = name_;
|
||||
this->operator= (tclass.GetLayout(lexrc.getString()));
|
||||
name_ = tmpname;
|
||||
if (obsoleted_by().empty())
|
||||
obsoleted_by_ = lexrc.getString();
|
||||
} else {
|
||||
lexrc.printError("Cannot replace with"
|
||||
" unknown style "
|
||||
"`$$Token'");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LT_MARGIN: // Margin style definition.
|
||||
readMargin(lexrc);
|
||||
break;
|
||||
|
||||
case LT_LATEXTYPE: // Latex style definition.
|
||||
readLatexType(lexrc);
|
||||
break;
|
||||
|
||||
case LT_INTITLE:
|
||||
intitle = lexrc.next() && lexrc.getInteger();
|
||||
break;
|
||||
|
||||
case LT_NEED_PROTECT:
|
||||
needprotect = lexrc.next() && lexrc.getInteger();
|
||||
break;
|
||||
|
||||
case LT_KEEPEMPTY:
|
||||
keepempty = lexrc.next() && lexrc.getInteger();
|
||||
break;
|
||||
|
||||
case LT_FONT:
|
||||
font.lyxRead(lexrc);
|
||||
labelfont= font;
|
||||
break;
|
||||
|
||||
case LT_TEXTFONT:
|
||||
font.lyxRead(lexrc);
|
||||
break;
|
||||
|
||||
case LT_LABELFONT:
|
||||
labelfont.lyxRead(lexrc);
|
||||
break;
|
||||
|
||||
case LT_NEXTNOINDENT: // Indent next paragraph?
|
||||
if (lexrc.next() && lexrc.getInteger())
|
||||
nextnoindent = true;
|
||||
else
|
||||
nextnoindent = false;
|
||||
break;
|
||||
|
||||
case LT_LATEXNAME:
|
||||
if (lexrc.next())
|
||||
latexname_ = lexrc.getString();
|
||||
break;
|
||||
|
||||
case LT_LATEXPARAM:
|
||||
if (lexrc.next())
|
||||
latexparam_ = lexrc.getString();
|
||||
break;
|
||||
|
||||
case LT_PREAMBLE:
|
||||
preamble_ = lexrc.getLongString("EndPreamble");
|
||||
break;
|
||||
|
||||
case LT_LABELTYPE:
|
||||
readLabelType(lexrc);
|
||||
break;
|
||||
|
||||
case LT_ENDLABELTYPE:
|
||||
readEndLabelType(lexrc);
|
||||
break;
|
||||
|
||||
case LT_LEFTMARGIN: // left margin type
|
||||
if (lexrc.next())
|
||||
leftmargin = lexrc.getString();
|
||||
break;
|
||||
|
||||
case LT_RIGHTMARGIN: // right margin type
|
||||
if (lexrc.next())
|
||||
rightmargin = lexrc.getString();
|
||||
break;
|
||||
|
||||
case LT_LABELINDENT: // label indenting flag
|
||||
if (lexrc.next())
|
||||
labelindent = lexrc.getString();
|
||||
break;
|
||||
|
||||
case LT_PARINDENT: // paragraph indent. flag
|
||||
if (lexrc.next())
|
||||
parindent = lexrc.getString();
|
||||
break;
|
||||
|
||||
case LT_PARSKIP: // paragraph skip size
|
||||
if (lexrc.next())
|
||||
parskip = lexrc.getFloat();
|
||||
break;
|
||||
|
||||
case LT_ITEMSEP: // item separation size
|
||||
if (lexrc.next())
|
||||
itemsep = lexrc.getFloat();
|
||||
break;
|
||||
|
||||
case LT_TOPSEP: // top separation size
|
||||
if (lexrc.next())
|
||||
topsep = lexrc.getFloat();
|
||||
break;
|
||||
|
||||
case LT_BOTTOMSEP: // bottom separation size
|
||||
if (lexrc.next())
|
||||
bottomsep = lexrc.getFloat();
|
||||
break;
|
||||
|
||||
case LT_LABEL_BOTTOMSEP: // label bottom separation size
|
||||
if (lexrc.next())
|
||||
labelbottomsep = lexrc.getFloat();
|
||||
break;
|
||||
|
||||
case LT_LABELSEP: // label separator
|
||||
if (lexrc.next()) {
|
||||
labelsep = subst(lexrc.getString(), 'x', ' ');
|
||||
}
|
||||
break;
|
||||
|
||||
case LT_PARSEP: // par. separation size
|
||||
if (lexrc.next())
|
||||
parsep = lexrc.getFloat();
|
||||
break;
|
||||
|
||||
case LT_FILL_TOP: // fill top flag
|
||||
if (lexrc.next())
|
||||
fill_top = lexrc.getInteger();
|
||||
break;
|
||||
|
||||
case LT_FILL_BOTTOM: // fill bottom flag
|
||||
if (lexrc.next())
|
||||
fill_bottom = lexrc.getInteger();
|
||||
break;
|
||||
|
||||
case LT_NEWLINE: // newlines allowed?
|
||||
if (lexrc.next())
|
||||
newline_allowed = lexrc.getInteger();
|
||||
break;
|
||||
|
||||
case LT_ALIGN: // paragraph align
|
||||
readAlign(lexrc);
|
||||
break;
|
||||
case LT_ALIGNPOSSIBLE: // paragraph allowed align
|
||||
readAlignPossible(lexrc);
|
||||
break;
|
||||
|
||||
case LT_LABELSTRING: // label string definition
|
||||
if (lexrc.next())
|
||||
labelstring_ = lexrc.getString();
|
||||
break;
|
||||
|
||||
case LT_ENDLABELSTRING: // endlabel string definition
|
||||
if (lexrc.next())
|
||||
endlabelstring_ = lexrc.getString();
|
||||
break;
|
||||
|
||||
case LT_LABELSTRING_APPENDIX: // label string appendix definition
|
||||
if (lexrc.next())
|
||||
labelstring_appendix_ = lexrc.getString();
|
||||
break;
|
||||
|
||||
case LT_FREE_SPACING: // Allow for free spacing.
|
||||
if (lexrc.next())
|
||||
free_spacing = lexrc.getInteger();
|
||||
break;
|
||||
|
||||
case LT_PASS_THRU: // Allow for pass thru.
|
||||
if (lexrc.next())
|
||||
pass_thru = lexrc.getInteger();
|
||||
break;
|
||||
|
||||
case LT_SPACING: // setspace.sty
|
||||
readSpacing(lexrc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
lexrc.popTable();
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
enum AlignTags {
|
||||
AT_BLOCK = 1,
|
||||
AT_LEFT,
|
||||
AT_RIGHT,
|
||||
AT_CENTER,
|
||||
AT_LAYOUT
|
||||
};
|
||||
|
||||
|
||||
void LyXLayout::readAlign(LyXLex & lexrc)
|
||||
{
|
||||
keyword_item alignTags[] = {
|
||||
{ "block", AT_BLOCK },
|
||||
{ "center", AT_CENTER },
|
||||
{ "layout", AT_LAYOUT },
|
||||
{ "left", AT_LEFT },
|
||||
{ "right", AT_RIGHT }
|
||||
};
|
||||
|
||||
pushpophelper pph(lexrc, alignTags, AT_LAYOUT);
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown alignment `$$Token'");
|
||||
return;
|
||||
default: break;
|
||||
};
|
||||
switch (static_cast<AlignTags>(le)) {
|
||||
case AT_BLOCK:
|
||||
align = LYX_ALIGN_BLOCK;
|
||||
break;
|
||||
case AT_LEFT:
|
||||
align = LYX_ALIGN_LEFT;
|
||||
break;
|
||||
case AT_RIGHT:
|
||||
align = LYX_ALIGN_RIGHT;
|
||||
break;
|
||||
case AT_CENTER:
|
||||
align = LYX_ALIGN_CENTER;
|
||||
break;
|
||||
case AT_LAYOUT:
|
||||
align = LYX_ALIGN_LAYOUT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LyXLayout::readAlignPossible(LyXLex & lexrc)
|
||||
{
|
||||
keyword_item alignTags[] = {
|
||||
{ "block", AT_BLOCK },
|
||||
{ "center", AT_CENTER },
|
||||
{ "layout", AT_LAYOUT },
|
||||
{ "left", AT_LEFT },
|
||||
{ "right", AT_RIGHT }
|
||||
};
|
||||
|
||||
lexrc.pushTable(alignTags, AT_LAYOUT);
|
||||
alignpossible = LYX_ALIGN_NONE;
|
||||
int lineno = lexrc.getLineNo();
|
||||
do {
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown alignment `$$Token'");
|
||||
continue;
|
||||
default: break;
|
||||
};
|
||||
switch (static_cast<AlignTags>(le)) {
|
||||
case AT_BLOCK:
|
||||
alignpossible |= LYX_ALIGN_BLOCK;
|
||||
break;
|
||||
case AT_LEFT:
|
||||
alignpossible |= LYX_ALIGN_LEFT;
|
||||
break;
|
||||
case AT_RIGHT:
|
||||
alignpossible |= LYX_ALIGN_RIGHT;
|
||||
break;
|
||||
case AT_CENTER:
|
||||
alignpossible |= LYX_ALIGN_CENTER;
|
||||
break;
|
||||
case AT_LAYOUT:
|
||||
alignpossible |= LYX_ALIGN_LAYOUT;
|
||||
break;
|
||||
}
|
||||
} while (lineno == lexrc.getLineNo());
|
||||
lexrc.popTable();
|
||||
}
|
||||
|
||||
|
||||
enum LabelTypeTags {
|
||||
LA_NO_LABEL = 1,
|
||||
LA_MANUAL,
|
||||
LA_TOP_ENVIRONMENT,
|
||||
LA_CENTERED_TOP_ENVIRONMENT,
|
||||
LA_STATIC,
|
||||
LA_SENSITIVE,
|
||||
LA_COUNTER_CHAPTER,
|
||||
LA_COUNTER_SECTION,
|
||||
LA_COUNTER_SUBSECTION,
|
||||
LA_COUNTER_SUBSUBSECTION,
|
||||
LA_COUNTER_PARAGRAPH,
|
||||
LA_COUNTER_SUBPARAGRAPH,
|
||||
LA_COUNTER_ENUMI,
|
||||
LA_COUNTER_ENUMII,
|
||||
LA_COUNTER_ENUMIII,
|
||||
LA_COUNTER_ENUMIV,
|
||||
LA_BIBLIO
|
||||
};
|
||||
|
||||
|
||||
void LyXLayout::readLabelType(LyXLex & lexrc)
|
||||
{
|
||||
keyword_item labelTypeTags[] = {
|
||||
{ "bibliography", LA_BIBLIO },
|
||||
{ "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
|
||||
{ "counter_chapter", LA_COUNTER_CHAPTER },
|
||||
{ "counter_enumi", LA_COUNTER_ENUMI },
|
||||
{ "counter_enumii", LA_COUNTER_ENUMII },
|
||||
{ "counter_enumiii", LA_COUNTER_ENUMIII },
|
||||
{ "counter_enumiv", LA_COUNTER_ENUMIV },
|
||||
{ "counter_paragraph", LA_COUNTER_PARAGRAPH },
|
||||
{ "counter_section", LA_COUNTER_SECTION },
|
||||
{ "counter_subparagraph", LA_COUNTER_SUBPARAGRAPH },
|
||||
{ "counter_subsection", LA_COUNTER_SUBSECTION },
|
||||
{ "counter_subsubsection", LA_COUNTER_SUBSUBSECTION },
|
||||
{ "manual", LA_MANUAL },
|
||||
{ "no_label", LA_NO_LABEL },
|
||||
{ "sensitive", LA_SENSITIVE },
|
||||
{ "static", LA_STATIC },
|
||||
{ "top_environment", LA_TOP_ENVIRONMENT }
|
||||
};
|
||||
|
||||
pushpophelper pph(lexrc, labelTypeTags, LA_BIBLIO);
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown labeltype tag `$$Token'");
|
||||
return;
|
||||
default: break;
|
||||
}
|
||||
switch (static_cast<LabelTypeTags>(le)) {
|
||||
case LA_NO_LABEL:
|
||||
labeltype = LABEL_NO_LABEL;
|
||||
break;
|
||||
case LA_MANUAL:
|
||||
labeltype = LABEL_MANUAL;
|
||||
break;
|
||||
case LA_TOP_ENVIRONMENT:
|
||||
labeltype = LABEL_TOP_ENVIRONMENT;
|
||||
break;
|
||||
case LA_CENTERED_TOP_ENVIRONMENT:
|
||||
labeltype = LABEL_CENTERED_TOP_ENVIRONMENT;
|
||||
break;
|
||||
case LA_STATIC:
|
||||
labeltype = LABEL_STATIC;
|
||||
break;
|
||||
case LA_SENSITIVE:
|
||||
labeltype = LABEL_SENSITIVE;
|
||||
break;
|
||||
case LA_COUNTER_CHAPTER:
|
||||
labeltype = LABEL_COUNTER_CHAPTER;
|
||||
break;
|
||||
case LA_COUNTER_SECTION:
|
||||
labeltype = LABEL_COUNTER_SECTION;
|
||||
break;
|
||||
case LA_COUNTER_SUBSECTION:
|
||||
labeltype = LABEL_COUNTER_SUBSECTION;
|
||||
break;
|
||||
case LA_COUNTER_SUBSUBSECTION:
|
||||
labeltype = LABEL_COUNTER_SUBSUBSECTION;
|
||||
break;
|
||||
case LA_COUNTER_PARAGRAPH:
|
||||
labeltype = LABEL_COUNTER_PARAGRAPH;
|
||||
break;
|
||||
case LA_COUNTER_SUBPARAGRAPH:
|
||||
labeltype = LABEL_COUNTER_SUBPARAGRAPH;
|
||||
break;
|
||||
case LA_COUNTER_ENUMI:
|
||||
labeltype = LABEL_COUNTER_ENUMI;
|
||||
break;
|
||||
case LA_COUNTER_ENUMII:
|
||||
labeltype = LABEL_COUNTER_ENUMII;
|
||||
break;
|
||||
case LA_COUNTER_ENUMIII:
|
||||
labeltype = LABEL_COUNTER_ENUMIII;
|
||||
break;
|
||||
case LA_COUNTER_ENUMIV:
|
||||
labeltype = LABEL_COUNTER_ENUMIV;
|
||||
break;
|
||||
case LA_BIBLIO:
|
||||
labeltype = LABEL_BIBLIO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
keyword_item endlabelTypeTags[] = {
|
||||
{ "box", END_LABEL_BOX },
|
||||
{ "filled_box", END_LABEL_FILLED_BOX },
|
||||
{ "no_label", END_LABEL_NO_LABEL },
|
||||
{ "static", END_LABEL_STATIC }
|
||||
};
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
void LyXLayout::readEndLabelType(LyXLex & lexrc)
|
||||
{
|
||||
pushpophelper pph(lexrc, endlabelTypeTags,
|
||||
END_LABEL_ENUM_LAST-END_LABEL_ENUM_FIRST+1);
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown labeltype tag `$$Token'");
|
||||
break;
|
||||
case END_LABEL_STATIC:
|
||||
case END_LABEL_BOX:
|
||||
case END_LABEL_FILLED_BOX:
|
||||
case END_LABEL_NO_LABEL:
|
||||
endlabeltype = static_cast<LYX_END_LABEL_TYPES>(le);
|
||||
break;
|
||||
default:
|
||||
lyxerr << "Unhandled value " << le
|
||||
<< " in LyXLayout::readEndLabelType." << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LyXLayout::readMargin(LyXLex & lexrc)
|
||||
{
|
||||
keyword_item marginTags[] = {
|
||||
{ "dynamic", MARGIN_DYNAMIC },
|
||||
{ "first_dynamic", MARGIN_FIRST_DYNAMIC },
|
||||
{ "manual", MARGIN_MANUAL },
|
||||
{ "right_address_box", MARGIN_RIGHT_ADDRESS_BOX },
|
||||
{ "static", MARGIN_STATIC }
|
||||
};
|
||||
|
||||
pushpophelper pph(lexrc, marginTags, MARGIN_RIGHT_ADDRESS_BOX);
|
||||
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown margin type tag `$$Token'");
|
||||
return;
|
||||
case MARGIN_STATIC:
|
||||
case MARGIN_MANUAL:
|
||||
case MARGIN_DYNAMIC:
|
||||
case MARGIN_FIRST_DYNAMIC:
|
||||
case MARGIN_RIGHT_ADDRESS_BOX:
|
||||
margintype = static_cast<LYX_MARGIN_TYPE>(le);
|
||||
break;
|
||||
default:
|
||||
lyxerr << "Unhandled value " << le
|
||||
<< " in LyXLayout::readMargin." << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LyXLayout::readLatexType(LyXLex & lexrc)
|
||||
{
|
||||
keyword_item latexTypeTags[] = {
|
||||
{ "command", LATEX_COMMAND },
|
||||
{ "environment", LATEX_ENVIRONMENT },
|
||||
{ "item_environment", LATEX_ITEM_ENVIRONMENT },
|
||||
{ "list_environment", LATEX_LIST_ENVIRONMENT },
|
||||
{ "paragraph", LATEX_PARAGRAPH }
|
||||
};
|
||||
|
||||
pushpophelper pph(lexrc, latexTypeTags, LATEX_LIST_ENVIRONMENT);
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown latextype tag `$$Token'");
|
||||
return;
|
||||
case LATEX_PARAGRAPH:
|
||||
case LATEX_COMMAND:
|
||||
case LATEX_ENVIRONMENT:
|
||||
case LATEX_ITEM_ENVIRONMENT:
|
||||
case LATEX_LIST_ENVIRONMENT:
|
||||
latextype = static_cast<LYX_LATEX_TYPES>(le);
|
||||
break;
|
||||
default:
|
||||
lyxerr << "Unhandled value " << le
|
||||
<< " in LyXLayout::readLatexType." << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum SpacingTags {
|
||||
ST_SPACING_SINGLE = 1,
|
||||
ST_SPACING_ONEHALF,
|
||||
ST_SPACING_DOUBLE,
|
||||
ST_OTHER
|
||||
};
|
||||
|
||||
|
||||
void LyXLayout::readSpacing(LyXLex & lexrc)
|
||||
{
|
||||
keyword_item spacingTags[] = {
|
||||
{"double", ST_SPACING_DOUBLE },
|
||||
{"onehalf", ST_SPACING_ONEHALF },
|
||||
{"other", ST_OTHER },
|
||||
{"single", ST_SPACING_SINGLE }
|
||||
};
|
||||
|
||||
pushpophelper pph(lexrc, spacingTags, ST_OTHER);
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown spacing token `$$Token'");
|
||||
return;
|
||||
default: break;
|
||||
}
|
||||
switch (static_cast<SpacingTags>(le)) {
|
||||
case ST_SPACING_SINGLE:
|
||||
spacing.set(Spacing::Single);
|
||||
break;
|
||||
case ST_SPACING_ONEHALF:
|
||||
spacing.set(Spacing::Onehalf);
|
||||
break;
|
||||
case ST_SPACING_DOUBLE:
|
||||
spacing.set(Spacing::Double);
|
||||
break;
|
||||
case ST_OTHER:
|
||||
lexrc.next();
|
||||
spacing.set(Spacing::Other, lexrc.getFloat());
|
||||
break;
|
||||
}
|
||||
}
|
219
src/lyxlayout.h
Normal file
219
src/lyxlayout.h
Normal file
@ -0,0 +1,219 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifndef LYX_LAYOUT_H
|
||||
#define LYX_LAYOUT_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "lyxfont.h"
|
||||
#include "layout.h"
|
||||
#include "Spacing.h"
|
||||
#include "LString.h"
|
||||
|
||||
class LyXLex;
|
||||
class LyXTextClass;
|
||||
|
||||
///
|
||||
class LyXLayout {
|
||||
public:
|
||||
///
|
||||
LyXLayout ();
|
||||
|
||||
///
|
||||
bool Read (LyXLex &, LyXTextClass const &);
|
||||
///
|
||||
void readAlign(LyXLex &);
|
||||
///
|
||||
void readAlignPossible(LyXLex &);
|
||||
///
|
||||
void readLabelType(LyXLex &);
|
||||
///
|
||||
void readEndLabelType(LyXLex &);
|
||||
///
|
||||
void readMargin(LyXLex &);
|
||||
///
|
||||
void readLatexType(LyXLex &);
|
||||
///
|
||||
void readSpacing(LyXLex &);
|
||||
///
|
||||
string const & name() const { return name_; }
|
||||
///
|
||||
void setName(string const & n) { name_ = n; }
|
||||
///
|
||||
string const & obsoleted_by() const { return obsoleted_by_; }
|
||||
///
|
||||
string const & latexname() const { return latexname_; }
|
||||
///
|
||||
string const & labelstring() const { return labelstring_; }
|
||||
///
|
||||
string const & endlabelstring() const { return endlabelstring_; }
|
||||
///
|
||||
string const & preamble() const { return preamble_; }
|
||||
///
|
||||
string const & latexparam() const { return latexparam_; }
|
||||
///
|
||||
string const & labelstring_appendix() const {
|
||||
return labelstring_appendix_;
|
||||
}
|
||||
/** Default font for this layout/environment.
|
||||
The main font for this kind of environment. If an attribute has
|
||||
LyXFont::INHERITED_*, it means that the value is specified by
|
||||
the defaultfont for the entire layout. If we are nested, the
|
||||
font is inherited from the font in the environment one level
|
||||
up until the font is resolved. The values LyXFont::IGNORE_*
|
||||
and LyXFont::TOGGLE are illegal here.
|
||||
*/
|
||||
LyXFont font;
|
||||
|
||||
/** Default font for labels.
|
||||
Interpretation the same as for font above
|
||||
*/
|
||||
LyXFont labelfont;
|
||||
|
||||
/** Resolved version of the font for this layout/environment.
|
||||
This is a resolved version the default font. The font is resolved
|
||||
against the defaultfont of the entire layout.
|
||||
*/
|
||||
LyXFont resfont;
|
||||
|
||||
/** Resolved version of the font used for labels.
|
||||
This is a resolved version the label font. The font is resolved
|
||||
against the defaultfont of the entire layout.
|
||||
*/
|
||||
LyXFont reslabelfont;
|
||||
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
string leftmargin;
|
||||
|
||||
/// Text that dictates how wide the right margin is on the screen
|
||||
string rightmargin;
|
||||
|
||||
/// Text that dictates how much space to leave after a potential label
|
||||
string labelsep;
|
||||
|
||||
/// Text that dictates how much space to leave before a potential label
|
||||
string labelindent;
|
||||
|
||||
/** Text that dictates the width of the indentation of
|
||||
indented paragraphs.
|
||||
*/
|
||||
string parindent;
|
||||
|
||||
///
|
||||
float parskip;
|
||||
|
||||
///
|
||||
float itemsep;
|
||||
|
||||
///
|
||||
float topsep;
|
||||
|
||||
///
|
||||
float bottomsep;
|
||||
|
||||
///
|
||||
float labelbottomsep;
|
||||
|
||||
///
|
||||
float parsep;
|
||||
|
||||
///
|
||||
Spacing spacing;
|
||||
|
||||
///
|
||||
LyXAlignment align;
|
||||
|
||||
///
|
||||
LyXAlignment alignpossible;
|
||||
|
||||
///
|
||||
char labeltype; // add approp. type
|
||||
|
||||
///
|
||||
LYX_END_LABEL_TYPES endlabeltype;
|
||||
|
||||
///
|
||||
LYX_MARGIN_TYPE margintype;
|
||||
|
||||
///
|
||||
bool fill_top;
|
||||
|
||||
///
|
||||
bool fill_bottom;
|
||||
|
||||
///
|
||||
bool newline_allowed;
|
||||
|
||||
///
|
||||
bool nextnoindent;
|
||||
|
||||
///
|
||||
bool free_spacing;
|
||||
|
||||
///
|
||||
bool pass_thru;
|
||||
|
||||
/** true when the fragile commands in the paragraph need to be
|
||||
\protect'ed. */
|
||||
bool needprotect;
|
||||
/// true when empty paragraphs should be kept.
|
||||
bool keepempty;
|
||||
///
|
||||
bool isParagraph() const {
|
||||
return latextype == LATEX_PARAGRAPH;
|
||||
}
|
||||
///
|
||||
bool isCommand() const {
|
||||
return latextype == LATEX_COMMAND;
|
||||
}
|
||||
///
|
||||
bool isEnvironment() const {
|
||||
return (latextype == LATEX_ENVIRONMENT
|
||||
|| latextype == LATEX_ITEM_ENVIRONMENT
|
||||
|| latextype == LATEX_LIST_ENVIRONMENT);
|
||||
}
|
||||
/// Type of LaTeX object
|
||||
LYX_LATEX_TYPES latextype;
|
||||
/// Does this object belong in the title part of the document?
|
||||
bool intitle;
|
||||
private:
|
||||
/// Name of the layout/paragraph environment
|
||||
string name_;
|
||||
|
||||
/** Name of an layout that has replaced this layout.
|
||||
This is used to rename a layout, while keeping backward
|
||||
compatibility
|
||||
*/
|
||||
string obsoleted_by_;
|
||||
|
||||
/// LaTeX name for environment
|
||||
string latexname_;
|
||||
|
||||
/// Label string. "Abstract", "Reference", "Caption"...
|
||||
string labelstring_;
|
||||
|
||||
///
|
||||
string endlabelstring_;
|
||||
|
||||
/// Label string inside appendix. "Appendix", ...
|
||||
string labelstring_appendix_;
|
||||
|
||||
/// LaTeX parameter for environment
|
||||
string latexparam_;
|
||||
|
||||
/// Macro definitions needed for this layout
|
||||
string preamble_;
|
||||
};
|
||||
|
||||
#endif
|
540
src/lyxtextclass.C
Normal file
540
src/lyxtextclass.C
Normal file
@ -0,0 +1,540 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "lyxtextclass.h"
|
||||
#include "debug.h"
|
||||
#include "lyxlex.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "support/lyxfunctional.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
|
||||
/* ******************************************************************* */
|
||||
|
||||
LyXTextClass::LyXTextClass(string const & fn, string const & cln,
|
||||
string const & desc)
|
||||
: name_(fn), latexname_(cln), description_(desc)
|
||||
{
|
||||
outputType_ = LATEX;
|
||||
columns_ = 1;
|
||||
sides_ = OneSide;
|
||||
secnumdepth_ = 3;
|
||||
tocdepth_ = 3;
|
||||
pagestyle_ = "default";
|
||||
maxcounter_ = LABEL_COUNTER_CHAPTER;
|
||||
defaultfont_ = LyXFont(LyXFont::ALL_SANE);
|
||||
opt_fontsize_ = "10|11|12";
|
||||
opt_pagestyle_ = "empty|plain|headings|fancy";
|
||||
provides_ = nothing;
|
||||
loaded = false;
|
||||
}
|
||||
|
||||
|
||||
bool LyXTextClass::do_readStyle(LyXLex & lexrc, LyXLayout & lay)
|
||||
{
|
||||
lyxerr[Debug::TCLASS] << "Reading style " << lay.name() << endl;
|
||||
if (!lay.Read(lexrc, *this)) {
|
||||
// Reslove fonts
|
||||
lay.resfont = lay.font;
|
||||
#ifndef INHERIT_LANGUAGE
|
||||
lay.resfont.realize(defaultfont());
|
||||
lay.reslabelfont = lay.labelfont;
|
||||
lay.reslabelfont.realize(defaultfont());
|
||||
#else
|
||||
lay.resfont.realize(defaultfont(), default_language);
|
||||
lay.reslabelfont = lay.labelfont;
|
||||
lay.reslabelfont.realize(defaultfont(), default_language);
|
||||
#endif
|
||||
return false; // no errors
|
||||
}
|
||||
lyxerr << "Error parsing style `" << lay.name() << "'" << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
enum TextClassTags {
|
||||
TC_OUTPUTTYPE = 1,
|
||||
TC_INPUT,
|
||||
TC_STYLE,
|
||||
TC_NOSTYLE,
|
||||
TC_COLUMNS,
|
||||
TC_SIDES,
|
||||
TC_PAGESTYLE,
|
||||
TC_DEFAULTFONT,
|
||||
TC_MAXCOUNTER,
|
||||
TC_SECNUMDEPTH,
|
||||
TC_TOCDEPTH,
|
||||
TC_CLASSOPTIONS,
|
||||
TC_PREAMBLE,
|
||||
TC_PROVIDESAMSMATH,
|
||||
TC_PROVIDESMAKEIDX,
|
||||
TC_PROVIDESURL,
|
||||
TC_LEFTMARGIN,
|
||||
TC_RIGHTMARGIN
|
||||
};
|
||||
|
||||
|
||||
// Reads a textclass structure from file.
|
||||
bool LyXTextClass::Read(string const & filename, bool merge)
|
||||
{
|
||||
keyword_item textClassTags[] = {
|
||||
{ "classoptions", TC_CLASSOPTIONS },
|
||||
{ "columns", TC_COLUMNS },
|
||||
{ "defaultfont", TC_DEFAULTFONT },
|
||||
{ "input", TC_INPUT },
|
||||
{ "leftmargin", TC_LEFTMARGIN },
|
||||
{ "maxcounter", TC_MAXCOUNTER },
|
||||
{ "nostyle", TC_NOSTYLE },
|
||||
{ "outputtype", TC_OUTPUTTYPE },
|
||||
{ "pagestyle", TC_PAGESTYLE },
|
||||
{ "preamble", TC_PREAMBLE },
|
||||
{ "providesamsmath", TC_PROVIDESAMSMATH },
|
||||
{ "providesmakeidx", TC_PROVIDESMAKEIDX },
|
||||
{ "providesurl", TC_PROVIDESURL },
|
||||
{ "rightmargin", TC_RIGHTMARGIN },
|
||||
{ "secnumdepth", TC_SECNUMDEPTH },
|
||||
{ "sides", TC_SIDES },
|
||||
{ "style", TC_STYLE },
|
||||
{ "tocdepth", TC_TOCDEPTH }
|
||||
};
|
||||
|
||||
if (!merge)
|
||||
lyxerr[Debug::TCLASS] << "Reading textclass "
|
||||
<< MakeDisplayPath(filename)
|
||||
<< endl;
|
||||
else
|
||||
lyxerr[Debug::TCLASS] << "Reading input file "
|
||||
<< MakeDisplayPath(filename)
|
||||
<< endl;
|
||||
|
||||
LyXLex lexrc(textClassTags, TC_RIGHTMARGIN);
|
||||
bool error = false;
|
||||
|
||||
lexrc.setFile(filename);
|
||||
if (!lexrc.isOK()) error = true;
|
||||
|
||||
// parsing
|
||||
while (lexrc.isOK() && !error) {
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_FEOF:
|
||||
continue;
|
||||
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown TextClass tag `$$Token'");
|
||||
error = true;
|
||||
continue;
|
||||
default: break;
|
||||
}
|
||||
switch (static_cast<TextClassTags>(le)) {
|
||||
case TC_OUTPUTTYPE: // output type definition
|
||||
readOutputType(lexrc);
|
||||
break;
|
||||
|
||||
case TC_INPUT: // Include file
|
||||
if (lexrc.next()) {
|
||||
string tmp = LibFileSearch("layouts",
|
||||
lexrc.getString(),
|
||||
"layout");
|
||||
|
||||
if (Read(tmp, true)) {
|
||||
lexrc.printError("Error reading input"
|
||||
"file: "+tmp);
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_STYLE:
|
||||
if (lexrc.next()) {
|
||||
string name = subst(lexrc.getString(),
|
||||
'_', ' ');
|
||||
if (hasLayout(name)) {
|
||||
LyXLayout & lay = GetLayout(name);
|
||||
error = do_readStyle(lexrc, lay);
|
||||
} else {
|
||||
LyXLayout lay;
|
||||
lay.setName(name);
|
||||
if (!(error = do_readStyle(lexrc, lay)))
|
||||
layoutlist.push_back(lay);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lexrc.printError("No name given for style: `$$Token'.");
|
||||
error = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_NOSTYLE:
|
||||
if (lexrc.next()) {
|
||||
string const style = subst(lexrc.getString(),
|
||||
'_', ' ');
|
||||
if (!delete_layout(style))
|
||||
lexrc.printError("Cannot delete style"
|
||||
" `$$Token'");
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_COLUMNS:
|
||||
if (lexrc.next())
|
||||
columns_ = lexrc.getInteger();
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
case TC_PAGESTYLE:
|
||||
lexrc.next();
|
||||
pagestyle_ = strip(lexrc.getString());
|
||||
break;
|
||||
|
||||
case TC_DEFAULTFONT:
|
||||
defaultfont_.lyxRead(lexrc);
|
||||
if (!defaultfont_.resolved()) {
|
||||
lexrc.printError("Warning: defaultfont should "
|
||||
"be fully instantiated!");
|
||||
#ifndef INHERIT_LANGUAGE
|
||||
defaultfont_.realize(LyXFont(LyXFont::ALL_SANE));
|
||||
#else
|
||||
defaultfont_.realize(LyXFont(LyXFont::ALL_SANE),
|
||||
default_language);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case TC_MAXCOUNTER:
|
||||
readMaxCounter(lexrc);
|
||||
break;
|
||||
|
||||
case TC_SECNUMDEPTH:
|
||||
lexrc.next();
|
||||
secnumdepth_ = lexrc.getInteger();
|
||||
break;
|
||||
|
||||
case TC_TOCDEPTH:
|
||||
lexrc.next();
|
||||
tocdepth_ = lexrc.getInteger();
|
||||
break;
|
||||
|
||||
// First step to support options
|
||||
case TC_CLASSOPTIONS:
|
||||
readClassOptions(lexrc);
|
||||
break;
|
||||
|
||||
case TC_PREAMBLE:
|
||||
preamble_ = lexrc.getLongString("EndPreamble");
|
||||
break;
|
||||
|
||||
case TC_PROVIDESAMSMATH:
|
||||
if (lexrc.next() && lexrc.getInteger())
|
||||
provides_ |= amsmath;
|
||||
break;
|
||||
|
||||
case TC_PROVIDESMAKEIDX:
|
||||
if (lexrc.next() && lexrc.getInteger())
|
||||
provides_ |= makeidx;
|
||||
break;
|
||||
|
||||
case TC_PROVIDESURL:
|
||||
if (lexrc.next() && lexrc.getInteger())
|
||||
provides_ = url;
|
||||
break;
|
||||
|
||||
case TC_LEFTMARGIN: // left margin type
|
||||
if (lexrc.next())
|
||||
leftmargin_ = lexrc.getString();
|
||||
break;
|
||||
|
||||
case TC_RIGHTMARGIN: // right margin type
|
||||
if (lexrc.next())
|
||||
rightmargin_ = lexrc.getString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!merge) { // we are at top level here.
|
||||
lyxerr[Debug::TCLASS] << "Finished reading textclass "
|
||||
<< MakeDisplayPath(filename)
|
||||
<< endl;
|
||||
} else
|
||||
lyxerr[Debug::TCLASS] << "Finished reading input file "
|
||||
<< MakeDisplayPath(filename)
|
||||
<< endl;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
void LyXTextClass::readOutputType(LyXLex & lexrc)
|
||||
{
|
||||
keyword_item outputTypeTags[] = {
|
||||
{ "docbook", DOCBOOK },
|
||||
{ "latex", LATEX },
|
||||
{ "linuxdoc", LINUXDOC },
|
||||
{ "literate", LITERATE }
|
||||
};
|
||||
|
||||
pushpophelper pph(lexrc, outputTypeTags, LITERATE);
|
||||
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown output type `$$Token'");
|
||||
return;
|
||||
case LATEX:
|
||||
case LINUXDOC:
|
||||
case DOCBOOK:
|
||||
case LITERATE:
|
||||
outputType_ = static_cast<OutputType>(le);
|
||||
break;
|
||||
default:
|
||||
lyxerr << "Unhandled value " << le
|
||||
<< " in LyXTextClass::readOutputType." << endl;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum MaxCounterTags {
|
||||
MC_COUNTER_CHAPTER = 1,
|
||||
MC_COUNTER_SECTION,
|
||||
MC_COUNTER_SUBSECTION,
|
||||
MC_COUNTER_SUBSUBSECTION,
|
||||
MC_COUNTER_PARAGRAPH,
|
||||
MC_COUNTER_SUBPARAGRAPH,
|
||||
MC_COUNTER_ENUMI,
|
||||
MC_COUNTER_ENUMII,
|
||||
MC_COUNTER_ENUMIII,
|
||||
MC_COUNTER_ENUMIV
|
||||
};
|
||||
|
||||
|
||||
void LyXTextClass::readMaxCounter(LyXLex & lexrc)
|
||||
{
|
||||
keyword_item maxCounterTags[] = {
|
||||
{"counter_chapter", MC_COUNTER_CHAPTER },
|
||||
{"counter_enumi", MC_COUNTER_ENUMI },
|
||||
{"counter_enumii", MC_COUNTER_ENUMII },
|
||||
{"counter_enumiii", MC_COUNTER_ENUMIII },
|
||||
{"counter_enumiv", MC_COUNTER_ENUMIV },
|
||||
{"counter_paragraph", MC_COUNTER_PARAGRAPH },
|
||||
{"counter_section", MC_COUNTER_SECTION },
|
||||
{"counter_subparagraph", MC_COUNTER_SUBPARAGRAPH },
|
||||
{"counter_subsection", MC_COUNTER_SUBSECTION },
|
||||
{"counter_subsubsection", MC_COUNTER_SUBSUBSECTION }
|
||||
};
|
||||
|
||||
pushpophelper pph(lexrc, maxCounterTags, MC_COUNTER_ENUMIV);
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown MaxCounter tag `$$Token'");
|
||||
return;
|
||||
default: break;
|
||||
}
|
||||
switch (static_cast<MaxCounterTags>(le)) {
|
||||
case MC_COUNTER_CHAPTER:
|
||||
maxcounter_ = LABEL_COUNTER_CHAPTER;
|
||||
break;
|
||||
case MC_COUNTER_SECTION:
|
||||
maxcounter_ = LABEL_COUNTER_SECTION;
|
||||
break;
|
||||
case MC_COUNTER_SUBSECTION:
|
||||
maxcounter_ = LABEL_COUNTER_SUBSECTION;
|
||||
break;
|
||||
case MC_COUNTER_SUBSUBSECTION:
|
||||
maxcounter_ = LABEL_COUNTER_SUBSUBSECTION;
|
||||
break;
|
||||
case MC_COUNTER_PARAGRAPH:
|
||||
maxcounter_ = LABEL_COUNTER_PARAGRAPH;
|
||||
break;
|
||||
case MC_COUNTER_SUBPARAGRAPH:
|
||||
maxcounter_ = LABEL_COUNTER_SUBPARAGRAPH;
|
||||
break;
|
||||
case MC_COUNTER_ENUMI:
|
||||
maxcounter_ = LABEL_COUNTER_ENUMI;
|
||||
break;
|
||||
case MC_COUNTER_ENUMII:
|
||||
maxcounter_ = LABEL_COUNTER_ENUMII;
|
||||
break;
|
||||
case MC_COUNTER_ENUMIII:
|
||||
maxcounter_ = LABEL_COUNTER_ENUMIII;
|
||||
break;
|
||||
case MC_COUNTER_ENUMIV:
|
||||
maxcounter_ = LABEL_COUNTER_ENUMIV;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum ClassOptionsTags {
|
||||
CO_FONTSIZE = 1,
|
||||
CO_PAGESTYLE,
|
||||
CO_OTHER,
|
||||
CO_END
|
||||
};
|
||||
|
||||
|
||||
void LyXTextClass::readClassOptions(LyXLex & lexrc)
|
||||
{
|
||||
keyword_item classOptionsTags[] = {
|
||||
{"end", CO_END },
|
||||
{"fontsize", CO_FONTSIZE },
|
||||
{"other", CO_OTHER },
|
||||
{"pagestyle", CO_PAGESTYLE }
|
||||
};
|
||||
|
||||
lexrc.pushTable(classOptionsTags, CO_END);
|
||||
bool getout = false;
|
||||
while (!getout && lexrc.isOK()) {
|
||||
int le = lexrc.lex();
|
||||
switch (le) {
|
||||
case LyXLex::LEX_UNDEF:
|
||||
lexrc.printError("Unknown ClassOption tag `$$Token'");
|
||||
continue;
|
||||
default: break;
|
||||
}
|
||||
switch (static_cast<ClassOptionsTags>(le)) {
|
||||
case CO_FONTSIZE:
|
||||
lexrc.next();
|
||||
opt_fontsize_ = strip(lexrc.getString());
|
||||
break;
|
||||
case CO_PAGESTYLE:
|
||||
lexrc.next();
|
||||
opt_pagestyle_ = strip(lexrc.getString());
|
||||
break;
|
||||
case CO_OTHER:
|
||||
lexrc.next();
|
||||
options_ = lexrc.getString();
|
||||
break;
|
||||
case CO_END:
|
||||
getout = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
lexrc.popTable();
|
||||
}
|
||||
|
||||
|
||||
LyXFont const & LyXTextClass::defaultfont() const
|
||||
{
|
||||
return defaultfont_;
|
||||
}
|
||||
|
||||
|
||||
string const & LyXTextClass::leftmargin() const
|
||||
{
|
||||
return leftmargin_;
|
||||
}
|
||||
|
||||
|
||||
string const & LyXTextClass::rightmargin() const
|
||||
{
|
||||
return rightmargin_;
|
||||
}
|
||||
|
||||
|
||||
bool LyXTextClass::hasLayout(string const & name) const
|
||||
{
|
||||
return find_if(layoutlist.begin(), layoutlist.end(),
|
||||
lyx::compare_memfun(&LyXLayout::name, name))
|
||||
!= layoutlist.end();
|
||||
}
|
||||
|
||||
|
||||
LyXLayout const & LyXTextClass::GetLayout (string const & name) const
|
||||
{
|
||||
LayoutList::const_iterator cit =
|
||||
find_if(layoutlist.begin(),
|
||||
layoutlist.end(),
|
||||
lyx::compare_memfun(&LyXLayout::name, name));
|
||||
lyx::Assert(cit != layoutlist.end()); // we require the name to exist
|
||||
return (*cit);
|
||||
}
|
||||
|
||||
|
||||
LyXLayout & LyXTextClass::GetLayout(string const & name)
|
||||
{
|
||||
LayoutList::iterator it =
|
||||
find_if(layoutlist.begin(),
|
||||
layoutlist.end(),
|
||||
lyx::compare_memfun(&LyXLayout::name, name));
|
||||
lyx::Assert(it != layoutlist.end()); // we require the name to exist
|
||||
return (*it);
|
||||
}
|
||||
|
||||
|
||||
bool LyXTextClass::delete_layout(string const & name)
|
||||
{
|
||||
LayoutList::iterator it =
|
||||
remove_if(layoutlist.begin(), layoutlist.end(),
|
||||
lyx::compare_memfun(&LyXLayout::name, name));
|
||||
LayoutList::iterator end = layoutlist.end();
|
||||
bool const ret = (it != end);
|
||||
layoutlist.erase(it, end);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// Load textclass info if not loaded yet
|
||||
void LyXTextClass::load()
|
||||
{
|
||||
if (loaded) return;
|
||||
|
||||
// Read style-file
|
||||
string const real_file = LibFileSearch("layouts", name_, "layout");
|
||||
|
||||
if (Read(real_file)) {
|
||||
lyxerr << "Error reading `"
|
||||
<< MakeDisplayPath(real_file)
|
||||
<< "'\n(Check `" << name_
|
||||
<< "')\nCheck your installation and "
|
||||
"try Options/Reconfigure..." << endl;
|
||||
}
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p)
|
||||
{
|
||||
switch (p) {
|
||||
case LyXTextClass::OneSide:
|
||||
os << "1";
|
||||
break;
|
||||
case LyXTextClass::TwoSides:
|
||||
os << "2";
|
||||
break;
|
||||
}
|
||||
return os;
|
||||
}
|
200
src/lyxtextclass.h
Normal file
200
src/lyxtextclass.h
Normal file
@ -0,0 +1,200 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifndef LYXTEXTCLASS_H
|
||||
#define LYXTEXTCLASS_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "lyxlayout.h"
|
||||
|
||||
#include "support/types.h"
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class LyXLex;
|
||||
|
||||
|
||||
|
||||
///
|
||||
class LyXTextClass {
|
||||
public:
|
||||
///
|
||||
typedef std::vector<LyXLayout> LayoutList;
|
||||
///
|
||||
typedef LayoutList::const_iterator const_iterator;
|
||||
///
|
||||
explicit
|
||||
LyXTextClass (string const & = string(),
|
||||
string const & = string(),
|
||||
string const & = string());
|
||||
|
||||
///
|
||||
const_iterator begin() const { return layoutlist.begin(); }
|
||||
///
|
||||
const_iterator end() const { return layoutlist.end(); }
|
||||
|
||||
///
|
||||
bool Read(string const & filename, bool merge = false);
|
||||
///
|
||||
void readOutputType(LyXLex &);
|
||||
///
|
||||
void readMaxCounter(LyXLex &);
|
||||
///
|
||||
void readClassOptions(LyXLex &);
|
||||
///
|
||||
bool hasLayout(string const & name) const;
|
||||
|
||||
///
|
||||
LyXLayout const & GetLayout(string const & vname) const;
|
||||
|
||||
///
|
||||
LyXLayout & GetLayout(string const & vname);
|
||||
|
||||
/// Sees to that the textclass structure has been loaded
|
||||
void load();
|
||||
|
||||
///
|
||||
string const & name() const { return name_; }
|
||||
///
|
||||
string const & latexname() const { return latexname_; }
|
||||
///
|
||||
string const & description() const { return description_; }
|
||||
///
|
||||
string const & opt_fontsize() const { return opt_fontsize_; }
|
||||
///
|
||||
string const & opt_pagestyle() const { return opt_pagestyle_; }
|
||||
///
|
||||
string const & options() const { return options_; }
|
||||
///
|
||||
string const & pagestyle() const { return pagestyle_; }
|
||||
///
|
||||
string const & preamble() const { return preamble_; }
|
||||
|
||||
/// Packages that are already loaded by the class
|
||||
enum Provides {
|
||||
///
|
||||
nothing = 0,
|
||||
///
|
||||
amsmath = 1,
|
||||
///
|
||||
makeidx = 2,
|
||||
///
|
||||
url = 4
|
||||
};
|
||||
///
|
||||
bool provides(Provides p) const { return provides_ & p; }
|
||||
|
||||
///
|
||||
unsigned int columns() const { return columns_; }
|
||||
///
|
||||
enum PageSides {
|
||||
///
|
||||
OneSide,
|
||||
///
|
||||
TwoSides
|
||||
};
|
||||
///
|
||||
PageSides sides() const { return sides_; }
|
||||
///
|
||||
int secnumdepth() const { return secnumdepth_; }
|
||||
///
|
||||
int tocdepth() const { return tocdepth_; }
|
||||
|
||||
///
|
||||
OutputType outputType() const { return outputType_; }
|
||||
|
||||
///
|
||||
LyXFont const & defaultfont() const;
|
||||
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
string const & leftmargin() const;
|
||||
|
||||
/// Text that dictates how wide the right margin is on the screen
|
||||
string const & rightmargin() const;
|
||||
///
|
||||
int maxcounter() const { return maxcounter_; }
|
||||
///
|
||||
lyx::layout_type numLayouts() const { return layoutlist.size(); }
|
||||
///
|
||||
LyXLayout const & operator[](lyx::layout_type i) const {
|
||||
return layoutlist[i];
|
||||
}
|
||||
private:
|
||||
///
|
||||
bool delete_layout(string const &);
|
||||
///
|
||||
bool do_readStyle(LyXLex &, LyXLayout &);
|
||||
///
|
||||
string name_;
|
||||
///
|
||||
string latexname_;
|
||||
///
|
||||
string description_;
|
||||
/// Specific class options
|
||||
string opt_fontsize_;
|
||||
///
|
||||
string opt_pagestyle_;
|
||||
///
|
||||
string options_;
|
||||
///
|
||||
string pagestyle_;
|
||||
///
|
||||
string preamble_;
|
||||
///
|
||||
Provides provides_;
|
||||
///
|
||||
unsigned int columns_;
|
||||
///
|
||||
PageSides sides_;
|
||||
///
|
||||
int secnumdepth_;
|
||||
///
|
||||
int tocdepth_;
|
||||
///
|
||||
OutputType outputType_;
|
||||
/** Base font. The paragraph and layout fonts are resolved against
|
||||
this font. This has to be fully instantiated. Attributes
|
||||
LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
|
||||
extremely illegal.
|
||||
*/
|
||||
LyXFont defaultfont_;
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
string leftmargin_;
|
||||
|
||||
/// Text that dictates how wide the right margin is on the screen
|
||||
string rightmargin_;
|
||||
///
|
||||
int maxcounter_; // add approp. signedness
|
||||
|
||||
///
|
||||
LayoutList layoutlist;
|
||||
|
||||
/// Has this layout file been loaded yet?
|
||||
bool loaded;
|
||||
};
|
||||
|
||||
///
|
||||
inline
|
||||
void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
|
||||
{
|
||||
p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
|
||||
|
||||
#endif
|
279
src/lyxtextclasslist.C
Normal file
279
src/lyxtextclasslist.C
Normal file
@ -0,0 +1,279 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "lyxtextclass.h"
|
||||
#include "debug.h"
|
||||
#include "lyxlex.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
|
||||
#include "support/lyxfunctional.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using lyx::layout_type;
|
||||
using lyx::textclass_type;
|
||||
using std::pair;
|
||||
using std::make_pair;
|
||||
using std::endl;
|
||||
|
||||
|
||||
// Gets textclass number from name
|
||||
pair<bool, textclass_type> const
|
||||
LyXTextClassList::NumberOfClass(string const & textclass) const
|
||||
{
|
||||
ClassList::const_iterator cit =
|
||||
find_if(classlist.begin(), classlist.end(),
|
||||
lyx::compare_memfun(&LyXTextClass::name, textclass));
|
||||
return cit != classlist.end() ?
|
||||
make_pair(true, textclass_type(cit - classlist.begin())) :
|
||||
make_pair(false, textclass_type(0));
|
||||
}
|
||||
|
||||
|
||||
// Gets layout structure from style number and textclass number
|
||||
LyXLayout const &
|
||||
LyXTextClassList::Style(textclass_type textclass,
|
||||
layout_type layout) const
|
||||
{
|
||||
classlist[textclass].load();
|
||||
if (layout < classlist[textclass].numLayouts())
|
||||
return classlist[textclass][layout];
|
||||
return classlist[textclass][0];
|
||||
}
|
||||
|
||||
|
||||
// Gets layout number from name and textclass number
|
||||
pair<bool, layout_type> const
|
||||
LyXTextClassList::NumberOfLayout(textclass_type textclass,
|
||||
string const & name) const
|
||||
{
|
||||
classlist[textclass].load();
|
||||
for (unsigned int i = 0; i < classlist[textclass].numLayouts(); ++i) {
|
||||
if (classlist[textclass][i].name() == name)
|
||||
return make_pair(true, i);
|
||||
}
|
||||
return make_pair(false, layout_type(0)); // not found
|
||||
}
|
||||
|
||||
|
||||
// Gets a layout (style) name from layout number and textclass number
|
||||
string const &
|
||||
LyXTextClassList::NameOfLayout(textclass_type textclass,
|
||||
layout_type layout) const
|
||||
{
|
||||
static string const dummy("dummy");
|
||||
classlist[textclass].load();
|
||||
if (layout < classlist[textclass].numLayouts())
|
||||
return classlist[textclass][layout].name();
|
||||
return dummy;
|
||||
}
|
||||
|
||||
|
||||
// Gets a textclass name from number
|
||||
string const &
|
||||
LyXTextClassList::NameOfClass(textclass_type number) const
|
||||
{
|
||||
static string const dummy("dummy");
|
||||
if (classlist.empty()) {
|
||||
return dummy;
|
||||
}
|
||||
lyx::Assert(number < classlist.size());
|
||||
return classlist[number].name();
|
||||
}
|
||||
|
||||
|
||||
// Gets a textclass latexname from number
|
||||
string const &
|
||||
LyXTextClassList::LatexnameOfClass(textclass_type number) const
|
||||
{
|
||||
static string const dummy("dummy");
|
||||
classlist[number].load();
|
||||
if (classlist.empty()) {
|
||||
return dummy;
|
||||
}
|
||||
lyx::Assert(number < classlist.size());
|
||||
return classlist[number].latexname();
|
||||
}
|
||||
|
||||
|
||||
// Gets a textclass description from number
|
||||
string const &
|
||||
LyXTextClassList::DescOfClass(textclass_type number) const
|
||||
{
|
||||
static string const dummy("dummy");
|
||||
if (classlist.empty()) {
|
||||
return dummy;
|
||||
}
|
||||
lyx::Assert(number < classlist.size());
|
||||
return classlist[number].description();
|
||||
}
|
||||
|
||||
|
||||
// Gets a textclass structure from number
|
||||
LyXTextClass const &
|
||||
LyXTextClassList::TextClass(textclass_type textclass) const
|
||||
{
|
||||
classlist[textclass].load();
|
||||
if (textclass < classlist.size())
|
||||
return classlist[textclass];
|
||||
else
|
||||
return classlist[0];
|
||||
}
|
||||
|
||||
|
||||
void LyXTextClassList::Add(LyXTextClass const & t)
|
||||
{
|
||||
classlist.push_back(t);
|
||||
}
|
||||
|
||||
|
||||
// used when sorting the textclass list.
|
||||
class less_textclass_desc {
|
||||
public:
|
||||
int operator()(LyXTextClass const & tc1, LyXTextClass const & tc2) {
|
||||
return tc1.description() < tc2.description();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Reads LyX textclass definitions according to textclass config file
|
||||
bool LyXTextClassList::Read ()
|
||||
{
|
||||
LyXLex lex(0, 0);
|
||||
string real_file = LibFileSearch("", "textclass.lst");
|
||||
lyxerr[Debug::TCLASS] << "Reading textclasses from `"
|
||||
<< real_file << "'" << endl;
|
||||
|
||||
if (real_file.empty()) {
|
||||
lyxerr << "LyXTextClassList::Read: unable to find "
|
||||
"textclass file `" << MakeDisplayPath(real_file, 1000)
|
||||
<< "'. Exiting." << endl;
|
||||
|
||||
Alert::alert(_("LyX wasn't able to find its layout descriptions!"),
|
||||
_("Check that the file \"textclass.lst\""),
|
||||
_("is installed correctly. Sorry, has to exit :-("));
|
||||
return false;
|
||||
// This causes LyX to end... Not a desirable behaviour. Lgb
|
||||
// What do you propose? That the user gets a file dialog
|
||||
// and is allowed to hunt for the file? (Asger)
|
||||
// more that we have a layout for minimal.cls statically
|
||||
// compiled in... (Lgb)
|
||||
}
|
||||
|
||||
if (!lex.setFile(real_file)) {
|
||||
lyxerr << "LyXTextClassList::Read: "
|
||||
"lyxlex was not able to set file: "
|
||||
<< real_file << endl;
|
||||
}
|
||||
|
||||
if (!lex.isOK()) {
|
||||
lyxerr << "LyXTextClassList::Read: unable to open "
|
||||
"textclass file `" << MakeDisplayPath(real_file, 1000)
|
||||
<< "'\nCheck your installation. LyX can't continue."
|
||||
<< endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool finished = false;
|
||||
// Parse config-file
|
||||
lyxerr[Debug::TCLASS] << "Starting parsing of textclass.lst" << endl;
|
||||
while (lex.isOK() && !finished) {
|
||||
lyxerr[Debug::TCLASS] << "\tline by line" << endl;
|
||||
switch (lex.lex()) {
|
||||
case LyXLex::LEX_FEOF:
|
||||
finished = true;
|
||||
break;
|
||||
default:
|
||||
string const fname = lex.getString();
|
||||
lyxerr[Debug::TCLASS] << "Fname: " << fname << endl;
|
||||
if (lex.next()) {
|
||||
string const clname = lex.getString();
|
||||
lyxerr[Debug::TCLASS]
|
||||
<< "Clname: " << clname << endl;
|
||||
if (lex.next()) {
|
||||
string const desc = lex.getString();
|
||||
lyxerr[Debug::TCLASS]
|
||||
<< "Desc: " << desc << endl;
|
||||
// This code is run when we have
|
||||
// fname, clname and desc
|
||||
LyXTextClass tmpl(fname,
|
||||
clname,
|
||||
desc);
|
||||
if (lyxerr.
|
||||
debugging(Debug::TCLASS)) {
|
||||
tmpl.load();
|
||||
}
|
||||
Add (tmpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lyxerr[Debug::TCLASS] << "End of parsing of textclass.lst" << endl;
|
||||
|
||||
if (classlist.empty()) {
|
||||
lyxerr << "LyXTextClassList::Read: no textclasses found!"
|
||||
<< endl;
|
||||
Alert::alert(_("LyX wasn't able to find any layout description!"),
|
||||
_("Check the contents of the file \"textclass.lst\""),
|
||||
_("Sorry, has to exit :-("));
|
||||
return false;
|
||||
}
|
||||
// Ok everything loaded ok, now sort the list.
|
||||
sort(classlist.begin(), classlist.end(), less_textclass_desc());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Load textclass
|
||||
Returns false if this fails
|
||||
*/
|
||||
bool LyXTextClassList::Load(textclass_type number) const
|
||||
{
|
||||
bool result = true;
|
||||
if (number < classlist.size()) {
|
||||
classlist[number].load();
|
||||
if (classlist[number].numLayouts() == 0) {
|
||||
result = false;
|
||||
}
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Global variable: textclass table.
|
||||
LyXTextClassList textclasslist;
|
||||
|
||||
// Reads the style files
|
||||
void LyXSetStyle()
|
||||
{
|
||||
lyxerr[Debug::TCLASS] << "LyXSetStyle: parsing configuration...\n";
|
||||
|
||||
if (!textclasslist.Read()) {
|
||||
lyxerr[Debug::TCLASS] << "LyXSetStyle: an error occured "
|
||||
"during parsing.\n Exiting." << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
lyxerr[Debug::TCLASS] << "LyXSetStyle: configuration parsed." << endl;
|
||||
}
|
94
src/lyxtextclasslist.h
Normal file
94
src/lyxtextclasslist.h
Normal file
@ -0,0 +1,94 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifndef LYXTEXTCLASSLIST_H
|
||||
#define LYXTEXTCLASSLIST_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "support/types.h"
|
||||
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class LyXTextClass;
|
||||
class LyXLayout;
|
||||
|
||||
/// Reads the style files
|
||||
extern void LyXSetStyle();
|
||||
|
||||
///
|
||||
class LyXTextClassList : boost::noncopyable {
|
||||
public:
|
||||
///
|
||||
typedef std::vector<LyXTextClass> ClassList;
|
||||
///
|
||||
typedef ClassList::const_iterator const_iterator;
|
||||
///
|
||||
const_iterator begin() const { return classlist.begin(); }
|
||||
///
|
||||
const_iterator end() const { return classlist.end(); }
|
||||
|
||||
/// Gets layout structure from layout number and textclass number
|
||||
LyXLayout const & Style(lyx::textclass_type textclass,
|
||||
lyx::layout_type layout) const;
|
||||
|
||||
/// Gets layout number from textclass number and layout name
|
||||
std::pair<bool, lyx::layout_type> const
|
||||
NumberOfLayout(lyx::textclass_type textclass, string const & name) const;
|
||||
|
||||
/// Gets a layout name from layout number and textclass number
|
||||
string const &
|
||||
NameOfLayout(lyx::textclass_type textclass, lyx::layout_type layout) const;
|
||||
|
||||
/** Gets textclass number from name.
|
||||
Returns -1 if textclass name does not exist
|
||||
*/
|
||||
std::pair<bool, lyx::textclass_type> const
|
||||
NumberOfClass(string const & textclass) const;
|
||||
|
||||
///
|
||||
string const & NameOfClass(lyx::textclass_type number) const;
|
||||
|
||||
///
|
||||
string const & LatexnameOfClass(lyx::textclass_type number) const;
|
||||
|
||||
///
|
||||
string const & DescOfClass(lyx::textclass_type number) const;
|
||||
|
||||
///
|
||||
LyXTextClass const & TextClass(lyx::textclass_type textclass) const;
|
||||
|
||||
/** Read textclass list.
|
||||
Returns false if this fails
|
||||
*/
|
||||
bool Read();
|
||||
|
||||
/** Load textclass.
|
||||
Returns false if this fails
|
||||
*/
|
||||
bool Load(lyx::textclass_type number) const;
|
||||
private:
|
||||
///
|
||||
mutable ClassList classlist;
|
||||
///
|
||||
void Add (LyXTextClass const &);
|
||||
};
|
||||
|
||||
///
|
||||
extern LyXTextClassList textclasslist;
|
||||
|
||||
#endif
|
@ -14,35 +14,38 @@
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <csignal>
|
||||
|
||||
#include "paragraph.h"
|
||||
#include "paragraph_pimpl.h"
|
||||
#include "support/textutils.h"
|
||||
#include "lyxrc.h"
|
||||
#include "layout.h"
|
||||
#include "language.h"
|
||||
#include "tex-strings.h"
|
||||
#include "buffer.h"
|
||||
#include "bufferparams.h"
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "debug.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "insets/insetinclude.h"
|
||||
#include "insets/insetbib.h"
|
||||
#include "insets/insettext.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "lyx_gui_misc.h"
|
||||
#include "texrow.h"
|
||||
#include "support/lyxmanip.h"
|
||||
#include "BufferView.h"
|
||||
#include "encoding.h"
|
||||
#include "ParameterStruct.h"
|
||||
#include "gettext.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#include "insets/insetinclude.h"
|
||||
#include "insets/insetbib.h"
|
||||
#include "insets/insettext.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxmanip.h"
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <csignal>
|
||||
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "encoding.h"
|
||||
#include "lyxrc.h"
|
||||
#include "debug.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
|
||||
#include "support/LAssert.h"
|
||||
|
||||
using lyx::pos_type;
|
||||
|
@ -18,8 +18,11 @@
|
||||
|
||||
#include "paragraph.h"
|
||||
#include "ParagraphParameters.h"
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
class LyXLayout;
|
||||
|
||||
struct Paragraph::Pimpl {
|
||||
///
|
||||
typedef std::vector<value_type> TextContainer;
|
||||
|
@ -16,15 +16,16 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
|
||||
#include "lyxlex.h"
|
||||
#include "layout.h"
|
||||
#include "LString.h"
|
||||
#include "insets/insettext.h"
|
||||
#include "lyxlength.h"
|
||||
|
||||
#include "insets/insettext.h"
|
||||
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
|
||||
class InsetTabular;
|
||||
class LaTeXFeatures;
|
||||
class Buffer;
|
||||
|
@ -19,7 +19,6 @@
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
#include "layout.h"
|
||||
#include "tabular.h"
|
||||
|
||||
#include <iosfwd>
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include "lyxtext.h"
|
||||
#include "lyxrow.h"
|
||||
#include "layout.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "paragraph.h"
|
||||
#include "lyx_gui_misc.h"
|
||||
#include "gettext.h"
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "lyxtext.h"
|
||||
#include "LString.h"
|
||||
#include "paragraph.h"
|
||||
#include "layout.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "LyXView.h"
|
||||
#include "undo_funcs.h"
|
||||
#include "buffer.h"
|
||||
|
Loading…
Reference in New Issue
Block a user