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