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 /// Index in globel text class list. Basically a 'strong typedef'/
46 TextClassIndex(size_t t) : data_(t) {}
48 operator size_t() const { return data_; }
56 /// Stores the layout specification of a LyX document class.
59 /// The individual styles comprising the document class
60 typedef std::vector<LayoutPtr> LayoutList;
61 /// Enumerate the paragraph styles.
62 typedef LayoutList::const_iterator const_iterator;
63 /// Construct a layout with default values. Actual values loaded later.
65 TextClass(std::string const & = std::string(),
66 std::string const & = std::string(),
67 std::string const & = std::string(),
68 bool texClassAvail = false);
70 /// check whether the TeX class is available
71 bool isTeXClassAvailable() const;
73 /// paragraph styles begin iterator.
74 const_iterator begin() const { return layoutlist_.begin(); }
75 /// paragraph styles end iterator
76 const_iterator end() const { return layoutlist_.end(); }
78 ///Enum used with TextClass::read
80 BASECLASS, //>This is a base class, i.e., top-level layout file
81 MERGE, //>This is a file included in a layout file
82 MODULE //>This is a layout module
84 /// Performs the read of the layout file.
85 /// \return true on success.
86 bool read(support::FileName const & filename, ReadType rt = BASECLASS);
88 void readOutputType(Lexer &);
90 void readTitleType(Lexer &);
92 void readMaxCounter(Lexer &);
94 void readClassOptions(Lexer &);
96 void readCharStyle(Lexer &, std::string const &);
98 void readFloat(Lexer &);
100 void readCounter(Lexer &);
102 bool hasLayout(docstring const & name) const;
105 LayoutPtr const & operator[](docstring const & vname) const;
107 /// Sees to that the textclass structure has been loaded
108 bool load(std::string const & path = std::string()) const;
109 /// Has this layout file been loaded yet?
110 bool loaded() const { return loaded_; }
112 /// the list of floats defined in the document class
113 FloatList & floats();
114 /// the list of floats defined in the document class
115 FloatList const & floats() const;
116 /// The Counters present in this document class.
117 Counters & counters() const;
118 /// Inset layouts of this doc class
119 InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
121 InsetLayout const & insetlayout(docstring const & name) const;
123 docstring const & defaultLayoutName() const;
125 LayoutPtr const & defaultLayout() const;
126 /// returns a special layout for use when we don't really want one,
127 /// e.g., in table cells
128 LayoutPtr const & emptyLayout() const
129 { return operator[](emptylayout_); };
131 docstring const & emptyLayoutName() const
132 { return emptylayout_; }
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;
161 /// features required by the class?
162 std::set<std::string> const & requires() const { return requires_; }
165 unsigned int columns() const;
167 PageSides sides() const;
169 int secnumdepth() const;
171 int tocdepth() const;
173 /// Can be LaTeX, DocBook, etc.
174 OutputType outputType() const;
177 FontInfo const & defaultfont() const;
179 /// Text that dictates how wide the left margin is on the screen
180 docstring const & leftmargin() const;
182 /// Text that dictates how wide the right margin is on the screen
183 docstring const & rightmargin() const;
185 /// The type of command used to produce a title
186 TitleLatexType titletype() const;
187 /// The name of the title command
188 std::string const & titlename() const;
192 /// The minimal TocLevel of sectioning layouts
193 int min_toclevel() const;
194 /// The maximal TocLevel of sectioning layouts
195 int max_toclevel() const;
196 /// returns true if the class has a ToC structure
197 bool hasTocLevels() const;
199 static InsetLayout const & emptyInsetLayout() { return empty_insetlayout_; }
202 bool deleteLayout(docstring const &);
203 /// \return true for success.
204 bool readStyle(Lexer &, Layout &);
207 /// document class name
208 std::string latexname_;
209 /// document class description
210 std::string description_;
211 /// whether this is a modular layout, i.e., whether it has been
212 /// modified by loading of layout modules.
215 std::string opt_fontsize_;
217 std::string opt_pagestyle_;
218 /// Specific class options
219 std::string options_;
221 std::string pagestyle_;
223 std::string class_header_;
225 docstring defaultlayout_;
226 /// name of empty layout
227 static const docstring emptylayout_;
228 /// preamble text to support layout styles
230 /// latex packages loaded by document class.
231 std::set<std::string> provides_;
232 /// latex packages requested by document class.
233 std::set<std::string> requires_;
235 unsigned int columns_;
238 /// header depth to have numbering
240 /// header depth to appear in table of contents
242 /// Can be LaTeX, DocBook, etc.
243 OutputType outputType_;
244 /** Base font. The paragraph and layout fonts are resolved against
245 this font. This has to be fully instantiated. Attributes
246 FONT_INHERIT, FONT_IGNORE, and FONT_TOGGLE are
249 FontInfo defaultfont_;
250 /// Text that dictates how wide the left margin is on the screen
251 docstring leftmargin_;
253 /// Text that dictates how wide the right margin is on the screen
254 docstring rightmargin_;
256 /// The type of command used to produce a title
257 TitleLatexType titletype_;
258 /// The name of the title command
259 std::string titlename_;
261 /// Paragraph styles used in this layout
262 LayoutList layoutlist_;
264 /// Input layouts available to this layout
265 mutable InsetLayouts insetlayoutlist_;
267 /// available types of float, eg. figure, algorithm.
268 boost::shared_ptr<FloatList> floatlist_;
270 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
271 boost::shared_ptr<Counters> counters_;
273 /// Has this layout file been loaded yet?
274 mutable bool loaded_;
276 /// Is the TeX class available?
279 /// The minimal TocLevel of sectioning layouts
281 /// The maximal TocLevel of sectioning layouts
284 static InsetLayout empty_insetlayout_;
288 /// convert page sides option to text 1 or 2
289 std::ostream & operator<<(std::ostream & os, PageSides p);