]> git.lyx.org Git - lyx.git/blob - src/paragraph.h
remove broken xpm
[lyx.git] / src / paragraph.h
1 // -*- C++ -*-
2 /**
3  *  \file paragraph.h
4  *  Copyright 1995 Matthias Ettrich
5  *  Copyright 2002 the LyX Team
6  *  Read the file COPYING
7  */
8
9 #ifndef PARAGRAPH_H
10 #define PARAGRAPH_H
11
12 #ifdef __GNUG__
13 #pragma interface
14 #endif
15
16 #include "lyxlayout_ptr_fwd.h"
17 #include "lyxfont.h" // Just for LyXFont::FONT_SIZE
18 #include "InsetList.h"
19
20 #include "insets/inset.h" // Just for Inset::Code
21
22 #include "support/types.h"
23
24 #include "LString.h"
25
26 class BufferParams;
27 class BufferView;
28 class Counters;
29 class InsetBibKey;
30 class Language;
31 class LaTeXFeatures;
32 class ParagraphParameters;
33 class TexRow;
34
35 // Define this if you want to try out the new storage container for
36 // paragraphs. (Lgb)
37 // This is non working and far from finished.
38 // #define NO_NEXT 1
39
40 /// A Paragraph holds all text, attributes and insets in a text paragraph
41 class Paragraph  {
42 public:
43         ///
44         enum META_KIND {
45                 ///
46                 META_HFILL = 1,
47                 ///
48                 META_NEWLINE,
49                 ///
50                 META_INSET
51         };
52         ///
53         typedef char value_type;
54         /// The same as ParameterStruct::depth_type
55         typedef unsigned int depth_type;
56
57         ///
58         Paragraph();
59 #ifndef NO_NEXT
60         /// this constructor inserts the new paragraph in a list
61         explicit
62         Paragraph(Paragraph * par);
63 #endif
64         ///
65         Paragraph(Paragraph const &, bool same_ids);
66         /// the destructor removes the new paragraph from the list
67         ~Paragraph();
68
69         ///
70         Language const * getParLanguage(BufferParams const &) const;
71         ///
72         bool isRightToLeftPar(BufferParams const &) const;
73         ///
74         void changeLanguage(BufferParams const & bparams,
75                             Language const * from, Language const * to);
76         ///
77         bool isMultiLingual(BufferParams const &);
78
79         ///
80         string const asString(Buffer const *, bool label);
81         ///
82         string const asString(Buffer const *, lyx::pos_type beg, lyx::pos_type end,
83                               bool label);
84
85         ///
86         void write(Buffer const *, std::ostream &, BufferParams const &,
87                        depth_type & depth) const;
88         ///
89         void validate(LaTeXFeatures &) const;
90
91         /// return the unique ID of this paragraph
92         int id() const;
93         ///
94         void read();
95
96         ///
97         Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
98                                  std::ostream &, TexRow & texrow,
99                                  bool moving_arg);
100
101         ///
102         int startTeXParParams(BufferParams const &, std::ostream &, bool) const;
103
104         ///
105         int endTeXParParams(BufferParams const &, std::ostream &, bool) const;
106
107
108         ///
109         bool simpleTeXOnePar(Buffer const *, BufferParams const &,
110                              std::ostream &, TexRow & texrow, bool moving_arg);
111
112         ///
113         Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
114                                       std::ostream &, TexRow & texrow);
115         ///
116         bool hasSameLayout(Paragraph const * par) const;
117
118         ///
119         void makeSameLayout(Paragraph const * par);
120
121         /// Is it the first par with same depth and layout?
122         bool isFirstInSequence() const;
123
124         /** Check if the current paragraph is the last paragraph in a
125             proof environment */
126         int getEndLabel() const;
127         ///
128         Inset * inInset() const;
129         ///
130         void setInsetOwner(Inset * i);
131         ///
132         void deleteInsetsLyXText(BufferView *);
133         ///
134         void resizeInsetsLyXText(BufferView *);
135
136         ///
137         lyx::pos_type size() const;
138         ///
139         bool empty() const;
140         ///
141         void setContentsFromPar(Paragraph * par);
142         ///
143         void clearContents();
144
145         ///
146         LyXLayout_ptr const & layout() const;
147         ///
148         void layout(LyXLayout_ptr const & new_layout);
149
150         ///
151         char enumdepth;
152
153         ///
154         char itemdepth;
155
156         ///
157         InsetBibKey * bibkey;  // ale970302
158
159 #ifndef NO_NEXT
160         ///
161         void next(Paragraph *);
162         /** these function are able to hide closed footnotes
163          */
164         Paragraph * next();
165         ///
166         Paragraph const * next() const;
167
168         ///
169         void previous(Paragraph *);
170         ///
171         Paragraph * previous();
172         ///
173         Paragraph const * previous() const;
174 #endif
175         /// for the environments
176         Paragraph * depthHook(depth_type depth);
177         /// for the environments
178         Paragraph const * depthHook(depth_type depth) const;
179         ///
180         Paragraph * outerHook();
181         ///
182         Paragraph const * outerHook() const;
183         ///
184         int beginningOfMainBody() const;
185         ///
186         string const & getLabelstring() const;
187
188         /// the next two functions are for the manual labels
189         string const getLabelWidthString() const;
190         ///
191         void setLabelWidthString(string const & s);
192         ///
193         char getAlign() const;
194         /// The nesting depth of a paragraph
195         depth_type getDepth() const;
196         /// The maximal possible depth of a paragraph after this one
197         depth_type getMaxDepthAfter() const;
198         ///
199         void applyLayout(LyXLayout_ptr const & new_layout);
200         ///
201         void erase(lyx::pos_type pos);
202         /** Get unistantiated font setting. Returns the difference
203             between the characters font and the layoutfont.
204             This is what is stored in the fonttable
205         */
206         LyXFont const
207         getFontSettings(BufferParams const &, lyx::pos_type pos) const;
208         ///
209         LyXFont const getFirstFontSettings() const;
210
211         /** Get fully instantiated font. If pos == -1, use the layout
212             font attached to this paragraph.
213             If pos == -2, use the label font of the layout attached here.
214             In all cases, the font is instantiated, i.e. does not have any
215             attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
216             LyXFont::TOGGLE.
217         */
218         LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const;
219         LyXFont const getLayoutFont(BufferParams const &) const;
220         LyXFont const getLabelFont(BufferParams const &) const;
221         ///
222         value_type getChar(lyx::pos_type pos) const;
223         ///
224         value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
225         /// The position must already exist.
226         void setChar(lyx::pos_type pos, value_type c);
227         /// pos <= size() (there is a dummy font change at the end of each par)
228         void setFont(lyx::pos_type pos, LyXFont const & font);
229         /// Returns the height of the highest font in range
230         LyXFont::FONT_SIZE
231         highestFontInRange(lyx::pos_type startpos,
232                            lyx::pos_type endpos,
233                            LyXFont::FONT_SIZE const def_size) const;
234         ///
235         void insertChar(lyx::pos_type pos, value_type c);
236         ///
237         void insertChar(lyx::pos_type pos, value_type c, LyXFont const &);
238         ///
239         bool checkInsertChar(LyXFont &);
240         ///
241         void insertInset(lyx::pos_type pos, Inset * inset);
242         ///
243         void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &);
244         ///
245         bool insetAllowed(Inset::Code code);
246         ///
247         Inset * getInset(lyx::pos_type pos);
248         ///
249         Inset const * getInset(lyx::pos_type pos) const;
250         /** important for cut and paste
251             Temporary change from BufferParams to Buffer. Will revert when we
252             get rid of the argument to Inset::clone(Buffer const &) */
253         void copyIntoMinibuffer(Buffer const &, lyx::pos_type pos) const;
254         ///
255         void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
256         ///
257         bool insertFromMinibuffer(lyx::pos_type pos);
258
259         ///
260         bool isHfill(lyx::pos_type pos) const;
261         ///
262         bool isInset(lyx::pos_type pos) const;
263         ///
264         bool isNewline(lyx::pos_type pos) const;
265         ///
266         bool isSeparator(lyx::pos_type pos) const;
267         ///
268         bool isLineSeparator(lyx::pos_type pos) const;
269         ///
270         bool isKomma(lyx::pos_type pos) const;
271         /// Used by the spellchecker
272         bool isLetter(lyx::pos_type pos) const;
273         ///
274         bool isWord(lyx::pos_type pos) const;
275
276         /// returns -1 if inset not found
277         int getPositionOfInset(Inset const * inset) const;
278
279         /// some good comment here John?
280         Paragraph * getParFromID(int id) const;
281
282         ///
283         int stripLeadingSpaces();
284
285         ///
286         bool isFreeSpacing() const;
287
288         ///
289         ParagraphParameters & params();
290         ///
291         ParagraphParameters const & params() const;
292         ///
293         InsetList insetlist;
294         ///
295         //Counters & counters();
296
297 private:
298         ///
299         LyXLayout_ptr layout_;
300         /// if anything uses this we don't want it to.
301         Paragraph(Paragraph const &);
302 #ifndef NO_NEXT
303         ///
304         Paragraph * next_;
305         ///
306         Paragraph * previous_;
307 #endif
308         struct Pimpl;
309         ///
310         friend struct Paragraph::Pimpl;
311         ///
312         Pimpl * pimpl_;
313 };
314
315 #endif