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>
18 #include "support/std_string.h"
25 /// Stores the layout specification of a LyX document class.
28 /// The individual styles comprising the document class
29 typedef std::vector<LyXLayout_ptr> LayoutList;
30 /// Enumerate the paragraph styles.
31 typedef LayoutList::const_iterator const_iterator;
32 /// Construct a layout with default values. Actual values loaded later.
34 LyXTextClass(string const & = string(),
35 string const & = string(),
36 string const & = string(),
39 /// check whether the TeX class is available
40 bool isTeXClassAvailable() const;
42 /// paragraph styles begin iterator.
43 const_iterator begin() const { return layoutlist_.begin(); }
44 /// paragraph styles end iterator
45 const_iterator end() const { return layoutlist_.end(); }
47 /// Performs the read of the layout file.
48 bool Read(string const & filename, bool merge = false);
50 void readOutputType(LyXLex &);
52 void readTitleType(LyXLex &);
54 void readMaxCounter(LyXLex &);
56 void readClassOptions(LyXLex &);
58 void readFloat(LyXLex &);
60 void readCounter(LyXLex &);
62 bool hasLayout(string const & name) const;
65 LyXLayout_ptr const & operator[](string const & vname) const;
67 /// Sees to that the textclass structure has been loaded
70 /// the list of floats defined in the document class
72 /// the list of floats defined in the document class
73 FloatList const & floats() const;
74 /// The Counters present in this document class.
75 Counters & counters() const;
77 string const & defaultLayoutName() const;
79 LyXLayout_ptr const & defaultLayout() const;
81 string const & name() const;
83 string const & latexname() const;
85 string const & description() const;
87 string const & opt_fontsize() const;
89 string const & opt_pagestyle() const;
91 string const & options() const;
93 string const & pagestyle() const;
95 string const & preamble() const;
97 /// Packages that are already loaded by the class
111 bool provides(Provides p) const;
114 unsigned int columns() const;
123 PageSides sides() const;
125 int secnumdepth() const;
127 int tocdepth() const;
129 /// Can be LaTeX, LinuxDoc, etc.
130 OutputType outputType() const;
133 LyXFont const & defaultfont() const;
135 /// Text that dictates how wide the left margin is on the screen
136 string const & leftmargin() const;
138 /// Text that dictates how wide the right margin is on the screen
139 string const & rightmargin() const;
141 int maxcounter() const;
143 /// The type of command used to produce a title
144 LYX_TITLE_LATEX_TYPES titletype() const;
145 /// The name of the title command
146 string const & titlename() const;
152 bool delete_layout(string const &);
154 bool do_readStyle(LyXLex &, LyXLayout &);
157 /// document class name
159 /// document class description
161 /// Specific class options
162 string opt_fontsize_;
164 string opt_pagestyle_;
170 string defaultlayout_;
171 /// preamble text to support layout styles
173 /// latex packages loaded by document class.
176 unsigned int columns_;
179 /// header depth to have numbering
181 /// header depth to appear in table of contents
183 /// Can be LaTeX, LinuxDoc, etc.
184 OutputType outputType_;
185 /** Base font. The paragraph and layout fonts are resolved against
186 this font. This has to be fully instantiated. Attributes
187 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
190 LyXFont defaultfont_;
191 /// Text that dictates how wide the left margin is on the screen
194 /// Text that dictates how wide the right margin is on the screen
196 /// highest header level used in this layout.
197 int maxcounter_; // add approp. signedness
199 /// The type of command used to produce a title
200 LYX_TITLE_LATEX_TYPES titletype_;
201 /// The name of the title command
204 /// Paragraph styles used in this layout
205 LayoutList layoutlist_;
207 /// available types of float, eg. figure, algorithm.
208 boost::shared_ptr<FloatList> floatlist_;
210 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
211 boost::shared_ptr<Counters> ctrs_;
213 /// Has this layout file been loaded yet?
216 /// Is the TeX class available?
221 /// Merge two different provides flags into one bit field record
223 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
225 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
229 /// convert page sides option to text 1 or 2
230 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);