]> git.lyx.org Git - lyx.git/blob - src/TextClass.h
I'll find a solution for the 'dirList problem', Abdel.
[lyx.git] / src / TextClass.h
1 // -*- C++ -*-
2 /**
3  * \file TextClass.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * Full author contact details are available in file CREDITS.
8  */
9
10 #ifndef TEXTCLASS_H
11 #define TEXTCLASS_H
12
13 #include "ColorCode.h"
14 #include "FontInfo.h"
15 #include "LayoutEnums.h"
16 #include "LayoutPtr.h"
17
18 #include "insets/InsetLayout.h"
19
20 #include "support/docstring.h"
21 #include "support/types.h"
22
23 #include <boost/shared_ptr.hpp>
24
25 #include <vector>
26 #include <set>
27 #include <map>
28
29 namespace lyx {
30
31 namespace support { class FileName; }
32
33 class Layout;
34 class Lexer;
35 class Counters;
36 class FloatList;
37
38 /// List of inset layouts
39 typedef std::map<docstring, InsetLayout> InsetLayouts;
40
41 /// Stores the layout specification of a LyX document class.
42 class TextClass {
43 public:
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.
49         explicit
50         TextClass(std::string const & = std::string(),
51                      std::string const & = std::string(),
52                      std::string const & = std::string(),
53                      bool texClassAvail = false);
54         
55         /// check whether the TeX class is available
56         bool isTeXClassAvailable() const;
57
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(); }
62
63         ///Enum used with TextClass::read
64         enum ReadType { 
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
68         };
69         /// Performs the read of the layout file.
70         bool read(support::FileName const & filename, ReadType rt = BASECLASS);
71         ///
72         void readOutputType(Lexer &);
73         ///
74         void readTitleType(Lexer &);
75         ///
76         void readMaxCounter(Lexer &);
77         ///
78         void readClassOptions(Lexer &);
79         ///
80         void readCharStyle(Lexer &, std::string const &);
81         ///
82         void readInsetLayout(Lexer &, docstring const &);
83         ///
84         void readFloat(Lexer &);
85         ///
86         void readCounter(Lexer &);
87         ///
88         bool hasLayout(docstring const & name) const;
89
90         ///
91         LayoutPtr const & operator[](docstring const & vname) const;
92
93         /// Sees to that the textclass structure has been loaded
94         bool load(std::string const & path = std::string()) const;
95         /// Has this layout file been loaded yet?
96         bool loaded() const { return loaded_; }
97
98         /// the list of floats defined in the document class
99         FloatList & floats();
100         /// the list of floats defined in the document class
101         FloatList const & floats() const;
102         /// The Counters present in this document class.
103         Counters & counters() const;
104         /// Inset layouts of this doc class
105         InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
106         ///
107         InsetLayout const & insetlayout(docstring const & name) const;
108         ///
109         docstring const & defaultLayoutName() const;
110         ///
111         LayoutPtr const & defaultLayout() const;
112         ///
113         std::string const & name() const;
114         ///
115         docstring const & labelstring() const;
116         ///
117         std::string const & latexname() const;
118         ///
119         std::string const & description() const;
120         ///
121         bool isModular() const { return modular_; }
122         /// Sets the layout as a modular one. There is never any
123         /// need to reset this.
124         void markAsModular() { modular_ = true; }
125         ///
126         std::string const & opt_fontsize() const;
127         ///
128         std::string const & opt_pagestyle() const;
129         ///
130         std::string const & options() const;
131         ///
132         std::string const & class_header() const;
133         ///
134         std::string const & pagestyle() const;
135         ///
136         docstring const & preamble() const;
137
138         /// is this feature already provided by the class?
139         bool provides(std::string const & p) const;
140
141         ///
142         unsigned int columns() const;
143         ///
144         PageSides sides() const;
145         ///
146         int secnumdepth() const;
147         ///
148         int tocdepth() const;
149
150         /// Can be LaTeX, DocBook, etc.
151         OutputType outputType() const;
152
153         ///
154         FontInfo const & defaultfont() const;
155
156         /// Text that dictates how wide the left margin is on the screen
157         docstring const & leftmargin() const;
158
159         /// Text that dictates how wide the right margin is on the screen
160         docstring const & rightmargin() const;
161
162         /// The type of command used to produce a title
163         TitleLatexType titletype() const;
164         /// The name of the title command
165         std::string const & titlename() const;
166
167         ///
168         int size() const;
169         /// The minimal TocLevel of sectioning layouts
170         int min_toclevel() const;
171         /// The maximal TocLevel of sectioning layouts
172         int max_toclevel() const;
173         /// returns true if the class has a ToC structure
174         bool hasTocLevels() const;
175 private:
176         ///
177         bool deleteLayout(docstring const &);
178         ///
179         bool readStyle(Lexer &, Layout &);
180         /// Layout file name
181         std::string name_;
182         /// document class name
183         std::string latexname_;
184         /// document class description
185         std::string description_;
186         /// whether this is a modular layout, i.e., whether it has been
187         /// modified by loading of layout modules.
188         bool modular_;
189         ///
190         std::string opt_fontsize_;
191         ///
192         std::string opt_pagestyle_;
193         /// Specific class options
194         std::string options_;
195         ///
196         std::string pagestyle_;
197         ///
198         std::string class_header_;
199         ///
200         docstring defaultlayout_;
201         /// preamble text to support layout styles
202         docstring preamble_;
203         /// latex packages loaded by document class.
204         std::set<std::string> provides_;
205         ///
206         unsigned int columns_;
207         ///
208         PageSides sides_;
209         /// header depth to have numbering
210         int secnumdepth_;
211         /// header depth to appear in table of contents
212         int tocdepth_;
213         /// Can be LaTeX, DocBook, etc.
214         OutputType outputType_;
215         /** Base font. The paragraph and layout fonts are resolved against
216             this font. This has to be fully instantiated. Attributes
217             FONT_INHERIT, FONT_IGNORE, and FONT_TOGGLE are
218             extremely illegal.
219         */
220         FontInfo defaultfont_;
221         /// Text that dictates how wide the left margin is on the screen
222         docstring leftmargin_;
223
224         /// Text that dictates how wide the right margin is on the screen
225         docstring rightmargin_;
226
227         /// The type of command used to produce a title
228         TitleLatexType titletype_;
229         /// The name of the title command
230         std::string titlename_;
231
232         /// Paragraph styles used in this layout
233         LayoutList layoutlist_;
234
235         /// Input layouts available to this layout
236         mutable InsetLayouts insetlayoutlist_;
237
238         /// available types of float, eg. figure, algorithm.
239         boost::shared_ptr<FloatList> floatlist_;
240
241         /// Types of counters, eg. sections, eqns, figures, avail. in document class.
242         boost::shared_ptr<Counters> counters_;
243
244         /// Has this layout file been loaded yet?
245         mutable bool loaded_;
246
247         /// Is the TeX class available?
248         bool texClassAvail_;
249
250         /// The minimal TocLevel of sectioning layouts
251         int min_toclevel_;
252         /// The maximal TocLevel of sectioning layouts
253         int max_toclevel_;
254 };
255
256
257 /// convert page sides option to text 1 or 2
258 std::ostream & operator<<(std::ostream & os, PageSides p);
259
260 } // namespace lyx
261
262 #endif