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;
53 /// List of inset layouts
54 typedef std::map<docstring, InsetLayout> InsetLayouts;
56 /// Stores the layout specification of a LyX document class.
59 /// The individual styles comprising the document class
60 typedef std::vector<LayoutPtr> LayoutList;
61 /// Enumerate the paragraph styles.
62 typedef LayoutList::const_iterator const_iterator;
63 /// Construct a layout with default values. Actual values loaded later.
65 TextClass(std::string const & = std::string(),
66 std::string const & = std::string(),
67 std::string const & = std::string(),
68 bool texClassAvail = false);
70 /// check whether the TeX class is available
71 bool isTeXClassAvailable() const;
73 /// paragraph styles begin iterator.
74 const_iterator begin() const { return layoutlist_.begin(); }
75 /// paragraph styles end iterator
76 const_iterator end() const { return layoutlist_.end(); }
78 ///Enum used with TextClass::read
80 BASECLASS, //>This is a base class, i.e., top-level layout file
81 MERGE, //>This is a file included in a layout file
82 MODULE //>This is a layout module
84 /// Performs the read of the layout file.
85 bool read(support::FileName const & filename, ReadType rt = BASECLASS);
87 void readOutputType(Lexer &);
89 void readTitleType(Lexer &);
91 void readMaxCounter(Lexer &);
93 void readClassOptions(Lexer &);
95 void readCharStyle(Lexer &, std::string const &);
97 void readInsetLayout(Lexer &, docstring const &);
99 void readFloat(Lexer &);
101 void readCounter(Lexer &);
103 bool hasLayout(docstring const & name) const;
106 LayoutPtr const & operator[](docstring const & vname) const;
108 /// Sees to that the textclass structure has been loaded
109 bool load(std::string const & path = std::string()) const;
110 /// Has this layout file been loaded yet?
111 bool loaded() const { return loaded_; }
113 /// the list of floats defined in the document class
114 FloatList & floats();
115 /// the list of floats defined in the document class
116 FloatList const & floats() const;
117 /// The Counters present in this document class.
118 Counters & counters() const;
119 /// Inset layouts of this doc class
120 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
122 InsetLayout const & insetlayout(docstring const & name) const;
124 docstring const & defaultLayoutName() const;
126 LayoutPtr const & defaultLayout() const;
128 std::string const & name() const;
130 docstring const & labelstring() const;
132 std::string const & latexname() const;
134 std::string const & description() const;
136 bool isModular() const { return modular_; }
137 /// Sets the layout as a modular one. There is never any
138 /// need to reset this.
139 void markAsModular() { modular_ = true; }
141 std::string const & opt_fontsize() const;
143 std::string const & opt_pagestyle() const;
145 std::string const & options() const;
147 std::string const & class_header() const;
149 std::string const & pagestyle() const;
151 docstring const & preamble() const;
153 /// is this feature already provided by the class?
154 bool provides(std::string const & p) const;
157 unsigned int columns() const;
166 PageSides sides() const;
168 int secnumdepth() const;
170 int tocdepth() const;
172 /// Can be LaTeX, DocBook, etc.
173 OutputType outputType() const;
176 Font const & defaultfont() const;
178 /// Text that dictates how wide the left margin is on the screen
179 docstring const & leftmargin() const;
181 /// Text that dictates how wide the right margin is on the screen
182 docstring const & rightmargin() const;
184 /// The type of command used to produce a title
185 TitleLatexType titletype() const;
186 /// The name of the title command
187 std::string const & titlename() const;
191 /// The minimal TocLevel of sectioning layouts
192 int min_toclevel() const;
193 /// The maximal TocLevel of sectioning layouts
194 int max_toclevel() const;
195 /// returns true if the class has a ToC structure
196 bool hasTocLevels() const;
199 bool delete_layout(docstring const &);
201 bool do_readStyle(Lexer &, Layout &);
204 /// document class name
205 std::string latexname_;
206 /// document class description
207 std::string description_;
208 /// whether this is a modular layout, i.e., whether it has been
209 /// modified by loading of layout modules.
212 std::string opt_fontsize_;
214 std::string opt_pagestyle_;
215 /// Specific class options
216 std::string options_;
218 std::string pagestyle_;
220 std::string class_header_;
222 docstring defaultlayout_;
223 /// preamble text to support layout styles
225 /// latex packages loaded by document class.
226 std::set<std::string> provides_;
228 unsigned int columns_;
231 /// header depth to have numbering
233 /// header depth to appear in table of contents
235 /// Can be LaTeX, DocBook, etc.
236 OutputType outputType_;
237 /** Base font. The paragraph and layout fonts are resolved against
238 this font. This has to be fully instantiated. Attributes
239 Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
243 /// Text that dictates how wide the left margin is on the screen
244 docstring leftmargin_;
246 /// Text that dictates how wide the right margin is on the screen
247 docstring rightmargin_;
249 /// The type of command used to produce a title
250 TitleLatexType titletype_;
251 /// The name of the title command
252 std::string titlename_;
254 /// Paragraph styles used in this layout
255 LayoutList layoutlist_;
257 /// Input layouts available to this layout
258 mutable InsetLayouts insetlayoutlist_;
260 /// available types of float, eg. figure, algorithm.
261 boost::shared_ptr<FloatList> floatlist_;
263 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
264 boost::shared_ptr<Counters> counters_;
266 /// Has this layout file been loaded yet?
267 mutable bool loaded_;
269 /// Is the TeX class available?
272 /// The minimal TocLevel of sectioning layouts
274 /// The maximal TocLevel of sectioning layouts
279 /// convert page sides option to text 1 or 2
280 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);
282 /** Shared pointer for possibly modular layout. Needed so that paste,
283 * for example, will still be able to retain the pointer, even when
284 * the buffer itself is closed.
286 typedef boost::shared_ptr<TextClass> TextClassPtr;