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"
32 #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(FILE *, BufferParams &, char, char);
127 void validate(LaTeXFeatures &);
134 void id(int id_arg) {
142 void readSimpleWholeFile(FILE *);
145 LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
146 string & foot, TexRow & foot_texrow,
150 LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
151 string & foot, TexRow & foot_texrow,
155 LyXParagraph * Clone() const;
158 bool HasSameLayout(LyXParagraph const * par);
161 void MakeSameLayout(LyXParagraph const * par);
163 /// Is it the first par with same depth and layout?
164 bool IsFirstInSequence() const {
165 LyXParagraph const * dhook = DepthHook(GetDepth());
166 return (dhook == this
167 || dhook->GetLayout() != GetLayout()
168 || dhook->GetDepth() != GetDepth());
173 typedef char value_type;
175 typedef vector<value_type> 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;
227 block<int, 10> counter_;
230 void setCounter(int i, int v) { counter_[i] = v; }
231 int getCounter(int i) const { return counter_[i]; }
232 void incCounter(int i) { counter_[i]++; }
234 bool start_of_appendix;
245 /* This is for the paragraph extra stuff */
251 string pextra_widthp;
253 int pextra_alignment;
257 bool pextra_start_minipage;
263 string labelwidthstring;
269 LyXParagraph * previous;
271 /* table stuff -- begin*/
274 /* table stuff -- end*/
277 InsetBibKey * bibkey; // ale970302
279 /** these function are able to hide closed footnotes
281 LyXParagraph * Next();
284 LyXParagraph * Previous();
286 LyXParagraph const * Previous() const;
288 /** these function are able to hide open and closed footnotes
290 LyXParagraph * NextAfterFootnote();
292 LyXParagraph const * NextAfterFootnote() const;
295 LyXParagraph * PreviousBeforeFootnote();
297 LyXParagraph * LastPhysicalPar();
300 LyXParagraph * FirstPhysicalPar();
302 LyXParagraph const * FirstPhysicalPar() const;
304 /// returns the physical paragraph
305 LyXParagraph * ParFromPos(size_type pos);
306 /// returns the position in the physical par
307 int PositionInParFromPos(size_type pos) const;
309 /// for the environments
310 LyXParagraph * DepthHook(int depth);
311 /// for the environments
312 LyXParagraph const * DepthHook(int depth) const;
314 int BeginningOfMainBody() const;
316 string GetLabestring() const;
318 /// the next two functions are for the manual labels
319 string GetLabelWidthString() const;
321 void SetLabelWidthString(string const & s);
323 LyXTextClass::LayoutList::size_type GetLayout() const;
325 char GetAlign() const;
327 char GetDepth() const;
329 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
331 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
333 int GetFirstCounter(int i) const;
335 size_type Last() const;
337 void Erase(size_type pos);
338 /** the flag determines wether the layout should be copied
340 void BreakParagraph(size_type pos, int flag);
342 void BreakParagraphConservative(size_type pos);
343 /** Get unistantiated font setting. Returns the difference
344 between the characters font and the layoutfont.
345 This is what is stored in the fonttable
347 LyXFont GetFontSettings(size_type pos) const;
348 /** Get fully instantiated font. If pos == -1, use the layout
349 font attached to this paragraph.
350 If pos == -2, use the label font of the layout attached here.
351 In all cases, the font is instantiated, i.e. does not have any
352 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
355 LyXFont getFont(size_type pos) const;
357 char GetChar(size_type pos);
359 char GetChar(size_type pos) const;
361 void SetFont(size_type pos, LyXFont const & font);
363 string GetWord(size_type &) const;
364 /// Returns the height of the highest font in range
365 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
366 size_type endpos) const;
368 void InsertChar(size_type pos, char c);
370 void InsertInset(size_type pos, Inset * inset);
372 Inset * GetInset(size_type pos);
374 Inset const * GetInset(size_type pos) const;
376 Inset * ReturnNextInsetPointer(size_type & pos);
378 void OpenFootnote(size_type pos);
380 void CloseFootnote(size_type pos);
381 /// important for cut and paste
382 void CopyIntoMinibuffer(size_type pos) const;
384 void CutIntoMinibuffer(size_type pos);
386 void InsertFromMinibuffer(size_type pos);
389 bool IsHfill(size_type pos) const;
391 bool IsInset(size_type pos) const;
393 bool IsFloat(size_type pos) const;
395 bool IsNewline(size_type pos) const;
397 bool IsSeparator(size_type pos) const;
399 bool IsLineSeparator(size_type pos) const;
401 bool IsKomma(size_type pos) const;
402 /// Used by the spellchecker
403 bool IsLetter(size_type pos) const;
405 bool IsWord(size_type pos) const;
407 /** This one resets all layout and dtp switches but not the font
408 of the single characters
412 /** paste this paragraph with the next one
413 be carefull, this doesent make any check at all
415 void PasteParagraph();
417 /// used to remove the error messages
418 int AutoDeleteInsets();
420 /// returns -1 if inset not found
421 int GetPositionOfInset(Inset * inset) const;
423 /// ok and now some footnote functions
424 void OpenFootnotes();
427 void CloseFootnotes();
430 LyXParagraph * FirstSelfrowPar();
433 int ClearParagraph(){
435 if (!IsDummy() && !table){
438 || IsLineSeparator(0))){
446 /** A paragraph following a footnote is a "dummy". A paragraph
447 with a footnote in it is stored as three paragraphs:
448 First a paragraph with the text up to the footnote, then
449 one (or more) paragraphs with the footnote, and finally
450 the a paragraph with the text after the footnote. Only the
451 first paragraph keeps information about layoutparameters, */
452 bool IsDummy() const{
453 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
454 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
457 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
458 I have to set it on each of it's elements */
460 void SetPExtraType(int type, char const * width, char const * widthp);
462 void UnsetPExtraType();
464 bool RoffContTableRows(FILE * file, size_type i,
467 void DocBookContTableRows(string & file, string & extra, int & desc_on,
469 int current_cell_number, int & column);
471 bool linuxDocConvertChar(char c, string & sgml_string);
473 void SimpleDocBookOneTablePar(string & file, string & extra,
474 int & desc_on, int depth);
476 /** A font entry covers a range of positions. Notice that the
477 entries in the list are inserted in random order.
478 I don't think it's worth the effort to implement a more effective
479 datastructure, because the number of different fonts in a paragraph
483 /// Start position of paragraph this font attribute covers
485 /// Ending position of paragraph this font attribute covers
487 /** Font. Interpretation of the font values:
488 If a value is LyXFont::INHERIT_*, it means that the font
489 attribute is inherited from either the layout of this
490 paragraph or, in the case of nested paragraphs, from the
491 layout in the environment one level up until completely
493 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
494 allowed in these font tables.
498 /// Pointer to next font entry
515 typedef list<FontTable> FontList;
517 typedef list<InsetTable> InsetList;
524 FontTable * fonttable;
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;