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 & class_header() const;
116 std::string const & pagestyle() const;
118 std::string const & preamble() const;
120 /// Packages that are already loaded by the class
134 bool provides(Provides p) const;
137 unsigned int columns() const;
146 PageSides sides() const;
148 int secnumdepth() const;
150 int tocdepth() const;
152 /// Can be LaTeX, LinuxDoc, etc.
153 OutputType outputType() const;
156 LyXFont const & defaultfont() const;
158 /// Text that dictates how wide the left margin is on the screen
159 std::string const & leftmargin() const;
161 /// Text that dictates how wide the right margin is on the screen
162 std::string const & rightmargin() const;
164 /// The type of command used to produce a title
165 LYX_TITLE_LATEX_TYPES titletype() const;
166 /// The name of the title command
167 std::string const & titlename() const;
173 bool delete_layout(std::string const &);
175 bool do_readStyle(LyXLex &, LyXLayout &);
178 /// document class name
179 std::string latexname_;
180 /// document class description
181 std::string description_;
182 /// Specific class options
183 std::string opt_fontsize_;
185 std::string opt_pagestyle_;
187 std::string options_;
189 std::string pagestyle_;
191 std::string class_header_;
193 std::string defaultlayout_;
194 /// preamble text to support layout styles
195 std::string preamble_;
196 /// latex packages loaded by document class.
199 unsigned int columns_;
202 /// header depth to have numbering
204 /// header depth to appear in table of contents
206 /// Can be LaTeX, LinuxDoc, etc.
207 OutputType outputType_;
208 /** Base font. The paragraph and layout fonts are resolved against
209 this font. This has to be fully instantiated. Attributes
210 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
213 LyXFont defaultfont_;
214 /// Text that dictates how wide the left margin is on the screen
215 std::string leftmargin_;
217 /// Text that dictates how wide the right margin is on the screen
218 std::string rightmargin_;
220 /// The type of command used to produce a title
221 LYX_TITLE_LATEX_TYPES titletype_;
222 /// The name of the title command
223 std::string titlename_;
225 /// Paragraph styles used in this layout
226 LayoutList layoutlist_;
227 /// CharStyles available to this layout
228 mutable CharStyles charstylelist_;
230 /// available types of float, eg. figure, algorithm.
231 boost::shared_ptr<FloatList> floatlist_;
233 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
234 boost::shared_ptr<Counters> ctrs_;
236 /// Has this layout file been loaded yet?
239 /// Is the TeX class available?
244 /// Merge two different provides flags into one bit field record
246 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
248 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
252 /// convert page sides option to text 1 or 2
253 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);