]> git.lyx.org Git - lyx.git/blob - src/paragraph.h
add some NO_NEXT ifdefs
[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 // After 1.2.0 is released, during 1.3.0cvs, we enable this. And after
36 // a while we verify that reading of 1.2.x files work perfectly we remove
37 // this code completely. (Lgb)
38 #define NO_PEXTRA_REALLY 1
39
40 // Define this if you want to try out the new storage container for
41 // paragraphs. (Lgb)
42 // This is non working and far from finished.
43 // #define NO_NEXT 1
44
45 /// A Paragraph holds all text, attributes and insets in a text paragraph
46 class Paragraph  {
47 public:
48 #ifndef NO_PEXTRA_REALLY
49         ///
50         enum PEXTRA_TYPE {
51                 ///
52                 PEXTRA_NONE,
53                 ///
54                 PEXTRA_INDENT,
55                 ///
56                 PEXTRA_MINIPAGE,
57                 ///
58                 PEXTRA_FLOATFLT
59         };
60         ///
61         enum MINIPAGE_ALIGNMENT {
62                 ///
63                 MINIPAGE_ALIGN_TOP,
64                 ///
65                 MINIPAGE_ALIGN_MIDDLE,
66                 ///
67                 MINIPAGE_ALIGN_BOTTOM
68         };
69 #endif
70         ///
71         enum META_KIND {
72                 ///
73                 META_HFILL = 1,
74                 ///
75                 META_NEWLINE,
76                 ///
77                 META_INSET
78         };
79         ///
80         typedef char value_type;
81         /// The same as ParameterStruct::depth_type
82         typedef unsigned int depth_type;
83
84         ///
85         Paragraph();
86 #ifndef NO_NEXT
87         /// this constructor inserts the new paragraph in a list
88         explicit
89         Paragraph(Paragraph * par);
90 #endif
91         ///
92         Paragraph(Paragraph const &, bool same_ids);
93         /// the destructor removes the new paragraph from the list
94         ~Paragraph();
95
96         ///
97         Language const * getParLanguage(BufferParams const &) const;
98         ///
99         bool isRightToLeftPar(BufferParams const &) const;
100         ///
101         void changeLanguage(BufferParams const & bparams,
102                             Language const * from, Language const * to);
103         ///
104         bool isMultiLingual(BufferParams const &);
105
106         ///
107         string const asString(Buffer const *, bool label);
108         ///
109         string const asString(Buffer const *, lyx::pos_type beg, lyx::pos_type end,
110                               bool label);
111
112         ///
113         void writeFile(Buffer const *, std::ostream &, BufferParams const &,
114                        depth_type) const;
115         ///
116         void validate(LaTeXFeatures &) const;
117
118         /// return the unique ID of this paragraph
119         int id() const;
120         ///
121         void read();
122
123         ///
124         Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
125                                  std::ostream &, TexRow & texrow,
126                                  bool moving_arg);
127
128         ///
129         int startTeXParParams(BufferParams const &, std::ostream &, bool) const;
130
131         ///
132         int endTeXParParams(BufferParams const &, std::ostream &, bool) const;
133
134
135         ///
136         bool simpleTeXOnePar(Buffer const *, BufferParams const &,
137                              std::ostream &, TexRow & texrow, bool moving_arg);
138
139         ///
140         Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
141                                       std::ostream &, TexRow & texrow);
142         ///
143         bool hasSameLayout(Paragraph const * par) const;
144
145         ///
146         void makeSameLayout(Paragraph const * par);
147
148         /// Is it the first par with same depth and layout?
149         bool isFirstInSequence() const;
150
151         /** Check if the current paragraph is the last paragraph in a
152             proof environment */
153         int getEndLabel() const;
154         ///
155         Inset * inInset() const;
156         ///
157         void setInsetOwner(Inset * i);
158         ///
159         void deleteInsetsLyXText(BufferView *);
160         ///
161         void resizeInsetsLyXText(BufferView *);
162
163         ///
164         lyx::pos_type size() const;
165         ///
166         bool empty() const;
167         ///
168         void setContentsFromPar(Paragraph * par);
169         ///
170         void clearContents();
171
172         ///
173         LyXLayout_ptr const & layout() const;
174         ///
175         void layout(LyXLayout_ptr const & new_layout);
176
177         ///
178         char enumdepth;
179
180         ///
181         char itemdepth;
182
183         ///
184         InsetBibKey * bibkey;  // ale970302
185
186 #ifndef NO_NEXT
187         ///
188         void next(Paragraph *);
189         /** these function are able to hide closed footnotes
190          */
191         Paragraph * next();
192         ///
193         Paragraph const * next() const;
194
195         ///
196         void previous(Paragraph *);
197         ///
198         Paragraph * previous();
199         ///
200         Paragraph const * previous() const;
201 #endif
202         /// for the environments
203         Paragraph * depthHook(depth_type depth);
204         /// for the environments
205         Paragraph const * depthHook(depth_type depth) const;
206         ///
207         Paragraph * outerHook();
208         ///
209         Paragraph const * outerHook() const;
210         ///
211         int beginningOfMainBody() const;
212         ///
213         string const & getLabelstring() const;
214
215         /// the next two functions are for the manual labels
216         string const getLabelWidthString() const;
217         ///
218         void setLabelWidthString(string const & s);
219         ///
220         char getAlign() const;
221         /// The nesting depth of a paragraph
222         depth_type getDepth() const;
223         /// The maximal possible depth of a paragraph after this one
224         depth_type getMaxDepthAfter() const;
225         ///
226         void applyLayout(LyXLayout_ptr const & new_layout);
227         ///
228         void erase(lyx::pos_type pos);
229         /** the flag determines wether the layout should be copied
230          */
231         void breakParagraph(BufferParams const &, lyx::pos_type pos, int flag);
232         ///
233         void breakParagraphConservative(BufferParams const &, lyx::pos_type pos);
234         /** Get unistantiated font setting. Returns the difference
235             between the characters font and the layoutfont.
236             This is what is stored in the fonttable
237         */
238         LyXFont const
239         getFontSettings(BufferParams const &, lyx::pos_type pos) const;
240         ///
241         LyXFont const getFirstFontSettings() const;
242
243         /** Get fully instantiated font. If pos == -1, use the layout
244             font attached to this paragraph.
245             If pos == -2, use the label font of the layout attached here.
246             In all cases, the font is instantiated, i.e. does not have any
247             attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
248             LyXFont::TOGGLE.
249         */
250         LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const;
251         LyXFont const getLayoutFont(BufferParams const &) const;
252         LyXFont const getLabelFont(BufferParams const &) const;
253         ///
254         value_type getChar(lyx::pos_type pos) const;
255         ///
256         value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
257         /// The position must already exist.
258         void setChar(lyx::pos_type pos, value_type c);
259         /// pos <= size() (there is a dummy font change at the end of each par)
260         void setFont(lyx::pos_type pos, LyXFont const & font);
261         /// Returns the height of the highest font in range
262         LyXFont::FONT_SIZE
263         highestFontInRange(lyx::pos_type startpos,
264                            lyx::pos_type endpos,
265                            LyXFont::FONT_SIZE const def_size) const;
266         ///
267         void insertChar(lyx::pos_type pos, value_type c);
268         ///
269         void insertChar(lyx::pos_type pos, value_type c, LyXFont const &);
270         ///
271         bool checkInsertChar(LyXFont &);
272         ///
273         void insertInset(lyx::pos_type pos, Inset * inset);
274         ///
275         void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &);
276         ///
277         bool insetAllowed(Inset::Code code);
278         ///
279         Inset * getInset(lyx::pos_type pos);
280         ///
281         Inset const * getInset(lyx::pos_type pos) const;
282         /** important for cut and paste
283             Temporary change from BufferParams to Buffer. Will revert when we
284             get rid of the argument to Inset::clone(Buffer const &) */
285         void copyIntoMinibuffer(Buffer const &, lyx::pos_type pos) const;
286         ///
287         void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
288         ///
289         bool insertFromMinibuffer(lyx::pos_type pos);
290
291         ///
292         bool isHfill(lyx::pos_type pos) const;
293         ///
294         bool isInset(lyx::pos_type pos) const;
295         ///
296         bool isNewline(lyx::pos_type pos) const;
297         ///
298         bool isSeparator(lyx::pos_type pos) const;
299         ///
300         bool isLineSeparator(lyx::pos_type pos) const;
301         ///
302         bool isKomma(lyx::pos_type pos) const;
303         /// Used by the spellchecker
304         bool isLetter(lyx::pos_type pos) const;
305         ///
306         bool isWord(lyx::pos_type pos) const;
307
308         /** paste this paragraph with the next one
309             be carefull, this doesent make any check at all
310         */
311         void pasteParagraph(BufferParams const &);
312
313         /// returns -1 if inset not found
314         int getPositionOfInset(Inset const * inset) const;
315
316         /// some good comment here John?
317         Paragraph * getParFromID(int id) const;
318
319         ///
320         int stripLeadingSpaces();
321
322 #ifndef NO_PEXTRA_REALLY
323         /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
324            I have to set it on each of it's elements */
325         ///
326         void setPExtraType(BufferParams const &, int type,
327                            string const & width, string const & widthp);
328         ///
329         void unsetPExtraType(BufferParams const &);
330 #endif
331         ///
332         bool isFreeSpacing() const;
333
334         ///
335         ParagraphParameters & params();
336         ///
337         ParagraphParameters const & params() const;
338         ///
339         InsetList insetlist;
340         ///
341         Counters & counters();
342
343 private:
344         ///
345         LyXLayout_ptr layout_;
346         /// if anything uses this we don't want it to.
347         Paragraph(Paragraph const &);
348 #ifndef NO_NEXT
349         ///
350         Paragraph * next_;
351         ///
352         Paragraph * previous_;
353 #endif
354         struct Pimpl;
355         ///
356         friend struct Paragraph::Pimpl;
357         ///
358         Pimpl * pimpl_;
359 };
360
361 #endif