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 LyXParagraph * TeXOnePar(ostream &, TexRow & texrow,
152 ostream & foot, TexRow & foot_texrow,
155 bool SimpleTeXOnePar(ostream &, TexRow & texrow);
158 LyXParagraph * TeXEnvironment(ostream &, TexRow & texrow,
159 ostream & foot, TexRow & foot_texrow,
162 LyXParagraph * Clone() const;
165 bool HasSameLayout(LyXParagraph const * par) const;
168 void MakeSameLayout(LyXParagraph const * par);
170 /// Is it the first par with same depth and layout?
171 bool IsFirstInSequence() const {
172 LyXParagraph const * dhook = DepthHook(GetDepth());
173 return (dhook == this
174 || dhook->GetLayout() != GetLayout()
175 || dhook->GetDepth() != GetDepth());
178 /// Check if the current paragraph is the last paragraph in a
179 /// proof environment
180 int GetEndLabel() const;
187 size_type size() const { return text.size(); }
190 text.resize(text.size());
192 void setContentsFromPar(LyXParagraph * par) {
195 void clearContents() {
200 VSpace added_space_top;
203 VSpace added_space_bottom;
206 LyXTextClass::LayoutList::size_type layout;
210 \item no footnote, closed footnote,
211 \item open footnote, where footnote
212 \item means footnote-environment
215 footnote_flag footnoteflag;
217 /// footnote, margin, fig, tab
218 footnote_kind footnotekind;
220 //@Man: the LyX- DTP-switches
232 bool pagebreak_bottom;
244 block<int, 10> counter_;
247 void setCounter(int i, int v) { counter_[i] = v; }
248 int getCounter(int i) const { return counter_[i]; }
249 void incCounter(int i) { counter_[i]++; }
251 bool start_of_appendix;
262 /* This is for the paragraph extra stuff */
268 string pextra_widthp;
270 int pextra_alignment;
274 bool pextra_start_minipage;
280 string labelwidthstring;
286 LyXParagraph * previous;
288 /* table stuff -- begin*/
291 /* table stuff -- end*/
294 InsetBibKey * bibkey; // ale970302
296 /** these function are able to hide closed footnotes
298 LyXParagraph * Next();
301 LyXParagraph * Previous();
303 LyXParagraph const * Previous() const;
305 /** these function are able to hide open and closed footnotes
307 LyXParagraph * NextAfterFootnote();
309 LyXParagraph const * NextAfterFootnote() const;
312 LyXParagraph * PreviousBeforeFootnote();
314 LyXParagraph * LastPhysicalPar();
316 LyXParagraph const * LastPhysicalPar() const;
319 LyXParagraph * FirstPhysicalPar();
321 LyXParagraph const * FirstPhysicalPar() const;
323 /// returns the physical paragraph
324 LyXParagraph * ParFromPos(size_type pos);
325 /// returns the position in the physical par
326 int PositionInParFromPos(size_type pos) const;
328 /// for the environments
329 LyXParagraph * DepthHook(int depth);
330 /// for the environments
331 LyXParagraph const * DepthHook(int depth) const;
333 int BeginningOfMainBody() const;
335 string GetLabestring() const;
337 /// the next two functions are for the manual labels
338 string GetLabelWidthString() const;
340 void SetLabelWidthString(string const & s);
342 LyXTextClass::LayoutList::size_type GetLayout() const;
344 char GetAlign() const;
346 char GetDepth() const;
348 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
350 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
352 int GetFirstCounter(int i) const;
354 size_type Last() const;
356 void Erase(size_type pos);
357 /** the flag determines wether the layout should be copied
359 void BreakParagraph(size_type pos, int flag);
361 void BreakParagraphConservative(size_type pos);
362 /** Get unistantiated font setting. Returns the difference
363 between the characters font and the layoutfont.
364 This is what is stored in the fonttable
366 LyXFont GetFontSettings(size_type pos) const;
367 /** Get fully instantiated font. If pos == -1, use the layout
368 font attached to this paragraph.
369 If pos == -2, use the label font of the layout attached here.
370 In all cases, the font is instantiated, i.e. does not have any
371 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
374 LyXFont getFont(size_type pos) const;
376 char GetChar(size_type pos);
378 char GetChar(size_type pos) const;
379 /// The position must already exist.
380 void SetChar(size_type pos, char c) {
385 void SetFont(size_type pos, LyXFont const & font);
387 string GetWord(size_type &) const;
388 /// Returns the height of the highest font in range
389 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
390 size_type endpos) const;
392 void InsertChar(size_type pos, char c);
394 void InsertInset(size_type pos, Inset * inset);
396 Inset * GetInset(size_type pos);
398 Inset const * GetInset(size_type pos) const;
400 Inset * ReturnNextInsetPointer(size_type & pos);
402 void OpenFootnote(size_type pos);
404 void CloseFootnote(size_type pos);
405 /// important for cut and paste
406 void CopyIntoMinibuffer(size_type pos) const;
408 void CutIntoMinibuffer(size_type pos);
410 void InsertFromMinibuffer(size_type pos);
413 bool IsHfill(size_type pos) const;
415 bool IsInset(size_type pos) const;
417 bool IsFloat(size_type pos) const;
419 bool IsNewline(size_type pos) const;
421 bool IsSeparator(size_type pos) const;
423 bool IsLineSeparator(size_type pos) const;
425 bool IsKomma(size_type pos) const;
426 /// Used by the spellchecker
427 bool IsLetter(size_type pos) const;
429 bool IsWord(size_type pos) const;
431 /** This one resets all layout and dtp switches but not the font
432 of the single characters
436 /** paste this paragraph with the next one
437 be carefull, this doesent make any check at all
439 void PasteParagraph();
441 /// used to remove the error messages
442 int AutoDeleteInsets();
444 /// returns -1 if inset not found
445 int GetPositionOfInset(Inset * inset) const;
447 /// ok and now some footnote functions
448 void OpenFootnotes();
451 void CloseFootnotes();
454 LyXParagraph * FirstSelfrowPar();
457 int ClearParagraph() {
459 if (!IsDummy() && !table){
462 || IsLineSeparator(0))){
470 /** A paragraph following a footnote is a "dummy". A paragraph
471 with a footnote in it is stored as three paragraphs:
472 First a paragraph with the text up to the footnote, then
473 one (or more) paragraphs with the footnote, and finally
474 the a paragraph with the text after the footnote. Only the
475 first paragraph keeps information about layoutparameters, */
476 bool IsDummy() const {
477 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
478 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
481 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
482 I have to set it on each of it's elements */
484 void SetPExtraType(int type, char const * width, char const * widthp);
486 void UnsetPExtraType();
489 bool RoffContTableRows(ostream &, size_type i, int actcell);
492 bool linuxDocConvertChar(char c, string & sgml_string);
494 void DocBookContTableRows(ostream &, string & extra, int & desc_on,
496 int current_cell_number, int & column);
498 void SimpleDocBookOneTablePar(ostream &, string & extra,
499 int & desc_on, int depth);
501 /** A font entry covers a range of positions. Notice that the
502 entries in the list are inserted in random order.
503 I don't think it's worth the effort to implement a more effective
504 datastructure, because the number of different fonts in a paragraph
508 /// Start position of paragraph this font attribute covers
510 /// Ending position of paragraph this font attribute covers
512 /** Font. Interpretation of the font values:
513 If a value is LyXFont::INHERIT_*, it means that the font
514 attribute is inherited from either the layout of this
515 paragraph or, in the case of nested paragraphs, from the
516 layout in the environment one level up until completely
518 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
519 allowed in these font tables.
531 typedef list<FontTable> FontList;
535 typedef list<InsetTable> InsetList;
539 LyXParagraph * TeXDeeper(ostream &, TexRow & texrow,
540 ostream & foot, TexRow & foot_texrow,
543 LyXParagraph * TeXFootnote(ostream &, TexRow & texrow,
544 ostream & foot, TexRow & foot_texrow,
546 LyXDirection par_direction);
548 bool SimpleTeXOneTablePar(ostream &, TexRow & texrow);
550 bool TeXContTableRows(ostream &, size_type i,
551 int current_cell_number,
552 int & column, TexRow & texrow);
554 void SimpleTeXBlanks(ostream &, TexRow & texrow,
556 int & column, LyXFont const & font,
557 LyXLayout const & style);
559 void SimpleTeXSpecialChars(ostream &, TexRow & texrow,
560 LyXFont & font, LyXFont & running_font,
561 LyXFont & basefont, bool & open_font,
562 LyXLayout const & style,
564 int & column, char const c);
568 static unsigned int paragraph_id;