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;
181 bool delete_layout(std::string const &);
183 bool do_readStyle(LyXLex &, LyXLayout &);
186 /// document class name
187 std::string latexname_;
188 /// document class description
189 std::string description_;
190 /// Specific class options
191 std::string opt_fontsize_;
193 std::string opt_pagestyle_;
195 std::string options_;
197 std::string pagestyle_;
199 std::string class_header_;
201 std::string defaultlayout_;
202 /// preamble text to support layout styles
203 std::string preamble_;
204 /// latex packages loaded by document class.
207 unsigned int columns_;
210 /// header depth to have numbering
212 /// header depth to appear in table of contents
214 /// Can be LaTeX, LinuxDoc, etc.
215 OutputType outputType_;
216 /** Base font. The paragraph and layout fonts are resolved against
217 this font. This has to be fully instantiated. Attributes
218 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
221 LyXFont defaultfont_;
222 /// Text that dictates how wide the left margin is on the screen
223 std::string leftmargin_;
225 /// Text that dictates how wide the right margin is on the screen
226 std::string rightmargin_;
228 /// The type of command used to produce a title
229 LYX_TITLE_LATEX_TYPES titletype_;
230 /// The name of the title command
231 std::string titlename_;
233 /// Paragraph styles used in this layout
234 LayoutList layoutlist_;
235 /// CharStyles available to this layout
236 mutable CharStyles charstylelist_;
238 /// available types of float, eg. figure, algorithm.
239 boost::shared_ptr<FloatList> floatlist_;
241 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
242 boost::shared_ptr<Counters> ctrs_;
244 /// Has this layout file been loaded yet?
245 mutable bool loaded_;
247 /// Is the TeX class available?
250 /// The minimal TocLevel of sectioning layouts
252 /// The maximal TocLevel of sectioning layouts
257 /// Merge two different provides flags into one bit field record
259 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
261 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
265 /// convert page sides option to text 1 or 2
266 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);