2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1999 The LyX Team.
10 * ====================================================== */
12 #ifndef LYXPARAGRAPH_H
13 #define LYXPARAGRAPH_H
22 #include "insets/lyxinset.h"
23 #include "insets/insetbib.h"
27 #include "support/block.h"
30 #define NEW_INSETTABLE 1
31 #define NEW_FONTTABLE 1
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
117 /// this konstruktor inserts the new paragraph in a list
118 LyXParagraph(LyXParagraph * par);
119 /// the destruktors removes the new paragraph from the list
123 void writeFile(ostream &, BufferParams &, char, char);
125 void validate(LaTeXFeatures &);
132 void id(int id_arg) {
140 void readSimpleWholeFile(istream &);
143 LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
144 string & foot, TexRow & foot_texrow,
148 LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
149 string & foot, TexRow & foot_texrow,
153 LyXParagraph * Clone() const;
156 bool HasSameLayout(LyXParagraph const * par);
159 void MakeSameLayout(LyXParagraph const * par);
161 /// Is it the first par with same depth and layout?
162 bool IsFirstInSequence() const {
163 LyXParagraph const * dhook = DepthHook(GetDepth());
164 return (dhook == this
165 || dhook->GetLayout() != GetLayout()
166 || dhook->GetDepth() != GetDepth());
171 typedef char value_type;
173 typedef vector<value_type> TextContainer;
175 typedef int size_type;
179 size_type size() const { return text.size(); }
181 VSpace added_space_top;
184 VSpace added_space_bottom;
187 LyXTextClass::LayoutList::size_type layout;
191 \item no footnote, closed footnote,
192 \item open footnote, where footnote
193 \item means footnote-environment
196 footnote_flag footnoteflag;
198 /// footnote, margin, fig, tab
199 footnote_kind footnotekind;
201 //@Man: the LyX- DTP-switches
213 bool pagebreak_bottom;
225 block<int, 10> counter_;
228 void setCounter(int i, int v) { counter_[i] = v; }
229 int getCounter(int i) const { return counter_[i]; }
230 void incCounter(int i) { counter_[i]++; }
232 bool start_of_appendix;
243 /* This is for the paragraph extra stuff */
249 string pextra_widthp;
251 int pextra_alignment;
255 bool pextra_start_minipage;
261 string labelwidthstring;
267 LyXParagraph * previous;
269 /* table stuff -- begin*/
272 /* table stuff -- end*/
275 InsetBibKey * bibkey; // ale970302
277 /** these function are able to hide closed footnotes
279 LyXParagraph * Next();
282 LyXParagraph * Previous();
284 LyXParagraph const * Previous() const;
286 /** these function are able to hide open and closed footnotes
288 LyXParagraph * NextAfterFootnote();
290 LyXParagraph const * NextAfterFootnote() const;
293 LyXParagraph * PreviousBeforeFootnote();
295 LyXParagraph * LastPhysicalPar();
298 LyXParagraph * FirstPhysicalPar();
300 LyXParagraph const * FirstPhysicalPar() const;
302 /// returns the physical paragraph
303 LyXParagraph * ParFromPos(size_type pos);
304 /// returns the position in the physical par
305 int PositionInParFromPos(size_type pos) const;
307 /// for the environments
308 LyXParagraph * DepthHook(int depth);
309 /// for the environments
310 LyXParagraph const * DepthHook(int depth) const;
312 int BeginningOfMainBody() const;
314 string GetLabestring() const;
316 /// the next two functions are for the manual labels
317 string GetLabelWidthString() const;
319 void SetLabelWidthString(string const & s);
321 LyXTextClass::LayoutList::size_type GetLayout() const;
323 char GetAlign() const;
325 char GetDepth() const;
327 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
329 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
331 int GetFirstCounter(int i) const;
333 size_type Last() const;
335 void Erase(size_type pos);
336 /** the flag determines wether the layout should be copied
338 void BreakParagraph(size_type pos, int flag);
340 void BreakParagraphConservative(size_type pos);
341 /** Get unistantiated font setting. Returns the difference
342 between the characters font and the layoutfont.
343 This is what is stored in the fonttable
345 LyXFont GetFontSettings(size_type pos) const;
346 /** Get fully instantiated font. If pos == -1, use the layout
347 font attached to this paragraph.
348 If pos == -2, use the label font of the layout attached here.
349 In all cases, the font is instantiated, i.e. does not have any
350 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
353 LyXFont getFont(size_type pos) const;
355 char GetChar(size_type pos);
357 char GetChar(size_type pos) const;
359 void SetFont(size_type pos, LyXFont const & font);
361 string GetWord(size_type &) const;
362 /// Returns the height of the highest font in range
363 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
364 size_type endpos) const;
366 void InsertChar(size_type pos, char c);
368 void InsertInset(size_type pos, Inset * inset);
370 Inset * GetInset(size_type pos);
372 Inset const * GetInset(size_type pos) const;
374 Inset * ReturnNextInsetPointer(size_type & pos);
376 void OpenFootnote(size_type pos);
378 void CloseFootnote(size_type pos);
379 /// important for cut and paste
380 void CopyIntoMinibuffer(size_type pos) const;
382 void CutIntoMinibuffer(size_type pos);
384 void InsertFromMinibuffer(size_type pos);
387 bool IsHfill(size_type pos) const;
389 bool IsInset(size_type pos) const;
391 bool IsFloat(size_type pos) const;
393 bool IsNewline(size_type pos) const;
395 bool IsSeparator(size_type pos) const;
397 bool IsLineSeparator(size_type pos) const;
399 bool IsKomma(size_type pos) const;
400 /// Used by the spellchecker
401 bool IsLetter(size_type pos) const;
403 bool IsWord(size_type pos) const;
405 /** This one resets all layout and dtp switches but not the font
406 of the single characters
410 /** paste this paragraph with the next one
411 be carefull, this doesent make any check at all
413 void PasteParagraph();
415 /// used to remove the error messages
416 int AutoDeleteInsets();
418 /// returns -1 if inset not found
419 int GetPositionOfInset(Inset * inset) const;
421 /// ok and now some footnote functions
422 void OpenFootnotes();
425 void CloseFootnotes();
428 LyXParagraph * FirstSelfrowPar();
431 int ClearParagraph(){
433 if (!IsDummy() && !table){
436 || IsLineSeparator(0))){
444 /** A paragraph following a footnote is a "dummy". A paragraph
445 with a footnote in it is stored as three paragraphs:
446 First a paragraph with the text up to the footnote, then
447 one (or more) paragraphs with the footnote, and finally
448 the a paragraph with the text after the footnote. Only the
449 first paragraph keeps information about layoutparameters, */
450 bool IsDummy() const{
451 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
452 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
455 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
456 I have to set it on each of it's elements */
458 void SetPExtraType(int type, char const * width, char const * widthp);
460 void UnsetPExtraType();
462 bool RoffContTableRows(ostream &, size_type i, int actcell);
464 void DocBookContTableRows(string & file, string & extra, int & desc_on,
466 int current_cell_number, int & column);
468 bool linuxDocConvertChar(char c, string & sgml_string);
470 void SimpleDocBookOneTablePar(string & file, string & extra,
471 int & desc_on, int depth);
473 /** A font entry covers a range of positions. Notice that the
474 entries in the list are inserted in random order.
475 I don't think it's worth the effort to implement a more effective
476 datastructure, because the number of different fonts in a paragraph
480 /// Start position of paragraph this font attribute covers
482 /// Ending position of paragraph this font attribute covers
484 /** Font. Interpretation of the font values:
485 If a value is LyXFont::INHERIT_*, it means that the font
486 attribute is inherited from either the layout of this
487 paragraph or, in the case of nested paragraphs, from the
488 layout in the environment one level up until completely
490 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
491 allowed in these font tables.
494 #ifndef NEW_FONTTABLE
495 /// Pointer to next font entry
505 #ifndef NEW_INSETTABLE
512 typedef list<FontTable> FontList;
517 FontTable * fonttable;
519 #ifdef NEW_INSETTABLE
521 typedef list<InsetTable> InsetList;
526 InsetTable * insettable;
529 LyXParagraph * TeXDeeper(string & file, TexRow & texrow,
530 string & foot, TexRow & foot_texrow,
533 LyXParagraph * TeXFootnote(string & file, TexRow & texrow,
534 string & foot, TexRow & foot_texrow,
537 bool SimpleTeXOnePar(string & file, TexRow & texrow);
539 bool SimpleTeXOneTablePar(string & file, TexRow & texrow);
541 bool TeXContTableRows(string & file, size_type i,
542 int current_cell_number,
543 int & column, TexRow & texrow);
545 void SimpleTeXBlanks(string & file, TexRow & texrow,
547 int & column, LyXFont const & font,
548 LyXLayout const & style);
550 void SimpleTeXSpecialChars(string & file, TexRow & texrow,
551 LyXFont & font, LyXFont & running_font,
552 LyXFont & basefont, bool & open_font,
553 LyXLayout const & style,
555 int & column, char const c);
559 static unsigned int paragraph_id;