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
14 #include "lyxlayout_ptr_fwd.h"
16 #include <boost/shared_ptr.hpp>
24 namespace support { class FileName; }
36 docstring labelstring;
37 std::string decoration;
38 std::string latextype;
39 std::string latexname;
40 std::string latexparam;
47 /// List of semantically defined character style insets
48 typedef std::vector<InsetLayout> CharStyles;
50 /// List of inset layouts
51 typedef std::map<docstring, InsetLayout> InsetLayouts;
53 /// Stores the layout specification of a LyX document class.
56 /// The individual styles comprising the document class
57 typedef std::vector<LayoutPtr> LayoutList;
58 /// Enumerate the paragraph styles.
59 typedef LayoutList::const_iterator const_iterator;
60 /// Construct a layout with default values. Actual values loaded later.
62 TextClass(std::string const & = std::string(),
63 std::string const & = std::string(),
64 std::string const & = std::string(),
67 /// check whether the TeX class is available
68 bool isTeXClassAvailable() const;
70 /// paragraph styles begin iterator.
71 const_iterator begin() const { return layoutlist_.begin(); }
72 /// paragraph styles end iterator
73 const_iterator end() const { return layoutlist_.end(); }
75 /// Performs the read of the layout file.
76 bool read(support::FileName const & filename, bool merge = false);
78 void readOutputType(Lexer &);
80 void readTitleType(Lexer &);
82 void readMaxCounter(Lexer &);
84 void readClassOptions(Lexer &);
86 void readCharStyle(Lexer &, std::string const &);
88 void readInsetLayout(Lexer &, docstring const &);
90 void readFloat(Lexer &);
92 void readCounter(Lexer &);
94 bool hasLayout(docstring const & name) const;
97 LayoutPtr const & operator[](docstring const & vname) const;
99 /// Sees to that the textclass structure has been loaded
100 bool load(std::string const & path = std::string()) const;
101 /// Has this layout file been loaded yet?
102 bool loaded() const { return loaded_; }
104 /// the list of floats defined in the document class
105 FloatList & floats();
106 /// the list of floats defined in the document class
107 FloatList const & floats() const;
108 /// The Counters present in this document class.
109 Counters & counters() const;
110 /// CharStyles of this doc class
111 CharStyles & charstyles() const { return charstylelist_; };
112 /// Inset layouts of this doc class
113 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
115 InsetLayout const & insetlayout(docstring const & name) const;
117 docstring const & defaultLayoutName() const;
119 LayoutPtr const & defaultLayout() const;
121 std::string const & name() const;
123 docstring const & labelstring() const;
125 std::string const & latexname() const;
127 std::string const & description() const;
129 std::string const & opt_fontsize() const;
131 std::string const & opt_pagestyle() const;
133 std::string const & options() const;
135 std::string const & class_header() const;
137 std::string const & pagestyle() const;
139 docstring const & preamble() const;
141 /// is this feature already provided by the class?
142 bool provides(std::string const & p) const;
145 unsigned int columns() const;
154 PageSides sides() const;
156 int secnumdepth() const;
158 int tocdepth() const;
160 /// Can be LaTeX, DocBook, etc.
161 OutputType outputType() const;
164 Font const & defaultfont() const;
166 /// Text that dictates how wide the left margin is on the screen
167 docstring const & leftmargin() const;
169 /// Text that dictates how wide the right margin is on the screen
170 docstring const & rightmargin() const;
172 /// The type of command used to produce a title
173 LYX_TITLE_LATEX_TYPES titletype() const;
174 /// The name of the title command
175 std::string const & titlename() const;
179 /// The minimal TocLevel of sectioning layouts
180 int min_toclevel() const;
181 /// The maximal TocLevel of sectioning layouts
182 int max_toclevel() const;
183 /// returns true if the class has a ToC structure
184 bool hasTocLevels() const;
187 bool delete_layout(docstring const &);
189 bool do_readStyle(Lexer &, Layout &);
192 /// document class name
193 std::string latexname_;
194 /// document class description
195 std::string description_;
196 /// Specific class options
197 std::string opt_fontsize_;
199 std::string opt_pagestyle_;
201 std::string options_;
203 std::string pagestyle_;
205 std::string class_header_;
207 docstring defaultlayout_;
208 /// preamble text to support layout styles
210 /// latex packages loaded by document class.
211 std::set<std::string> provides_;
213 unsigned int columns_;
216 /// header depth to have numbering
218 /// header depth to appear in table of contents
220 /// Can be LaTeX, DocBook, etc.
221 OutputType outputType_;
222 /** Base font. The paragraph and layout fonts are resolved against
223 this font. This has to be fully instantiated. Attributes
224 Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
228 /// Text that dictates how wide the left margin is on the screen
229 docstring leftmargin_;
231 /// Text that dictates how wide the right margin is on the screen
232 docstring rightmargin_;
234 /// The type of command used to produce a title
235 LYX_TITLE_LATEX_TYPES titletype_;
236 /// The name of the title command
237 std::string titlename_;
239 /// Paragraph styles used in this layout
240 LayoutList layoutlist_;
241 /// CharStyles available to this layout
242 mutable CharStyles charstylelist_;
244 /// Input layouts available to this layout
245 mutable InsetLayouts insetlayoutlist_;
247 /// available types of float, eg. figure, algorithm.
248 boost::shared_ptr<FloatList> floatlist_;
250 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
251 boost::shared_ptr<Counters> counters_;
253 /// Has this layout file been loaded yet?
254 mutable bool loaded_;
256 /// Is the TeX class available?
259 /// The minimal TocLevel of sectioning layouts
261 /// The maximal TocLevel of sectioning layouts
266 /// convert page sides option to text 1 or 2
267 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);