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
13 #include "lyxlayout.h"
14 #include "lyxlayout_ptr_fwd.h"
16 #include <boost/shared_ptr.hpp>
29 std::string latextype;
30 std::string latexname;
31 std::string latexparam;
38 /// List of semantically defined character style insets
39 typedef std::vector<CharStyle> CharStyles;
42 /// Stores the layout specification of a LyX document class.
45 /// The individual styles comprising the document class
46 typedef std::vector<LyXLayout_ptr> LayoutList;
47 /// Enumerate the paragraph styles.
48 typedef LayoutList::const_iterator const_iterator;
49 /// Construct a layout with default values. Actual values loaded later.
51 LyXTextClass(std::string const & = std::string(),
52 std::string const & = std::string(),
53 std::string const & = std::string(),
56 /// check whether the TeX class is available
57 bool isTeXClassAvailable() const;
59 /// paragraph styles begin iterator.
60 const_iterator begin() const { return layoutlist_.begin(); }
61 /// paragraph styles end iterator
62 const_iterator end() const { return layoutlist_.end(); }
64 /// Performs the read of the layout file.
65 bool read(std::string const & filename, bool merge = false);
67 void readOutputType(LyXLex &);
69 void readTitleType(LyXLex &);
71 void readMaxCounter(LyXLex &);
73 void readClassOptions(LyXLex &);
75 void readCharStyle(LyXLex &, std::string const &);
77 void readFloat(LyXLex &);
79 void readCounter(LyXLex &);
81 bool hasLayout(std::string const & name) const;
84 LyXLayout_ptr const & operator[](std::string const & vname) const;
86 /// Sees to that the textclass structure has been loaded
88 /// Has this layout file been loaded yet?
89 bool loaded() const { return loaded_; }
91 /// the list of floats defined in the document class
93 /// the list of floats defined in the document class
94 FloatList const & floats() const;
95 /// The Counters present in this document class.
96 Counters & counters() const;
97 /// CharStyles of this doc class
98 CharStyles & charstyles() const { return charstylelist_; };
99 /// Retrieve element of name s:
100 CharStyles::iterator charstyle(std::string const & s) const;
102 std::string const & defaultLayoutName() const;
104 LyXLayout_ptr const & defaultLayout() const;
106 std::string const & name() const;
108 std::string const & latexname() const;
110 std::string const & description() const;
112 std::string const & opt_fontsize() const;
114 std::string const & opt_pagestyle() const;
116 std::string const & options() const;
118 std::string const & class_header() const;
120 std::string const & pagestyle() const;
122 std::string const & preamble() const;
124 /// Packages that are already loaded by the class
138 bool provides(Provides p) const;
141 unsigned int columns() const;
150 PageSides sides() const;
152 int secnumdepth() const;
154 int tocdepth() const;
156 /// Can be LaTeX, LinuxDoc, etc.
157 OutputType outputType() const;
160 LyXFont const & defaultfont() const;
162 /// Text that dictates how wide the left margin is on the screen
163 std::string const & leftmargin() const;
165 /// Text that dictates how wide the right margin is on the screen
166 std::string const & rightmargin() const;
168 /// The type of command used to produce a title
169 LYX_TITLE_LATEX_TYPES titletype() const;
170 /// The name of the title command
171 std::string const & titlename() const;
175 /// The minimal TocLevel of sectioning layouts
176 int min_toclevel() const;
177 /// The maximal TocLevel of sectioning layouts
178 int max_toclevel() const;
179 /// returns true if the class has a ToC structure
180 bool hasTocLevels() const;
183 bool delete_layout(std::string const &);
185 bool do_readStyle(LyXLex &, LyXLayout &);
188 /// document class name
189 std::string latexname_;
190 /// document class description
191 std::string description_;
192 /// Specific class options
193 std::string opt_fontsize_;
195 std::string opt_pagestyle_;
197 std::string options_;
199 std::string pagestyle_;
201 std::string class_header_;
203 std::string defaultlayout_;
204 /// preamble text to support layout styles
205 std::string preamble_;
206 /// latex packages loaded by document class.
209 unsigned int columns_;
212 /// header depth to have numbering
214 /// header depth to appear in table of contents
216 /// Can be LaTeX, LinuxDoc, etc.
217 OutputType outputType_;
218 /** Base font. The paragraph and layout fonts are resolved against
219 this font. This has to be fully instantiated. Attributes
220 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
223 LyXFont defaultfont_;
224 /// Text that dictates how wide the left margin is on the screen
225 std::string leftmargin_;
227 /// Text that dictates how wide the right margin is on the screen
228 std::string rightmargin_;
230 /// The type of command used to produce a title
231 LYX_TITLE_LATEX_TYPES titletype_;
232 /// The name of the title command
233 std::string titlename_;
235 /// Paragraph styles used in this layout
236 LayoutList layoutlist_;
237 /// CharStyles available to this layout
238 mutable CharStyles charstylelist_;
240 /// available types of float, eg. figure, algorithm.
241 boost::shared_ptr<FloatList> floatlist_;
243 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
244 boost::shared_ptr<Counters> ctrs_;
246 /// Has this layout file been loaded yet?
247 mutable bool loaded_;
249 /// Is the TeX class available?
252 /// The minimal TocLevel of sectioning layouts
254 /// The maximal TocLevel of sectioning layouts
259 /// Merge two different provides flags into one bit field record
261 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
263 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
267 /// convert page sides option to text 1 or 2
268 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);