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
31 #include "definitions.h"
32 #include "insets/lyxinset.h"
34 #include "support/textutils.h"
36 #include "insets/insetbib.h"
44 /// A LyXParagraph holds all text, attributes and insets in a text paragraph
68 ALGORITHM, // Bernhard, 970807
70 WIDE_FIG, // CFO-G, 971106
72 WIDE_TAB // CFO-G, 971106
77 /// this konstruktor inserts the new paragraph in a list
78 LyXParagraph(LyXParagraph * par);
79 /// the destruktors removes the new paragraph from the list
83 void writeFile(FILE *, BufferParams &, char, char);
86 void validate(LaTeXFeatures &);
93 void SetID(int id_arg){
98 /** allocates more memory for the specified paragraph
99 pos is needed to specify the paragraph correctly. Remember the
102 void Enlarge(int pos, int number);
103 /** make the allocated memory fit to the needed size
104 used to make a paragraph smaller
113 void readSimpleWholeFile(FILE *);
116 LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
117 string & foot, TexRow & foot_texrow,
121 LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
122 string & foot, TexRow & foot_texrow,
126 LyXParagraph * Clone();
129 bool HasSameLayout(LyXParagraph * par);
132 void MakeSameLayout(LyXParagraph * par);
134 /// Is it the first par with same depth and layout?
135 bool IsFirstInSequence() {
136 LyXParagraph * dhook = DepthHook(GetDepth());
137 return (dhook == this
138 || dhook->GetLayout() != GetLayout()
139 || dhook->GetDepth() != GetDepth());
145 typedef deque<char> TextContainer;
146 typedef int size_type;
150 size_type size() const { return text.size(); }
160 VSpace added_space_top;
163 VSpace added_space_bottom;
166 LyXTextClass::LayoutList::size_type layout;
170 \item no footnote, closed footnote,
171 \item open footnote, where footnote
172 \item means footnote-environment
175 footnote_flag footnoteflag;
177 /// footnote, margin, fig, tab
178 footnote_kind footnotekind;
180 //@Man: the LyX- DTP-switches
192 bool pagebreak_bottom;
208 void setCounter(int i, int v) { counter[i] = v; }
209 int getCounter(int i) { return counter[i]; }
210 void incCounter(int i) { counter[i]++; }
212 bool start_of_appendix;
223 /* This is for the paragraph extra stuff */
229 string pextra_widthp;
231 int pextra_alignment;
235 bool pextra_start_minipage;
241 string labelwidthstring;
247 LyXParagraph * previous;
249 /* table stuff -- begin*/
252 /* table stuff -- end*/
255 InsetBibKey * bibkey; // ale970302
257 /** these function are able to hide closed footnotes
259 LyXParagraph * Next();
262 LyXParagraph * Previous();
264 /** these function are able to hide open and closed footnotes
266 LyXParagraph * NextAfterFootnote();
268 LyXParagraph * PreviousBeforeFootnote();
270 LyXParagraph * LastPhysicalPar();
272 LyXParagraph * FirstPhysicalPar();
275 /// returns the physical paragraph
276 LyXParagraph * ParFromPos(size_type pos);
277 /// returns the position in the physical par
278 int PositionInParFromPos(size_type pos);
280 /// returns the physical paragraph
281 LyXParagraph * ParFromPos(int pos);
282 /// returns the position in the physical par
283 int PositionInParFromPos(int pos);
286 /// for the environments
287 LyXParagraph * DepthHook(int depth);
289 int BeginningOfMainBody();
291 string GetLabestring();
293 /// the next two functions are for the manual labels
294 string GetLabelWidthString();
296 void SetLabelWidthString(string const & s);
298 LyXTextClass::LayoutList::size_type GetLayout();
304 void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
306 void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
308 int GetFirstCounter(int i);
313 void Erase(size_type pos);
314 /** the flag determines wether the layout should be copied
316 void BreakParagraph(size_type pos, int flag);
318 void BreakParagraphConservative(size_type pos);
319 /** Get unistantiated font setting. Returns the difference
320 between the characters font and the layoutfont.
321 This is what is stored in the fonttable
323 LyXFont GetFontSettings(size_type pos);
324 /** Get fully instantiated font. If pos == -1, use the layout
325 font attached to this paragraph.
326 If pos == -2, use the label font of the layout attached here.
327 In all cases, the font is instantiated, i.e. does not have any
328 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
331 LyXFont getFont(size_type pos);
333 char GetChar(size_type pos);
335 void SetFont(size_type pos, LyXFont const & font);
337 string GetWord(size_type &);
338 /// Returns the height of the highest font in range
339 LyXFont::FONT_SIZE HighestFontInRange(size_type startpos, size_type endpos) const;
341 void InsertChar(size_type pos, char c);
343 void InsertInset(size_type pos, Inset * inset);
345 Inset * GetInset(size_type pos);
347 Inset * ReturnNextInsetPointer(size_type & pos);
349 void OpenFootnote(size_type pos);
351 void CloseFootnote(size_type pos);
352 /// important for cut and paste
353 void CopyIntoMinibuffer(size_type pos);
355 void CutIntoMinibuffer(size_type pos);
357 void InsertFromMinibuffer(size_type pos);
359 bool IsHfill(size_type pos) {
360 return IsHfillChar(GetChar(pos));
364 bool IsInset(size_type pos) {
365 return IsInsetChar(GetChar(pos));
369 bool IsFloat(size_type pos) {
370 return IsFloatChar(GetChar(pos));
374 bool IsNewline(size_type pos) {
377 tmp= IsNewlineChar(GetChar(pos));
382 bool IsSeparator(size_type pos) {
383 return IsSeparatorChar(GetChar(pos));
387 bool IsLineSeparator(size_type pos) {
388 return IsLineSeparatorChar(GetChar(pos));
392 bool IsKomma(size_type pos){
393 return IsKommaChar(GetChar(pos));
396 /// Used by the spellchecker
397 bool IsLetter(size_type pos);
400 bool IsWord(size_type pos ) {
401 return IsWordChar( GetChar(pos) ) ;
408 /** the flag determines wether the layout should be copied
410 void BreakParagraph(int pos, int flag);
412 void BreakParagraphConservative(int pos);
413 /** Get unistantiated font setting. Returns the difference
414 between the characters font and the layoutfont.
415 This is what is stored in the fonttable
417 LyXFont GetFontSettings(int pos);
418 /** Get fully instantiated font. If pos == -1, use the layout
419 font attached to this paragraph.
420 If pos == -2, use the label font of the layout attached here.
421 In all cases, the font is instantiated, i.e. does not have any
422 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
425 LyXFont getFont(int pos);
427 char GetChar(int pos);
429 void SetFont(int pos, LyXFont const & font);
431 string GetWord(int &);
432 /// Returns the height of the highest font in range
433 LyXFont::FONT_SIZE HighestFontInRange(int startpos, int endpos) const;
435 void InsertChar(int pos, char c);
437 void InsertInset(int pos, Inset * inset);
439 Inset * GetInset(int pos);
441 Inset * ReturnNextInsetPointer(int & pos);
443 void OpenFootnote(int pos);
445 void CloseFootnote(int pos);
446 /// important for cut and paste
447 void CopyIntoMinibuffer(int pos);
449 void CutIntoMinibuffer(int pos);
451 void InsertFromMinibuffer(int pos);
453 bool IsHfill(int pos) {
454 return IsHfillChar(GetChar(pos));
458 bool IsInset(int pos) {
459 return IsInsetChar(GetChar(pos));
463 bool IsFloat(int pos) {
464 return IsFloatChar(GetChar(pos));
468 bool IsNewline(int pos) {
471 tmp= IsNewlineChar(GetChar(pos));
476 bool IsSeparator(int pos) {
477 return IsSeparatorChar(GetChar(pos));
481 bool IsLineSeparator(int pos) {
482 return IsLineSeparatorChar(GetChar(pos));
486 bool IsKomma(int pos){
487 return IsKommaChar(GetChar(pos));
490 /// Used by the spellchecker
491 bool IsLetter(int pos);
494 bool IsWord( int pos ) {
495 return IsWordChar( GetChar(pos) ) ;
498 /** This one resets all layout and dtp switches but not the font
499 of the single characters
503 /** paste this paragraph with the next one
504 be carefull, this doesent make any check at all
506 void PasteParagraph();
508 /// used to remove the error messages
509 int AutoDeleteInsets();
511 /// returns -1 if inset not found
512 int GetPositionOfInset(Inset * inset);
514 /// ok and now some footnote functions
515 void OpenFootnotes();
518 void CloseFootnotes();
521 LyXParagraph * FirstSelfrowPar();
524 int ClearParagraph(){
526 if (!IsDummy() && !table){
529 || IsLineSeparator(0))){
537 /** A paragraph following a footnote is a "dummy". A paragraph
538 with a footnote in it is stored as three paragraphs:
539 First a paragraph with the text up to the footnote, then
540 one (or more) paragraphs with the footnote, and finally
541 the a paragraph with the text after the footnote. Only the
542 first paragraph keeps information about layoutparameters, */
544 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
545 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
548 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
549 I have to set it on each of it's elements */
551 void SetPExtraType(int type, char const * width, char const * widthp);
553 void UnsetPExtraType();
556 bool RoffContTableRows(FILE * file, size_type i,
559 void DocBookContTableRows(string & file, string & extra, int & desc_on,
561 int current_cell_number, int & column);
564 bool RoffContTableRows(FILE * file, int i, int actcell);
566 void DocBookContTableRows(string & file, string & extra, int & desc_on,
567 int i, int current_cell_number, int & column);
570 bool linuxDocConvertChar(char c, string & sgml_string);
572 void SimpleDocBookOneTablePar(string & file, string & extra,
573 int & desc_on, int depth);
575 /** A font entry covers a range of positions. Notice that the
576 entries in the list are inserted in random order.
577 I don't think it's worth the effort to implement a more effective
578 datastructure, because the number of different fonts in a paragraph
583 /// Start position of paragraph this font attribute covers
585 /// Ending position of paragraph this font attribute covers
588 /// Start position of paragraph this font attribute covers
590 /// Ending position of paragraph this font attribute covers
593 /** Font. Interpretation of the font values:
594 If a value is LyXFont::INHERIT_*, it means that the font
595 attribute is inherited from either the layout of this
596 paragraph or, in the case of nested paragraphs, from the
597 layout in the environment one level up until completely
599 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
600 allowed in these font tables.
604 /// Pointer to next font entry
626 typedef list<FontTable> FontList;
628 typedef list<InsetTable> InsetList;
635 FontTable * fonttable;
637 InsetTable * insettable;
640 LyXParagraph * TeXDeeper(string & file, TexRow & texrow,
641 string & foot, TexRow & foot_texrow,
644 LyXParagraph * TeXFootnote(string & file, TexRow & texrow,
645 string & foot, TexRow & foot_texrow,
648 bool SimpleTeXOnePar(string & file, TexRow & texrow);
650 bool SimpleTeXOneTablePar(string & file, TexRow & texrow);
653 bool TeXContTableRows(string & file, size_type i,
654 int current_cell_number,
655 int & column, TexRow & texrow);
657 void SimpleTeXBlanks(string & file, TexRow & texrow,
659 int & column, LyXFont const & font,
660 LyXLayout const & style);
662 void SimpleTeXSpecialChars(string & file, TexRow & texrow,
663 LyXFont & font, LyXFont & running_font,
664 LyXFont & basefont, bool & open_font,
665 LyXLayout const & style,
667 int & column, char const c);
670 bool TeXContTableRows(string & file, int i, int current_cell_number,
671 int & column, TexRow & texrow);
673 void SimpleTeXBlanks(string & file, TexRow & texrow,
674 int const i, int & column, LyXFont const & font,
675 LyXLayout const & style);
677 void SimpleTeXSpecialChars(string & file, TexRow & texrow,
678 LyXFont & font, LyXFont & running_font,
679 LyXFont & basefont, bool & open_font,
680 LyXLayout const & style,
681 int & i, int & column, char const c);
686 static unsigned int paragraph_id;