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.
13 #include "ColorCode.h"
15 #include "LayoutEnums.h"
16 #include "LayoutPtr.h"
18 #include "insets/InsetLayout.h"
20 #include "support/docstring.h"
21 #include "support/types.h"
23 #include <boost/shared_ptr.hpp>
31 namespace support { class FileName; }
38 /// List of inset layouts
39 typedef std::map<docstring, InsetLayout> InsetLayouts;
41 /// Stores the layout specification of a LyX document class.
44 /// The individual styles comprising the document class
45 typedef std::vector<LayoutPtr> LayoutList;
46 /// Enumerate the paragraph styles.
47 typedef LayoutList::const_iterator const_iterator;
48 /// Construct a layout with default values. Actual values loaded later.
50 TextClass(std::string const & = std::string(),
51 std::string const & = std::string(),
52 std::string const & = std::string(),
53 bool texClassAvail = false);
55 /// check whether the TeX class is available
56 bool isTeXClassAvailable() const;
58 /// paragraph styles begin iterator.
59 const_iterator begin() const { return layoutlist_.begin(); }
60 /// paragraph styles end iterator
61 const_iterator end() const { return layoutlist_.end(); }
63 ///Enum used with TextClass::read
65 BASECLASS, //>This is a base class, i.e., top-level layout file
66 MERGE, //>This is a file included in a layout file
67 MODULE //>This is a layout module
69 /// Performs the read of the layout file.
70 bool read(support::FileName const & filename, ReadType rt = BASECLASS);
72 void readOutputType(Lexer &);
74 void readTitleType(Lexer &);
76 void readMaxCounter(Lexer &);
78 void readClassOptions(Lexer &);
80 void readCharStyle(Lexer &, std::string const &);
82 void readInsetLayout(Lexer &, docstring const &);
84 void readFloat(Lexer &);
86 void readCounter(Lexer &);
88 bool hasLayout(docstring const & name) const;
91 LayoutPtr const & operator[](docstring const & vname) const;
93 /// Sees to that the textclass structure has been loaded
94 bool load(std::string const & path = std::string()) const;
95 /// Has this layout file been loaded yet?
96 bool loaded() const { return loaded_; }
98 /// the list of floats defined in the document class
100 /// the list of floats defined in the document class
101 FloatList const & floats() const;
102 /// The Counters present in this document class.
103 Counters & counters() const;
104 /// Inset layouts of this doc class
105 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
107 InsetLayout const & insetlayout(docstring const & name) const;
109 docstring const & defaultLayoutName() const;
111 LayoutPtr const & defaultLayout() const;
113 std::string const & name() const;
115 docstring const & labelstring() const;
117 std::string const & latexname() const;
119 std::string const & description() const;
121 bool isModular() const { return modular_; }
122 /// Sets the layout as a modular one. There is never any
123 /// need to reset this.
124 void markAsModular() { modular_ = true; }
126 std::string const & opt_fontsize() const;
128 std::string const & opt_pagestyle() const;
130 std::string const & options() const;
132 std::string const & class_header() const;
134 std::string const & pagestyle() const;
136 docstring const & preamble() const;
138 /// is this feature already provided by the class?
139 bool provides(std::string const & p) const;
140 /// features required by the class?
141 std::vector<std::string> requires() const { return requires_; }
144 unsigned int columns() const;
146 PageSides sides() const;
148 int secnumdepth() const;
150 int tocdepth() const;
152 /// Can be LaTeX, DocBook, etc.
153 OutputType outputType() const;
156 FontInfo const & defaultfont() const;
158 /// Text that dictates how wide the left margin is on the screen
159 docstring const & leftmargin() const;
161 /// Text that dictates how wide the right margin is on the screen
162 docstring const & rightmargin() const;
164 /// The type of command used to produce a title
165 TitleLatexType titletype() const;
166 /// The name of the title command
167 std::string const & titlename() const;
171 /// The minimal TocLevel of sectioning layouts
172 int min_toclevel() const;
173 /// The maximal TocLevel of sectioning layouts
174 int max_toclevel() const;
175 /// returns true if the class has a ToC structure
176 bool hasTocLevels() const;
179 bool deleteLayout(docstring const &);
181 bool readStyle(Lexer &, Layout &);
184 /// document class name
185 std::string latexname_;
186 /// document class description
187 std::string description_;
188 /// whether this is a modular layout, i.e., whether it has been
189 /// modified by loading of layout modules.
192 std::string opt_fontsize_;
194 std::string opt_pagestyle_;
195 /// Specific class options
196 std::string options_;
198 std::string pagestyle_;
200 std::string class_header_;
202 docstring defaultlayout_;
203 /// preamble text to support layout styles
205 /// latex packages loaded by document class.
206 std::set<std::string> provides_;
207 /// latex packages requested by document class.
208 std::vector<std::string> requires_;
210 unsigned int columns_;
213 /// header depth to have numbering
215 /// header depth to appear in table of contents
217 /// Can be LaTeX, DocBook, etc.
218 OutputType outputType_;
219 /** Base font. The paragraph and layout fonts are resolved against
220 this font. This has to be fully instantiated. Attributes
221 FONT_INHERIT, FONT_IGNORE, and FONT_TOGGLE are
224 FontInfo defaultfont_;
225 /// Text that dictates how wide the left margin is on the screen
226 docstring leftmargin_;
228 /// Text that dictates how wide the right margin is on the screen
229 docstring rightmargin_;
231 /// The type of command used to produce a title
232 TitleLatexType titletype_;
233 /// The name of the title command
234 std::string titlename_;
236 /// Paragraph styles used in this layout
237 LayoutList layoutlist_;
239 /// Input layouts available to this layout
240 mutable InsetLayouts insetlayoutlist_;
242 /// available types of float, eg. figure, algorithm.
243 boost::shared_ptr<FloatList> floatlist_;
245 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
246 boost::shared_ptr<Counters> counters_;
248 /// Has this layout file been loaded yet?
249 mutable bool loaded_;
251 /// Is the TeX class available?
254 /// The minimal TocLevel of sectioning layouts
256 /// The maximal TocLevel of sectioning layouts
261 /// convert page sides option to text 1 or 2
262 std::ostream & operator<<(std::ostream & os, PageSides p);