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
19 #include "insets/lyxinset.h"
20 #include "insets/insetbib.h"
24 #include "support/block.h"
39 /// A LyXParagraph holds all text, attributes and insets in a text paragraph
54 enum MINIPAGE_ALIGNMENT {
58 MINIPAGE_ALIGN_MIDDLE,
83 META_PROTECTED_SEPARATOR,
109 ALGORITHM, // Bernhard, 970807
111 WIDE_FIG, // CFO-G, 971106
113 WIDE_TAB // CFO-G, 971106
118 /// this konstruktor inserts the new paragraph in a list
119 LyXParagraph(LyXParagraph * par);
120 /// the destruktors removes the new paragraph from the list
124 void writeFile(ostream &, BufferParams &, char, char);
126 void validate(LaTeXFeatures &);
133 void id(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() const;
157 bool HasSameLayout(LyXParagraph const * par);
160 void MakeSameLayout(LyXParagraph const * par);
162 /// Is it the first par with same depth and layout?
163 bool IsFirstInSequence() const {
164 LyXParagraph const * 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;
176 typedef int size_type;
180 size_type size() const { return text.size(); }
182 VSpace added_space_top;
185 VSpace added_space_bottom;
188 LyXTextClass::LayoutList::size_type layout;
192 \item no footnote, closed footnote,
193 \item open footnote, where footnote
194 \item means footnote-environment
197 footnote_flag footnoteflag;
199 /// footnote, margin, fig, tab
200 footnote_kind footnotekind;
202 //@Man: the LyX- DTP-switches
214 bool pagebreak_bottom;
226 block<int, 10> counter_;
229 void setCounter(int i, int v) { counter_[i] = v; }
230 int getCounter(int i) const { return counter_[i]; }
231 void incCounter(int i) { counter_[i]++; }
233 bool start_of_appendix;
244 /* This is for the paragraph extra stuff */
250 string pextra_widthp;
252 int pextra_alignment;
256 bool pextra_start_minipage;
262 string labelwidthstring;
268 LyXParagraph * previous;
270 /* table stuff -- begin*/
273 /* table stuff -- end*/
276 InsetBibKey * bibkey; // ale970302
278 /** these function are able to hide closed footnotes
280 LyXParagraph * Next();
283 LyXParagraph * Previous();
285 LyXParagraph const * Previous() const;
287 /** these function are able to hide open and closed footnotes
289 LyXParagraph * NextAfterFootnote();
291 LyXParagraph const * NextAfterFootnote() const;
294 LyXParagraph * PreviousBeforeFootnote();
296 LyXParagraph * LastPhysicalPar();
299 LyXParagraph * FirstPhysicalPar();
301 LyXParagraph const * FirstPhysicalPar() const;
303 /// returns the physical paragraph
304 LyXParagraph * ParFromPos(size_type pos);
305 /// returns the position in the physical par
306 int PositionInParFromPos(size_type pos) const;
308 /// for the environments
309 LyXParagraph * DepthHook(int depth);
310 /// for the environments
311 LyXParagraph const * DepthHook(int depth) const;
313 int BeginningOfMainBody() const;
315 string GetLabestring() const;
317 /// the next two functions are for the manual labels
318 string GetLabelWidthString() const;
320 void SetLabelWidthString(string const & s);
322 LyXTextClass::LayoutList::size_type GetLayout() const;
324 char GetAlign() const;
326 char GetDepth() const;
328 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
330 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
332 int GetFirstCounter(int i) const;
334 size_type Last() const;
336 void Erase(size_type pos);
337 /** the flag determines wether the layout should be copied
339 void BreakParagraph(size_type pos, int flag);
341 void BreakParagraphConservative(size_type pos);
342 /** Get unistantiated font setting. Returns the difference
343 between the characters font and the layoutfont.
344 This is what is stored in the fonttable
346 LyXFont GetFontSettings(size_type pos) const;
347 /** Get fully instantiated font. If pos == -1, use the layout
348 font attached to this paragraph.
349 If pos == -2, use the label font of the layout attached here.
350 In all cases, the font is instantiated, i.e. does not have any
351 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
354 LyXFont getFont(size_type pos) const;
356 char GetChar(size_type pos);
358 char GetChar(size_type pos) const;
360 void SetFont(size_type pos, LyXFont const & font);
362 string GetWord(size_type &) const;
363 /// Returns the height of the highest font in range
364 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
365 size_type endpos) const;
367 void InsertChar(size_type pos, char c);
369 void InsertInset(size_type pos, Inset * inset);
371 Inset * GetInset(size_type pos);
373 Inset const * GetInset(size_type pos) const;
375 Inset * ReturnNextInsetPointer(size_type & pos);
377 void OpenFootnote(size_type pos);
379 void CloseFootnote(size_type pos);
380 /// important for cut and paste
381 void CopyIntoMinibuffer(size_type pos) const;
383 void CutIntoMinibuffer(size_type pos);
385 void InsertFromMinibuffer(size_type pos);
388 bool IsHfill(size_type pos) const;
390 bool IsInset(size_type pos) const;
392 bool IsFloat(size_type pos) const;
394 bool IsNewline(size_type pos) const;
396 bool IsSeparator(size_type pos) const;
398 bool IsLineSeparator(size_type pos) const;
400 bool IsKomma(size_type pos) const;
401 /// Used by the spellchecker
402 bool IsLetter(size_type pos) const;
404 bool IsWord(size_type pos) const;
406 /** This one resets all layout and dtp switches but not the font
407 of the single characters
411 /** paste this paragraph with the next one
412 be carefull, this doesent make any check at all
414 void PasteParagraph();
416 /// used to remove the error messages
417 int AutoDeleteInsets();
419 /// returns -1 if inset not found
420 int GetPositionOfInset(Inset * inset) const;
422 /// ok and now some footnote functions
423 void OpenFootnotes();
426 void CloseFootnotes();
429 LyXParagraph * FirstSelfrowPar();
432 int ClearParagraph(){
434 if (!IsDummy() && !table){
437 || IsLineSeparator(0))){
445 /** A paragraph following a footnote is a "dummy". A paragraph
446 with a footnote in it is stored as three paragraphs:
447 First a paragraph with the text up to the footnote, then
448 one (or more) paragraphs with the footnote, and finally
449 the a paragraph with the text after the footnote. Only the
450 first paragraph keeps information about layoutparameters, */
451 bool IsDummy() const{
452 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
453 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
456 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
457 I have to set it on each of it's elements */
459 void SetPExtraType(int type, char const * width, char const * widthp);
461 void UnsetPExtraType();
463 bool RoffContTableRows(ostream &, size_type i, int actcell);
465 void DocBookContTableRows(string & file, string & extra, int & desc_on,
467 int current_cell_number, int & column);
469 bool linuxDocConvertChar(char c, string & sgml_string);
471 void SimpleDocBookOneTablePar(string & file, string & extra,
472 int & desc_on, int depth);
474 /** A font entry covers a range of positions. Notice that the
475 entries in the list are inserted in random order.
476 I don't think it's worth the effort to implement a more effective
477 datastructure, because the number of different fonts in a paragraph
481 /// Start position of paragraph this font attribute covers
483 /// Ending position of paragraph this font attribute covers
485 /** Font. Interpretation of the font values:
486 If a value is LyXFont::INHERIT_*, it means that the font
487 attribute is inherited from either the layout of this
488 paragraph or, in the case of nested paragraphs, from the
489 layout in the environment one level up until completely
491 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
492 allowed in these font tables.
496 /// Pointer to next font entry
513 typedef list<FontTable> FontList;
515 typedef list<InsetTable> InsetList;
522 FontTable * fonttable;
524 InsetTable * insettable;
527 LyXParagraph * TeXDeeper(string & file, TexRow & texrow,
528 string & foot, TexRow & foot_texrow,
531 LyXParagraph * TeXFootnote(string & file, TexRow & texrow,
532 string & foot, TexRow & foot_texrow,
535 bool SimpleTeXOnePar(string & file, TexRow & texrow);
537 bool SimpleTeXOneTablePar(string & file, TexRow & texrow);
539 bool TeXContTableRows(string & file, size_type i,
540 int current_cell_number,
541 int & column, TexRow & texrow);
543 void SimpleTeXBlanks(string & file, TexRow & texrow,
545 int & column, LyXFont const & font,
546 LyXLayout const & style);
548 void SimpleTeXSpecialChars(string & file, TexRow & texrow,
549 LyXFont & font, LyXFont & running_font,
550 LyXFont & basefont, bool & open_font,
551 LyXLayout const & style,
553 int & column, char const c);
557 static unsigned int paragraph_id;