2001-12-28 13:26:54 +00:00
|
|
|
// -*- C++ -*-
|
2002-11-07 19:51:22 +00:00
|
|
|
/**
|
|
|
|
* \file lyxtextclass.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-11-07 19:51:22 +00:00
|
|
|
*/
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
#ifndef LYXTEXTCLASS_H
|
|
|
|
#define LYXTEXTCLASS_H
|
|
|
|
|
|
|
|
#include "lyxlayout.h"
|
2002-06-24 20:28:12 +00:00
|
|
|
#include "lyxlayout_ptr_fwd.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-09-06 14:48:01 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class LyXLex;
|
2002-09-06 14:48:01 +00:00
|
|
|
class Counters;
|
2002-09-11 07:39:55 +00:00
|
|
|
class FloatList;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2003-09-15 15:51:48 +00:00
|
|
|
|
2003-11-12 14:38:26 +00:00
|
|
|
///
|
2005-01-19 15:03:31 +00:00
|
|
|
class CharStyle {
|
|
|
|
public:
|
2003-11-12 14:38:26 +00:00
|
|
|
std::string name;
|
|
|
|
std::string latextype;
|
|
|
|
std::string latexname;
|
2003-12-01 16:01:50 +00:00
|
|
|
std::string latexparam;
|
2003-11-12 14:38:26 +00:00
|
|
|
LyXFont font;
|
|
|
|
LyXFont labelfont;
|
|
|
|
std::string preamble;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// List of semantically defined character style insets
|
|
|
|
typedef std::vector<CharStyle> CharStyles;
|
|
|
|
|
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Stores the layout specification of a LyX document class.
|
2001-12-28 13:26:54 +00:00
|
|
|
class LyXTextClass {
|
|
|
|
public:
|
2002-11-07 19:51:22 +00:00
|
|
|
/// The individual styles comprising the document class
|
2002-06-24 20:28:12 +00:00
|
|
|
typedef std::vector<LyXLayout_ptr> LayoutList;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Enumerate the paragraph styles.
|
2001-12-28 13:26:54 +00:00
|
|
|
typedef LayoutList::const_iterator const_iterator;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Construct a layout with default values. Actual values loaded later.
|
2001-12-28 13:26:54 +00:00
|
|
|
explicit
|
2003-10-06 15:43:21 +00:00
|
|
|
LyXTextClass(std::string const & = std::string(),
|
|
|
|
std::string const & = std::string(),
|
|
|
|
std::string const & = std::string(),
|
2003-05-03 19:24:36 +00:00
|
|
|
bool = false);
|
|
|
|
|
|
|
|
/// check whether the TeX class is available
|
|
|
|
bool isTeXClassAvailable() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// paragraph styles begin iterator.
|
2002-08-27 15:51:19 +00:00
|
|
|
const_iterator begin() const { return layoutlist_.begin(); }
|
2002-11-07 19:51:22 +00:00
|
|
|
/// paragraph styles end iterator
|
2002-08-27 15:51:19 +00:00
|
|
|
const_iterator end() const { return layoutlist_.end(); }
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Performs the read of the layout file.
|
2006-04-09 00:26:19 +00:00
|
|
|
bool read(std::string const & filename, bool merge = false);
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
|
|
|
void readOutputType(LyXLex &);
|
|
|
|
///
|
2003-02-13 17:49:09 +00:00
|
|
|
void readTitleType(LyXLex &);
|
|
|
|
///
|
2001-12-28 13:26:54 +00:00
|
|
|
void readMaxCounter(LyXLex &);
|
|
|
|
///
|
|
|
|
void readClassOptions(LyXLex &);
|
|
|
|
///
|
2003-11-12 14:38:26 +00:00
|
|
|
void readCharStyle(LyXLex &, std::string const &);
|
|
|
|
///
|
2002-09-04 06:52:26 +00:00
|
|
|
void readFloat(LyXLex &);
|
|
|
|
///
|
2002-09-06 14:48:01 +00:00
|
|
|
void readCounter(LyXLex &);
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
bool hasLayout(std::string const & name) const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
LyXLayout_ptr const & operator[](std::string const & vname) const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
/// Sees to that the textclass structure has been loaded
|
2006-04-09 04:35:24 +00:00
|
|
|
bool load(std::string const & path=".") const;
|
2004-03-30 16:19:50 +00:00
|
|
|
/// Has this layout file been loaded yet?
|
|
|
|
bool loaded() const { return loaded_; }
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// the list of floats defined in the document class
|
2002-08-27 15:51:19 +00:00
|
|
|
FloatList & floats();
|
2002-11-07 19:51:22 +00:00
|
|
|
/// the list of floats defined in the document class
|
2002-08-27 15:51:19 +00:00
|
|
|
FloatList const & floats() const;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// The Counters present in this document class.
|
2002-09-06 14:48:01 +00:00
|
|
|
Counters & counters() const;
|
2003-11-12 14:38:26 +00:00
|
|
|
/// CharStyles of this doc class
|
|
|
|
CharStyles & charstyles() const { return charstylelist_; };
|
|
|
|
/// Retrieve element of name s:
|
|
|
|
CharStyles::iterator charstyle(std::string const & s) const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & defaultLayoutName() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-06-24 20:28:12 +00:00
|
|
|
LyXLayout_ptr const & defaultLayout() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & name() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & latexname() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & description() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & opt_fontsize() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & opt_pagestyle() const;
|
2002-03-02 16:39:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & options() const;
|
2002-03-02 16:39:54 +00:00
|
|
|
///
|
2003-11-27 16:57:12 +00:00
|
|
|
std::string const & class_header() const;
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & pagestyle() const;
|
2002-03-02 16:39:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & preamble() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
/// Packages that are already loaded by the class
|
|
|
|
enum Provides {
|
|
|
|
///
|
|
|
|
nothing = 0,
|
|
|
|
///
|
|
|
|
amsmath = 1,
|
|
|
|
///
|
|
|
|
makeidx = 2,
|
|
|
|
///
|
2002-04-23 22:34:24 +00:00
|
|
|
url = 4,
|
|
|
|
///
|
|
|
|
natbib = 8
|
2001-12-28 13:26:54 +00:00
|
|
|
};
|
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
bool provides(Provides p) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
unsigned int columns() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
|
|
|
enum PageSides {
|
|
|
|
///
|
|
|
|
OneSide,
|
|
|
|
///
|
|
|
|
TwoSides
|
|
|
|
};
|
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
PageSides sides() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
int secnumdepth() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
int tocdepth() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Can be LaTeX, LinuxDoc, etc.
|
2002-03-02 16:39:54 +00:00
|
|
|
OutputType outputType() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
LyXFont const & defaultfont() const;
|
|
|
|
|
|
|
|
/// Text that dictates how wide the left margin is on the screen
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & leftmargin() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
/// Text that dictates how wide the right margin is on the screen
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & rightmargin() const;
|
2003-02-13 17:49:09 +00:00
|
|
|
|
|
|
|
/// The type of command used to produce a title
|
|
|
|
LYX_TITLE_LATEX_TYPES titletype() const;
|
|
|
|
/// The name of the title command
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & titlename() const;
|
2003-02-13 17:49:09 +00:00
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
int size() const;
|
2005-05-12 10:16:04 +00:00
|
|
|
/// The minimal TocLevel of sectioning layouts
|
|
|
|
int min_toclevel() const;
|
|
|
|
/// The maximal TocLevel of sectioning layouts
|
|
|
|
int max_toclevel() const;
|
2006-03-24 11:57:19 +00:00
|
|
|
/// returns true if the class has a ToC structure
|
|
|
|
bool hasTocLevels() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
private:
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
bool delete_layout(std::string const &);
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
|
|
|
bool do_readStyle(LyXLex &, LyXLayout &);
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Layout file name
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string name_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// document class name
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string latexname_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// document class description
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string description_;
|
2001-12-28 13:26:54 +00:00
|
|
|
/// Specific class options
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string opt_fontsize_;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string opt_pagestyle_;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string options_;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string pagestyle_;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2003-11-27 16:57:12 +00:00
|
|
|
std::string class_header_;
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string defaultlayout_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// preamble text to support layout styles
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string preamble_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// latex packages loaded by document class.
|
2001-12-28 13:26:54 +00:00
|
|
|
Provides provides_;
|
|
|
|
///
|
|
|
|
unsigned int columns_;
|
|
|
|
///
|
|
|
|
PageSides sides_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// header depth to have numbering
|
2001-12-28 13:26:54 +00:00
|
|
|
int secnumdepth_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// header depth to appear in table of contents
|
2001-12-28 13:26:54 +00:00
|
|
|
int tocdepth_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Can be LaTeX, LinuxDoc, etc.
|
2001-12-28 13:26:54 +00:00
|
|
|
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
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string leftmargin_;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
/// Text that dictates how wide the right margin is on the screen
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string rightmargin_;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2003-02-13 17:49:09 +00:00
|
|
|
/// The type of command used to produce a title
|
|
|
|
LYX_TITLE_LATEX_TYPES titletype_;
|
|
|
|
/// The name of the title command
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string titlename_;
|
2003-02-13 17:49:09 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Paragraph styles used in this layout
|
2002-08-27 15:51:19 +00:00
|
|
|
LayoutList layoutlist_;
|
2003-11-12 14:38:26 +00:00
|
|
|
/// CharStyles available to this layout
|
|
|
|
mutable CharStyles charstylelist_;
|
2004-01-31 15:30:24 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// available types of float, eg. figure, algorithm.
|
2002-09-11 07:39:55 +00:00
|
|
|
boost::shared_ptr<FloatList> floatlist_;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Types of counters, eg. sections, eqns, figures, avail. in document class.
|
2002-09-06 14:48:01 +00:00
|
|
|
boost::shared_ptr<Counters> ctrs_;
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
/// Has this layout file been loaded yet?
|
2004-03-30 16:19:50 +00:00
|
|
|
mutable bool loaded_;
|
2003-05-03 19:24:36 +00:00
|
|
|
|
|
|
|
/// Is the TeX class available?
|
|
|
|
bool texClassAvail_;
|
2005-05-12 10:16:04 +00:00
|
|
|
|
|
|
|
/// The minimal TocLevel of sectioning layouts
|
|
|
|
int min_toclevel_;
|
|
|
|
/// The maximal TocLevel of sectioning layouts
|
|
|
|
int max_toclevel_;
|
2001-12-28 13:26:54 +00:00
|
|
|
};
|
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Merge two different provides flags into one bit field record
|
2001-12-28 13:26:54 +00:00
|
|
|
inline
|
|
|
|
void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
|
|
|
|
{
|
|
|
|
p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// convert page sides option to text 1 or 2
|
2001-12-28 13:26:54 +00:00
|
|
|
std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
|
|
|
|
|
|
|
|
#endif
|