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 "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;
59 /// List of inset layouts
60 typedef std::map<docstring, InsetLayout> InsetLayouts;
62 /// Stores the layout specification of a LyX document class.
65 /// The individual styles comprising the document class
66 typedef std::vector<LayoutPtr> LayoutList;
67 /// Enumerate the paragraph styles.
68 typedef LayoutList::const_iterator const_iterator;
69 /// Construct a layout with default values. Actual values loaded later.
71 TextClass(std::string const & = std::string(),
72 std::string const & = std::string(),
73 std::string const & = std::string(),
74 bool texClassAvail = false);
76 /// check whether the TeX class is available
77 bool isTeXClassAvailable() const;
79 /// paragraph styles begin iterator.
80 const_iterator begin() const { return layoutlist_.begin(); }
81 /// paragraph styles end iterator
82 const_iterator end() const { return layoutlist_.end(); }
84 ///Enum used with TextClass::read
86 BASECLASS, //>This is a base class, i.e., top-level layout file
87 MERGE, //>This is a file included in a layout file
88 MODULE //>This is a layout module
90 /// Performs the read of the layout file.
91 bool read(support::FileName const & filename, ReadType rt = BASECLASS);
93 void readOutputType(Lexer &);
95 void readTitleType(Lexer &);
97 void readMaxCounter(Lexer &);
99 void readClassOptions(Lexer &);
101 void readCharStyle(Lexer &, std::string const &);
103 void readInsetLayout(Lexer &, docstring const &);
105 void readFloat(Lexer &);
107 void readCounter(Lexer &);
109 bool hasLayout(docstring const & name) const;
112 LayoutPtr const & operator[](docstring const & vname) const;
114 /// Sees to that the textclass structure has been loaded
115 bool load(std::string const & path = std::string()) const;
116 /// Has this layout file been loaded yet?
117 bool loaded() const { return loaded_; }
119 /// the list of floats defined in the document class
120 FloatList & floats();
121 /// the list of floats defined in the document class
122 FloatList const & floats() const;
123 /// The Counters present in this document class.
124 Counters & counters() const;
125 /// Inset layouts of this doc class
126 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
128 InsetLayout const & insetlayout(docstring const & name) const;
130 docstring const & defaultLayoutName() const;
132 LayoutPtr const & defaultLayout() const;
134 std::string const & name() const;
136 docstring const & labelstring() const;
138 std::string const & latexname() const;
140 std::string const & description() const;
142 bool isModular() const { return modular_; }
143 /// Sets the layout as a modular one. There is never any
144 /// need to reset this.
145 void markAsModular() { modular_ = true; }
147 std::string const & opt_fontsize() const;
149 std::string const & opt_pagestyle() const;
151 std::string const & options() const;
153 std::string const & class_header() const;
155 std::string const & pagestyle() const;
157 docstring const & preamble() const;
159 /// is this feature already provided by the class?
160 bool provides(std::string const & p) const;
163 unsigned int columns() const;
172 PageSides sides() const;
174 int secnumdepth() const;
176 int tocdepth() const;
178 /// Can be LaTeX, DocBook, etc.
179 OutputType outputType() const;
182 FontInfo const & defaultfont() const;
184 /// Text that dictates how wide the left margin is on the screen
185 docstring const & leftmargin() const;
187 /// Text that dictates how wide the right margin is on the screen
188 docstring const & rightmargin() const;
190 /// The type of command used to produce a title
191 TitleLatexType titletype() const;
192 /// The name of the title command
193 std::string const & titlename() const;
197 /// The minimal TocLevel of sectioning layouts
198 int min_toclevel() const;
199 /// The maximal TocLevel of sectioning layouts
200 int max_toclevel() const;
201 /// returns true if the class has a ToC structure
202 bool hasTocLevels() const;
205 bool deleteLayout(docstring const &);
207 bool readStyle(Lexer &, Layout &);
210 /// document class name
211 std::string latexname_;
212 /// document class description
213 std::string description_;
214 /// whether this is a modular layout, i.e., whether it has been
215 /// modified by loading of layout modules.
218 std::string opt_fontsize_;
220 std::string opt_pagestyle_;
221 /// Specific class options
222 std::string options_;
224 std::string pagestyle_;
226 std::string class_header_;
228 docstring defaultlayout_;
229 /// preamble text to support layout styles
231 /// latex packages loaded by document class.
232 std::set<std::string> provides_;
234 unsigned int columns_;
237 /// header depth to have numbering
239 /// header depth to appear in table of contents
241 /// Can be LaTeX, DocBook, etc.
242 OutputType outputType_;
243 /** Base font. The paragraph and layout fonts are resolved against
244 this font. This has to be fully instantiated. Attributes
245 FONT_INHERIT, FONT_IGNORE, and FONT_TOGGLE are
248 FontInfo defaultfont_;
249 /// Text that dictates how wide the left margin is on the screen
250 docstring leftmargin_;
252 /// Text that dictates how wide the right margin is on the screen
253 docstring rightmargin_;
255 /// The type of command used to produce a title
256 TitleLatexType titletype_;
257 /// The name of the title command
258 std::string titlename_;
260 /// Paragraph styles used in this layout
261 LayoutList layoutlist_;
263 /// Input layouts available to this layout
264 mutable InsetLayouts insetlayoutlist_;
266 /// available types of float, eg. figure, algorithm.
267 boost::shared_ptr<FloatList> floatlist_;
269 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
270 boost::shared_ptr<Counters> counters_;
272 /// Has this layout file been loaded yet?
273 mutable bool loaded_;
275 /// Is the TeX class available?
278 /// The minimal TocLevel of sectioning layouts
280 /// The maximal TocLevel of sectioning layouts
285 /// convert page sides option to text 1 or 2
286 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);
288 /** Shared pointer for possibly modular layout. Needed so that paste,
289 * for example, will still be able to retain the pointer, even when
290 * the buffer itself is closed.
292 typedef boost::shared_ptr<TextClass> TextClassPtr;