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