4 * Copyright 1995 Matthias Ettrich
5 * Copyright 2002 the LyX Team
6 * Read the file COPYING
16 #include "lyxlayout_ptr_fwd.h"
17 #include "lyxfont.h" // Just for LyXFont::FONT_SIZE
18 #include "InsetList.h"
20 #include "insets/inset.h" // Just for Inset::Code
22 #include "support/types.h"
32 class ParagraphParameters;
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
40 // Define this if you want to try out the new storage container for
42 // This is non working and far from finished.
45 /// A Paragraph holds all text, attributes and insets in a text paragraph
48 #ifndef NO_PEXTRA_REALLY
61 enum MINIPAGE_ALIGNMENT {
65 MINIPAGE_ALIGN_MIDDLE,
80 typedef char value_type;
81 /// The same as ParameterStruct::depth_type
82 typedef unsigned int depth_type;
87 /// this constructor inserts the new paragraph in a list
89 Paragraph(Paragraph * par);
92 Paragraph(Paragraph const &, bool same_ids);
93 /// the destructor removes the new paragraph from the list
97 Language const * getParLanguage(BufferParams const &) const;
99 bool isRightToLeftPar(BufferParams const &) const;
101 void changeLanguage(BufferParams const & bparams,
102 Language const * from, Language const * to);
104 bool isMultiLingual(BufferParams const &);
107 string const asString(Buffer const *, bool label);
109 string const asString(Buffer const *, lyx::pos_type beg, lyx::pos_type end,
113 void write(Buffer const *, std::ostream &, BufferParams const &,
116 void validate(LaTeXFeatures &) const;
118 /// return the unique ID of this paragraph
124 Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
125 std::ostream &, TexRow & texrow,
129 int startTeXParParams(BufferParams const &, std::ostream &, bool) const;
132 int endTeXParParams(BufferParams const &, std::ostream &, bool) const;
136 bool simpleTeXOnePar(Buffer const *, BufferParams const &,
137 std::ostream &, TexRow & texrow, bool moving_arg);
140 Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
141 std::ostream &, TexRow & texrow);
143 bool hasSameLayout(Paragraph const * par) const;
146 void makeSameLayout(Paragraph const * par);
148 /// Is it the first par with same depth and layout?
149 bool isFirstInSequence() const;
151 /** Check if the current paragraph is the last paragraph in a
153 int getEndLabel() const;
155 Inset * inInset() const;
157 void setInsetOwner(Inset * i);
159 void deleteInsetsLyXText(BufferView *);
161 void resizeInsetsLyXText(BufferView *);
164 lyx::pos_type size() const;
168 void setContentsFromPar(Paragraph * par);
170 void clearContents();
173 LyXLayout_ptr const & layout() const;
175 void layout(LyXLayout_ptr const & new_layout);
184 InsetBibKey * bibkey; // ale970302
188 void next(Paragraph *);
189 /** these function are able to hide closed footnotes
193 Paragraph const * next() const;
196 void previous(Paragraph *);
198 Paragraph * previous();
200 Paragraph const * previous() const;
202 /// for the environments
203 Paragraph * depthHook(depth_type depth);
204 /// for the environments
205 Paragraph const * depthHook(depth_type depth) const;
207 Paragraph * outerHook();
209 Paragraph const * outerHook() const;
211 int beginningOfMainBody() const;
213 string const & getLabelstring() const;
215 /// the next two functions are for the manual labels
216 string const getLabelWidthString() const;
218 void setLabelWidthString(string const & s);
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;
226 void applyLayout(LyXLayout_ptr const & new_layout);
228 void erase(lyx::pos_type pos);
229 /** Get unistantiated font setting. Returns the difference
230 between the characters font and the layoutfont.
231 This is what is stored in the fonttable
234 getFontSettings(BufferParams const &, lyx::pos_type pos) const;
236 LyXFont const getFirstFontSettings() const;
238 /** Get fully instantiated font. If pos == -1, use the layout
239 font attached to this paragraph.
240 If pos == -2, use the label font of the layout attached here.
241 In all cases, the font is instantiated, i.e. does not have any
242 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
245 LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const;
246 LyXFont const getLayoutFont(BufferParams const &) const;
247 LyXFont const getLabelFont(BufferParams const &) const;
249 value_type getChar(lyx::pos_type pos) const;
251 value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
252 /// The position must already exist.
253 void setChar(lyx::pos_type pos, value_type c);
254 /// pos <= size() (there is a dummy font change at the end of each par)
255 void setFont(lyx::pos_type pos, LyXFont const & font);
256 /// Returns the height of the highest font in range
258 highestFontInRange(lyx::pos_type startpos,
259 lyx::pos_type endpos,
260 LyXFont::FONT_SIZE const def_size) const;
262 void insertChar(lyx::pos_type pos, value_type c);
264 void insertChar(lyx::pos_type pos, value_type c, LyXFont const &);
266 bool checkInsertChar(LyXFont &);
268 void insertInset(lyx::pos_type pos, Inset * inset);
270 void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &);
272 bool insetAllowed(Inset::Code code);
274 Inset * getInset(lyx::pos_type pos);
276 Inset const * getInset(lyx::pos_type pos) const;
277 /** important for cut and paste
278 Temporary change from BufferParams to Buffer. Will revert when we
279 get rid of the argument to Inset::clone(Buffer const &) */
280 void copyIntoMinibuffer(Buffer const &, lyx::pos_type pos) const;
282 void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
284 bool insertFromMinibuffer(lyx::pos_type pos);
287 bool isHfill(lyx::pos_type pos) const;
289 bool isInset(lyx::pos_type pos) const;
291 bool isNewline(lyx::pos_type pos) const;
293 bool isSeparator(lyx::pos_type pos) const;
295 bool isLineSeparator(lyx::pos_type pos) const;
297 bool isKomma(lyx::pos_type pos) const;
298 /// Used by the spellchecker
299 bool isLetter(lyx::pos_type pos) const;
301 bool isWord(lyx::pos_type pos) const;
303 /** paste this paragraph with the next one
304 be carefull, this doesent make any check at all
306 void pasteParagraph(BufferParams const &);
308 /// returns -1 if inset not found
309 int getPositionOfInset(Inset const * inset) const;
311 /// some good comment here John?
312 Paragraph * getParFromID(int id) const;
315 int stripLeadingSpaces();
317 #ifndef NO_PEXTRA_REALLY
318 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
319 I have to set it on each of it's elements */
321 void setPExtraType(BufferParams const &, int type,
322 string const & width, string const & widthp);
324 void unsetPExtraType(BufferParams const &);
327 bool isFreeSpacing() const;
330 ParagraphParameters & params();
332 ParagraphParameters const & params() const;
336 Counters & counters();
340 LyXLayout_ptr layout_;
341 /// if anything uses this we don't want it to.
342 Paragraph(Paragraph const &);
347 Paragraph * previous_;
351 friend struct Paragraph::Pimpl;