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
88 /// the list of floats defined in the document class
90 /// the list of floats defined in the document class
91 FloatList const & floats() const;
92 /// The Counters present in this document class.
93 Counters & counters() const;
94 /// CharStyles of this doc class
95 CharStyles & charstyles() const { return charstylelist_; };
96 /// Retrieve element of name s:
97 CharStyles::iterator charstyle(std::string const & s) const;
99 std::string const & defaultLayoutName() const;
101 LyXLayout_ptr const & defaultLayout() const;
103 std::string const & name() const;
105 std::string const & latexname() const;
107 std::string const & description() const;
109 std::string const & opt_fontsize() const;
111 std::string const & opt_pagestyle() const;
113 std::string const & options() const;
115 std::string const & class_header() const;
117 std::string const & pagestyle() const;
119 std::string const & preamble() const;
121 /// Packages that are already loaded by the class
135 bool provides(Provides p) const;
138 unsigned int columns() const;
147 PageSides sides() const;
149 int secnumdepth() const;
151 int tocdepth() const;
153 /// Can be LaTeX, LinuxDoc, etc.
154 OutputType outputType() const;
157 LyXFont const & defaultfont() const;
159 /// Text that dictates how wide the left margin is on the screen
160 std::string const & leftmargin() const;
162 /// Text that dictates how wide the right margin is on the screen
163 std::string const & rightmargin() const;
165 /// The type of command used to produce a title
166 LYX_TITLE_LATEX_TYPES titletype() const;
167 /// The name of the title command
168 std::string const & titlename() const;
174 bool delete_layout(std::string const &);
176 bool do_readStyle(LyXLex &, LyXLayout &);
179 /// document class name
180 std::string latexname_;
181 /// document class description
182 std::string description_;
183 /// Specific class options
184 std::string opt_fontsize_;
186 std::string opt_pagestyle_;
188 std::string options_;
190 std::string pagestyle_;
192 std::string class_header_;
194 std::string defaultlayout_;
195 /// preamble text to support layout styles
196 std::string preamble_;
197 /// latex packages loaded by document class.
200 unsigned int columns_;
203 /// header depth to have numbering
205 /// header depth to appear in table of contents
207 /// Can be LaTeX, LinuxDoc, etc.
208 OutputType outputType_;
209 /** Base font. The paragraph and layout fonts are resolved against
210 this font. This has to be fully instantiated. Attributes
211 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
214 LyXFont defaultfont_;
215 /// Text that dictates how wide the left margin is on the screen
216 std::string leftmargin_;
218 /// Text that dictates how wide the right margin is on the screen
219 std::string rightmargin_;
221 /// The type of command used to produce a title
222 LYX_TITLE_LATEX_TYPES titletype_;
223 /// The name of the title command
224 std::string titlename_;
226 /// Paragraph styles used in this layout
227 LayoutList layoutlist_;
228 /// CharStyles available to this layout
229 mutable CharStyles charstylelist_;
231 /// available types of float, eg. figure, algorithm.
232 boost::shared_ptr<FloatList> floatlist_;
234 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
235 boost::shared_ptr<Counters> ctrs_;
237 /// Has this layout file been loaded yet?
240 /// Is the TeX class available?
245 /// Merge two different provides flags into one bit field record
247 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
249 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
253 /// convert page sides option to text 1 or 2
254 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);