]> git.lyx.org Git - lyx.git/blob - src/lyxtextclass.h
cleanup some debug messages
[lyx.git] / src / lyxtextclass.h
1 // -*- C++ -*-
2 /**
3  * \file lyxtextclass.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 "lyxlayout.h"
14 #include "lyxlayout_ptr_fwd.h"
15
16 #include <boost/shared_ptr.hpp>
17
18 #include <vector>
19
20 class LyXLex;
21 class Counters;
22 class FloatList;
23
24
25 ///
26 class CharStyle {
27 public:
28         std::string name;
29         std::string latextype;
30         std::string latexname;
31         std::string latexparam;
32         LyXFont font;
33         LyXFont labelfont;
34         std::string preamble;
35 };
36
37
38 /// List of semantically defined character style insets
39 typedef std::vector<CharStyle> CharStyles;
40
41
42 /// Stores the layout specification of a LyX document class.
43 class LyXTextClass {
44 public:
45         /// The individual styles comprising the document class
46         typedef std::vector<LyXLayout_ptr> LayoutList;
47         /// Enumerate the paragraph styles.
48         typedef LayoutList::const_iterator const_iterator;
49         /// Construct a layout with default values. Actual values loaded later.
50         explicit
51         LyXTextClass(std::string const & = std::string(),
52                      std::string const & = std::string(),
53                      std::string const & = std::string(),
54                      bool = false);
55
56         /// check whether the TeX class is available
57         bool isTeXClassAvailable() const;
58
59         /// paragraph styles begin iterator.
60         const_iterator begin() const { return layoutlist_.begin(); }
61         /// paragraph styles end iterator
62         const_iterator end() const { return layoutlist_.end(); }
63
64         /// Performs the read of the layout file.
65         bool Read(std::string const & filename, bool merge = false);
66         ///
67         void readOutputType(LyXLex &);
68         ///
69         void readTitleType(LyXLex &);
70         ///
71         void readMaxCounter(LyXLex &);
72         ///
73         void readClassOptions(LyXLex &);
74         ///
75         void readCharStyle(LyXLex &, std::string const &);
76         ///
77         void readFloat(LyXLex &);
78         ///
79         void readCounter(LyXLex &);
80         ///
81         bool hasLayout(std::string const & name) const;
82
83         ///
84         LyXLayout_ptr const & operator[](std::string const & vname) const;
85
86         /// Sees to that the textclass structure has been loaded
87         bool load() const;
88         /// Has this layout file been loaded yet?
89         bool loaded() const { return loaded_; }
90
91         /// the list of floats defined in the document class
92         FloatList & floats();
93         /// the list of floats defined in the document class
94         FloatList const & floats() const;
95         /// The Counters present in this document class.
96         Counters & counters() const;
97         /// CharStyles of this doc class
98         CharStyles & charstyles() const { return charstylelist_; };
99         /// Retrieve element of name s:
100         CharStyles::iterator charstyle(std::string const & s) const;
101         ///
102         std::string const & defaultLayoutName() const;
103         ///
104         LyXLayout_ptr const & defaultLayout() const;
105         ///
106         std::string const & name() const;
107         ///
108         std::string const & latexname() const;
109         ///
110         std::string const & description() const;
111         ///
112         std::string const & opt_fontsize() const;
113         ///
114         std::string const & opt_pagestyle() const;
115         ///
116         std::string const & options() const;
117         ///
118         std::string const & class_header() const;
119         ///
120         std::string const & pagestyle() const;
121         ///
122         std::string const & preamble() const;
123
124         /// Packages that are already loaded by the class
125         enum Provides {
126                 ///
127                 nothing = 0,
128                 ///
129                 amsmath = 1,
130                 ///
131                 makeidx = 2,
132                 ///
133                 url = 4,
134                 ///
135                 natbib = 8
136         };
137         ///
138         bool provides(Provides p) const;
139
140         ///
141         unsigned int columns() const;
142         ///
143         enum PageSides {
144                 ///
145                 OneSide,
146                 ///
147                 TwoSides
148         };
149         ///
150         PageSides sides() const;
151         ///
152         int secnumdepth() const;
153         ///
154         int tocdepth() const;
155
156         /// Can be LaTeX, LinuxDoc, etc.
157         OutputType outputType() const;
158
159         ///
160         LyXFont const & defaultfont() const;
161
162         /// Text that dictates how wide the left margin is on the screen
163         std::string const & leftmargin() const;
164
165         /// Text that dictates how wide the right margin is on the screen
166         std::string const & rightmargin() const;
167
168         /// The type of command used to produce a title
169         LYX_TITLE_LATEX_TYPES titletype() const;
170         /// The name of the title command
171         std::string const & titlename() const;
172
173         ///
174         int size() 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 private:
180         ///
181         bool delete_layout(std::string const &);
182         ///
183         bool do_readStyle(LyXLex &, LyXLayout &);
184         /// Layout file name
185         std::string name_;
186         /// document class name
187         std::string latexname_;
188         /// document class description
189         std::string description_;
190         /// Specific class options
191         std::string opt_fontsize_;
192         ///
193         std::string opt_pagestyle_;
194         ///
195         std::string options_;
196         ///
197         std::string pagestyle_;
198         ///
199         std::string class_header_;
200         ///
201         std::string defaultlayout_;
202         /// preamble text to support layout styles
203         std::string preamble_;
204         /// latex packages loaded by document class.
205         Provides provides_;
206         ///
207         unsigned int columns_;
208         ///
209         PageSides sides_;
210         /// header depth to have numbering
211         int secnumdepth_;
212         /// header depth to appear in table of contents
213         int tocdepth_;
214         /// Can be LaTeX, LinuxDoc, etc.
215         OutputType outputType_;
216         /** Base font. The paragraph and layout fonts are resolved against
217             this font. This has to be fully instantiated. Attributes
218             LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
219             extremely illegal.
220         */
221         LyXFont defaultfont_;
222         /// Text that dictates how wide the left margin is on the screen
223         std::string leftmargin_;
224
225         /// Text that dictates how wide the right margin is on the screen
226         std::string rightmargin_;
227
228         /// The type of command used to produce a title
229         LYX_TITLE_LATEX_TYPES titletype_;
230         /// The name of the title command
231         std::string titlename_;
232
233         /// Paragraph styles used in this layout
234         LayoutList layoutlist_;
235         /// CharStyles available to this layout
236         mutable CharStyles charstylelist_;
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> ctrs_;
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 /// Merge two different provides flags into one bit field record
258 inline
259 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
260 {
261         p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
262 }
263
264
265 /// convert page sides option to text 1 or 2
266 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
267
268 #endif