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; }
36 docstring labelstring;
37 std::string latextype;
38 std::string latexname;
39 std::string latexparam;
46 /// List of semantically defined character style insets
47 typedef std::vector<InsetLayout> CharStyles;
49 /// List of inset layouts
50 typedef std::map<docstring, InsetLayout> InsetLayouts;
52 /// Stores the layout specification of a LyX document class.
55 /// The individual styles comprising the document class
56 typedef std::vector<LayoutPtr> LayoutList;
57 /// Enumerate the paragraph styles.
58 typedef LayoutList::const_iterator const_iterator;
59 /// Construct a layout with default values. Actual values loaded later.
61 TextClass(std::string const & = std::string(),
62 std::string const & = std::string(),
63 std::string const & = std::string(),
66 /// check whether the TeX class is available
67 bool isTeXClassAvailable() const;
69 /// paragraph styles begin iterator.
70 const_iterator begin() const { return layoutlist_.begin(); }
71 /// paragraph styles end iterator
72 const_iterator end() const { return layoutlist_.end(); }
74 /// Performs the read of the layout file.
75 bool read(support::FileName const & filename, bool merge = false);
77 void readOutputType(Lexer &);
79 void readTitleType(Lexer &);
81 void readMaxCounter(Lexer &);
83 void readClassOptions(Lexer &);
85 void readCharStyle(Lexer &, std::string const &);
87 void readInsetLayout(Lexer &, docstring const &);
89 void readFloat(Lexer &);
91 void readCounter(Lexer &);
93 bool hasLayout(docstring const & name) const;
96 LayoutPtr const & operator[](docstring const & vname) const;
98 /// Sees to that the textclass structure has been loaded
99 bool load(std::string const & path = std::string()) const;
100 /// Has this layout file been loaded yet?
101 bool loaded() const { return loaded_; }
103 /// the list of floats defined in the document class
104 FloatList & floats();
105 /// the list of floats defined in the document class
106 FloatList const & floats() const;
107 /// The Counters present in this document class.
108 Counters & counters() const;
109 /// CharStyles of this doc class
110 CharStyles & charstyles() const { return charstylelist_; };
111 /// Inset layouts of this doc class
112 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
114 InsetLayout const & insetlayout(docstring const & name) const;
115 /// Retrieve element of name s:
116 CharStyles::iterator charstyle(std::string const & s) const;
118 docstring const & defaultLayoutName() const;
120 LayoutPtr const & defaultLayout() const;
122 std::string const & name() const;
124 docstring const & labelstring() const;
126 std::string const & latexname() const;
128 std::string const & description() const;
130 std::string const & opt_fontsize() const;
132 std::string const & opt_pagestyle() const;
134 std::string const & options() const;
136 std::string const & class_header() const;
138 std::string const & pagestyle() const;
140 docstring const & preamble() const;
142 /// is this feature already provided by the class?
143 bool provides(std::string const & p) const;
146 unsigned int columns() const;
155 PageSides sides() const;
157 int secnumdepth() const;
159 int tocdepth() const;
161 /// Can be LaTeX, DocBook, etc.
162 OutputType outputType() const;
165 Font const & defaultfont() const;
167 /// Text that dictates how wide the left margin is on the screen
168 docstring const & leftmargin() const;
170 /// Text that dictates how wide the right margin is on the screen
171 docstring const & rightmargin() const;
173 /// The type of command used to produce a title
174 LYX_TITLE_LATEX_TYPES titletype() const;
175 /// The name of the title command
176 std::string const & titlename() const;
180 /// The minimal TocLevel of sectioning layouts
181 int min_toclevel() const;
182 /// The maximal TocLevel of sectioning layouts
183 int max_toclevel() const;
184 /// returns true if the class has a ToC structure
185 bool hasTocLevels() const;
188 bool delete_layout(docstring const &);
190 bool do_readStyle(Lexer &, Layout &);
193 /// document class name
194 std::string latexname_;
195 /// document class description
196 std::string description_;
197 /// Specific class options
198 std::string opt_fontsize_;
200 std::string opt_pagestyle_;
202 std::string options_;
204 std::string pagestyle_;
206 std::string class_header_;
208 docstring defaultlayout_;
209 /// preamble text to support layout styles
211 /// latex packages loaded by document class.
212 std::set<std::string> provides_;
214 unsigned int columns_;
217 /// header depth to have numbering
219 /// header depth to appear in table of contents
221 /// Can be LaTeX, DocBook, etc.
222 OutputType outputType_;
223 /** Base font. The paragraph and layout fonts are resolved against
224 this font. This has to be fully instantiated. Attributes
225 Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
229 /// Text that dictates how wide the left margin is on the screen
230 docstring leftmargin_;
232 /// Text that dictates how wide the right margin is on the screen
233 docstring rightmargin_;
235 /// The type of command used to produce a title
236 LYX_TITLE_LATEX_TYPES titletype_;
237 /// The name of the title command
238 std::string titlename_;
240 /// Paragraph styles used in this layout
241 LayoutList layoutlist_;
242 /// CharStyles available to this layout
243 mutable CharStyles charstylelist_;
245 /// Input layouts available to this layout
246 mutable InsetLayouts insetlayoutlist_;
248 /// available types of float, eg. figure, algorithm.
249 boost::shared_ptr<FloatList> floatlist_;
251 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
252 boost::shared_ptr<Counters> counters_;
254 /// Has this layout file been loaded yet?
255 mutable bool loaded_;
257 /// Is the TeX class available?
260 /// The minimal TocLevel of sectioning layouts
262 /// The maximal TocLevel of sectioning layouts
267 /// convert page sides option to text 1 or 2
268 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);