4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * Full author contact details are available in file CREDITS.
10 #ifndef LYXTEXTCLASS_H
11 #define LYXTEXTCLASS_H
14 #include "lyxlayout_ptr_fwd.h"
16 #include <boost/shared_ptr.hpp>
23 namespace support { class FileName; }
34 std::string latextype;
35 std::string latexname;
36 std::string latexparam;
43 /// List of semantically defined character style insets
44 typedef std::vector<CharStyle> CharStyles;
47 /// Stores the layout specification of a LyX document class.
50 /// The individual styles comprising the document class
51 typedef std::vector<Layout_ptr> LayoutList;
52 /// Enumerate the paragraph styles.
53 typedef LayoutList::const_iterator const_iterator;
54 /// Construct a layout with default values. Actual values loaded later.
56 TextClass(std::string const & = std::string(),
57 std::string const & = std::string(),
58 std::string const & = std::string(),
61 /// check whether the TeX class is available
62 bool isTeXClassAvailable() const;
64 /// paragraph styles begin iterator.
65 const_iterator begin() const { return layoutlist_.begin(); }
66 /// paragraph styles end iterator
67 const_iterator end() const { return layoutlist_.end(); }
69 /// Performs the read of the layout file.
70 bool read(support::FileName const & filename, bool merge = false);
72 void readOutputType(Lexer &);
74 void readTitleType(Lexer &);
76 void readMaxCounter(Lexer &);
78 void readClassOptions(Lexer &);
80 void readCharStyle(Lexer &, std::string const &);
82 void readFloat(Lexer &);
84 void readCounter(Lexer &);
86 bool hasLayout(std::string const & name) const;
89 Layout_ptr const & operator[](std::string const & vname) const;
91 /// Sees to that the textclass structure has been loaded
92 bool load(std::string const & path = std::string()) const;
93 /// Has this layout file been loaded yet?
94 bool loaded() const { return loaded_; }
96 /// the list of floats defined in the document class
98 /// the list of floats defined in the document class
99 FloatList const & floats() const;
100 /// The Counters present in this document class.
101 Counters & counters() const;
102 /// CharStyles of this doc class
103 CharStyles & charstyles() const { return charstylelist_; };
104 /// Retrieve element of name s:
105 CharStyles::iterator charstyle(std::string const & s) const;
107 std::string const & defaultLayoutName() const;
109 Layout_ptr const & defaultLayout() const;
111 std::string const & name() const;
113 std::string const & latexname() const;
115 std::string const & description() const;
117 std::string const & opt_fontsize() const;
119 std::string const & opt_pagestyle() const;
121 std::string const & options() const;
123 std::string const & class_header() const;
125 std::string const & pagestyle() const;
127 docstring const & preamble() const;
129 /// is this feature already provided by the class?
130 bool provides(std::string const & p) const;
133 unsigned int columns() const;
142 PageSides sides() const;
144 int secnumdepth() const;
146 int tocdepth() const;
148 /// Can be LaTeX, DocBook, etc.
149 OutputType outputType() const;
152 Font const & defaultfont() const;
154 /// Text that dictates how wide the left margin is on the screen
155 std::string const & leftmargin() const;
157 /// Text that dictates how wide the right margin is on the screen
158 std::string const & rightmargin() const;
160 /// The type of command used to produce a title
161 LYX_TITLE_LATEX_TYPES titletype() const;
162 /// The name of the title command
163 std::string const & titlename() const;
167 /// The minimal TocLevel of sectioning layouts
168 int min_toclevel() const;
169 /// The maximal TocLevel of sectioning layouts
170 int max_toclevel() const;
171 /// returns true if the class has a ToC structure
172 bool hasTocLevels() const;
175 bool delete_layout(std::string const &);
177 bool do_readStyle(Lexer &, Layout &);
180 /// document class name
181 std::string latexname_;
182 /// document class description
183 std::string description_;
184 /// Specific class options
185 std::string opt_fontsize_;
187 std::string opt_pagestyle_;
189 std::string options_;
191 std::string pagestyle_;
193 std::string class_header_;
195 std::string defaultlayout_;
196 /// preamble text to support layout styles
198 /// latex packages loaded by document class.
199 std::set<std::string> provides_;
201 unsigned int columns_;
204 /// header depth to have numbering
206 /// header depth to appear in table of contents
208 /// Can be LaTeX, DocBook, etc.
209 OutputType outputType_;
210 /** Base font. The paragraph and layout fonts are resolved against
211 this font. This has to be fully instantiated. Attributes
212 Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
216 /// Text that dictates how wide the left margin is on the screen
217 std::string leftmargin_;
219 /// Text that dictates how wide the right margin is on the screen
220 std::string rightmargin_;
222 /// The type of command used to produce a title
223 LYX_TITLE_LATEX_TYPES titletype_;
224 /// The name of the title command
225 std::string titlename_;
227 /// Paragraph styles used in this layout
228 LayoutList layoutlist_;
229 /// CharStyles available to this layout
230 mutable CharStyles charstylelist_;
232 /// available types of float, eg. figure, algorithm.
233 boost::shared_ptr<FloatList> floatlist_;
235 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
236 boost::shared_ptr<Counters> ctrs_;
238 /// Has this layout file been loaded yet?
239 mutable bool loaded_;
241 /// Is the TeX class available?
244 /// The minimal TocLevel of sectioning layouts
246 /// The maximal TocLevel of sectioning layouts
251 /// convert page sides option to text 1 or 2
252 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);