2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright (C) 1995 Matthias Ettrich
8 * Copyright (C) 1995-1998 The LyX Team.
10 *======================================================*/
11 #ifndef _LYXPARAGRAPH_H
12 #define _LYXPARAGRAPH_H
18 #include "definitions.h"
19 #include "insets/lyxinset.h"
21 #include "textutils.h"
23 #include "insets/insetbib.h"
31 /// A LyXParagraph holds all text, attributes and insets in a text paragraph
56 ALGORITHM, // Bernhard, 970807
58 WIDE_FIG, // CFO-G, 971106
60 WIDE_TAB // CFO-G, 971106
65 /// this konstruktor inserts the new paragraph in a list
66 LyXParagraph(LyXParagraph *par);
67 /// the destruktors removes the new paragraph from the list
71 void writeFile(FILE*, BufferParams &, char, char);
74 //void writeLaTeX(FILE*, BufferParams &);
77 void validate(LaTeXFeatures&);
84 void SetID(int id_arg){
88 /** allocates more memory for the specified paragraph
89 pos is needed to specify the paragraph correctly. Remember the
92 void Enlarge(int pos, int number);
94 /** make the allocated memory fit to the needed size
95 used to make a paragraph smaller
103 void readSimpleWholeFile(FILE *);
106 LyXParagraph* TeXOnePar(LString &file, TexRow &texrow,
107 LString &foot, TexRow &foot_texrow,
111 LyXParagraph* TeXEnvironment(LString &file, TexRow &texrow,
112 LString &foot, TexRow &foot_texrow,
116 LyXParagraph* Clone();
119 bool HasSameLayout(LyXParagraph *par);
122 void MakeSameLayout(LyXParagraph *par);
124 /// Is it the first par with same depth and layout?
125 bool IsFirstInSequence() {
126 LyXParagraph *dhook = DepthHook(GetDepth());
127 return (dhook == this
128 || dhook->GetLayout() != GetLayout()
129 || dhook->GetDepth() != GetDepth());
139 VSpace added_space_top;
142 VSpace added_space_bottom;
149 \item no footnote, closed footnote,
150 \item open footnote, where footnote
151 \item means footnote-environment
154 footnote_flag footnoteflag;
156 /// footnote, margin, fig, tab
157 footnote_kind footnotekind;
159 //@Man: the LyX- DTP-switches
171 bool pagebreak_bottom;
187 void setCounter(int i, int v) { counter[i] = v; }
188 int getCounter(int i) { return counter[i]; }
189 void incCounter(int i) { counter[i]++; }
191 bool start_of_appendix;
202 /* This is for the paragraph extra stuff */
206 LString pextra_width;
208 LString pextra_widthp;
210 int pextra_alignment;
214 bool pextra_start_minipage;
220 LString labelwidthstring;
228 LyXParagraph *previous;
230 /* table stuff -- begin*/
233 /* table stuff -- end*/
236 InsetBibKey* bibkey; // ale970302
238 /** these function are able to hide closed footnotes
240 LyXParagraph *Next();
243 LyXParagraph *Previous();
245 /** these function are able to hide open and closed footnotes
247 LyXParagraph *NextAfterFootnote();
249 LyXParagraph *PreviousBeforeFootnote();
251 LyXParagraph *LastPhysicalPar();
253 LyXParagraph *FirstPhysicalPar();
255 /// returns the physical paragraph
256 LyXParagraph *ParFromPos(int pos);
257 /// returns the position in the physical par
258 int PositionInParFromPos(int pos);
260 /// for the environments
261 LyXParagraph* DepthHook(int depth);
263 int BeginningOfMainBody();
265 LString GetLabelString();
267 /// the next two functions are for the manual labels
268 LString GetLabelWidthString();
270 void SetLabelWidthString(const LString &s);
278 void SetLayout(char new_layout);
280 void SetOnlyLayout(char new_layout);
282 int GetFirstCounter(int i);
286 /** This one resets all layout and dtp switches but not the font
287 of the single characters
293 /** the flag determines wether the layout should be copied
295 void BreakParagraph(int pos, int flag);
297 void BreakParagraphConservative(int pos);
299 /** paste this paragraph with the next one
300 be carefull, this doesent make any check at all
302 void PasteParagraph();
304 /** Get unistantiated font setting. Returns the difference
305 between the characters font and the layoutfont.
306 This is what is stored in the fonttable
308 LyXFont GetFontSettings(int pos);
310 /** Get fully instantiated font. If pos == -1, use the layout
311 font attached to this paragraph.
312 If pos == -2, use the label font of the layout attached here.
313 In all cases, the font is instantiated, i.e. does not have any
314 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
317 LyXFont getFont(int pos);
320 char GetChar(int pos);
322 LString GetWord(int &);
324 void SetFont(int pos, LyXFont const & font);
325 /// Returns the height of the highest font in range
326 LyXFont::FONT_SIZE HighestFontInRange(int startpos, int endpos) const;
328 void InsertChar(int pos, char c);
330 void InsertInset(int pos, Inset *inset);
332 Inset* GetInset(int pos);
334 /// used to remove the error messages
335 int AutoDeleteInsets();
338 Inset* ReturnNextInsetPointer(int &pos);
340 /// returns -1 if inset not found
341 int GetPositionOfInset(Inset* inset);
343 /// ok and now some footnote functions
344 void OpenFootnotes();
346 void OpenFootnote(int pos);
348 void CloseFootnotes();
350 void CloseFootnote(int pos);
352 /// important for cut and paste
353 void CopyIntoMinibuffer(int pos);
355 void CutIntoMinibuffer(int pos);
357 void InsertFromMinibuffer(int pos);
360 LyXParagraph *FirstSelfrowPar();
363 bool IsHfill(int pos) {
364 return IsHfillChar(GetChar(pos));
368 bool IsInset(int pos) {
369 return IsInsetChar(GetChar(pos));
373 bool IsFloat(int pos) {
374 return IsFloatChar(GetChar(pos));
378 bool IsNewline(int pos) {
381 tmp= IsNewlineChar(GetChar(pos));
386 bool IsSeparator(int pos) {
387 return IsSeparatorChar(GetChar(pos));
391 bool IsLineSeparator(int pos) {
392 return IsLineSeparatorChar(GetChar(pos));
396 bool IsKomma(int pos){
397 return IsKommaChar(GetChar(pos));
400 /// Used by the spellchecker
401 bool IsLetter(int pos);
404 bool IsWord( int pos ) {
405 return IsWordChar( GetChar(pos) ) ;
409 int ClearParagraph(){
411 if (!IsDummy() && !table){
414 || IsLineSeparator(0))){
422 /** A paragraph following a footnote is a "dummy". A paragraph
423 with a footnote in it is stored as three paragraphs:
424 First a paragraph with the text up to the footnote, then
425 one (or more) paragraphs with the footnote, and finally
426 the a paragraph with the text after the footnote. Only the
427 first paragraph keeps information about layoutparameters, */
429 return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
430 && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
433 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
434 I have to set it on each of it's elements */
436 void SetPExtraType(int type, const char *width, const char *widthp);
438 void UnsetPExtraType();
440 bool RoffContTableRows(FILE *file, int i, int actcell);
442 bool linuxDocConvertChar(char c, LString &sgml_string);
444 void SimpleDocBookOneTablePar(LString &file, LString &extra,
445 int &desc_on, int depth);
447 void DocBookContTableRows(LString &file, LString &extra, int &desc_on,
448 int i, int current_cell_number, int &column);
450 /** A font entry covers a range of positions. Notice that the
451 entries in the list are inserted in random order.
452 I don't think it's worth the effort to implement a more effective
453 datastructure, because the number of different fonts in a paragraph
457 /// Start position of paragraph this font attribute covers
459 /// Ending position of paragraph this font attribute covers
462 /** Font. Interpretation of the font values:
463 If a value is LyXFont::INHERIT_*, it means that the font
464 attribute is inherited from either the layout of this
465 paragraph or, in the case of nested paragraphs, from the
466 layout in the environment one level up until completely
468 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
469 allowed in these font tables.
472 /// Pointer to next font entry
485 FontTable *fonttable;
487 InsetTable *insettable;
489 LyXParagraph * TeXDeeper(LString &file, TexRow &texrow,
490 LString &foot, TexRow &foot_texrow,
493 LyXParagraph * TeXFootnote(LString &file, TexRow &texrow,
494 LString &foot, TexRow &foot_texrow,
497 bool SimpleTeXOnePar(LString &file, TexRow &texrow);
499 bool SimpleTeXOneTablePar(LString &file, TexRow &texrow);
501 bool TeXContTableRows(LString &file, int i, int current_cell_number,
502 int &column, TexRow &texrow);
504 void SimpleTeXBlanks(LString &file, TexRow &texrow,
505 int const i, int &column, LyXFont const &font,
506 LyXLayout const * const style);
508 void SimpleTeXSpecialChars(LString &file, TexRow &texrow,
509 LyXFont &font, LyXFont &running_font,
510 LyXFont &basefont, bool &open_font,
511 LyXLayout const * const style,
512 int &i, int &column, char const c);
516 static unsigned int paragraph_id;