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 void readSimpleWholeFile(istream &);
154 LyXParagraph * TeXOnePar(ostream &, TexRow & texrow,
155 ostream & foot, TexRow & foot_texrow,
158 bool SimpleTeXOnePar(ostream &, TexRow & texrow);
161 LyXParagraph * TeXEnvironment(ostream &, TexRow & texrow,
162 ostream & foot, TexRow & foot_texrow,
165 LyXParagraph * Clone() const;
168 bool HasSameLayout(LyXParagraph const * par) const;
171 void MakeSameLayout(LyXParagraph const * par);
173 /// Is it the first par with same depth and layout?
174 bool IsFirstInSequence() const {
175 LyXParagraph const * dhook = DepthHook(GetDepth());
176 return (dhook == this
177 || dhook->GetLayout() != GetLayout()
178 || dhook->GetDepth() != GetDepth());
185 size_type size() const { return text.size(); }
187 VSpace added_space_top;
190 VSpace added_space_bottom;
193 LyXTextClass::LayoutList::size_type layout;
197 \item no footnote, closed footnote,
198 \item open footnote, where footnote
199 \item means footnote-environment
202 footnote_flag footnoteflag;
204 /// footnote, margin, fig, tab
205 footnote_kind footnotekind;
207 //@Man: the LyX- DTP-switches
219 bool pagebreak_bottom;
231 block<int, 10> counter_;
234 void setCounter(int i, int v) { counter_[i] = v; }
235 int getCounter(int i) const { return counter_[i]; }
236 void incCounter(int i) { counter_[i]++; }
238 bool start_of_appendix;
249 /* This is for the paragraph extra stuff */
255 string pextra_widthp;
257 int pextra_alignment;
261 bool pextra_start_minipage;
267 string labelwidthstring;
273 LyXParagraph * previous;
275 /* table stuff -- begin*/
278 /* table stuff -- end*/
281 InsetBibKey * bibkey; // ale970302
283 /** these function are able to hide closed footnotes
285 LyXParagraph * Next();
288 LyXParagraph * Previous();
290 LyXParagraph const * Previous() const;
292 /** these function are able to hide open and closed footnotes
294 LyXParagraph * NextAfterFootnote();
296 LyXParagraph const * NextAfterFootnote() const;
299 LyXParagraph * PreviousBeforeFootnote();
301 LyXParagraph * LastPhysicalPar();
304 LyXParagraph * FirstPhysicalPar();
306 LyXParagraph const * FirstPhysicalPar() const;
308 /// returns the physical paragraph
309 LyXParagraph * ParFromPos(size_type pos);
310 /// returns the position in the physical par
311 int PositionInParFromPos(size_type pos) const;
313 /// for the environments
314 LyXParagraph * DepthHook(int depth);
315 /// for the environments
316 LyXParagraph const * DepthHook(int depth) const;
318 int BeginningOfMainBody() const;
320 string GetLabestring() const;
322 /// the next two functions are for the manual labels
323 string GetLabelWidthString() const;
325 void SetLabelWidthString(string const & s);
327 LyXTextClass::LayoutList::size_type GetLayout() const;
329 char GetAlign() const;
331 char GetDepth() const;
333 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
335 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
337 int GetFirstCounter(int i) const;
339 size_type Last() const;
341 void Erase(size_type pos);
342 /** the flag determines wether the layout should be copied
344 void BreakParagraph(size_type pos, int flag);
346 void BreakParagraphConservative(size_type pos);
347 /** Get unistantiated font setting. Returns the difference
348 between the characters font and the layoutfont.
349 This is what is stored in the fonttable
351 LyXFont GetFontSettings(size_type pos) const;
352 /** Get fully instantiated font. If pos == -1, use the layout
353 font attached to this paragraph.
354 If pos == -2, use the label font of the layout attached here.
355 In all cases, the font is instantiated, i.e. does not have any
356 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
359 LyXFont getFont(size_type pos) const;
361 char GetChar(size_type pos);
363 char GetChar(size_type pos) const;
365 void SetFont(size_type pos, LyXFont const & font);
367 string GetWord(size_type &) const;
368 /// Returns the height of the highest font in range
369 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
370 size_type endpos) const;
372 void InsertChar(size_type pos, char c);
374 void InsertInset(size_type pos, Inset * inset);
376 Inset * GetInset(size_type pos);
378 Inset const * GetInset(size_type pos) const;
380 Inset * ReturnNextInsetPointer(size_type & pos);
382 void OpenFootnote(size_type pos);
384 void CloseFootnote(size_type pos);
385 /// important for cut and paste
386 void CopyIntoMinibuffer(size_type pos) const;
388 void CutIntoMinibuffer(size_type pos);
390 void InsertFromMinibuffer(size_type pos);
393 bool IsHfill(size_type pos) const;
395 bool IsInset(size_type pos) const;
397 bool IsFloat(size_type pos) const;
399 bool IsNewline(size_type pos) const;
401 bool IsSeparator(size_type pos) const;
403 bool IsLineSeparator(size_type pos) const;
405 bool IsKomma(size_type pos) const;
406 /// Used by the spellchecker
407 bool IsLetter(size_type pos) const;
409 bool IsWord(size_type pos) const;
411 /** This one resets all layout and dtp switches but not the font
412 of the single characters
416 /** paste this paragraph with the next one
417 be carefull, this doesent make any check at all
419 void PasteParagraph();
421 /// used to remove the error messages
422 int AutoDeleteInsets();
424 /// returns -1 if inset not found
425 int GetPositionOfInset(Inset * inset) const;
427 /// ok and now some footnote functions
428 void OpenFootnotes();
431 void CloseFootnotes();
434 LyXParagraph * FirstSelfrowPar();
437 int ClearParagraph() {
439 if (!IsDummy() && !table){
442 || IsLineSeparator(0))){
450 /** A paragraph following a footnote is a "dummy". A paragraph
451 with a footnote in it is stored as three paragraphs:
452 First a paragraph with the text up to the footnote, then
453 one (or more) paragraphs with the footnote, and finally
454 the a paragraph with the text after the footnote. Only the
455 first paragraph keeps information about layoutparameters, */
456 bool IsDummy() const {
457 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
458 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
461 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
462 I have to set it on each of it's elements */
464 void SetPExtraType(int type, char const * width, char const * widthp);
466 void UnsetPExtraType();
469 bool RoffContTableRows(ostream &, size_type i, int actcell);
472 bool linuxDocConvertChar(char c, string & sgml_string);
474 void DocBookContTableRows(ostream &, string & extra, int & desc_on,
476 int current_cell_number, int & column);
478 void SimpleDocBookOneTablePar(ostream &, string & extra,
479 int & desc_on, int depth);
481 /** A font entry covers a range of positions. Notice that the
482 entries in the list are inserted in random order.
483 I don't think it's worth the effort to implement a more effective
484 datastructure, because the number of different fonts in a paragraph
488 /// Start position of paragraph this font attribute covers
490 /// Ending position of paragraph this font attribute covers
492 /** Font. Interpretation of the font values:
493 If a value is LyXFont::INHERIT_*, it means that the font
494 attribute is inherited from either the layout of this
495 paragraph or, in the case of nested paragraphs, from the
496 layout in the environment one level up until completely
498 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
499 allowed in these font tables.
511 typedef list<FontTable> FontList;
515 typedef list<InsetTable> InsetList;
519 LyXParagraph * TeXDeeper(ostream &, TexRow & texrow,
520 ostream & foot, TexRow & foot_texrow,
523 LyXParagraph * TeXFootnote(ostream &, TexRow & texrow,
524 ostream & foot, TexRow & foot_texrow,
526 LyXDirection par_direction);
528 bool SimpleTeXOneTablePar(ostream &, TexRow & texrow);
530 bool TeXContTableRows(ostream &, size_type i,
531 int current_cell_number,
532 int & column, TexRow & texrow);
534 void SimpleTeXBlanks(ostream &, TexRow & texrow,
536 int & column, LyXFont const & font,
537 LyXLayout const & style);
539 void SimpleTeXSpecialChars(ostream &, TexRow & texrow,
540 LyXFont & font, LyXFont & running_font,
541 LyXFont & basefont, bool & open_font,
542 LyXLayout const & style,
544 int & column, char const c);
548 static unsigned int paragraph_id;