]> git.lyx.org Git - lyx.git/blob - src/TextClass.h
- Fileformat change: rename "arabic" to "arabic_arabtex"
[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 LYXTEXTCLASS_H
11 #define LYXTEXTCLASS_H
12
13 #include "Layout.h"
14 #include "lyxlayout_ptr_fwd.h"
15
16 #include <boost/shared_ptr.hpp>
17
18 #include <vector>
19 #include <set>
20
21 namespace lyx {
22
23 namespace support { class FileName; }
24
25 class Lexer;
26 class Counters;
27 class FloatList;
28
29
30 ///
31 class CharStyle {
32 public:
33         std::string name;
34         std::string latextype;
35         std::string latexname;
36         std::string latexparam;
37         Font font;
38         Font labelfont;
39         docstring preamble;
40 };
41
42
43 /// List of semantically defined character style insets
44 typedef std::vector<CharStyle> CharStyles;
45
46
47 /// Stores the layout specification of a LyX document class.
48 class TextClass {
49 public:
50         /// The individual styles comprising the document class
51         typedef std::vector<Layout_ptr> LayoutList;
52         /// Enumerate the paragraph styles.
53         typedef LayoutList::const_iterator const_iterator;
54         /// Construct a layout with default values. Actual values loaded later.
55         explicit
56         TextClass(std::string const & = std::string(),
57                      std::string const & = std::string(),
58                      std::string const & = std::string(),
59                      bool = false);
60
61         /// check whether the TeX class is available
62         bool isTeXClassAvailable() const;
63
64         /// paragraph styles begin iterator.
65         const_iterator begin() const { return layoutlist_.begin(); }
66         /// paragraph styles end iterator
67         const_iterator end() const { return layoutlist_.end(); }
68
69         /// Performs the read of the layout file.
70         bool read(support::FileName const & filename, bool merge = false);
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 readFloat(Lexer &);
83         ///
84         void readCounter(Lexer &);
85         ///
86         bool hasLayout(std::string const & name) const;
87
88         ///
89         Layout_ptr const & operator[](std::string const & vname) const;
90
91         /// Sees to that the textclass structure has been loaded
92         bool load(std::string const & path = std::string()) const;
93         /// Has this layout file been loaded yet?
94         bool loaded() const { return loaded_; }
95
96         /// the list of floats defined in the document class
97         FloatList & floats();
98         /// the list of floats defined in the document class
99         FloatList const & floats() const;
100         /// The Counters present in this document class.
101         Counters & counters() const;
102         /// CharStyles of this doc class
103         CharStyles & charstyles() const { return charstylelist_; };
104         /// Retrieve element of name s:
105         CharStyles::iterator charstyle(std::string const & s) const;
106         ///
107         std::string const & defaultLayoutName() const;
108         ///
109         Layout_ptr const & defaultLayout() const;
110         ///
111         std::string const & name() const;
112         ///
113         std::string const & latexname() const;
114         ///
115         std::string const & description() const;
116         ///
117         std::string const & opt_fontsize() const;
118         ///
119         std::string const & opt_pagestyle() const;
120         ///
121         std::string const & options() const;
122         ///
123         std::string const & class_header() const;
124         ///
125         std::string const & pagestyle() const;
126         ///
127         docstring const & preamble() const;
128
129         /// is this feature already provided by the class?
130         bool provides(std::string const & p) const;
131
132         ///
133         unsigned int columns() const;
134         ///
135         enum PageSides {
136                 ///
137                 OneSide,
138                 ///
139                 TwoSides
140         };
141         ///
142         PageSides sides() const;
143         ///
144         int secnumdepth() const;
145         ///
146         int tocdepth() const;
147
148         /// Can be LaTeX, DocBook, etc.
149         OutputType outputType() const;
150
151         ///
152         Font const & defaultfont() const;
153
154         /// Text that dictates how wide the left margin is on the screen
155         std::string const & leftmargin() const;
156
157         /// Text that dictates how wide the right margin is on the screen
158         std::string const & rightmargin() const;
159
160         /// The type of command used to produce a title
161         LYX_TITLE_LATEX_TYPES titletype() const;
162         /// The name of the title command
163         std::string const & titlename() const;
164
165         ///
166         int size() const;
167         /// The minimal TocLevel of sectioning layouts
168         int min_toclevel() const;
169         /// The maximal TocLevel of sectioning layouts
170         int max_toclevel() const;
171         /// returns true if the class has a ToC structure
172         bool hasTocLevels() const;
173 private:
174         ///
175         bool delete_layout(std::string const &);
176         ///
177         bool do_readStyle(Lexer &, Layout &);
178         /// Layout file name
179         std::string name_;
180         /// document class name
181         std::string latexname_;
182         /// document class description
183         std::string description_;
184         /// Specific class options
185         std::string opt_fontsize_;
186         ///
187         std::string opt_pagestyle_;
188         ///
189         std::string options_;
190         ///
191         std::string pagestyle_;
192         ///
193         std::string class_header_;
194         ///
195         std::string defaultlayout_;
196         /// preamble text to support layout styles
197         docstring preamble_;
198         /// latex packages loaded by document class.
199         std::set<std::string> provides_;
200         ///
201         unsigned int columns_;
202         ///
203         PageSides sides_;
204         /// header depth to have numbering
205         int secnumdepth_;
206         /// header depth to appear in table of contents
207         int tocdepth_;
208         /// Can be LaTeX, DocBook, etc.
209         OutputType outputType_;
210         /** Base font. The paragraph and layout fonts are resolved against
211             this font. This has to be fully instantiated. Attributes
212             Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
213             extremely illegal.
214         */
215         Font defaultfont_;
216         /// Text that dictates how wide the left margin is on the screen
217         std::string leftmargin_;
218
219         /// Text that dictates how wide the right margin is on the screen
220         std::string rightmargin_;
221
222         /// The type of command used to produce a title
223         LYX_TITLE_LATEX_TYPES titletype_;
224         /// The name of the title command
225         std::string titlename_;
226
227         /// Paragraph styles used in this layout
228         LayoutList layoutlist_;
229         /// CharStyles available to this layout
230         mutable CharStyles charstylelist_;
231
232         /// available types of float, eg. figure, algorithm.
233         boost::shared_ptr<FloatList> floatlist_;
234
235         /// Types of counters, eg. sections, eqns, figures, avail. in document class.
236         boost::shared_ptr<Counters> ctrs_;
237
238         /// Has this layout file been loaded yet?
239         mutable bool loaded_;
240
241         /// Is the TeX class available?
242         bool texClassAvail_;
243
244         /// The minimal TocLevel of sectioning layouts
245         int min_toclevel_;
246         /// The maximal TocLevel of sectioning layouts
247         int max_toclevel_;
248 };
249
250
251 /// convert page sides option to text 1 or 2
252 std::ostream & operator<<(std::ostream & os, TextClass::PageSides p);
253
254
255 } // namespace lyx
256
257 #endif