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"
37 /// A LyXParagraph holds all text, attributes and insets in a text paragraph
52 enum MINIPAGE_ALIGNMENT {
56 MINIPAGE_ALIGN_MIDDLE,
81 META_PROTECTED_SEPARATOR,
107 ALGORITHM, // Bernhard, 970807
109 WIDE_FIG, // CFO-G, 971106
111 WIDE_TAB // CFO-G, 971106
115 typedef char value_type;
117 typedef vector<value_type> TextContainer;
119 typedef int size_type;
123 /// this konstruktor inserts the new paragraph in a list
124 LyXParagraph(LyXParagraph * par);
125 /// the destruktors removes the new paragraph from the list
129 LyXDirection getParDirection() const;
131 LyXDirection getLetterDirection(size_type pos) const;
134 void writeFile(ostream &, BufferParams &, char, char);
136 void validate(LaTeXFeatures &) const;
143 void id(int id_arg) {
151 void readSimpleWholeFile(istream &);
154 LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
155 string & foot, TexRow & foot_texrow,
159 LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
160 string & foot, TexRow & foot_texrow,
164 LyXParagraph * Clone() const;
167 bool HasSameLayout(LyXParagraph const * par) const;
170 void MakeSameLayout(LyXParagraph const * par);
172 /// Is it the first par with same depth and layout?
173 bool IsFirstInSequence() const {
174 LyXParagraph const * dhook = DepthHook(GetDepth());
175 return (dhook == this
176 || dhook->GetLayout() != GetLayout()
177 || dhook->GetDepth() != GetDepth());
184 size_type size() const { return text.size(); }
186 VSpace added_space_top;
189 VSpace added_space_bottom;
192 LyXTextClass::LayoutList::size_type layout;
196 \item no footnote, closed footnote,
197 \item open footnote, where footnote
198 \item means footnote-environment
201 footnote_flag footnoteflag;
203 /// footnote, margin, fig, tab
204 footnote_kind footnotekind;
206 //@Man: the LyX- DTP-switches
218 bool pagebreak_bottom;
230 block<int, 10> counter_;
233 void setCounter(int i, int v) { counter_[i] = v; }
234 int getCounter(int i) const { return counter_[i]; }
235 void incCounter(int i) { counter_[i]++; }
237 bool start_of_appendix;
248 /* This is for the paragraph extra stuff */
254 string pextra_widthp;
256 int pextra_alignment;
260 bool pextra_start_minipage;
266 string labelwidthstring;
272 LyXParagraph * previous;
274 /* table stuff -- begin*/
277 /* table stuff -- end*/
280 InsetBibKey * bibkey; // ale970302
282 /** these function are able to hide closed footnotes
284 LyXParagraph * Next();
287 LyXParagraph * Previous();
289 LyXParagraph const * Previous() const;
291 /** these function are able to hide open and closed footnotes
293 LyXParagraph * NextAfterFootnote();
295 LyXParagraph const * NextAfterFootnote() const;
298 LyXParagraph * PreviousBeforeFootnote();
300 LyXParagraph * LastPhysicalPar();
303 LyXParagraph * FirstPhysicalPar();
305 LyXParagraph const * FirstPhysicalPar() const;
307 /// returns the physical paragraph
308 LyXParagraph * ParFromPos(size_type pos);
309 /// returns the position in the physical par
310 int PositionInParFromPos(size_type pos) const;
312 /// for the environments
313 LyXParagraph * DepthHook(int depth);
314 /// for the environments
315 LyXParagraph const * DepthHook(int depth) const;
317 int BeginningOfMainBody() const;
319 string GetLabestring() const;
321 /// the next two functions are for the manual labels
322 string GetLabelWidthString() const;
324 void SetLabelWidthString(string const & s);
326 LyXTextClass::LayoutList::size_type GetLayout() const;
328 char GetAlign() const;
330 char GetDepth() const;
332 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
334 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
336 int GetFirstCounter(int i) const;
338 size_type Last() const;
340 void Erase(size_type pos);
341 /** the flag determines wether the layout should be copied
343 void BreakParagraph(size_type pos, int flag);
345 void BreakParagraphConservative(size_type pos);
346 /** Get unistantiated font setting. Returns the difference
347 between the characters font and the layoutfont.
348 This is what is stored in the fonttable
350 LyXFont GetFontSettings(size_type pos) const;
351 /** Get fully instantiated font. If pos == -1, use the layout
352 font attached to this paragraph.
353 If pos == -2, use the label font of the layout attached here.
354 In all cases, the font is instantiated, i.e. does not have any
355 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
358 LyXFont getFont(size_type pos) const;
360 char GetChar(size_type pos);
362 char GetChar(size_type pos) const;
364 void SetFont(size_type pos, LyXFont const & font);
366 string GetWord(size_type &) const;
367 /// Returns the height of the highest font in range
368 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
369 size_type endpos) const;
371 void InsertChar(size_type pos, char c);
373 void InsertInset(size_type pos, Inset * inset);
375 Inset * GetInset(size_type pos);
377 Inset const * GetInset(size_type pos) const;
379 Inset * ReturnNextInsetPointer(size_type & pos);
381 void OpenFootnote(size_type pos);
383 void CloseFootnote(size_type pos);
384 /// important for cut and paste
385 void CopyIntoMinibuffer(size_type pos) const;
387 void CutIntoMinibuffer(size_type pos);
389 void InsertFromMinibuffer(size_type pos);
392 bool IsHfill(size_type pos) const;
394 bool IsInset(size_type pos) const;
396 bool IsFloat(size_type pos) const;
398 bool IsNewline(size_type pos) const;
400 bool IsSeparator(size_type pos) const;
402 bool IsLineSeparator(size_type pos) const;
404 bool IsKomma(size_type pos) const;
405 /// Used by the spellchecker
406 bool IsLetter(size_type pos) const;
408 bool IsWord(size_type pos) const;
410 /** This one resets all layout and dtp switches but not the font
411 of the single characters
415 /** paste this paragraph with the next one
416 be carefull, this doesent make any check at all
418 void PasteParagraph();
420 /// used to remove the error messages
421 int AutoDeleteInsets();
423 /// returns -1 if inset not found
424 int GetPositionOfInset(Inset * inset) const;
426 /// ok and now some footnote functions
427 void OpenFootnotes();
430 void CloseFootnotes();
433 LyXParagraph * FirstSelfrowPar();
436 int ClearParagraph() {
438 if (!IsDummy() && !table){
441 || IsLineSeparator(0))){
449 /** A paragraph following a footnote is a "dummy". A paragraph
450 with a footnote in it is stored as three paragraphs:
451 First a paragraph with the text up to the footnote, then
452 one (or more) paragraphs with the footnote, and finally
453 the a paragraph with the text after the footnote. Only the
454 first paragraph keeps information about layoutparameters, */
455 bool IsDummy() const {
456 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
457 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
460 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
461 I have to set it on each of it's elements */
463 void SetPExtraType(int type, char const * width, char const * widthp);
465 void UnsetPExtraType();
467 bool RoffContTableRows(ostream &, size_type i, int actcell);
469 void DocBookContTableRows(string & file, string & extra, int & desc_on,
471 int current_cell_number, int & column);
473 bool linuxDocConvertChar(char c, string & sgml_string);
475 void SimpleDocBookOneTablePar(string & file, string & extra,
476 int & desc_on, int depth);
478 /** A font entry covers a range of positions. Notice that the
479 entries in the list are inserted in random order.
480 I don't think it's worth the effort to implement a more effective
481 datastructure, because the number of different fonts in a paragraph
485 /// Start position of paragraph this font attribute covers
487 /// Ending position of paragraph this font attribute covers
489 /** Font. Interpretation of the font values:
490 If a value is LyXFont::INHERIT_*, it means that the font
491 attribute is inherited from either the layout of this
492 paragraph or, in the case of nested paragraphs, from the
493 layout in the environment one level up until completely
495 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
496 allowed in these font tables.
508 typedef list<FontTable> FontList;
512 typedef list<InsetTable> InsetList;
516 LyXParagraph * TeXDeeper(string & file, TexRow & texrow,
517 string & foot, TexRow & foot_texrow,
520 LyXParagraph * TeXFootnote(string & file, TexRow & texrow,
521 string & foot, TexRow & foot_texrow,
523 LyXDirection par_direction);
525 bool SimpleTeXOnePar(string & file, TexRow & texrow);
527 bool SimpleTeXOneTablePar(string & file, TexRow & texrow);
529 bool TeXContTableRows(string & file, size_type i,
530 int current_cell_number,
531 int & column, TexRow & texrow);
533 void SimpleTeXBlanks(string & file, TexRow & texrow,
535 int & column, LyXFont const & font,
536 LyXLayout const & style);
538 void SimpleTeXSpecialChars(string & file, TexRow & texrow,
539 LyXFont & font, LyXFont & running_font,
540 LyXFont & basefont, bool & open_font,
541 LyXLayout const & style,
543 int & column, char const c);
547 static unsigned int paragraph_id;