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 /// \return true on success.
71 bool read(support::FileName const & filename, ReadType rt = BASECLASS);
73 void readOutputType(Lexer &);
75 void readTitleType(Lexer &);
77 void readMaxCounter(Lexer &);
79 void readClassOptions(Lexer &);
81 void readCharStyle(Lexer &, std::string const &);
83 void readFloat(Lexer &);
85 void readCounter(Lexer &);
87 bool hasLayout(docstring const & name) const;
90 LayoutPtr const & operator[](docstring const & vname) const;
92 /// Sees to that the textclass structure has been loaded
93 bool load(std::string const & path = std::string()) const;
94 /// Has this layout file been loaded yet?
95 bool loaded() const { return loaded_; }
97 /// the list of floats defined in the document class
99 /// the list of floats defined in the document class
100 FloatList const & floats() const;
101 /// The Counters present in this document class.
102 Counters & counters() const;
103 /// Inset layouts of this doc class
104 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
106 InsetLayout const & insetlayout(docstring const & name) const;
108 docstring const & defaultLayoutName() const;
110 LayoutPtr const & defaultLayout() const;
111 /// returns a special layout for use when we don't really want one,
112 /// e.g., in table cells
113 LayoutPtr const & emptyLayout() const
114 { return operator[](emptylayout_); };
116 docstring const & emptyLayoutName() const
117 { return emptylayout_; }
119 std::string const & name() const;
121 docstring const & labelstring() const;
123 std::string const & latexname() const;
125 std::string const & description() const;
127 bool isModular() const { return modular_; }
128 /// Sets the layout as a modular one. There is never any
129 /// need to reset this.
130 void markAsModular() { modular_ = true; }
132 std::string const & opt_fontsize() const;
134 std::string const & opt_pagestyle() const;
136 std::string const & options() const;
138 std::string const & class_header() const;
140 std::string const & pagestyle() const;
142 docstring const & preamble() const;
144 /// is this feature already provided by the class?
145 bool provides(std::string const & p) const;
146 /// features required by the class?
147 std::set<std::string> const & requires() const { return requires_; }
150 unsigned int columns() const;
152 PageSides sides() const;
154 int secnumdepth() const;
156 int tocdepth() const;
158 /// Can be LaTeX, DocBook, etc.
159 OutputType outputType() const;
162 FontInfo const & defaultfont() const;
164 /// Text that dictates how wide the left margin is on the screen
165 docstring const & leftmargin() const;
167 /// Text that dictates how wide the right margin is on the screen
168 docstring const & rightmargin() const;
170 /// The type of command used to produce a title
171 TitleLatexType titletype() const;
172 /// The name of the title command
173 std::string const & titlename() const;
177 /// The minimal TocLevel of sectioning layouts
178 int min_toclevel() const;
179 /// The maximal TocLevel of sectioning layouts
180 int max_toclevel() const;
181 /// returns true if the class has a ToC structure
182 bool hasTocLevels() const;
184 static InsetLayout const & emptyInsetLayout() { return empty_insetlayout_; }
187 bool deleteLayout(docstring const &);
188 /// \return true for success.
189 bool readStyle(Lexer &, Layout &);
192 /// document class name
193 std::string latexname_;
194 /// document class description
195 std::string description_;
196 /// whether this is a modular layout, i.e., whether it has been
197 /// modified by loading of layout modules.
200 std::string opt_fontsize_;
202 std::string opt_pagestyle_;
203 /// Specific class options
204 std::string options_;
206 std::string pagestyle_;
208 std::string class_header_;
210 docstring defaultlayout_;
211 /// name of empty layout
212 static const docstring emptylayout_;
213 /// preamble text to support layout styles
215 /// latex packages loaded by document class.
216 std::set<std::string> provides_;
217 /// latex packages requested by document class.
218 std::set<std::string> requires_;
220 unsigned int columns_;
223 /// header depth to have numbering
225 /// header depth to appear in table of contents
227 /// Can be LaTeX, DocBook, etc.
228 OutputType outputType_;
229 /** Base font. The paragraph and layout fonts are resolved against
230 this font. This has to be fully instantiated. Attributes
231 FONT_INHERIT, FONT_IGNORE, and FONT_TOGGLE are
234 FontInfo defaultfont_;
235 /// Text that dictates how wide the left margin is on the screen
236 docstring leftmargin_;
238 /// Text that dictates how wide the right margin is on the screen
239 docstring rightmargin_;
241 /// The type of command used to produce a title
242 TitleLatexType titletype_;
243 /// The name of the title command
244 std::string titlename_;
246 /// Paragraph styles used in this layout
247 LayoutList layoutlist_;
249 /// Input layouts available to this layout
250 mutable InsetLayouts insetlayoutlist_;
252 /// available types of float, eg. figure, algorithm.
253 boost::shared_ptr<FloatList> floatlist_;
255 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
256 boost::shared_ptr<Counters> counters_;
258 /// Has this layout file been loaded yet?
259 mutable bool loaded_;
261 /// Is the TeX class available?
264 /// The minimal TocLevel of sectioning layouts
266 /// The maximal TocLevel of sectioning layouts
269 static InsetLayout empty_insetlayout_;
273 /// convert page sides option to text 1 or 2
274 std::ostream & operator<<(std::ostream & os, PageSides p);