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