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