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(),
67 bool texClassAvail = false);
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 ///Enum used with TextClass::read
79 BASECLASS, //>This is a base class, i.e., top-level layout file
80 MERGE, //>This is a file included in a layout file
81 MODULE //>This is a layout module
83 /// Performs the read of the layout file.
84 bool read(support::FileName const & filename, ReadType rt = BASECLASS);
86 void readOutputType(Lexer &);
88 void readTitleType(Lexer &);
90 void readMaxCounter(Lexer &);
92 void readClassOptions(Lexer &);
94 void readCharStyle(Lexer &, std::string const &);
96 void readInsetLayout(Lexer &, docstring const &);
98 void readFloat(Lexer &);
100 void readCounter(Lexer &);
102 bool hasLayout(docstring const & name) const;
105 LayoutPtr const & operator[](docstring const & vname) const;
107 /// Sees to that the textclass structure has been loaded
108 bool load(std::string const & path = std::string()) const;
109 /// Has this layout file been loaded yet?
110 bool loaded() const { return loaded_; }
112 /// the list of floats defined in the document class
113 FloatList & floats();
114 /// the list of floats defined in the document class
115 FloatList const & floats() const;
116 /// The Counters present in this document class.
117 Counters & counters() const;
118 /// CharStyles of this doc class
119 CharStyles & charstyles() const { return charstylelist_; };
120 /// Inset layouts of this doc class
121 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
123 InsetLayout const & insetlayout(docstring const & name) const;
125 docstring const & defaultLayoutName() const;
127 LayoutPtr const & defaultLayout() const;
129 std::string const & name() const;
131 docstring const & labelstring() const;
133 std::string const & latexname() const;
135 std::string const & description() const;
137 bool isModular() const { return modular_; }
138 /// Sets the layout as a modular one. There is never any
139 /// need to reset this.
140 void markAsModular() { modular_ = true; }
142 std::string const & opt_fontsize() const;
144 std::string const & opt_pagestyle() const;
146 std::string const & options() const;
148 std::string const & class_header() const;
150 std::string const & pagestyle() const;
152 docstring const & preamble() const;
154 /// is this feature already provided by the class?
155 bool provides(std::string const & p) const;
158 unsigned int columns() const;
167 PageSides sides() const;
169 int secnumdepth() const;
171 int tocdepth() const;
173 /// Can be LaTeX, DocBook, etc.
174 OutputType outputType() const;
177 Font const & defaultfont() const;
179 /// Text that dictates how wide the left margin is on the screen
180 docstring const & leftmargin() const;
182 /// Text that dictates how wide the right margin is on the screen
183 docstring const & rightmargin() const;
185 /// The type of command used to produce a title
186 LYX_TITLE_LATEX_TYPES titletype() const;
187 /// The name of the title command
188 std::string const & titlename() const;
192 /// The minimal TocLevel of sectioning layouts
193 int min_toclevel() const;
194 /// The maximal TocLevel of sectioning layouts
195 int max_toclevel() const;
196 /// returns true if the class has a ToC structure
197 bool hasTocLevels() const;
200 bool delete_layout(docstring const &);
202 bool do_readStyle(Lexer &, Layout &);
205 /// document class name
206 std::string latexname_;
207 /// document class description
208 std::string description_;
209 /// whether this is a modular layout, i.e., whether it has been
210 /// modified by loading of layout modules.
213 std::string opt_fontsize_;
215 std::string opt_pagestyle_;
216 /// Specific class options
217 std::string options_;
219 std::string pagestyle_;
221 std::string class_header_;
223 docstring defaultlayout_;
224 /// preamble text to support layout styles
226 /// latex packages loaded by document class.
227 std::set<std::string> provides_;
229 unsigned int columns_;
232 /// header depth to have numbering
234 /// header depth to appear in table of contents
236 /// Can be LaTeX, DocBook, etc.
237 OutputType outputType_;
238 /** Base font. The paragraph and layout fonts are resolved against
239 this font. This has to be fully instantiated. Attributes
240 Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
244 /// Text that dictates how wide the left margin is on the screen
245 docstring leftmargin_;
247 /// Text that dictates how wide the right margin is on the screen
248 docstring rightmargin_;
250 /// The type of command used to produce a title
251 LYX_TITLE_LATEX_TYPES titletype_;
252 /// The name of the title command
253 std::string titlename_;
255 /// Paragraph styles used in this layout
256 LayoutList layoutlist_;
257 /// CharStyles available to this layout
258 mutable CharStyles charstylelist_;
260 /// Input layouts available to this layout
261 mutable InsetLayouts insetlayoutlist_;
263 /// available types of float, eg. figure, algorithm.
264 boost::shared_ptr<FloatList> floatlist_;
266 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
267 boost::shared_ptr<Counters> counters_;
269 /// Has this layout file been loaded yet?
270 mutable bool loaded_;
272 /// Is the TeX class available?
275 /// The minimal TocLevel of sectioning layouts
277 /// The maximal TocLevel of sectioning layouts
282 /// convert page sides option to text 1 or 2
283 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);