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 const &, char, char) const;
136 void validate(LaTeXFeatures &) const;
143 void id(int id_arg) {
151 void readSimpleWholeFile(istream &);
153 #ifdef USE_OSTREAM_ONLY
155 LyXParagraph * TeXOnePar(ostream &, TexRow & texrow,
156 ostream & foot, TexRow & foot_texrow,
159 bool SimpleTeXOnePar(ostream &, TexRow & texrow);
162 LyXParagraph * TeXEnvironment(ostream &, TexRow & texrow,
163 ostream & foot, TexRow & foot_texrow,
167 LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
168 string & foot, TexRow & foot_texrow,
171 bool SimpleTeXOnePar(string & file, TexRow & texrow);
174 LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
175 string & foot, TexRow & foot_texrow,
179 LyXParagraph * Clone() const;
182 bool HasSameLayout(LyXParagraph const * par) const;
185 void MakeSameLayout(LyXParagraph const * par);
187 /// Is it the first par with same depth and layout?
188 bool IsFirstInSequence() const {
189 LyXParagraph const * dhook = DepthHook(GetDepth());
190 return (dhook == this
191 || dhook->GetLayout() != GetLayout()
192 || dhook->GetDepth() != GetDepth());
199 size_type size() const { return text.size(); }
201 VSpace added_space_top;
204 VSpace added_space_bottom;
207 LyXTextClass::LayoutList::size_type layout;
211 \item no footnote, closed footnote,
212 \item open footnote, where footnote
213 \item means footnote-environment
216 footnote_flag footnoteflag;
218 /// footnote, margin, fig, tab
219 footnote_kind footnotekind;
221 //@Man: the LyX- DTP-switches
233 bool pagebreak_bottom;
245 block<int, 10> counter_;
248 void setCounter(int i, int v) { counter_[i] = v; }
249 int getCounter(int i) const { return counter_[i]; }
250 void incCounter(int i) { counter_[i]++; }
252 bool start_of_appendix;
263 /* This is for the paragraph extra stuff */
269 string pextra_widthp;
271 int pextra_alignment;
275 bool pextra_start_minipage;
281 string labelwidthstring;
287 LyXParagraph * previous;
289 /* table stuff -- begin*/
292 /* table stuff -- end*/
295 InsetBibKey * bibkey; // ale970302
297 /** these function are able to hide closed footnotes
299 LyXParagraph * Next();
302 LyXParagraph * Previous();
304 LyXParagraph const * Previous() const;
306 /** these function are able to hide open and closed footnotes
308 LyXParagraph * NextAfterFootnote();
310 LyXParagraph const * NextAfterFootnote() const;
313 LyXParagraph * PreviousBeforeFootnote();
315 LyXParagraph * LastPhysicalPar();
318 LyXParagraph * FirstPhysicalPar();
320 LyXParagraph const * FirstPhysicalPar() const;
322 /// returns the physical paragraph
323 LyXParagraph * ParFromPos(size_type pos);
324 /// returns the position in the physical par
325 int PositionInParFromPos(size_type pos) const;
327 /// for the environments
328 LyXParagraph * DepthHook(int depth);
329 /// for the environments
330 LyXParagraph const * DepthHook(int depth) const;
332 int BeginningOfMainBody() const;
334 string GetLabestring() const;
336 /// the next two functions are for the manual labels
337 string GetLabelWidthString() const;
339 void SetLabelWidthString(string const & s);
341 LyXTextClass::LayoutList::size_type GetLayout() const;
343 char GetAlign() const;
345 char GetDepth() const;
347 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
349 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
351 int GetFirstCounter(int i) const;
353 size_type Last() const;
355 void Erase(size_type pos);
356 /** the flag determines wether the layout should be copied
358 void BreakParagraph(size_type pos, int flag);
360 void BreakParagraphConservative(size_type pos);
361 /** Get unistantiated font setting. Returns the difference
362 between the characters font and the layoutfont.
363 This is what is stored in the fonttable
365 LyXFont GetFontSettings(size_type pos) const;
366 /** Get fully instantiated font. If pos == -1, use the layout
367 font attached to this paragraph.
368 If pos == -2, use the label font of the layout attached here.
369 In all cases, the font is instantiated, i.e. does not have any
370 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
373 LyXFont getFont(size_type pos) const;
375 char GetChar(size_type pos);
377 char GetChar(size_type pos) const;
379 void SetFont(size_type pos, LyXFont const & font);
381 string GetWord(size_type &) const;
382 /// Returns the height of the highest font in range
383 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
384 size_type endpos) const;
386 void InsertChar(size_type pos, char c);
388 void InsertInset(size_type pos, Inset * inset);
390 Inset * GetInset(size_type pos);
392 Inset const * GetInset(size_type pos) const;
394 Inset * ReturnNextInsetPointer(size_type & pos);
396 void OpenFootnote(size_type pos);
398 void CloseFootnote(size_type pos);
399 /// important for cut and paste
400 void CopyIntoMinibuffer(size_type pos) const;
402 void CutIntoMinibuffer(size_type pos);
404 void InsertFromMinibuffer(size_type pos);
407 bool IsHfill(size_type pos) const;
409 bool IsInset(size_type pos) const;
411 bool IsFloat(size_type pos) const;
413 bool IsNewline(size_type pos) const;
415 bool IsSeparator(size_type pos) const;
417 bool IsLineSeparator(size_type pos) const;
419 bool IsKomma(size_type pos) const;
420 /// Used by the spellchecker
421 bool IsLetter(size_type pos) const;
423 bool IsWord(size_type pos) const;
425 /** This one resets all layout and dtp switches but not the font
426 of the single characters
430 /** paste this paragraph with the next one
431 be carefull, this doesent make any check at all
433 void PasteParagraph();
435 /// used to remove the error messages
436 int AutoDeleteInsets();
438 /// returns -1 if inset not found
439 int GetPositionOfInset(Inset * inset) const;
441 /// ok and now some footnote functions
442 void OpenFootnotes();
445 void CloseFootnotes();
448 LyXParagraph * FirstSelfrowPar();
451 int ClearParagraph() {
453 if (!IsDummy() && !table){
456 || IsLineSeparator(0))){
464 /** A paragraph following a footnote is a "dummy". A paragraph
465 with a footnote in it is stored as three paragraphs:
466 First a paragraph with the text up to the footnote, then
467 one (or more) paragraphs with the footnote, and finally
468 the a paragraph with the text after the footnote. Only the
469 first paragraph keeps information about layoutparameters, */
470 bool IsDummy() const {
471 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
472 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
475 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
476 I have to set it on each of it's elements */
478 void SetPExtraType(int type, char const * width, char const * widthp);
480 void UnsetPExtraType();
483 bool RoffContTableRows(ostream &, size_type i, int actcell);
486 bool linuxDocConvertChar(char c, string & sgml_string);
487 #ifdef USE_OSTREAM_ONLY
489 void DocBookContTableRows(ostream &, string & extra, int & desc_on,
491 int current_cell_number, int & column);
493 void SimpleDocBookOneTablePar(ostream &, string & extra,
494 int & desc_on, int depth);
497 void DocBookContTableRows(string & file, string & extra, int & desc_on,
499 int current_cell_number, int & column);
501 void SimpleDocBookOneTablePar(string & file, string & extra,
502 int & desc_on, int depth);
505 /** A font entry covers a range of positions. Notice that the
506 entries in the list are inserted in random order.
507 I don't think it's worth the effort to implement a more effective
508 datastructure, because the number of different fonts in a paragraph
512 /// Start position of paragraph this font attribute covers
514 /// Ending position of paragraph this font attribute covers
516 /** Font. Interpretation of the font values:
517 If a value is LyXFont::INHERIT_*, it means that the font
518 attribute is inherited from either the layout of this
519 paragraph or, in the case of nested paragraphs, from the
520 layout in the environment one level up until completely
522 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
523 allowed in these font tables.
535 typedef list<FontTable> FontList;
539 typedef list<InsetTable> InsetList;
542 #ifdef USE_OSTREAM_ONLY
544 LyXParagraph * TeXDeeper(ostream &, TexRow & texrow,
545 ostream & foot, TexRow & foot_texrow,
548 LyXParagraph * TeXFootnote(ostream &, TexRow & texrow,
549 ostream & foot, TexRow & foot_texrow,
551 LyXDirection par_direction);
553 bool SimpleTeXOneTablePar(ostream &, TexRow & texrow);
555 bool TeXContTableRows(ostream &, size_type i,
556 int current_cell_number,
557 int & column, TexRow & texrow);
559 void SimpleTeXBlanks(ostream &, TexRow & texrow,
561 int & column, LyXFont const & font,
562 LyXLayout const & style);
564 void SimpleTeXSpecialChars(ostream &, TexRow & texrow,
565 LyXFont & font, LyXFont & running_font,
566 LyXFont & basefont, bool & open_font,
567 LyXLayout const & style,
569 int & column, char const c);
572 LyXParagraph * TeXDeeper(string & file, TexRow & texrow,
573 string & foot, TexRow & foot_texrow,
576 LyXParagraph * TeXFootnote(string & file, TexRow & texrow,
577 string & foot, TexRow & foot_texrow,
579 LyXDirection par_direction);
581 bool SimpleTeXOneTablePar(string & file, TexRow & texrow);
583 bool TeXContTableRows(string & file, size_type i,
584 int current_cell_number,
585 int & column, TexRow & texrow);
587 void SimpleTeXBlanks(string & file, TexRow & texrow,
589 int & column, LyXFont const & font,
590 LyXLayout const & style);
592 void SimpleTeXSpecialChars(string & file, TexRow & texrow,
593 LyXFont & font, LyXFont & running_font,
594 LyXFont & basefont, bool & open_font,
595 LyXLayout const & style,
597 int & column, char const c);
602 static unsigned int paragraph_id;