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 &);
154 LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
155 string & foot, TexRow & foot_texrow,
158 bool SimpleTeXOnePar(string & file, TexRow & texrow);
161 LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
162 string & foot, TexRow & foot_texrow,
166 LyXParagraph * Clone() const;
169 bool HasSameLayout(LyXParagraph const * par) const;
172 void MakeSameLayout(LyXParagraph const * par);
174 /// Is it the first par with same depth and layout?
175 bool IsFirstInSequence() const {
176 LyXParagraph const * dhook = DepthHook(GetDepth());
177 return (dhook == this
178 || dhook->GetLayout() != GetLayout()
179 || dhook->GetDepth() != GetDepth());
186 size_type size() const { return text.size(); }
188 VSpace added_space_top;
191 VSpace added_space_bottom;
194 LyXTextClass::LayoutList::size_type layout;
198 \item no footnote, closed footnote,
199 \item open footnote, where footnote
200 \item means footnote-environment
203 footnote_flag footnoteflag;
205 /// footnote, margin, fig, tab
206 footnote_kind footnotekind;
208 //@Man: the LyX- DTP-switches
220 bool pagebreak_bottom;
232 block<int, 10> counter_;
235 void setCounter(int i, int v) { counter_[i] = v; }
236 int getCounter(int i) const { return counter_[i]; }
237 void incCounter(int i) { counter_[i]++; }
239 bool start_of_appendix;
250 /* This is for the paragraph extra stuff */
256 string pextra_widthp;
258 int pextra_alignment;
262 bool pextra_start_minipage;
268 string labelwidthstring;
274 LyXParagraph * previous;
276 /* table stuff -- begin*/
279 /* table stuff -- end*/
282 InsetBibKey * bibkey; // ale970302
284 /** these function are able to hide closed footnotes
286 LyXParagraph * Next();
289 LyXParagraph * Previous();
291 LyXParagraph const * Previous() const;
293 /** these function are able to hide open and closed footnotes
295 LyXParagraph * NextAfterFootnote();
297 LyXParagraph const * NextAfterFootnote() const;
300 LyXParagraph * PreviousBeforeFootnote();
302 LyXParagraph * LastPhysicalPar();
305 LyXParagraph * FirstPhysicalPar();
307 LyXParagraph const * FirstPhysicalPar() const;
309 /// returns the physical paragraph
310 LyXParagraph * ParFromPos(size_type pos);
311 /// returns the position in the physical par
312 int PositionInParFromPos(size_type pos) const;
314 /// for the environments
315 LyXParagraph * DepthHook(int depth);
316 /// for the environments
317 LyXParagraph const * DepthHook(int depth) const;
319 int BeginningOfMainBody() const;
321 string GetLabestring() const;
323 /// the next two functions are for the manual labels
324 string GetLabelWidthString() const;
326 void SetLabelWidthString(string const & s);
328 LyXTextClass::LayoutList::size_type GetLayout() const;
330 char GetAlign() const;
332 char GetDepth() const;
334 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
336 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
338 int GetFirstCounter(int i) const;
340 size_type Last() const;
342 void Erase(size_type pos);
343 /** the flag determines wether the layout should be copied
345 void BreakParagraph(size_type pos, int flag);
347 void BreakParagraphConservative(size_type pos);
348 /** Get unistantiated font setting. Returns the difference
349 between the characters font and the layoutfont.
350 This is what is stored in the fonttable
352 LyXFont GetFontSettings(size_type pos) const;
353 /** Get fully instantiated font. If pos == -1, use the layout
354 font attached to this paragraph.
355 If pos == -2, use the label font of the layout attached here.
356 In all cases, the font is instantiated, i.e. does not have any
357 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
360 LyXFont getFont(size_type pos) const;
362 char GetChar(size_type pos);
364 char GetChar(size_type pos) const;
366 void SetFont(size_type pos, LyXFont const & font);
368 string GetWord(size_type &) const;
369 /// Returns the height of the highest font in range
370 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
371 size_type endpos) const;
373 void InsertChar(size_type pos, char c);
375 void InsertInset(size_type pos, Inset * inset);
377 Inset * GetInset(size_type pos);
379 Inset const * GetInset(size_type pos) const;
381 Inset * ReturnNextInsetPointer(size_type & pos);
383 void OpenFootnote(size_type pos);
385 void CloseFootnote(size_type pos);
386 /// important for cut and paste
387 void CopyIntoMinibuffer(size_type pos) const;
389 void CutIntoMinibuffer(size_type pos);
391 void InsertFromMinibuffer(size_type pos);
394 bool IsHfill(size_type pos) const;
396 bool IsInset(size_type pos) const;
398 bool IsFloat(size_type pos) const;
400 bool IsNewline(size_type pos) const;
402 bool IsSeparator(size_type pos) const;
404 bool IsLineSeparator(size_type pos) const;
406 bool IsKomma(size_type pos) const;
407 /// Used by the spellchecker
408 bool IsLetter(size_type pos) const;
410 bool IsWord(size_type pos) const;
412 /** This one resets all layout and dtp switches but not the font
413 of the single characters
417 /** paste this paragraph with the next one
418 be carefull, this doesent make any check at all
420 void PasteParagraph();
422 /// used to remove the error messages
423 int AutoDeleteInsets();
425 /// returns -1 if inset not found
426 int GetPositionOfInset(Inset * inset) const;
428 /// ok and now some footnote functions
429 void OpenFootnotes();
432 void CloseFootnotes();
435 LyXParagraph * FirstSelfrowPar();
438 int ClearParagraph() {
440 if (!IsDummy() && !table){
443 || IsLineSeparator(0))){
451 /** A paragraph following a footnote is a "dummy". A paragraph
452 with a footnote in it is stored as three paragraphs:
453 First a paragraph with the text up to the footnote, then
454 one (or more) paragraphs with the footnote, and finally
455 the a paragraph with the text after the footnote. Only the
456 first paragraph keeps information about layoutparameters, */
457 bool IsDummy() const {
458 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
459 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
462 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
463 I have to set it on each of it's elements */
465 void SetPExtraType(int type, char const * width, char const * widthp);
467 void UnsetPExtraType();
469 bool RoffContTableRows(ostream &, size_type i, int actcell);
471 void DocBookContTableRows(string & file, string & extra, int & desc_on,
473 int current_cell_number, int & column);
475 bool linuxDocConvertChar(char c, string & sgml_string);
477 void SimpleDocBookOneTablePar(string & file, string & extra,
478 int & desc_on, int depth);
480 /** A font entry covers a range of positions. Notice that the
481 entries in the list are inserted in random order.
482 I don't think it's worth the effort to implement a more effective
483 datastructure, because the number of different fonts in a paragraph
487 /// Start position of paragraph this font attribute covers
489 /// Ending position of paragraph this font attribute covers
491 /** Font. Interpretation of the font values:
492 If a value is LyXFont::INHERIT_*, it means that the font
493 attribute is inherited from either the layout of this
494 paragraph or, in the case of nested paragraphs, from the
495 layout in the environment one level up until completely
497 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
498 allowed in these font tables.
510 typedef list<FontTable> FontList;
514 typedef list<InsetTable> InsetList;
518 LyXParagraph * TeXDeeper(string & file, TexRow & texrow,
519 string & foot, TexRow & foot_texrow,
522 LyXParagraph * TeXFootnote(string & file, TexRow & texrow,
523 string & foot, TexRow & foot_texrow,
525 LyXDirection par_direction);
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;