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 // Define this if you want to try out the new storage container for
37 // This is non working and far from finished.
40 /// A Paragraph holds all text, attributes and insets in a text paragraph
53 typedef char value_type;
54 /// The same as ParameterStruct::depth_type
55 typedef unsigned int depth_type;
60 /// this constructor inserts the new paragraph in a list
62 Paragraph(Paragraph * par);
65 Paragraph(Paragraph const &, bool same_ids);
66 /// the destructor removes the new paragraph from the list
70 Language const * getParLanguage(BufferParams const &) const;
72 bool isRightToLeftPar(BufferParams const &) const;
74 void changeLanguage(BufferParams const & bparams,
75 Language const * from, Language const * to);
77 bool isMultiLingual(BufferParams const &);
80 string const asString(Buffer const *, bool label);
82 string const asString(Buffer const *, lyx::pos_type beg, lyx::pos_type end,
86 void write(Buffer const *, std::ostream &, BufferParams const &,
89 void validate(LaTeXFeatures &) const;
91 /// return the unique ID of this paragraph
97 Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
98 std::ostream &, TexRow & texrow,
102 int startTeXParParams(BufferParams const &, std::ostream &, bool) const;
105 int endTeXParParams(BufferParams const &, std::ostream &, bool) const;
109 bool simpleTeXOnePar(Buffer const *, BufferParams const &,
110 std::ostream &, TexRow & texrow, bool moving_arg);
113 Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
114 std::ostream &, TexRow & texrow);
116 bool hasSameLayout(Paragraph const * par) const;
119 void makeSameLayout(Paragraph const * par);
121 /// Is it the first par with same depth and layout?
122 bool isFirstInSequence() const;
124 /** Check if the current paragraph is the last paragraph in a
126 int getEndLabel() const;
128 Inset * inInset() const;
130 void setInsetOwner(Inset * i);
132 void deleteInsetsLyXText(BufferView *);
134 void resizeInsetsLyXText(BufferView *);
137 lyx::pos_type size() const;
141 void setContentsFromPar(Paragraph * par);
143 void clearContents();
146 LyXLayout_ptr const & layout() const;
148 void layout(LyXLayout_ptr const & new_layout);
157 InsetBibKey * bibkey; // ale970302
161 void next(Paragraph *);
162 /** these function are able to hide closed footnotes
166 Paragraph const * next() const;
169 void previous(Paragraph *);
171 Paragraph * previous();
173 Paragraph const * previous() const;
175 /// for the environments
176 Paragraph * depthHook(depth_type depth);
177 /// for the environments
178 Paragraph const * depthHook(depth_type depth) const;
180 Paragraph * outerHook();
182 Paragraph const * outerHook() const;
184 int beginningOfMainBody() const;
186 string const & getLabelstring() const;
188 /// the next two functions are for the manual labels
189 string const getLabelWidthString() const;
191 void setLabelWidthString(string const & s);
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;
199 void applyLayout(LyXLayout_ptr const & new_layout);
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
207 getFontSettings(BufferParams const &, lyx::pos_type pos) const;
209 LyXFont const getFirstFontSettings() const;
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
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;
222 value_type getChar(lyx::pos_type pos) const;
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
231 highestFontInRange(lyx::pos_type startpos,
232 lyx::pos_type endpos,
233 LyXFont::FONT_SIZE const def_size) const;
235 void insertChar(lyx::pos_type pos, value_type c);
237 void insertChar(lyx::pos_type pos, value_type c, LyXFont const &);
239 bool checkInsertChar(LyXFont &);
241 void insertInset(lyx::pos_type pos, Inset * inset);
243 void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &);
245 bool insetAllowed(Inset::Code code);
247 Inset * getInset(lyx::pos_type pos);
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;
255 void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
257 bool insertFromMinibuffer(lyx::pos_type pos);
260 bool isHfill(lyx::pos_type pos) const;
262 bool isInset(lyx::pos_type pos) const;
264 bool isNewline(lyx::pos_type pos) const;
266 bool isSeparator(lyx::pos_type pos) const;
268 bool isLineSeparator(lyx::pos_type pos) const;
270 bool isKomma(lyx::pos_type pos) const;
271 /// Used by the spellchecker
272 bool isLetter(lyx::pos_type pos) const;
274 bool isWord(lyx::pos_type pos) const;
276 /// returns -1 if inset not found
277 int getPositionOfInset(Inset const * inset) const;
279 /// some good comment here John?
280 Paragraph * getParFromID(int id) const;
283 int stripLeadingSpaces();
286 bool isFreeSpacing() const;
289 ParagraphParameters & params();
291 ParagraphParameters const & params() const;
295 //Counters & counters();
299 LyXLayout_ptr layout_;
300 /// if anything uses this we don't want it to.
301 Paragraph(Paragraph const &);
306 Paragraph * previous_;
310 friend struct Paragraph::Pimpl;