4 * Copyright 1995 Matthias Ettrich
5 * Copyright 2002 the LyX Team
6 * Read the file COPYING
18 #include "lyxlayout_ptr_fwd.h"
19 #include "insets/inset.h" // Just for Inset::Code
20 #include "lyxfont.h" // Just for LyXFont::FONT_SIZE
21 #include "support/types.h"
23 class ParagraphParameters;
31 // After 1.2.0 is released, during 1.3.0cvs, we enable this. And after
32 // a while we verify that reading of 1.2.x files work perfectly we remove
33 // this code completely. (Lgb)
34 #define NO_PEXTRA_REALLY 1
36 // Define this if you want to try out the new storage container for
37 // paragraphs. std::container instead of obfuscated homegrown
39 // This is non working and far from finished.
42 /// A Paragraph holds all text, attributes and insets in a text paragraph
45 #ifndef NO_PEXTRA_REALLY
58 enum MINIPAGE_ALIGNMENT {
62 MINIPAGE_ALIGN_MIDDLE,
77 typedef char value_type;
78 /// The same as ParameterStruct::depth_type
79 typedef unsigned int depth_type;
83 /// this constructor inserts the new paragraph in a list
85 Paragraph(Paragraph * par);
87 Paragraph(Paragraph const &, bool same_ids);
88 /// the destructor removes the new paragraph from the list
92 Language const * getParLanguage(BufferParams const &) const;
94 bool isRightToLeftPar(BufferParams const &) const;
96 void changeLanguage(BufferParams const & bparams,
97 Language const * from, Language const * to);
99 bool isMultiLingual(BufferParams const &);
102 string const asString(Buffer const *, bool label);
104 string const asString(Buffer const *, lyx::pos_type beg, lyx::pos_type end,
108 void writeFile(Buffer const *, std::ostream &, BufferParams const &,
111 void validate(LaTeXFeatures &) const;
121 Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
122 std::ostream &, TexRow & texrow,
126 int startTeXParParams(BufferParams const &, std::ostream &, bool) const;
129 int endTeXParParams(BufferParams const &, std::ostream &, bool) const;
133 bool simpleTeXOnePar(Buffer const *, BufferParams const &,
134 std::ostream &, TexRow & texrow, bool moving_arg);
137 Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
138 std::ostream &, TexRow & texrow);
140 bool hasSameLayout(Paragraph const * par) const;
143 void makeSameLayout(Paragraph const * par);
145 /// Is it the first par with same depth and layout?
146 bool isFirstInSequence() const;
148 /** Check if the current paragraph is the last paragraph in a
150 int getEndLabel() const;
152 Inset * inInset() const;
154 void setInsetOwner(Inset * i);
156 void deleteInsetsLyXText(BufferView *);
158 void resizeInsetsLyXText(BufferView *);
161 lyx::pos_type size() const;
163 void setContentsFromPar(Paragraph * par);
165 void clearContents();
168 LyXLayout_ptr const & layout() const;
170 void layout(LyXLayout_ptr const & new_layout);
173 void setCounter(int i, int v);
175 int getCounter(int i) const;
177 void incCounter(int i);
186 InsetBibKey * bibkey; // ale970302
189 void next(Paragraph *);
190 /** these function are able to hide closed footnotes
194 Paragraph const * next() const;
197 void previous(Paragraph *);
199 Paragraph * previous();
201 Paragraph const * previous() const;
203 /// for the environments
204 Paragraph * depthHook(depth_type depth);
205 /// for the environments
206 Paragraph const * depthHook(depth_type depth) const;
208 Paragraph * outerHook();
210 Paragraph const * outerHook() const;
212 int beginningOfMainBody() const;
214 string const & getLabelstring() const;
216 /// the next two functions are for the manual labels
217 string const getLabelWidthString() const;
219 void setLabelWidthString(string const & s);
221 char getAlign() const;
222 /// The nesting depth of a paragraph
223 depth_type getDepth() const;
224 /// The maximal possible depth of a paragraph after this one
225 depth_type getMaxDepthAfter() const;
227 void applyLayout(LyXLayout_ptr const & new_layout);
229 int getFirstCounter(int i) const;
231 void erase(lyx::pos_type pos);
232 /** the flag determines wether the layout should be copied
234 void breakParagraph(BufferParams const &, lyx::pos_type pos, int flag);
236 void breakParagraphConservative(BufferParams const &, lyx::pos_type pos);
237 /** Get unistantiated font setting. Returns the difference
238 between the characters font and the layoutfont.
239 This is what is stored in the fonttable
242 getFontSettings(BufferParams const &, lyx::pos_type pos) const;
244 LyXFont const getFirstFontSettings() const;
246 /** Get fully instantiated font. If pos == -1, use the layout
247 font attached to this paragraph.
248 If pos == -2, use the label font of the layout attached here.
249 In all cases, the font is instantiated, i.e. does not have any
250 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
253 LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const;
254 LyXFont const getLayoutFont(BufferParams const &) const;
255 LyXFont const getLabelFont(BufferParams const &) const;
257 value_type getChar(lyx::pos_type pos) const;
259 value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
260 /// The position must already exist.
261 void setChar(lyx::pos_type pos, value_type c);
262 /// pos <= size() (there is a dummy font change at the end of each par)
263 void setFont(lyx::pos_type pos, LyXFont const & font);
264 /// Returns the height of the highest font in range
265 LyXFont::FONT_SIZE highestFontInRange(lyx::pos_type startpos,
266 lyx::pos_type endpos,
267 LyXFont::FONT_SIZE const def_size) const;
269 void insertChar(lyx::pos_type pos, value_type c);
271 void insertChar(lyx::pos_type pos, value_type c, LyXFont const &);
273 bool checkInsertChar(LyXFont &);
275 void insertInset(lyx::pos_type pos, Inset * inset);
277 void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &);
279 bool insetAllowed(Inset::Code code);
281 Inset * getInset(lyx::pos_type pos);
283 Inset const * getInset(lyx::pos_type pos) const;
284 /** important for cut and paste
285 Temporary change from BufferParams to Buffer. Will revert when we
286 get rid of the argument to Inset::clone(Buffer const &) */
287 void copyIntoMinibuffer(Buffer const &, lyx::pos_type pos) const;
289 void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
291 bool insertFromMinibuffer(lyx::pos_type pos);
294 bool isHfill(lyx::pos_type pos) const;
296 bool isInset(lyx::pos_type pos) const;
298 bool isNewline(lyx::pos_type pos) const;
300 bool isSeparator(lyx::pos_type pos) const;
302 bool isLineSeparator(lyx::pos_type pos) const;
304 bool isKomma(lyx::pos_type pos) const;
305 /// Used by the spellchecker
306 bool isLetter(lyx::pos_type pos) const;
308 bool isWord(lyx::pos_type pos) const;
310 /** paste this paragraph with the next one
311 be carefull, this doesent make any check at all
313 void pasteParagraph(BufferParams const &);
315 /// returns -1 if inset not found
316 int getPositionOfInset(Inset const * inset) const;
318 /// some good comment here John?
319 Paragraph * getParFromID(int id) const;
322 int stripLeadingSpaces();
324 #ifndef NO_PEXTRA_REALLY
325 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
326 I have to set it on each of it's elements */
328 void setPExtraType(BufferParams const &, int type,
329 string const & width, string const & widthp);
331 void unsetPExtraType(BufferParams const &);
334 bool sgmlConvertChar(char c, string & sgml_string);
336 bool isFreeSpacing() const;
338 ParagraphParameters & params();
339 ParagraphParameters const & params() const;
342 LyXLayout_ptr layout_;
344 /** Both these definitions must be made public to keep Compaq cxx 6.5
354 InsetTable(lyx::pos_type p, Inset * i) : pos(p), inset(i) {}
358 typedef std::vector<InsetTable> InsetList;
364 class inset_iterator {
369 inset_iterator(InsetList::iterator const & iter);
371 inset_iterator & operator++() {
376 Inset * operator*() { return it->inset; }
378 Inset * operator->() { return it->inset; }
381 lyx::pos_type getPos() const { return it->pos; }
383 bool operator==(inset_iterator const & iter) const {
384 return it == iter.it;
387 bool operator!=(inset_iterator const & iter) const {
388 return it != iter.it;
392 InsetList::iterator it;
395 friend class inset_iterator;
398 inset_iterator inset_iterator_begin();
400 inset_iterator inset_iterator_end();
401 /// returns inset iterator of the first inset at or after pos.
402 inset_iterator InsetIterator(lyx::pos_type pos);
405 /// if anything uses this we don't want it to.
406 Paragraph(Paragraph const &);
410 Paragraph * previous_;
414 friend struct Paragraph::Pimpl;