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 "ColorCode.h"
15 #include "LayoutEnums.h"
16 #include "LayoutPtr.h"
18 #include "support/docstring.h"
20 #include <boost/shared_ptr.hpp>
28 namespace support { class FileName; }
41 docstring labelstring;
42 std::string decoration;
43 std::string latextype;
44 std::string latexname;
45 std::string latexparam;
58 /// List of inset layouts
59 typedef std::map<docstring, InsetLayout> InsetLayouts;
61 /// Stores the layout specification of a LyX document class.
64 /// The individual styles comprising the document class
65 typedef std::vector<LayoutPtr> LayoutList;
66 /// Enumerate the paragraph styles.
67 typedef LayoutList::const_iterator const_iterator;
68 /// Construct a layout with default values. Actual values loaded later.
70 TextClass(std::string const & = std::string(),
71 std::string const & = std::string(),
72 std::string const & = std::string(),
73 bool texClassAvail = false);
75 /// check whether the TeX class is available
76 bool isTeXClassAvailable() const;
78 /// paragraph styles begin iterator.
79 const_iterator begin() const { return layoutlist_.begin(); }
80 /// paragraph styles end iterator
81 const_iterator end() const { return layoutlist_.end(); }
83 ///Enum used with TextClass::read
85 BASECLASS, //>This is a base class, i.e., top-level layout file
86 MERGE, //>This is a file included in a layout file
87 MODULE //>This is a layout module
89 /// Performs the read of the layout file.
90 bool read(support::FileName const & filename, ReadType rt = BASECLASS);
92 void readOutputType(Lexer &);
94 void readTitleType(Lexer &);
96 void readMaxCounter(Lexer &);
98 void readClassOptions(Lexer &);
100 void readCharStyle(Lexer &, std::string const &);
102 void readInsetLayout(Lexer &, docstring const &);
104 void readFloat(Lexer &);
106 void readCounter(Lexer &);
108 bool hasLayout(docstring const & name) const;
111 LayoutPtr const & operator[](docstring const & vname) const;
113 /// Sees to that the textclass structure has been loaded
114 bool load(std::string const & path = std::string()) const;
115 /// Has this layout file been loaded yet?
116 bool loaded() const { return loaded_; }
118 /// the list of floats defined in the document class
119 FloatList & floats();
120 /// the list of floats defined in the document class
121 FloatList const & floats() const;
122 /// The Counters present in this document class.
123 Counters & counters() const;
124 /// Inset layouts of this doc class
125 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
127 InsetLayout const & insetlayout(docstring const & name) const;
129 docstring const & defaultLayoutName() const;
131 LayoutPtr const & defaultLayout() const;
133 std::string const & name() const;
135 docstring const & labelstring() const;
137 std::string const & latexname() const;
139 std::string const & description() const;
141 bool isModular() const { return modular_; }
142 /// Sets the layout as a modular one. There is never any
143 /// need to reset this.
144 void markAsModular() { modular_ = true; }
146 std::string const & opt_fontsize() const;
148 std::string const & opt_pagestyle() const;
150 std::string const & options() const;
152 std::string const & class_header() const;
154 std::string const & pagestyle() const;
156 docstring const & preamble() const;
158 /// is this feature already provided by the class?
159 bool provides(std::string const & p) const;
162 unsigned int columns() const;
171 PageSides sides() const;
173 int secnumdepth() const;
175 int tocdepth() const;
177 /// Can be LaTeX, DocBook, etc.
178 OutputType outputType() const;
181 FontInfo const & defaultfont() const;
183 /// Text that dictates how wide the left margin is on the screen
184 docstring const & leftmargin() const;
186 /// Text that dictates how wide the right margin is on the screen
187 docstring const & rightmargin() const;
189 /// The type of command used to produce a title
190 TitleLatexType titletype() const;
191 /// The name of the title command
192 std::string const & titlename() const;
196 /// The minimal TocLevel of sectioning layouts
197 int min_toclevel() const;
198 /// The maximal TocLevel of sectioning layouts
199 int max_toclevel() const;
200 /// returns true if the class has a ToC structure
201 bool hasTocLevels() const;
204 bool delete_layout(docstring const &);
206 bool do_readStyle(Lexer &, Layout &);
209 /// document class name
210 std::string latexname_;
211 /// document class description
212 std::string description_;
213 /// whether this is a modular layout, i.e., whether it has been
214 /// modified by loading of layout modules.
217 std::string opt_fontsize_;
219 std::string opt_pagestyle_;
220 /// Specific class options
221 std::string options_;
223 std::string pagestyle_;
225 std::string class_header_;
227 docstring defaultlayout_;
228 /// preamble text to support layout styles
230 /// latex packages loaded by document class.
231 std::set<std::string> provides_;
233 unsigned int columns_;
236 /// header depth to have numbering
238 /// header depth to appear in table of contents
240 /// Can be LaTeX, DocBook, etc.
241 OutputType outputType_;
242 /** Base font. The paragraph and layout fonts are resolved against
243 this font. This has to be fully instantiated. Attributes
244 FONT_INHERIT, FONT_IGNORE, and FONT_TOGGLE are
247 FontInfo defaultfont_;
248 /// Text that dictates how wide the left margin is on the screen
249 docstring leftmargin_;
251 /// Text that dictates how wide the right margin is on the screen
252 docstring rightmargin_;
254 /// The type of command used to produce a title
255 TitleLatexType titletype_;
256 /// The name of the title command
257 std::string titlename_;
259 /// Paragraph styles used in this layout
260 LayoutList layoutlist_;
262 /// Input layouts available to this layout
263 mutable InsetLayouts insetlayoutlist_;
265 /// available types of float, eg. figure, algorithm.
266 boost::shared_ptr<FloatList> floatlist_;
268 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
269 boost::shared_ptr<Counters> counters_;
271 /// Has this layout file been loaded yet?
272 mutable bool loaded_;
274 /// Is the TeX class available?
277 /// The minimal TocLevel of sectioning layouts
279 /// The maximal TocLevel of sectioning layouts
284 /// convert page sides option to text 1 or 2
285 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);
287 /** Shared pointer for possibly modular layout. Needed so that paste,
288 * for example, will still be able to retain the pointer, even when
289 * the buffer itself is closed.
291 typedef boost::shared_ptr<TextClass> TextClassPtr;