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>
28 std::string latextype;
29 std::string latexname;
36 /// List of semantically defined character style insets
37 typedef std::vector<CharStyle> CharStyles;
40 /// Stores the layout specification of a LyX document class.
43 /// The individual styles comprising the document class
44 typedef std::vector<LyXLayout_ptr> LayoutList;
45 /// Enumerate the paragraph styles.
46 typedef LayoutList::const_iterator const_iterator;
47 /// Construct a layout with default values. Actual values loaded later.
49 LyXTextClass(std::string const & = std::string(),
50 std::string const & = std::string(),
51 std::string const & = std::string(),
54 /// check whether the TeX class is available
55 bool isTeXClassAvailable() const;
57 /// paragraph styles begin iterator.
58 const_iterator begin() const { return layoutlist_.begin(); }
59 /// paragraph styles end iterator
60 const_iterator end() const { return layoutlist_.end(); }
62 /// Performs the read of the layout file.
63 bool Read(std::string const & filename, bool merge = false);
65 void readOutputType(LyXLex &);
67 void readTitleType(LyXLex &);
69 void readMaxCounter(LyXLex &);
71 void readClassOptions(LyXLex &);
73 void readCharStyle(LyXLex &, std::string const &);
75 void readFloat(LyXLex &);
77 void readCounter(LyXLex &);
79 bool hasLayout(std::string const & name) const;
82 LyXLayout_ptr const & operator[](std::string const & vname) const;
84 /// Sees to that the textclass structure has been loaded
87 /// the list of floats defined in the document class
89 /// the list of floats defined in the document class
90 FloatList const & floats() const;
91 /// The Counters present in this document class.
92 Counters & counters() const;
93 /// CharStyles of this doc class
94 CharStyles & charstyles() const { return charstylelist_; };
95 /// Retrieve element of name s:
96 CharStyles::iterator charstyle(std::string const & s) const;
98 std::string const & defaultLayoutName() const;
100 LyXLayout_ptr const & defaultLayout() const;
102 std::string const & name() const;
104 std::string const & latexname() const;
106 std::string const & description() const;
108 std::string const & opt_fontsize() const;
110 std::string const & opt_pagestyle() const;
112 std::string const & options() const;
114 std::string const & pagestyle() const;
116 std::string const & preamble() const;
118 /// Packages that are already loaded by the class
132 bool provides(Provides p) const;
135 unsigned int columns() const;
144 PageSides sides() const;
146 int secnumdepth() const;
148 int tocdepth() const;
150 /// Can be LaTeX, LinuxDoc, etc.
151 OutputType outputType() const;
154 LyXFont const & defaultfont() const;
156 /// Text that dictates how wide the left margin is on the screen
157 std::string const & leftmargin() const;
159 /// Text that dictates how wide the right margin is on the screen
160 std::string const & rightmargin() const;
162 /// The type of command used to produce a title
163 LYX_TITLE_LATEX_TYPES titletype() const;
164 /// The name of the title command
165 std::string const & titlename() const;
171 bool delete_layout(std::string const &);
173 bool do_readStyle(LyXLex &, LyXLayout &);
176 /// document class name
177 std::string latexname_;
178 /// document class description
179 std::string description_;
180 /// Specific class options
181 std::string opt_fontsize_;
183 std::string opt_pagestyle_;
185 std::string options_;
187 std::string pagestyle_;
189 std::string defaultlayout_;
190 /// preamble text to support layout styles
191 std::string preamble_;
192 /// latex packages loaded by document class.
195 unsigned int columns_;
198 /// header depth to have numbering
200 /// header depth to appear in table of contents
202 /// Can be LaTeX, LinuxDoc, etc.
203 OutputType outputType_;
204 /** Base font. The paragraph and layout fonts are resolved against
205 this font. This has to be fully instantiated. Attributes
206 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
209 LyXFont defaultfont_;
210 /// Text that dictates how wide the left margin is on the screen
211 std::string leftmargin_;
213 /// Text that dictates how wide the right margin is on the screen
214 std::string rightmargin_;
216 /// The type of command used to produce a title
217 LYX_TITLE_LATEX_TYPES titletype_;
218 /// The name of the title command
219 std::string titlename_;
221 /// Paragraph styles used in this layout
222 LayoutList layoutlist_;
223 /// CharStyles available to this layout
224 mutable CharStyles charstylelist_;
226 /// available types of float, eg. figure, algorithm.
227 boost::shared_ptr<FloatList> floatlist_;
229 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
230 boost::shared_ptr<Counters> ctrs_;
232 /// Has this layout file been loaded yet?
235 /// Is the TeX class available?
240 /// Merge two different provides flags into one bit field record
242 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
244 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
248 /// convert page sides option to text 1 or 2
249 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);