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 /// Construct a layout with default values. Actual values loaded later.
48 TextClass(std::string const & = std::string(),
49 std::string const & = std::string(),
50 std::string const & = std::string(),
51 bool texClassAvail = false);
53 /// check whether the TeX class is available
54 bool isTeXClassAvailable() const;
56 /// Enumerate the paragraph styles.
57 size_t layoutCount() const { return layoutlist_.size(); }
58 /// Access the paragraph styles.
59 LayoutPtr const & layout(size_t index) const { return layoutlist_[index]; }
61 /// Enum used with TextClass::read
63 BASECLASS, //>This is a base class, i.e., top-level layout file
64 MERGE, //>This is a file included in a layout file
65 MODULE //>This is a layout module
67 /// Performs the read of the layout file.
68 /// \return true on success.
69 bool read(support::FileName const & filename, ReadType rt = BASECLASS);
71 void readOutputType(Lexer &);
73 void readTitleType(Lexer &);
75 void readMaxCounter(Lexer &);
77 void readClassOptions(Lexer &);
79 void readCharStyle(Lexer &, std::string const &);
81 void readFloat(Lexer &);
83 void readCounter(Lexer &);
85 bool hasLayout(docstring const & name) const;
88 LayoutPtr const & operator[](docstring const & vname) const;
90 /// Sees to that the textclass structure has been loaded
91 bool load(std::string const & path = std::string()) const;
92 /// Has this layout file been loaded yet?
93 bool loaded() const { return loaded_; }
95 /// the list of floats defined in the document class
97 /// the list of floats defined in the document class
98 FloatList const & floats() const;
99 /// The Counters present in this document class.
100 Counters & counters() const;
101 /// Inset layouts of this doc class
102 InsetLayouts & insetLayouts() const { return insetlayoutlist_; };
104 InsetLayout const & insetLayout(docstring const & name) const;
106 docstring const & defaultLayoutName() const;
108 LayoutPtr const & defaultLayout() const;
109 /// returns a special layout for use when we don't really want one,
110 /// e.g., in table cells
111 LayoutPtr const & emptyLayout() const
112 { return operator[](emptylayout_); };
114 docstring const & emptyLayoutName() const
115 { return emptylayout_; }
117 std::string const & name() const;
119 docstring const & labelstring() const;
121 std::string const & latexname() const;
123 std::string const & description() const;
125 bool isModular() const { return modular_; }
126 /// Sets the layout as a modular one. There is never any
127 /// need to reset this.
128 void markAsModular() { modular_ = true; }
130 std::string const & opt_fontsize() const;
132 std::string const & opt_pagestyle() const;
134 std::string const & options() const;
136 std::string const & class_header() const;
138 std::string const & pagestyle() const;
140 docstring const & preamble() const;
142 /// is this feature already provided by the class?
143 bool provides(std::string const & p) const;
144 /// features required by the class?
145 std::set<std::string> const & requires() const { return requires_; }
148 unsigned int columns() const;
150 PageSides sides() const;
152 int secnumdepth() const;
154 int tocdepth() const;
156 /// Can be LaTeX, DocBook, etc.
157 OutputType outputType() const;
160 FontInfo const & defaultfont() const;
162 /// Text that dictates how wide the left margin is on the screen
163 docstring const & leftmargin() const;
165 /// Text that dictates how wide the right margin is on the screen
166 docstring const & rightmargin() const;
168 /// The type of command used to produce a title
169 TitleLatexType titletype() const;
170 /// The name of the title command
171 std::string const & titlename() const;
175 /// The minimal TocLevel of sectioning layouts
176 int min_toclevel() const;
177 /// The maximal TocLevel of sectioning layouts
178 int max_toclevel() const;
179 /// returns true if the class has a ToC structure
180 bool hasTocLevels() const;
182 static InsetLayout const & emptyInsetLayout() { return empty_insetlayout_; }
185 bool deleteLayout(docstring const &);
186 /// \return true for success.
187 bool readStyle(Lexer &, Layout &);
190 /// document class name
191 std::string latexname_;
192 /// document class description
193 std::string description_;
194 /// whether this is a modular layout, i.e., whether it has been
195 /// modified by loading of layout modules.
198 std::string opt_fontsize_;
200 std::string opt_pagestyle_;
201 /// Specific class options
202 std::string options_;
204 std::string pagestyle_;
206 std::string class_header_;
208 docstring defaultlayout_;
209 /// name of empty layout
210 static const docstring emptylayout_;
211 /// preamble text to support layout styles
213 /// latex packages loaded by document class.
214 std::set<std::string> provides_;
215 /// latex packages requested by document class.
216 std::set<std::string> requires_;
218 unsigned int columns_;
221 /// header depth to have numbering
223 /// header depth to appear in table of contents
225 /// Can be LaTeX, DocBook, etc.
226 OutputType outputType_;
227 /** Base font. The paragraph and layout fonts are resolved against
228 this font. This has to be fully instantiated. Attributes
229 FONT_INHERIT, FONT_IGNORE, and FONT_TOGGLE are
232 FontInfo defaultfont_;
233 /// Text that dictates how wide the left margin is on the screen
234 docstring leftmargin_;
236 /// Text that dictates how wide the right margin is on the screen
237 docstring rightmargin_;
239 /// The type of command used to produce a title
240 TitleLatexType titletype_;
241 /// The name of the title command
242 std::string titlename_;
244 /// Paragraph styles used in this layout
245 LayoutList layoutlist_;
247 /// Input layouts available to this layout
248 mutable InsetLayouts insetlayoutlist_;
250 /// available types of float, eg. figure, algorithm.
251 boost::shared_ptr<FloatList> floatlist_;
253 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
254 boost::shared_ptr<Counters> counters_;
256 /// Has this layout file been loaded yet?
257 mutable bool loaded_;
259 /// Is the TeX class available?
262 /// The minimal TocLevel of sectioning layouts
264 /// The maximal TocLevel of sectioning layouts
267 static InsetLayout empty_insetlayout_;
271 /// convert page sides option to text 1 or 2
272 std::ostream & operator<<(std::ostream & os, PageSides p);