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
27 #include "insets/lyxinset.h"
28 #include "insets/insetbib.h"
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(FILE *, BufferParams &, char, char);
126 void validate(LaTeXFeatures &);
133 void SetID(int id_arg){
141 void readSimpleWholeFile(FILE *);
144 LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
145 string & foot, TexRow & foot_texrow,
149 LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
150 string & foot, TexRow & foot_texrow,
154 LyXParagraph * Clone();
157 bool HasSameLayout(LyXParagraph * par);
160 void MakeSameLayout(LyXParagraph * par);
162 /// Is it the first par with same depth and layout?
163 bool IsFirstInSequence() {
164 LyXParagraph * dhook = DepthHook(GetDepth());
165 return (dhook == this
166 || dhook->GetLayout() != GetLayout()
167 || dhook->GetDepth() != GetDepth());
172 typedef char value_type;
174 typedef vector<value_type> TextContainer;
175 //typedef deque<char> TextContainer;
176 //typedef rope<char> TextContainer;
177 typedef int size_type;
181 size_type size() const { return text.size(); }
183 VSpace added_space_top;
186 VSpace added_space_bottom;
189 LyXTextClass::LayoutList::size_type layout;
193 \item no footnote, closed footnote,
194 \item open footnote, where footnote
195 \item means footnote-environment
198 footnote_flag footnoteflag;
200 /// footnote, margin, fig, tab
201 footnote_kind footnotekind;
203 //@Man: the LyX- DTP-switches
215 bool pagebreak_bottom;
231 void setCounter(int i, int v) { counter[i] = v; }
232 int getCounter(int i) { return counter[i]; }
233 void incCounter(int i) { counter[i]++; }
235 bool start_of_appendix;
246 /* This is for the paragraph extra stuff */
252 string pextra_widthp;
254 int pextra_alignment;
258 bool pextra_start_minipage;
264 string labelwidthstring;
270 LyXParagraph * previous;
272 /* table stuff -- begin*/
275 /* table stuff -- end*/
278 InsetBibKey * bibkey; // ale970302
280 /** these function are able to hide closed footnotes
282 LyXParagraph * Next();
285 LyXParagraph * Previous();
287 /** these function are able to hide open and closed footnotes
289 LyXParagraph * NextAfterFootnote();
291 LyXParagraph * NextAfterFootnote() const;
293 LyXParagraph * PreviousBeforeFootnote();
295 LyXParagraph * LastPhysicalPar();
297 LyXParagraph * FirstPhysicalPar();
299 /// returns the physical paragraph
300 LyXParagraph * ParFromPos(size_type pos);
301 /// returns the position in the physical par
302 int PositionInParFromPos(size_type pos);
304 /// for the environments
305 LyXParagraph * DepthHook(int depth);
307 int BeginningOfMainBody();
309 string GetLabestring();
311 /// the next two functions are for the manual labels
312 string GetLabelWidthString();
314 void SetLabelWidthString(string const & s);
316 LyXTextClass::LayoutList::size_type GetLayout();
322 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
324 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
326 int GetFirstCounter(int i);
330 void Erase(size_type pos);
331 /** the flag determines wether the layout should be copied
333 void BreakParagraph(size_type pos, int flag);
335 void BreakParagraphConservative(size_type pos);
336 /** Get unistantiated font setting. Returns the difference
337 between the characters font and the layoutfont.
338 This is what is stored in the fonttable
340 LyXFont GetFontSettings(size_type pos);
341 /** Get fully instantiated font. If pos == -1, use the layout
342 font attached to this paragraph.
343 If pos == -2, use the label font of the layout attached here.
344 In all cases, the font is instantiated, i.e. does not have any
345 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
348 LyXFont getFont(size_type pos);
350 char GetChar(size_type pos);
352 char GetChar(size_type pos) const;
354 void SetFont(size_type pos, LyXFont const & font);
356 string GetWord(size_type &);
357 /// Returns the height of the highest font in range
358 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
359 size_type endpos) const;
361 void InsertChar(size_type pos, char c);
363 void InsertInset(size_type pos, Inset * inset);
365 Inset * GetInset(size_type pos);
367 Inset * ReturnNextInsetPointer(size_type & pos);
369 void OpenFootnote(size_type pos);
371 void CloseFootnote(size_type pos);
372 /// important for cut and paste
373 void CopyIntoMinibuffer(size_type pos);
375 void CutIntoMinibuffer(size_type pos);
377 void InsertFromMinibuffer(size_type pos);
380 bool IsHfill(size_type pos) const;
382 bool IsInset(size_type pos) const;
384 bool IsFloat(size_type pos) const;
386 bool IsNewline(size_type pos) const;
388 bool IsSeparator(size_type pos) const;
390 bool IsLineSeparator(size_type pos) const;
392 bool IsKomma(size_type pos) const;
393 /// Used by the spellchecker
394 bool IsLetter(size_type pos) const;
396 bool IsWord(size_type pos) const;
398 /** This one resets all layout and dtp switches but not the font
399 of the single characters
403 /** paste this paragraph with the next one
404 be carefull, this doesent make any check at all
406 void PasteParagraph();
408 /// used to remove the error messages
409 int AutoDeleteInsets();
411 /// returns -1 if inset not found
412 int GetPositionOfInset(Inset * inset);
414 /// ok and now some footnote functions
415 void OpenFootnotes();
418 void CloseFootnotes();
421 LyXParagraph * FirstSelfrowPar();
424 int ClearParagraph(){
426 if (!IsDummy() && !table){
429 || IsLineSeparator(0))){
437 /** A paragraph following a footnote is a "dummy". A paragraph
438 with a footnote in it is stored as three paragraphs:
439 First a paragraph with the text up to the footnote, then
440 one (or more) paragraphs with the footnote, and finally
441 the a paragraph with the text after the footnote. Only the
442 first paragraph keeps information about layoutparameters, */
444 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
445 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
448 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
449 I have to set it on each of it's elements */
451 void SetPExtraType(int type, char const * width, char const * widthp);
453 void UnsetPExtraType();
455 bool RoffContTableRows(FILE * file, size_type i,
458 void DocBookContTableRows(string & file, string & extra, int & desc_on,
460 int current_cell_number, int & column);
462 bool linuxDocConvertChar(char c, string & sgml_string);
464 void SimpleDocBookOneTablePar(string & file, string & extra,
465 int & desc_on, int depth);
467 /** A font entry covers a range of positions. Notice that the
468 entries in the list are inserted in random order.
469 I don't think it's worth the effort to implement a more effective
470 datastructure, because the number of different fonts in a paragraph
474 /// Start position of paragraph this font attribute covers
476 /// Ending position of paragraph this font attribute covers
478 /** Font. Interpretation of the font values:
479 If a value is LyXFont::INHERIT_*, it means that the font
480 attribute is inherited from either the layout of this
481 paragraph or, in the case of nested paragraphs, from the
482 layout in the environment one level up until completely
484 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
485 allowed in these font tables.
489 /// Pointer to next font entry
506 typedef list<FontTable> FontList;
508 typedef list<InsetTable> InsetList;
515 FontTable * fonttable;
517 InsetTable * insettable;
520 LyXParagraph * TeXDeeper(string & file, TexRow & texrow,
521 string & foot, TexRow & foot_texrow,
524 LyXParagraph * TeXFootnote(string & file, TexRow & texrow,
525 string & foot, TexRow & foot_texrow,
528 bool SimpleTeXOnePar(string & file, TexRow & texrow);
530 bool SimpleTeXOneTablePar(string & file, TexRow & texrow);
532 bool TeXContTableRows(string & file, size_type i,
533 int current_cell_number,
534 int & column, TexRow & texrow);
536 void SimpleTeXBlanks(string & file, TexRow & texrow,
538 int & column, LyXFont const & font,
539 LyXLayout const & style);
541 void SimpleTeXSpecialChars(string & file, TexRow & texrow,
542 LyXFont & font, LyXFont & running_font,
543 LyXFont & basefont, bool & open_font,
544 LyXLayout const & style,
546 int & column, char const c);
550 static unsigned int paragraph_id;