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 writeFile(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 /** the flag determines wether the layout should be copied
231 void breakParagraph(BufferParams const &, lyx::pos_type pos, int flag);
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
239 getFontSettings(BufferParams const &, lyx::pos_type pos) const;
241 LyXFont const getFirstFontSettings() const;
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
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;
254 value_type getChar(lyx::pos_type pos) const;
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
263 highestFontInRange(lyx::pos_type startpos,
264 lyx::pos_type endpos,
265 LyXFont::FONT_SIZE const def_size) const;
267 void insertChar(lyx::pos_type pos, value_type c);
269 void insertChar(lyx::pos_type pos, value_type c, LyXFont const &);
271 bool checkInsertChar(LyXFont &);
273 void insertInset(lyx::pos_type pos, Inset * inset);
275 void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &);
277 bool insetAllowed(Inset::Code code);
279 Inset * getInset(lyx::pos_type pos);
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;
287 void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
289 bool insertFromMinibuffer(lyx::pos_type pos);
292 bool isHfill(lyx::pos_type pos) const;
294 bool isInset(lyx::pos_type pos) const;
296 bool isNewline(lyx::pos_type pos) const;
298 bool isSeparator(lyx::pos_type pos) const;
300 bool isLineSeparator(lyx::pos_type pos) const;
302 bool isKomma(lyx::pos_type pos) const;
303 /// Used by the spellchecker
304 bool isLetter(lyx::pos_type pos) const;
306 bool isWord(lyx::pos_type pos) const;
308 /** paste this paragraph with the next one
309 be carefull, this doesent make any check at all
311 void pasteParagraph(BufferParams const &);
313 /// returns -1 if inset not found
314 int getPositionOfInset(Inset const * inset) const;
316 /// some good comment here John?
317 Paragraph * getParFromID(int id) const;
320 int stripLeadingSpaces();
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 */
326 void setPExtraType(BufferParams const &, int type,
327 string const & width, string const & widthp);
329 void unsetPExtraType(BufferParams const &);
332 bool isFreeSpacing() const;
335 ParagraphParameters & params();
337 ParagraphParameters const & params() const;
341 Counters & counters();
345 LyXLayout_ptr layout_;
346 /// if anything uses this we don't want it to.
347 Paragraph(Paragraph const &);
352 Paragraph * previous_;
356 friend struct Paragraph::Pimpl;