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;
86 /// this constructor inserts the new paragraph in a list
88 Paragraph(Paragraph * par);
90 Paragraph(Paragraph const &, bool same_ids);
91 /// the destructor removes the new paragraph from the list
95 Language const * getParLanguage(BufferParams const &) const;
97 bool isRightToLeftPar(BufferParams const &) const;
99 void changeLanguage(BufferParams const & bparams,
100 Language const * from, Language const * to);
102 bool isMultiLingual(BufferParams const &);
105 string const asString(Buffer const *, bool label);
107 string const asString(Buffer const *, lyx::pos_type beg, lyx::pos_type end,
111 void writeFile(Buffer const *, std::ostream &, BufferParams const &,
114 void validate(LaTeXFeatures &) const;
116 /// return the unique ID of this paragraph
122 Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
123 std::ostream &, TexRow & texrow,
127 int startTeXParParams(BufferParams const &, std::ostream &, bool) const;
130 int endTeXParParams(BufferParams const &, std::ostream &, bool) const;
134 bool simpleTeXOnePar(Buffer const *, BufferParams const &,
135 std::ostream &, TexRow & texrow, bool moving_arg);
138 Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
139 std::ostream &, TexRow & texrow);
141 bool hasSameLayout(Paragraph const * par) const;
144 void makeSameLayout(Paragraph const * par);
146 /// Is it the first par with same depth and layout?
147 bool isFirstInSequence() const;
149 /** Check if the current paragraph is the last paragraph in a
151 int getEndLabel() const;
153 Inset * inInset() const;
155 void setInsetOwner(Inset * i);
157 void deleteInsetsLyXText(BufferView *);
159 void resizeInsetsLyXText(BufferView *);
162 lyx::pos_type size() const;
166 void setContentsFromPar(Paragraph * par);
168 void clearContents();
171 LyXLayout_ptr const & layout() const;
173 void layout(LyXLayout_ptr const & new_layout);
182 InsetBibKey * bibkey; // ale970302
185 void next(Paragraph *);
186 /** these function are able to hide closed footnotes
190 Paragraph const * next() const;
193 void previous(Paragraph *);
195 Paragraph * previous();
197 Paragraph const * previous() const;
199 /// for the environments
200 Paragraph * depthHook(depth_type depth);
201 /// for the environments
202 Paragraph const * depthHook(depth_type depth) const;
204 Paragraph * outerHook();
206 Paragraph const * outerHook() const;
208 int beginningOfMainBody() const;
210 string const & getLabelstring() const;
212 /// the next two functions are for the manual labels
213 string const getLabelWidthString() const;
215 void setLabelWidthString(string const & s);
217 char getAlign() const;
218 /// The nesting depth of a paragraph
219 depth_type getDepth() const;
220 /// The maximal possible depth of a paragraph after this one
221 depth_type getMaxDepthAfter() const;
223 void applyLayout(LyXLayout_ptr const & new_layout);
225 int getFirstCounter(int i) const;
227 void erase(lyx::pos_type pos);
228 /** the flag determines wether the layout should be copied
230 void breakParagraph(BufferParams const &, lyx::pos_type pos, int flag);
232 void breakParagraphConservative(BufferParams const &, lyx::pos_type pos);
233 /** Get unistantiated font setting. Returns the difference
234 between the characters font and the layoutfont.
235 This is what is stored in the fonttable
238 getFontSettings(BufferParams const &, lyx::pos_type pos) const;
240 LyXFont const getFirstFontSettings() const;
242 /** Get fully instantiated font. If pos == -1, use the layout
243 font attached to this paragraph.
244 If pos == -2, use the label font of the layout attached here.
245 In all cases, the font is instantiated, i.e. does not have any
246 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
249 LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const;
250 LyXFont const getLayoutFont(BufferParams const &) const;
251 LyXFont const getLabelFont(BufferParams const &) const;
253 value_type getChar(lyx::pos_type pos) const;
255 value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
256 /// The position must already exist.
257 void setChar(lyx::pos_type pos, value_type c);
258 /// pos <= size() (there is a dummy font change at the end of each par)
259 void setFont(lyx::pos_type pos, LyXFont const & font);
260 /// Returns the height of the highest font in range
262 highestFontInRange(lyx::pos_type startpos,
263 lyx::pos_type endpos,
264 LyXFont::FONT_SIZE const def_size) const;
266 void insertChar(lyx::pos_type pos, value_type c);
268 void insertChar(lyx::pos_type pos, value_type c, LyXFont const &);
270 bool checkInsertChar(LyXFont &);
272 void insertInset(lyx::pos_type pos, Inset * inset);
274 void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &);
276 bool insetAllowed(Inset::Code code);
278 Inset * getInset(lyx::pos_type pos);
280 Inset const * getInset(lyx::pos_type pos) const;
281 /** important for cut and paste
282 Temporary change from BufferParams to Buffer. Will revert when we
283 get rid of the argument to Inset::clone(Buffer const &) */
284 void copyIntoMinibuffer(Buffer const &, lyx::pos_type pos) const;
286 void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
288 bool insertFromMinibuffer(lyx::pos_type pos);
291 bool isHfill(lyx::pos_type pos) const;
293 bool isInset(lyx::pos_type pos) const;
295 bool isNewline(lyx::pos_type pos) const;
297 bool isSeparator(lyx::pos_type pos) const;
299 bool isLineSeparator(lyx::pos_type pos) const;
301 bool isKomma(lyx::pos_type pos) const;
302 /// Used by the spellchecker
303 bool isLetter(lyx::pos_type pos) const;
305 bool isWord(lyx::pos_type pos) const;
307 /** paste this paragraph with the next one
308 be carefull, this doesent make any check at all
310 void pasteParagraph(BufferParams const &);
312 /// returns -1 if inset not found
313 int getPositionOfInset(Inset const * inset) const;
315 /// some good comment here John?
316 Paragraph * getParFromID(int id) const;
319 int stripLeadingSpaces();
321 #ifndef NO_PEXTRA_REALLY
322 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
323 I have to set it on each of it's elements */
325 void setPExtraType(BufferParams const &, int type,
326 string const & width, string const & widthp);
328 void unsetPExtraType(BufferParams const &);
331 bool isFreeSpacing() const;
334 ParagraphParameters & params();
336 ParagraphParameters const & params() const;
340 Counters & counters();
344 LyXLayout_ptr layout_;
345 /// if anything uses this we don't want it to.
346 Paragraph(Paragraph const &);
350 Paragraph * previous_;
354 friend struct Paragraph::Pimpl;