]> git.lyx.org Git - lyx.git/blob - src/lyxtextclass.h
Fix fuer #209
[lyx.git] / src / lyxtextclass.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef LYXTEXTCLASS_H
13 #define LYXTEXTCLASS_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "lyxlayout.h"
20
21 #include "support/types.h"
22
23 #include "LString.h"
24
25 #include <vector>
26
27 class LyXLex;
28
29
30
31 ///
32 class LyXTextClass {
33 public:
34         ///
35         typedef std::vector<LyXLayout> LayoutList;
36         ///
37         typedef LayoutList::const_iterator const_iterator;
38         ///
39         explicit
40         LyXTextClass (string const & = string(), 
41                       string const & = string(), 
42                       string const & = string());
43
44         ///
45         const_iterator begin() const { return layoutlist.begin(); }
46         ///
47         const_iterator end() const { return layoutlist.end(); }
48         
49         ///
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         bool hasLayout(string const & name) const;
59
60         ///
61         LyXLayout const & GetLayout(string const & vname) const;
62
63         ///
64         LyXLayout & GetLayout(string const & vname);
65
66         /// Sees to that the textclass structure has been loaded
67         void load();
68
69         ///
70         string const & name() const { return name_; }
71         ///
72         string const & latexname() const { return latexname_; }
73         ///
74         string const & description() const { return description_; }
75         ///
76         string const & opt_fontsize() const { return opt_fontsize_; }
77         ///
78         string const & opt_pagestyle() const { return opt_pagestyle_; }
79         ///
80         string const & options() const { return options_; }
81         ///
82         string const & pagestyle() const { return pagestyle_; }
83         ///
84         string const & preamble() const { return preamble_; }
85
86         /// Packages that are already loaded by the class
87         enum Provides {
88                 ///
89                 nothing = 0,
90                 ///
91                 amsmath = 1,
92                 ///
93                 makeidx = 2,
94                 ///
95                 url = 4
96         };
97         ///
98         bool provides(Provides p) const { return provides_ & p; }
99         
100         ///
101         unsigned int columns() const { return columns_; }
102         ///
103         enum PageSides {
104                 ///
105                 OneSide,
106                 ///
107                 TwoSides
108         };
109         ///
110         PageSides sides() const { return sides_; }
111         ///
112         int secnumdepth() const { return secnumdepth_; }
113         ///
114         int tocdepth() const { return tocdepth_; }
115
116         ///
117         OutputType outputType() const { return outputType_; }
118
119         ///
120         LyXFont const & defaultfont() const;
121
122         /// Text that dictates how wide the left margin is on the screen
123         string const & leftmargin() const;
124
125         /// Text that dictates how wide the right margin is on the screen
126         string const & rightmargin() const;
127         ///
128         int maxcounter() const { return maxcounter_; }
129         ///
130         lyx::layout_type numLayouts() const { return layoutlist.size(); }
131         ///
132         LyXLayout const & operator[](lyx::layout_type i) const {
133                 return layoutlist[i];
134         }
135 private:
136         ///
137         bool delete_layout(string const &);
138         ///
139         bool do_readStyle(LyXLex &, LyXLayout &);
140         ///
141         string name_;
142         ///
143         string latexname_;
144         ///
145         string description_;
146         /// Specific class options
147         string opt_fontsize_;
148         ///
149         string opt_pagestyle_;
150         ///
151         string options_;
152         ///
153         string pagestyle_;
154         ///
155         string preamble_;
156         ///
157         Provides provides_;
158         ///
159         unsigned int columns_;
160         ///
161         PageSides sides_;
162         ///
163         int secnumdepth_;
164         ///
165         int tocdepth_;
166         ///
167         OutputType outputType_;
168         /** Base font. The paragraph and layout fonts are resolved against
169             this font. This has to be fully instantiated. Attributes
170             LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
171             extremely illegal.
172         */
173         LyXFont defaultfont_;
174         /// Text that dictates how wide the left margin is on the screen
175         string leftmargin_;
176
177         /// Text that dictates how wide the right margin is on the screen
178         string rightmargin_;
179         ///
180         int maxcounter_; // add approp. signedness
181
182         ///
183         LayoutList layoutlist;
184
185         /// Has this layout file been loaded yet?
186         bool loaded;
187 };
188
189 ///
190 inline
191 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
192 {
193         p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
194 }
195
196
197 ///
198 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
199
200 #endif