2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 The LyX Team.
10 * ====================================================== */
12 #ifndef LYXPARAGRAPH_H
13 #define LYXPARAGRAPH_H
22 #include "insets/lyxinset.h"
26 #include "support/block.h"
27 #include "direction.h"
38 /// A LyXParagraph holds all text, attributes and insets in a text paragraph
53 enum MINIPAGE_ALIGNMENT {
57 MINIPAGE_ALIGN_MIDDLE,
82 //META_PROTECTED_SEPARATOR,
108 ALGORITHM, // Bernhard, 970807
110 WIDE_FIG, // CFO-G, 971106
112 WIDE_TAB // CFO-G, 971106
116 typedef char value_type;
118 typedef vector<value_type> TextContainer;
120 typedef int size_type;
124 /// this konstruktor inserts the new paragraph in a list
125 LyXParagraph(LyXParagraph * par);
126 /// the destruktors removes the new paragraph from the list
130 Language const * getParLanguage() const;
132 Language const * getLetterLanguage(size_type pos) const;
135 LyXDirection getParDirection() const;
137 LyXDirection getLetterDirection(size_type pos) const;
140 void writeFile(ostream &, BufferParams const &, char, char) const;
142 void validate(LaTeXFeatures &) const;
149 void id(int id_arg) {
157 LyXParagraph * TeXOnePar(ostream &, TexRow & texrow,
158 ostream & foot, TexRow & foot_texrow,
161 bool SimpleTeXOnePar(ostream &, TexRow & texrow);
164 LyXParagraph * TeXEnvironment(ostream &, TexRow & texrow,
165 ostream & foot, TexRow & foot_texrow,
168 LyXParagraph * Clone() const;
171 bool HasSameLayout(LyXParagraph const * par) const;
174 void MakeSameLayout(LyXParagraph const * par);
176 /// Is it the first par with same depth and layout?
177 bool IsFirstInSequence() const {
178 LyXParagraph const * dhook = DepthHook(GetDepth());
179 return (dhook == this
180 || dhook->GetLayout() != GetLayout()
181 || dhook->GetDepth() != GetDepth());
184 /// Check if the current paragraph is the last paragraph in a
185 /// proof environment
186 int GetEndLabel() const;
193 size_type size() const { return text.size(); }
196 text.resize(text.size());
198 void setContentsFromPar(LyXParagraph * par) {
201 void clearContents() {
206 VSpace added_space_top;
209 VSpace added_space_bottom;
212 LyXTextClass::LayoutList::size_type layout;
216 \item no footnote, closed footnote,
217 \item open footnote, where footnote
218 \item means footnote-environment
221 footnote_flag footnoteflag;
223 /// footnote, margin, fig, tab
224 footnote_kind footnotekind;
226 //@Man: the LyX- DTP-switches
238 bool pagebreak_bottom;
250 block<int, 10> counter_;
253 void setCounter(int i, int v) { counter_[i] = v; }
254 int getCounter(int i) const { return counter_[i]; }
255 void incCounter(int i) { counter_[i]++; }
257 bool start_of_appendix;
268 /* This is for the paragraph extra stuff */
274 string pextra_widthp;
276 int pextra_alignment;
280 bool pextra_start_minipage;
286 string labelwidthstring;
292 LyXParagraph * previous;
294 /* table stuff -- begin*/
297 /* table stuff -- end*/
300 InsetBibKey * bibkey; // ale970302
302 /** these function are able to hide closed footnotes
304 LyXParagraph * Next();
307 LyXParagraph * Previous();
309 LyXParagraph const * Previous() const;
311 /** these function are able to hide open and closed footnotes
313 LyXParagraph * NextAfterFootnote();
315 LyXParagraph const * NextAfterFootnote() const;
318 LyXParagraph * PreviousBeforeFootnote();
320 LyXParagraph * LastPhysicalPar();
322 LyXParagraph const * LastPhysicalPar() const;
325 LyXParagraph * FirstPhysicalPar();
327 LyXParagraph const * FirstPhysicalPar() const;
329 /// returns the physical paragraph
330 LyXParagraph * ParFromPos(size_type pos);
331 /// returns the position in the physical par
332 int PositionInParFromPos(size_type pos) const;
334 /// for the environments
335 LyXParagraph * DepthHook(int depth);
336 /// for the environments
337 LyXParagraph const * DepthHook(int depth) const;
339 int BeginningOfMainBody() const;
341 string GetLabestring() const;
343 /// the next two functions are for the manual labels
344 string GetLabelWidthString() const;
346 void SetLabelWidthString(string const & s);
348 LyXTextClass::LayoutList::size_type GetLayout() const;
350 char GetAlign() const;
352 char GetDepth() const;
354 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
356 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
358 int GetFirstCounter(int i) const;
360 size_type Last() const;
362 void Erase(size_type pos);
363 /** the flag determines wether the layout should be copied
365 void BreakParagraph(size_type pos, int flag);
367 void BreakParagraphConservative(size_type pos);
368 /** Get unistantiated font setting. Returns the difference
369 between the characters font and the layoutfont.
370 This is what is stored in the fonttable
372 LyXFont GetFontSettings(size_type pos) const;
374 LyXFont GetFirstFontSettings() const;
376 /** Get fully instantiated font. If pos == -1, use the layout
377 font attached to this paragraph.
378 If pos == -2, use the label font of the layout attached here.
379 In all cases, the font is instantiated, i.e. does not have any
380 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
383 LyXFont getFont(size_type pos) const;
385 char GetChar(size_type pos);
387 char GetChar(size_type pos) const;
388 /// The position must already exist.
389 void SetChar(size_type pos, char c) {
394 void SetFont(size_type pos, LyXFont const & font);
396 string GetWord(size_type &) const;
397 /// Returns the height of the highest font in range
398 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
399 size_type endpos) const;
401 void InsertChar(size_type pos, char c);
403 void InsertInset(size_type pos, Inset * inset);
405 Inset * GetInset(size_type pos);
407 Inset const * GetInset(size_type pos) const;
409 Inset * ReturnNextInsetPointer(size_type & pos);
411 void OpenFootnote(size_type pos);
413 void CloseFootnote(size_type pos);
414 /// important for cut and paste
415 void CopyIntoMinibuffer(size_type pos) const;
417 void CutIntoMinibuffer(size_type pos);
419 void InsertFromMinibuffer(size_type pos);
422 bool IsHfill(size_type pos) const;
424 bool IsInset(size_type pos) const;
426 bool IsFloat(size_type pos) const;
428 bool IsNewline(size_type pos) const;
430 bool IsSeparator(size_type pos) const;
432 bool IsLineSeparator(size_type pos) const;
434 bool IsKomma(size_type pos) const;
435 /// Used by the spellchecker
436 bool IsLetter(size_type pos) const;
438 bool IsWord(size_type pos) const;
440 /** This one resets all layout and dtp switches but not the font
441 of the single characters
445 /** paste this paragraph with the next one
446 be carefull, this doesent make any check at all
448 void PasteParagraph();
450 /// used to remove the error messages
451 int AutoDeleteInsets();
453 /// returns -1 if inset not found
454 int GetPositionOfInset(Inset * inset) const;
456 /// ok and now some footnote functions
457 void OpenFootnotes();
460 void CloseFootnotes();
463 LyXParagraph * FirstSelfrowPar();
466 int ClearParagraph() {
468 if (!IsDummy() && !table){
471 || IsLineSeparator(0))){
479 /** A paragraph following a footnote is a "dummy". A paragraph
480 with a footnote in it is stored as three paragraphs:
481 First a paragraph with the text up to the footnote, then
482 one (or more) paragraphs with the footnote, and finally
483 the a paragraph with the text after the footnote. Only the
484 first paragraph keeps information about layoutparameters, */
485 bool IsDummy() const {
486 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
487 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
490 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
491 I have to set it on each of it's elements */
493 void SetPExtraType(int type, char const * width, char const * widthp);
495 void UnsetPExtraType();
498 bool RoffContTableRows(ostream &, size_type i, int actcell);
501 bool linuxDocConvertChar(char c, string & sgml_string);
503 void DocBookContTableRows(ostream &, string & extra, int & desc_on,
505 int current_cell_number, int & column);
507 void SimpleDocBookOneTablePar(ostream &, string & extra,
508 int & desc_on, int depth);
510 /** A font entry covers a range of positions. Notice that the
511 entries in the list are inserted in random order.
512 I don't think it's worth the effort to implement a more effective
513 datastructure, because the number of different fonts in a paragraph
517 /// Start position of paragraph this font attribute covers
519 /// Ending position of paragraph this font attribute covers
521 /** Font. Interpretation of the font values:
522 If a value is LyXFont::INHERIT_*, it means that the font
523 attribute is inherited from either the layout of this
524 paragraph or, in the case of nested paragraphs, from the
525 layout in the environment one level up until completely
527 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
528 allowed in these font tables.
540 typedef list<FontTable> FontList;
544 typedef list<InsetTable> InsetList;
548 LyXParagraph * TeXDeeper(ostream &, TexRow & texrow,
549 ostream & foot, TexRow & foot_texrow,
552 LyXParagraph * TeXFootnote(ostream &, TexRow & texrow,
553 ostream & foot, TexRow & foot_texrow,
555 LyXDirection par_direction);
557 bool SimpleTeXOneTablePar(ostream &, TexRow & texrow);
559 bool TeXContTableRows(ostream &, size_type i,
560 int current_cell_number,
561 int & column, TexRow & texrow);
563 void SimpleTeXBlanks(ostream &, TexRow & texrow,
565 int & column, LyXFont const & font,
566 LyXLayout const & style);
568 void SimpleTeXSpecialChars(ostream &, TexRow & texrow,
569 LyXFont & font, LyXFont & running_font,
570 LyXFont & basefont, bool & open_font,
571 LyXLayout const & style,
573 int & column, char const c);
577 static unsigned int paragraph_id;