2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright (C) 1995 Matthias Ettrich
8 * Copyright (C) 1995-1999 The LyX Team.
10 *======================================================*/
12 #ifndef LYXPARAGRAPH_H
13 #define LYXPARAGRAPH_H
19 #include "definitions.h"
20 #include "insets/lyxinset.h"
22 #include "support/textutils.h"
24 #include "insets/insetbib.h"
32 /// A LyXParagraph holds all text, attributes and insets in a text paragraph
57 ALGORITHM, // Bernhard, 970807
59 WIDE_FIG, // CFO-G, 971106
61 WIDE_TAB // CFO-G, 971106
66 /// this konstruktor inserts the new paragraph in a list
67 LyXParagraph(LyXParagraph *par);
68 /// the destruktors removes the new paragraph from the list
72 void writeFile(FILE*, BufferParams &, char, char);
75 //void writeLaTeX(FILE*, BufferParams &);
78 void validate(LaTeXFeatures&);
85 void SetID(int id_arg){
89 /** allocates more memory for the specified paragraph
90 pos is needed to specify the paragraph correctly. Remember the
93 void Enlarge(int pos, int number);
95 /** make the allocated memory fit to the needed size
96 used to make a paragraph smaller
104 void readSimpleWholeFile(FILE *);
107 LyXParagraph* TeXOnePar(string &file, TexRow &texrow,
108 string &foot, TexRow &foot_texrow,
112 LyXParagraph* TeXEnvironment(string &file, TexRow &texrow,
113 string &foot, TexRow &foot_texrow,
117 LyXParagraph* Clone();
120 bool HasSameLayout(LyXParagraph *par);
123 void MakeSameLayout(LyXParagraph *par);
125 /// Is it the first par with same depth and layout?
126 bool IsFirstInSequence() {
127 LyXParagraph *dhook = DepthHook(GetDepth());
128 return (dhook == this
129 || dhook->GetLayout() != GetLayout()
130 || dhook->GetDepth() != GetDepth());
140 VSpace added_space_top;
143 VSpace added_space_bottom;
150 \item no footnote, closed footnote,
151 \item open footnote, where footnote
152 \item means footnote-environment
155 footnote_flag footnoteflag;
157 /// footnote, margin, fig, tab
158 footnote_kind footnotekind;
160 //@Man: the LyX- DTP-switches
172 bool pagebreak_bottom;
188 void setCounter(int i, int v) { counter[i] = v; }
189 int getCounter(int i) { return counter[i]; }
190 void incCounter(int i) { counter[i]++; }
192 bool start_of_appendix;
203 /* This is for the paragraph extra stuff */
209 string pextra_widthp;
211 int pextra_alignment;
215 bool pextra_start_minipage;
221 string labelwidthstring;
229 LyXParagraph *previous;
231 /* table stuff -- begin*/
234 /* table stuff -- end*/
237 InsetBibKey* bibkey; // ale970302
239 /** these function are able to hide closed footnotes
241 LyXParagraph *Next();
244 LyXParagraph *Previous();
246 /** these function are able to hide open and closed footnotes
248 LyXParagraph *NextAfterFootnote();
250 LyXParagraph *PreviousBeforeFootnote();
252 LyXParagraph *LastPhysicalPar();
254 LyXParagraph *FirstPhysicalPar();
256 /// returns the physical paragraph
257 LyXParagraph *ParFromPos(int pos);
258 /// returns the position in the physical par
259 int PositionInParFromPos(int pos);
261 /// for the environments
262 LyXParagraph* DepthHook(int depth);
264 int BeginningOfMainBody();
266 string GetLabestring();
268 /// the next two functions are for the manual labels
269 string GetLabelWidthString();
271 void SetLabelWidthString(const string &s);
279 void SetLayout(char new_layout);
281 void SetOnlyLayout(char new_layout);
283 int GetFirstCounter(int i);
287 /** This one resets all layout and dtp switches but not the font
288 of the single characters
294 /** the flag determines wether the layout should be copied
296 void BreakParagraph(int pos, int flag);
298 void BreakParagraphConservative(int pos);
300 /** paste this paragraph with the next one
301 be carefull, this doesent make any check at all
303 void PasteParagraph();
305 /** Get unistantiated font setting. Returns the difference
306 between the characters font and the layoutfont.
307 This is what is stored in the fonttable
309 LyXFont GetFontSettings(int pos);
311 /** Get fully instantiated font. If pos == -1, use the layout
312 font attached to this paragraph.
313 If pos == -2, use the label font of the layout attached here.
314 In all cases, the font is instantiated, i.e. does not have any
315 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
318 LyXFont getFont(int pos);
321 char GetChar(int pos);
323 string GetWord(int &);
325 void SetFont(int pos, LyXFont const & font);
326 /// Returns the height of the highest font in range
327 LyXFont::FONT_SIZE HighestFontInRange(int startpos, int endpos) const;
329 void InsertChar(int pos, char c);
331 void InsertInset(int pos, Inset *inset);
333 Inset* GetInset(int pos);
335 /// used to remove the error messages
336 int AutoDeleteInsets();
339 Inset* ReturnNextInsetPointer(int &pos);
341 /// returns -1 if inset not found
342 int GetPositionOfInset(Inset* inset);
344 /// ok and now some footnote functions
345 void OpenFootnotes();
347 void OpenFootnote(int pos);
349 void CloseFootnotes();
351 void CloseFootnote(int pos);
353 /// important for cut and paste
354 void CopyIntoMinibuffer(int pos);
356 void CutIntoMinibuffer(int pos);
358 void InsertFromMinibuffer(int pos);
361 LyXParagraph *FirstSelfrowPar();
364 bool IsHfill(int pos) {
365 return IsHfillChar(GetChar(pos));
369 bool IsInset(int pos) {
370 return IsInsetChar(GetChar(pos));
374 bool IsFloat(int pos) {
375 return IsFloatChar(GetChar(pos));
379 bool IsNewline(int pos) {
382 tmp= IsNewlineChar(GetChar(pos));
387 bool IsSeparator(int pos) {
388 return IsSeparatorChar(GetChar(pos));
392 bool IsLineSeparator(int pos) {
393 return IsLineSeparatorChar(GetChar(pos));
397 bool IsKomma(int pos){
398 return IsKommaChar(GetChar(pos));
401 /// Used by the spellchecker
402 bool IsLetter(int pos);
405 bool IsWord( int pos ) {
406 return IsWordChar( GetChar(pos) ) ;
410 int ClearParagraph(){
412 if (!IsDummy() && !table){
415 || IsLineSeparator(0))){
423 /** A paragraph following a footnote is a "dummy". A paragraph
424 with a footnote in it is stored as three paragraphs:
425 First a paragraph with the text up to the footnote, then
426 one (or more) paragraphs with the footnote, and finally
427 the a paragraph with the text after the footnote. Only the
428 first paragraph keeps information about layoutparameters, */
430 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
431 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
434 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
435 I have to set it on each of it's elements */
437 void SetPExtraType(int type, const char *width, const char *widthp);
439 void UnsetPExtraType();
441 bool RoffContTableRows(FILE *file, int i, int actcell);
443 bool linuxDocConvertChar(char c, string &sgml_string);
445 void SimpleDocBookOneTablePar(string &file, string &extra,
446 int &desc_on, int depth);
448 void DocBookContTableRows(string &file, string &extra, int &desc_on,
449 int i, int current_cell_number, int &column);
451 /** A font entry covers a range of positions. Notice that the
452 entries in the list are inserted in random order.
453 I don't think it's worth the effort to implement a more effective
454 datastructure, because the number of different fonts in a paragraph
458 /// Start position of paragraph this font attribute covers
460 /// Ending position of paragraph this font attribute covers
463 /** Font. Interpretation of the font values:
464 If a value is LyXFont::INHERIT_*, it means that the font
465 attribute is inherited from either the layout of this
466 paragraph or, in the case of nested paragraphs, from the
467 layout in the environment one level up until completely
469 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
470 allowed in these font tables.
473 /// Pointer to next font entry
486 FontTable *fonttable;
488 InsetTable *insettable;
490 LyXParagraph * TeXDeeper(string &file, TexRow &texrow,
491 string &foot, TexRow &foot_texrow,
494 LyXParagraph * TeXFootnote(string &file, TexRow &texrow,
495 string &foot, TexRow &foot_texrow,
498 bool SimpleTeXOnePar(string &file, TexRow &texrow);
500 bool SimpleTeXOneTablePar(string &file, TexRow &texrow);
502 bool TeXContTableRows(string &file, int i, int current_cell_number,
503 int &column, TexRow &texrow);
505 void SimpleTeXBlanks(string &file, TexRow &texrow,
506 int const i, int &column, LyXFont const &font,
507 LyXLayout const * const style);
509 void SimpleTeXSpecialChars(string &file, TexRow &texrow,
510 LyXFont &font, LyXFont &running_font,
511 LyXFont &basefont, bool &open_font,
512 LyXLayout const * const style,
513 int &i, int &column, char const c);
517 static unsigned int paragraph_id;