2001-12-28 13:26:54 +00:00
|
|
|
// -*- C++ -*-
|
2002-11-07 19:51:22 +00:00
|
|
|
/**
|
2007-04-29 19:53:54 +00:00
|
|
|
* \file TextClass.h
|
2002-11-07 19:51:22 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-08-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
|
|
|
|
|
2007-04-29 18:58:28 +00:00
|
|
|
#include "Layout.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>
|
2007-04-06 09:02:23 +00:00
|
|
|
#include <set>
|
2007-08-13 12:13:17 +00:00
|
|
|
#include <map>
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2006-11-26 21:30:39 +00:00
|
|
|
namespace support { class FileName; }
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
class Lexer;
|
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
|
|
|
///
|
2007-08-13 12:13:17 +00:00
|
|
|
class InsetLayout {
|
|
|
|
public:
|
2007-08-17 15:38:58 +00:00
|
|
|
std::string name;
|
|
|
|
std::string lyxtype;
|
2007-08-13 12:13:17 +00:00
|
|
|
docstring labelstring;
|
|
|
|
std::string latextype;
|
|
|
|
std::string latexname;
|
|
|
|
std::string latexparam;
|
|
|
|
Font font;
|
|
|
|
Font labelfont;
|
|
|
|
docstring preamble;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-11-12 14:38:26 +00:00
|
|
|
/// List of semantically defined character style insets
|
2007-08-17 15:38:58 +00:00
|
|
|
typedef std::vector<InsetLayout> CharStyles;
|
2003-11-12 14:38:26 +00:00
|
|
|
|
2007-08-13 12:13:17 +00:00
|
|
|
/// List of inset layouts
|
|
|
|
typedef std::map<docstring, InsetLayout> InsetLayouts;
|
2003-11-12 14:38:26 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Stores the layout specification of a LyX document class.
|
2007-04-29 19:53:54 +00:00
|
|
|
class TextClass {
|
2001-12-28 13:26:54 +00:00
|
|
|
public:
|
2002-11-07 19:51:22 +00:00
|
|
|
/// The individual styles comprising the document class
|
2007-04-29 18:58:28 +00:00
|
|
|
typedef std::vector<Layout_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
|
2007-04-29 19:53:54 +00:00
|
|
|
TextClass(std::string const & = std::string(),
|
2003-10-06 15:43:21 +00:00
|
|
|
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-11-26 21:30:39 +00:00
|
|
|
bool read(support::FileName const & filename, bool merge = false);
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void readOutputType(Lexer &);
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void readTitleType(Lexer &);
|
2003-02-13 17:49:09 +00:00
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void readMaxCounter(Lexer &);
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void readClassOptions(Lexer &);
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void readCharStyle(Lexer &, std::string const &);
|
2003-11-12 14:38:26 +00:00
|
|
|
///
|
2007-08-13 12:13:17 +00:00
|
|
|
void readInsetLayout(Lexer &, docstring const &);
|
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void readFloat(Lexer &);
|
2002-09-04 06:52:26 +00:00
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void readCounter(Lexer &);
|
2002-09-06 14:48:01 +00:00
|
|
|
///
|
2007-07-11 13:39:08 +00:00
|
|
|
bool hasLayout(docstring const & name) const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
///
|
2007-07-11 13:39:08 +00:00
|
|
|
Layout_ptr const & operator[](docstring const & vname) const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
/// Sees to that the textclass structure has been loaded
|
2006-10-20 22:17:16 +00:00
|
|
|
bool load(std::string const & path = std::string()) 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_; };
|
2007-08-13 12:13:17 +00:00
|
|
|
/// Inset layouts of this doc class
|
|
|
|
InsetLayout const & insetlayout(docstring const & name) const;
|
2003-11-12 14:38:26 +00:00
|
|
|
/// Retrieve element of name s:
|
|
|
|
CharStyles::iterator charstyle(std::string const & s) const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2007-07-11 13:39:08 +00:00
|
|
|
docstring const & defaultLayoutName() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2007-04-29 18:58:28 +00:00
|
|
|
Layout_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
|
|
|
///
|
2007-08-13 12:13:17 +00:00
|
|
|
docstring const & labelstring() const;
|
|
|
|
///
|
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
|
|
|
///
|
2006-11-08 17:22:44 +00:00
|
|
|
docstring const & preamble() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2007-04-06 09:02:23 +00:00
|
|
|
/// is this feature already provided by the class?
|
|
|
|
bool provides(std::string const & 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
|
|
|
|
2006-08-23 12:43:46 +00:00
|
|
|
/// Can be LaTeX, DocBook, etc.
|
2002-03-02 16:39:54 +00:00
|
|
|
OutputType outputType() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
///
|
2007-04-29 18:17:15 +00:00
|
|
|
Font const & defaultfont() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
/// Text that dictates how wide the left margin is on the screen
|
2007-08-18 13:21:12 +00:00
|
|
|
docstring const & leftmargin() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
/// Text that dictates how wide the right margin is on the screen
|
2007-08-18 13:21:12 +00:00
|
|
|
docstring 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:
|
|
|
|
///
|
2007-07-11 13:39:08 +00:00
|
|
|
bool delete_layout(docstring const &);
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2007-04-29 18:58:28 +00:00
|
|
|
bool do_readStyle(Lexer &, Layout &);
|
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_;
|
|
|
|
///
|
2007-07-11 13:39:08 +00:00
|
|
|
docstring defaultlayout_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// preamble text to support layout styles
|
2006-11-08 17:22:44 +00:00
|
|
|
docstring preamble_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// latex packages loaded by document class.
|
2007-04-06 09:02:23 +00:00
|
|
|
std::set<std::string> provides_;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
|
|
|
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_;
|
2006-08-23 12:43:46 +00:00
|
|
|
/// Can be LaTeX, DocBook, 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
|
2007-04-29 18:17:15 +00:00
|
|
|
Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
|
2001-12-28 13:26:54 +00:00
|
|
|
extremely illegal.
|
|
|
|
*/
|
2007-04-29 18:17:15 +00:00
|
|
|
Font defaultfont_;
|
2001-12-28 13:26:54 +00:00
|
|
|
/// Text that dictates how wide the left margin is on the screen
|
2007-08-18 13:21:12 +00:00
|
|
|
docstring leftmargin_;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
/// Text that dictates how wide the right margin is on the screen
|
2007-08-18 13:21:12 +00:00
|
|
|
docstring 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
|
|
|
|
2007-08-13 12:13:17 +00:00
|
|
|
/// Input layouts available to this layout
|
|
|
|
mutable InsetLayouts insetlayoutlist_;
|
|
|
|
|
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.
|
2007-08-16 15:26:00 +00:00
|
|
|
boost::shared_ptr<Counters> counters_;
|
2002-09-06 14:48:01 +00:00
|
|
|
|
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
|
|
|
/// convert page sides option to text 1 or 2
|
2007-04-29 19:53:54 +00:00
|
|
|
std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
#endif
|