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
15 #include "lyxlayout_ptr_fwd.h"
17 #include <boost/shared_ptr.hpp>
25 namespace support { class FileName; }
37 docstring labelstring;
38 std::string decoration;
39 std::string latextype;
40 std::string latexname;
41 std::string latexparam;
49 /// List of semantically defined character style insets
50 typedef std::vector<InsetLayout> CharStyles;
52 /// List of inset layouts
53 typedef std::map<docstring, InsetLayout> InsetLayouts;
55 /// Stores the layout specification of a LyX document class.
58 /// The individual styles comprising the document class
59 typedef std::vector<LayoutPtr> LayoutList;
60 /// Enumerate the paragraph styles.
61 typedef LayoutList::const_iterator const_iterator;
62 /// Construct a layout with default values. Actual values loaded later.
64 TextClass(std::string const & = std::string(),
65 std::string const & = std::string(),
66 std::string const & = std::string(),
69 /// check whether the TeX class is available
70 bool isTeXClassAvailable() const;
72 /// paragraph styles begin iterator.
73 const_iterator begin() const { return layoutlist_.begin(); }
74 /// paragraph styles end iterator
75 const_iterator end() const { return layoutlist_.end(); }
77 /// Performs the read of the layout file.
78 bool read(support::FileName const & filename, bool merge = false);
80 void readOutputType(Lexer &);
82 void readTitleType(Lexer &);
84 void readMaxCounter(Lexer &);
86 void readClassOptions(Lexer &);
88 void readCharStyle(Lexer &, std::string const &);
90 void readInsetLayout(Lexer &, docstring const &);
92 void readFloat(Lexer &);
94 void readCounter(Lexer &);
96 bool hasLayout(docstring const & name) const;
99 LayoutPtr const & operator[](docstring const & vname) const;
101 /// Sees to that the textclass structure has been loaded
102 bool load(std::string const & path = std::string()) const;
103 /// Has this layout file been loaded yet?
104 bool loaded() const { return loaded_; }
106 /// the list of floats defined in the document class
107 FloatList & floats();
108 /// the list of floats defined in the document class
109 FloatList const & floats() const;
110 /// The Counters present in this document class.
111 Counters & counters() const;
112 /// CharStyles of this doc class
113 CharStyles & charstyles() const { return charstylelist_; };
114 /// Inset layouts of this doc class
115 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
117 InsetLayout const & insetlayout(docstring const & name) const;
119 docstring const & defaultLayoutName() const;
121 LayoutPtr const & defaultLayout() const;
123 std::string const & name() const;
125 docstring const & labelstring() const;
127 std::string const & latexname() const;
129 std::string const & description() const;
131 std::string const & opt_fontsize() const;
133 std::string const & opt_pagestyle() const;
135 std::string const & options() const;
137 std::string const & class_header() const;
139 std::string const & pagestyle() const;
141 docstring const & preamble() const;
143 /// is this feature already provided by the class?
144 bool provides(std::string const & p) const;
147 unsigned int columns() const;
156 PageSides sides() const;
158 int secnumdepth() const;
160 int tocdepth() const;
162 /// Can be LaTeX, DocBook, etc.
163 OutputType outputType() const;
166 Font const & defaultfont() const;
168 /// Text that dictates how wide the left margin is on the screen
169 docstring const & leftmargin() const;
171 /// Text that dictates how wide the right margin is on the screen
172 docstring const & rightmargin() const;
174 /// The type of command used to produce a title
175 LYX_TITLE_LATEX_TYPES titletype() const;
176 /// The name of the title command
177 std::string const & titlename() const;
181 /// The minimal TocLevel of sectioning layouts
182 int min_toclevel() const;
183 /// The maximal TocLevel of sectioning layouts
184 int max_toclevel() const;
185 /// returns true if the class has a ToC structure
186 bool hasTocLevels() const;
189 bool delete_layout(docstring const &);
191 bool do_readStyle(Lexer &, Layout &);
194 /// document class name
195 std::string latexname_;
196 /// document class description
197 std::string description_;
198 /// Specific class options
199 std::string opt_fontsize_;
201 std::string opt_pagestyle_;
203 std::string options_;
205 std::string pagestyle_;
207 std::string class_header_;
209 docstring defaultlayout_;
210 /// preamble text to support layout styles
212 /// latex packages loaded by document class.
213 std::set<std::string> provides_;
215 unsigned int columns_;
218 /// header depth to have numbering
220 /// header depth to appear in table of contents
222 /// Can be LaTeX, DocBook, etc.
223 OutputType outputType_;
224 /** Base font. The paragraph and layout fonts are resolved against
225 this font. This has to be fully instantiated. Attributes
226 Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
230 /// Text that dictates how wide the left margin is on the screen
231 docstring leftmargin_;
233 /// Text that dictates how wide the right margin is on the screen
234 docstring rightmargin_;
236 /// The type of command used to produce a title
237 LYX_TITLE_LATEX_TYPES titletype_;
238 /// The name of the title command
239 std::string titlename_;
241 /// Paragraph styles used in this layout
242 LayoutList layoutlist_;
243 /// CharStyles available to this layout
244 mutable CharStyles charstylelist_;
246 /// Input layouts available to this layout
247 mutable InsetLayouts insetlayoutlist_;
249 /// available types of float, eg. figure, algorithm.
250 boost::shared_ptr<FloatList> floatlist_;
252 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
253 boost::shared_ptr<Counters> counters_;
255 /// Has this layout file been loaded yet?
256 mutable bool loaded_;
258 /// Is the TeX class available?
261 /// The minimal TocLevel of sectioning layouts
263 /// The maximal TocLevel of sectioning layouts
268 /// convert page sides option to text 1 or 2
269 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);