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 "LayoutEnums.h"
16 #include "lyxlayout_ptr_fwd.h"
18 #include <boost/shared_ptr.hpp>
26 namespace support { class FileName; }
39 docstring labelstring;
40 std::string decoration;
41 std::string latextype;
42 std::string latexname;
43 std::string latexparam;
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 /// Inset layouts of this doc class
119 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
121 InsetLayout const & insetlayout(docstring const & name) const;
123 docstring const & defaultLayoutName() const;
125 LayoutPtr const & defaultLayout() const;
127 std::string const & name() const;
129 docstring const & labelstring() const;
131 std::string const & latexname() const;
133 std::string const & description() const;
135 bool isModular() const { return modular_; }
136 /// Sets the layout as a modular one. There is never any
137 /// need to reset this.
138 void markAsModular() { modular_ = true; }
140 std::string const & opt_fontsize() const;
142 std::string const & opt_pagestyle() const;
144 std::string const & options() const;
146 std::string const & class_header() const;
148 std::string const & pagestyle() const;
150 docstring const & preamble() const;
152 /// is this feature already provided by the class?
153 bool provides(std::string const & p) const;
156 unsigned int columns() const;
165 PageSides sides() const;
167 int secnumdepth() const;
169 int tocdepth() const;
171 /// Can be LaTeX, DocBook, etc.
172 OutputType outputType() const;
175 Font const & defaultfont() const;
177 /// Text that dictates how wide the left margin is on the screen
178 docstring const & leftmargin() const;
180 /// Text that dictates how wide the right margin is on the screen
181 docstring const & rightmargin() const;
183 /// The type of command used to produce a title
184 TitleLatexType titletype() const;
185 /// The name of the title command
186 std::string const & titlename() const;
190 /// The minimal TocLevel of sectioning layouts
191 int min_toclevel() const;
192 /// The maximal TocLevel of sectioning layouts
193 int max_toclevel() const;
194 /// returns true if the class has a ToC structure
195 bool hasTocLevels() const;
198 bool delete_layout(docstring const &);
200 bool do_readStyle(Lexer &, Layout &);
203 /// document class name
204 std::string latexname_;
205 /// document class description
206 std::string description_;
207 /// whether this is a modular layout, i.e., whether it has been
208 /// modified by loading of layout modules.
211 std::string opt_fontsize_;
213 std::string opt_pagestyle_;
214 /// Specific class options
215 std::string options_;
217 std::string pagestyle_;
219 std::string class_header_;
221 docstring defaultlayout_;
222 /// preamble text to support layout styles
224 /// latex packages loaded by document class.
225 std::set<std::string> provides_;
227 unsigned int columns_;
230 /// header depth to have numbering
232 /// header depth to appear in table of contents
234 /// Can be LaTeX, DocBook, etc.
235 OutputType outputType_;
236 /** Base font. The paragraph and layout fonts are resolved against
237 this font. This has to be fully instantiated. Attributes
238 Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
242 /// Text that dictates how wide the left margin is on the screen
243 docstring leftmargin_;
245 /// Text that dictates how wide the right margin is on the screen
246 docstring rightmargin_;
248 /// The type of command used to produce a title
249 TitleLatexType titletype_;
250 /// The name of the title command
251 std::string titlename_;
253 /// Paragraph styles used in this layout
254 LayoutList layoutlist_;
256 /// Input layouts available to this layout
257 mutable InsetLayouts insetlayoutlist_;
259 /// available types of float, eg. figure, algorithm.
260 boost::shared_ptr<FloatList> floatlist_;
262 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
263 boost::shared_ptr<Counters> counters_;
265 /// Has this layout file been loaded yet?
266 mutable bool loaded_;
268 /// Is the TeX class available?
271 /// The minimal TocLevel of sectioning layouts
273 /// The maximal TocLevel of sectioning layouts
278 /// convert page sides option to text 1 or 2
279 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);
281 /** Shared pointer for possibly modular layout. Needed so that paste,
282 * for example, will still be able to retain the pointer, even when
283 * the buffer itself is closed.
285 typedef boost::shared_ptr<TextClass> TextClassPtr;