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());
181 /// Check if the current paragraph is the last paragraph in a
182 /// proof environment
183 int GetEndLabel() const;
188 size_type size() const { return text.size(); }
190 VSpace added_space_top;
193 VSpace added_space_bottom;
196 LyXTextClass::LayoutList::size_type layout;
200 \item no footnote, closed footnote,
201 \item open footnote, where footnote
202 \item means footnote-environment
205 footnote_flag footnoteflag;
207 /// footnote, margin, fig, tab
208 footnote_kind footnotekind;
210 //@Man: the LyX- DTP-switches
222 bool pagebreak_bottom;
234 block<int, 10> counter_;
237 void setCounter(int i, int v) { counter_[i] = v; }
238 int getCounter(int i) const { return counter_[i]; }
239 void incCounter(int i) { counter_[i]++; }
241 bool start_of_appendix;
252 /* This is for the paragraph extra stuff */
258 string pextra_widthp;
260 int pextra_alignment;
264 bool pextra_start_minipage;
270 string labelwidthstring;
276 LyXParagraph * previous;
278 /* table stuff -- begin*/
281 /* table stuff -- end*/
284 InsetBibKey * bibkey; // ale970302
286 /** these function are able to hide closed footnotes
288 LyXParagraph * Next();
291 LyXParagraph * Previous();
293 LyXParagraph const * Previous() const;
295 /** these function are able to hide open and closed footnotes
297 LyXParagraph * NextAfterFootnote();
299 LyXParagraph const * NextAfterFootnote() const;
302 LyXParagraph * PreviousBeforeFootnote();
304 LyXParagraph * LastPhysicalPar();
306 LyXParagraph const * LastPhysicalPar() const;
309 LyXParagraph * FirstPhysicalPar();
311 LyXParagraph const * FirstPhysicalPar() const;
313 /// returns the physical paragraph
314 LyXParagraph * ParFromPos(size_type pos);
315 /// returns the position in the physical par
316 int PositionInParFromPos(size_type pos) const;
318 /// for the environments
319 LyXParagraph * DepthHook(int depth);
320 /// for the environments
321 LyXParagraph const * DepthHook(int depth) const;
323 int BeginningOfMainBody() const;
325 string GetLabestring() const;
327 /// the next two functions are for the manual labels
328 string GetLabelWidthString() const;
330 void SetLabelWidthString(string const & s);
332 LyXTextClass::LayoutList::size_type GetLayout() const;
334 char GetAlign() const;
336 char GetDepth() const;
338 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
340 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
342 int GetFirstCounter(int i) const;
344 size_type Last() const;
346 void Erase(size_type pos);
347 /** the flag determines wether the layout should be copied
349 void BreakParagraph(size_type pos, int flag);
351 void BreakParagraphConservative(size_type pos);
352 /** Get unistantiated font setting. Returns the difference
353 between the characters font and the layoutfont.
354 This is what is stored in the fonttable
356 LyXFont GetFontSettings(size_type pos) const;
357 /** Get fully instantiated font. If pos == -1, use the layout
358 font attached to this paragraph.
359 If pos == -2, use the label font of the layout attached here.
360 In all cases, the font is instantiated, i.e. does not have any
361 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
364 LyXFont getFont(size_type pos) const;
366 char GetChar(size_type pos);
368 char GetChar(size_type pos) const;
370 void SetFont(size_type pos, LyXFont const & font);
372 string GetWord(size_type &) const;
373 /// Returns the height of the highest font in range
374 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
375 size_type endpos) const;
377 void InsertChar(size_type pos, char c);
379 void InsertInset(size_type pos, Inset * inset);
381 Inset * GetInset(size_type pos);
383 Inset const * GetInset(size_type pos) const;
385 Inset * ReturnNextInsetPointer(size_type & pos);
387 void OpenFootnote(size_type pos);
389 void CloseFootnote(size_type pos);
390 /// important for cut and paste
391 void CopyIntoMinibuffer(size_type pos) const;
393 void CutIntoMinibuffer(size_type pos);
395 void InsertFromMinibuffer(size_type pos);
398 bool IsHfill(size_type pos) const;
400 bool IsInset(size_type pos) const;
402 bool IsFloat(size_type pos) const;
404 bool IsNewline(size_type pos) const;
406 bool IsSeparator(size_type pos) const;
408 bool IsLineSeparator(size_type pos) const;
410 bool IsKomma(size_type pos) const;
411 /// Used by the spellchecker
412 bool IsLetter(size_type pos) const;
414 bool IsWord(size_type pos) const;
416 /** This one resets all layout and dtp switches but not the font
417 of the single characters
421 /** paste this paragraph with the next one
422 be carefull, this doesent make any check at all
424 void PasteParagraph();
426 /// used to remove the error messages
427 int AutoDeleteInsets();
429 /// returns -1 if inset not found
430 int GetPositionOfInset(Inset * inset) const;
432 /// ok and now some footnote functions
433 void OpenFootnotes();
436 void CloseFootnotes();
439 LyXParagraph * FirstSelfrowPar();
442 int ClearParagraph() {
444 if (!IsDummy() && !table){
447 || IsLineSeparator(0))){
455 /** A paragraph following a footnote is a "dummy". A paragraph
456 with a footnote in it is stored as three paragraphs:
457 First a paragraph with the text up to the footnote, then
458 one (or more) paragraphs with the footnote, and finally
459 the a paragraph with the text after the footnote. Only the
460 first paragraph keeps information about layoutparameters, */
461 bool IsDummy() const {
462 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
463 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
466 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
467 I have to set it on each of it's elements */
469 void SetPExtraType(int type, char const * width, char const * widthp);
471 void UnsetPExtraType();
474 bool RoffContTableRows(ostream &, size_type i, int actcell);
477 bool linuxDocConvertChar(char c, string & sgml_string);
479 void DocBookContTableRows(ostream &, string & extra, int & desc_on,
481 int current_cell_number, int & column);
483 void SimpleDocBookOneTablePar(ostream &, string & extra,
484 int & desc_on, int depth);
486 /** A font entry covers a range of positions. Notice that the
487 entries in the list are inserted in random order.
488 I don't think it's worth the effort to implement a more effective
489 datastructure, because the number of different fonts in a paragraph
493 /// Start position of paragraph this font attribute covers
495 /// Ending position of paragraph this font attribute covers
497 /** Font. Interpretation of the font values:
498 If a value is LyXFont::INHERIT_*, it means that the font
499 attribute is inherited from either the layout of this
500 paragraph or, in the case of nested paragraphs, from the
501 layout in the environment one level up until completely
503 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
504 allowed in these font tables.
516 typedef list<FontTable> FontList;
520 typedef list<InsetTable> InsetList;
524 LyXParagraph * TeXDeeper(ostream &, TexRow & texrow,
525 ostream & foot, TexRow & foot_texrow,
528 LyXParagraph * TeXFootnote(ostream &, TexRow & texrow,
529 ostream & foot, TexRow & foot_texrow,
531 LyXDirection par_direction);
533 bool SimpleTeXOneTablePar(ostream &, TexRow & texrow);
535 bool TeXContTableRows(ostream &, size_type i,
536 int current_cell_number,
537 int & column, TexRow & texrow);
539 void SimpleTeXBlanks(ostream &, TexRow & texrow,
541 int & column, LyXFont const & font,
542 LyXLayout const & style);
544 void SimpleTeXSpecialChars(ostream &, TexRow & texrow,
545 LyXFont & font, LyXFont & running_font,
546 LyXFont & basefont, bool & open_font,
547 LyXLayout const & style,
549 int & column, char const c);
553 static unsigned int paragraph_id;