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>
24 namespace support { class FileName; }
35 std::string latextype;
36 std::string latexname;
37 std::string latexparam;
46 docstring labelstring;
47 std::string latextype;
48 std::string latexname;
49 std::string latexparam;
56 /// List of semantically defined character style insets
57 typedef std::vector<CharStyle> CharStyles;
59 /// List of inset layouts
60 typedef std::map<docstring, InsetLayout> InsetLayouts;
62 /// Stores the layout specification of a LyX document class.
65 /// The individual styles comprising the document class
66 typedef std::vector<Layout_ptr> LayoutList;
67 /// Enumerate the paragraph styles.
68 typedef LayoutList::const_iterator const_iterator;
69 /// Construct a layout with default values. Actual values loaded later.
71 TextClass(std::string const & = std::string(),
72 std::string const & = std::string(),
73 std::string const & = std::string(),
76 /// check whether the TeX class is available
77 bool isTeXClassAvailable() const;
79 /// paragraph styles begin iterator.
80 const_iterator begin() const { return layoutlist_.begin(); }
81 /// paragraph styles end iterator
82 const_iterator end() const { return layoutlist_.end(); }
84 /// Performs the read of the layout file.
85 bool read(support::FileName const & filename, bool merge = false);
87 void readOutputType(Lexer &);
89 void readTitleType(Lexer &);
91 void readMaxCounter(Lexer &);
93 void readClassOptions(Lexer &);
95 void readCharStyle(Lexer &, std::string const &);
97 void readInsetLayout(Lexer &, docstring const &);
99 void readFloat(Lexer &);
101 void readCounter(Lexer &);
103 bool hasLayout(docstring const & name) const;
106 Layout_ptr const & operator[](docstring const & vname) const;
108 /// Sees to that the textclass structure has been loaded
109 bool load(std::string const & path = std::string()) const;
110 /// Has this layout file been loaded yet?
111 bool loaded() const { return loaded_; }
113 /// the list of floats defined in the document class
114 FloatList & floats();
115 /// the list of floats defined in the document class
116 FloatList const & floats() const;
117 /// The Counters present in this document class.
118 Counters & counters() const;
119 /// CharStyles of this doc class
120 CharStyles & charstyles() const { return charstylelist_; };
121 /// Inset layouts of this doc class
122 InsetLayout const & insetlayout(docstring const & name) const;
123 /// Retrieve element of name s:
124 CharStyles::iterator charstyle(std::string const & s) const;
126 docstring const & defaultLayoutName() const;
128 Layout_ptr const & defaultLayout() const;
130 std::string const & name() const;
132 docstring const & labelstring() const;
134 std::string const & latexname() const;
136 std::string const & description() const;
138 std::string const & opt_fontsize() const;
140 std::string const & opt_pagestyle() const;
142 std::string const & options() const;
144 std::string const & class_header() const;
146 std::string const & pagestyle() const;
148 docstring const & preamble() const;
150 /// is this feature already provided by the class?
151 bool provides(std::string const & p) const;
154 unsigned int columns() const;
163 PageSides sides() const;
165 int secnumdepth() const;
167 int tocdepth() const;
169 /// Can be LaTeX, DocBook, etc.
170 OutputType outputType() const;
173 Font const & defaultfont() const;
175 /// Text that dictates how wide the left margin is on the screen
176 std::string const & leftmargin() const;
178 /// Text that dictates how wide the right margin is on the screen
179 std::string const & rightmargin() const;
181 /// The type of command used to produce a title
182 LYX_TITLE_LATEX_TYPES titletype() const;
183 /// The name of the title command
184 std::string const & titlename() const;
188 /// The minimal TocLevel of sectioning layouts
189 int min_toclevel() const;
190 /// The maximal TocLevel of sectioning layouts
191 int max_toclevel() const;
192 /// returns true if the class has a ToC structure
193 bool hasTocLevels() const;
196 bool delete_layout(docstring const &);
198 bool do_readStyle(Lexer &, Layout &);
201 /// document class name
202 std::string latexname_;
203 /// document class description
204 std::string description_;
205 /// Specific class options
206 std::string opt_fontsize_;
208 std::string opt_pagestyle_;
210 std::string options_;
212 std::string pagestyle_;
214 std::string class_header_;
216 docstring defaultlayout_;
217 /// preamble text to support layout styles
219 /// latex packages loaded by document class.
220 std::set<std::string> provides_;
222 unsigned int columns_;
225 /// header depth to have numbering
227 /// header depth to appear in table of contents
229 /// Can be LaTeX, DocBook, etc.
230 OutputType outputType_;
231 /** Base font. The paragraph and layout fonts are resolved against
232 this font. This has to be fully instantiated. Attributes
233 Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
237 /// Text that dictates how wide the left margin is on the screen
238 std::string leftmargin_;
240 /// Text that dictates how wide the right margin is on the screen
241 std::string rightmargin_;
243 /// The type of command used to produce a title
244 LYX_TITLE_LATEX_TYPES titletype_;
245 /// The name of the title command
246 std::string titlename_;
248 /// Paragraph styles used in this layout
249 LayoutList layoutlist_;
250 /// CharStyles available to this layout
251 mutable CharStyles charstylelist_;
253 /// Input layouts available to this layout
254 mutable InsetLayouts insetlayoutlist_;
256 /// available types of float, eg. figure, algorithm.
257 boost::shared_ptr<FloatList> floatlist_;
259 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
260 boost::shared_ptr<Counters> ctrs_;
262 /// Has this layout file been loaded yet?
263 mutable bool loaded_;
265 /// Is the TeX class available?
268 /// The minimal TocLevel of sectioning layouts
270 /// The maximal TocLevel of sectioning layouts
275 /// convert page sides option to text 1 or 2
276 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);