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"
22 #include <boost/shared_ptr.hpp>
30 namespace support { class FileName; }
37 /// List of inset layouts
38 typedef std::map<docstring, InsetLayout> InsetLayouts;
40 /// Stores the layout specification of a LyX document class.
43 /// The individual styles comprising the document class
44 typedef std::vector<LayoutPtr> LayoutList;
45 /// Enumerate the paragraph styles.
46 typedef LayoutList::const_iterator const_iterator;
47 /// Construct a layout with default values. Actual values loaded later.
49 TextClass(std::string const & = std::string(),
50 std::string const & = std::string(),
51 std::string const & = std::string(),
52 bool texClassAvail = false);
54 /// check whether the TeX class is available
55 bool isTeXClassAvailable() const;
57 /// paragraph styles begin iterator.
58 const_iterator begin() const { return layoutlist_.begin(); }
59 /// paragraph styles end iterator
60 const_iterator end() const { return layoutlist_.end(); }
62 ///Enum used with TextClass::read
64 BASECLASS, //>This is a base class, i.e., top-level layout file
65 MERGE, //>This is a file included in a layout file
66 MODULE //>This is a layout module
68 /// Performs the read of the layout file.
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 readInsetLayout(Lexer &, docstring 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;
112 std::string const & name() const;
114 docstring const & labelstring() const;
116 std::string const & latexname() const;
118 std::string const & description() const;
120 bool isModular() const { return modular_; }
121 /// Sets the layout as a modular one. There is never any
122 /// need to reset this.
123 void markAsModular() { modular_ = true; }
125 std::string const & opt_fontsize() const;
127 std::string const & opt_pagestyle() const;
129 std::string const & options() const;
131 std::string const & class_header() const;
133 std::string const & pagestyle() const;
135 docstring const & preamble() const;
137 /// is this feature already provided by the class?
138 bool provides(std::string const & p) const;
141 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;
183 bool deleteLayout(docstring const &);
185 bool readStyle(Lexer &, Layout &);
188 /// document class name
189 std::string latexname_;
190 /// document class description
191 std::string description_;
192 /// whether this is a modular layout, i.e., whether it has been
193 /// modified by loading of layout modules.
196 std::string opt_fontsize_;
198 std::string opt_pagestyle_;
199 /// Specific class options
200 std::string options_;
202 std::string pagestyle_;
204 std::string class_header_;
206 docstring defaultlayout_;
207 /// preamble text to support layout styles
209 /// latex packages loaded by document class.
210 std::set<std::string> provides_;
212 unsigned int columns_;
215 /// header depth to have numbering
217 /// header depth to appear in table of contents
219 /// Can be LaTeX, DocBook, etc.
220 OutputType outputType_;
221 /** Base font. The paragraph and layout fonts are resolved against
222 this font. This has to be fully instantiated. Attributes
223 FONT_INHERIT, FONT_IGNORE, and FONT_TOGGLE are
226 FontInfo defaultfont_;
227 /// Text that dictates how wide the left margin is on the screen
228 docstring leftmargin_;
230 /// Text that dictates how wide the right margin is on the screen
231 docstring rightmargin_;
233 /// The type of command used to produce a title
234 TitleLatexType titletype_;
235 /// The name of the title command
236 std::string titlename_;
238 /// Paragraph styles used in this layout
239 LayoutList layoutlist_;
241 /// Input layouts available to this layout
242 mutable InsetLayouts insetlayoutlist_;
244 /// available types of float, eg. figure, algorithm.
245 boost::shared_ptr<FloatList> floatlist_;
247 /// Types of counters, eg. sections, eqns, figures, avail. in document class.
248 boost::shared_ptr<Counters> counters_;
250 /// Has this layout file been loaded yet?
251 mutable bool loaded_;
253 /// Is the TeX class available?
256 /// The minimal TocLevel of sectioning layouts
258 /// The maximal TocLevel of sectioning layouts
263 /// convert page sides option to text 1 or 2
264 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);
266 /** Shared pointer for possibly modular layout. Needed so that paste,
267 * for example, will still be able to retain the pointer, even when
268 * the buffer itself is closed.
270 typedef boost::shared_ptr<TextClass> TextClassPtr;