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