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;
30 std::string latexparam;
37 /// List of semantically defined character style insets
38 typedef std::vector<CharStyle> CharStyles;
41 /// Stores the layout specification of a LyX document class.
44 /// The individual styles comprising the document class
45 typedef std::vector<LyXLayout_ptr> LayoutList;
46 /// Enumerate the paragraph styles.
47 typedef LayoutList::const_iterator const_iterator;
48 /// Construct a layout with default values. Actual values loaded later.
50 LyXTextClass(std::string const & = std::string(),
51 std::string const & = std::string(),
52 std::string const & = std::string(),
55 /// check whether the TeX class is available
56 bool isTeXClassAvailable() const;
58 /// paragraph styles begin iterator.
59 const_iterator begin() const { return layoutlist_.begin(); }
60 /// paragraph styles end iterator
61 const_iterator end() const { return layoutlist_.end(); }
63 /// Performs the read of the layout file.
64 bool Read(std::string const & filename, bool merge = false);
66 void readOutputType(LyXLex &);
68 void readTitleType(LyXLex &);
70 void readMaxCounter(LyXLex &);
72 void readClassOptions(LyXLex &);
74 void readCharStyle(LyXLex &, std::string const &);
76 void readFloat(LyXLex &);
78 void readCounter(LyXLex &);
80 bool hasLayout(std::string const & name) const;
83 LyXLayout_ptr const & operator[](std::string const & vname) const;
85 /// Sees to that the textclass structure has been loaded
87 /// Has this layout file been loaded yet?
88 bool loaded() const { return loaded_; }
90 /// the list of floats defined in the document class
92 /// the list of floats defined in the document class
93 FloatList const & floats() const;
94 /// The Counters present in this document class.
95 Counters & counters() const;
96 /// CharStyles of this doc class
97 CharStyles & charstyles() const { return charstylelist_; };
98 /// Retrieve element of name s:
99 CharStyles::iterator charstyle(std::string const & s) const;
101 std::string const & defaultLayoutName() const;
103 LyXLayout_ptr const & defaultLayout() const;
105 std::string const & name() const;
107 std::string const & latexname() const;
109 std::string const & description() const;
111 std::string const & opt_fontsize() const;
113 std::string const & opt_pagestyle() const;
115 std::string const & options() const;
117 std::string const & class_header() const;
119 std::string const & pagestyle() const;
121 std::string const & preamble() const;
123 /// Packages that are already loaded by the class
137 bool provides(Provides p) const;
140 unsigned int columns() const;
149 PageSides sides() const;
151 int secnumdepth() const;
153 int tocdepth() const;
155 /// Can be LaTeX, LinuxDoc, etc.
156 OutputType outputType() const;
159 LyXFont const & defaultfont() const;
161 /// Text that dictates how wide the left margin is on the screen
162 std::string const & leftmargin() const;
164 /// Text that dictates how wide the right margin is on the screen
165 std::string const & rightmargin() const;
167 /// The type of command used to produce a title
168 LYX_TITLE_LATEX_TYPES titletype() const;
169 /// The name of the title command
170 std::string const & titlename() const;
176 bool delete_layout(std::string const &);
178 bool do_readStyle(LyXLex &, LyXLayout &);
181 /// document class name
182 std::string latexname_;
183 /// document class description
184 std::string description_;
185 /// Specific class options
186 std::string opt_fontsize_;
188 std::string opt_pagestyle_;
190 std::string options_;
192 std::string pagestyle_;
194 std::string class_header_;
196 std::string defaultlayout_;
197 /// preamble text to support layout styles
198 std::string preamble_;
199 /// latex packages loaded by document class.
202 unsigned int columns_;
205 /// header depth to have numbering
207 /// header depth to appear in table of contents
209 /// Can be LaTeX, LinuxDoc, etc.
210 OutputType outputType_;
211 /** Base font. The paragraph and layout fonts are resolved against
212 this font. This has to be fully instantiated. Attributes
213 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
216 LyXFont defaultfont_;
217 /// Text that dictates how wide the left margin is on the screen
218 std::string leftmargin_;
220 /// Text that dictates how wide the right margin is on the screen
221 std::string rightmargin_;
223 /// The type of command used to produce a title
224 LYX_TITLE_LATEX_TYPES titletype_;
225 /// The name of the title command
226 std::string titlename_;
228 /// Paragraph styles used in this layout
229 LayoutList layoutlist_;
230 /// CharStyles available to this layout
231 mutable CharStyles charstylelist_;
233 /// available types of float, eg. figure, algorithm.
234 boost::shared_ptr<FloatList> floatlist_;
236 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
237 boost::shared_ptr<Counters> ctrs_;
239 /// Has this layout file been loaded yet?
240 mutable bool loaded_;
242 /// Is the TeX class available?
247 /// Merge two different provides flags into one bit field record
249 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
251 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
255 /// convert page sides option to text 1 or 2
256 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);