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"
15 #include "lyxlayout_ptr_fwd.h"
17 #include "support/types.h"
19 #include <boost/shared_ptr.hpp>
27 /// Stores the layout specification of a LyX document class.
30 /// The individual styles comprising the document class
31 typedef std::vector<LyXLayout_ptr> LayoutList;
32 /// Enumerate the paragraph styles.
33 typedef LayoutList::const_iterator const_iterator;
34 /// Construct a layout with default values. Actual values loaded later.
36 LyXTextClass(string const & = string(),
37 string const & = string(),
38 string const & = string(),
41 /// check whether the TeX class is available
42 bool isTeXClassAvailable() const;
44 /// paragraph styles begin iterator.
45 const_iterator begin() const { return layoutlist_.begin(); }
46 /// paragraph styles end iterator
47 const_iterator end() const { return layoutlist_.end(); }
49 /// Performs the read of the layout file.
50 bool Read(string const & filename, bool merge = false);
52 void readOutputType(LyXLex &);
54 void readTitleType(LyXLex &);
56 void readMaxCounter(LyXLex &);
58 void readClassOptions(LyXLex &);
60 void readFloat(LyXLex &);
62 void readCounter(LyXLex &);
64 bool hasLayout(string const & name) const;
67 LyXLayout_ptr const & operator[](string const & vname) const;
69 /// Sees to that the textclass structure has been loaded
72 /// the list of floats defined in the document class
74 /// the list of floats defined in the document class
75 FloatList const & floats() const;
76 /// The Counters present in this document class.
77 Counters & counters() const;
79 string const & defaultLayoutName() const;
81 LyXLayout_ptr const & defaultLayout() const;
83 string const & name() const;
85 string const & latexname() const;
87 string const & description() const;
89 string const & opt_fontsize() const;
91 string const & opt_pagestyle() const;
93 string const & options() const;
95 string const & pagestyle() const;
97 string const & preamble() const;
99 /// Packages that are already loaded by the class
113 bool provides(Provides p) const;
116 unsigned int columns() const;
125 PageSides sides() const;
127 int secnumdepth() const;
129 int tocdepth() const;
131 /// Can be LaTeX, LinuxDoc, etc.
132 OutputType outputType() const;
135 LyXFont const & defaultfont() const;
137 /// Text that dictates how wide the left margin is on the screen
138 string const & leftmargin() const;
140 /// Text that dictates how wide the right margin is on the screen
141 string const & rightmargin() const;
143 int maxcounter() const;
145 /// The type of command used to produce a title
146 LYX_TITLE_LATEX_TYPES titletype() const;
147 /// The name of the title command
148 string const & titlename() const;
154 bool delete_layout(string const &);
156 bool do_readStyle(LyXLex &, LyXLayout &);
159 /// document class name
161 /// document class description
163 /// Specific class options
164 string opt_fontsize_;
166 string opt_pagestyle_;
172 string defaultlayout_;
173 /// preamble text to support layout styles
175 /// latex packages loaded by document class.
178 unsigned int columns_;
181 /// header depth to have numbering
183 /// header depth to appear in table of contents
185 /// Can be LaTeX, LinuxDoc, etc.
186 OutputType outputType_;
187 /** Base font. The paragraph and layout fonts are resolved against
188 this font. This has to be fully instantiated. Attributes
189 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
192 LyXFont defaultfont_;
193 /// Text that dictates how wide the left margin is on the screen
196 /// Text that dictates how wide the right margin is on the screen
198 /// highest header level used in this layout.
199 int maxcounter_; // add approp. signedness
201 /// The type of command used to produce a title
202 LYX_TITLE_LATEX_TYPES titletype_;
203 /// The name of the title command
206 /// Paragraph styles used in this layout
207 LayoutList layoutlist_;
209 /// available types of float, eg. figure, algorithm.
210 boost::shared_ptr<FloatList> floatlist_;
212 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
213 boost::shared_ptr<Counters> ctrs_;
215 /// Has this layout file been loaded yet?
218 /// Is the TeX class available?
223 /// Merge two different provides flags into one bit field record
225 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
227 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
231 /// convert page sides option to text 1 or 2
232 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);