4 * Copyright 1995 Matthias Ettrich
5 * Copyright 2002 the LyX Team
6 * Read the file COPYING
18 #include "insets/inset.h" // Just for Inset::Code
19 #include "lyxfont.h" // Just for LyXFont::FONT_SIZE
20 #include "support/types.h"
22 class ParagraphParameters;
30 // After 1.2.0 is released, during 1.3.0cvs, we enable this. And after
31 // a while we verify that reading of 1.2.x files work perfectly we remove
32 // this code completely. (Lgb)
33 #define NO_PEXTRA_REALLY 1
35 // Define this if you want to try out the new storage container for
36 // paragraphs. std::container instead of obfuscated homegrown
38 // This is non working and far from finished.
41 /// A Paragraph holds all text, attributes and insets in a text paragraph
44 #ifndef NO_PEXTRA_REALLY
57 enum MINIPAGE_ALIGNMENT {
61 MINIPAGE_ALIGN_MIDDLE,
76 typedef char value_type;
77 /// The same as ParameterStruct::depth_type
78 typedef unsigned int depth_type;
82 /// this constructor inserts the new paragraph in a list
84 Paragraph(Paragraph * par);
86 Paragraph(Paragraph const &, bool same_ids);
87 /// the destructor removes the new paragraph from the list
91 Language const * getParLanguage(BufferParams const &) const;
93 bool isRightToLeftPar(BufferParams const &) const;
95 void changeLanguage(BufferParams const & bparams,
96 Language const * from, Language const * to);
98 bool isMultiLingual(BufferParams const &);
101 string const asString(Buffer const *, bool label);
103 string const asString(Buffer const *, lyx::pos_type beg, lyx::pos_type end,
107 void writeFile(Buffer const *, std::ostream &, BufferParams const &,
110 void validate(LaTeXFeatures &) const;
120 Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
121 std::ostream &, TexRow & texrow,
125 int startTeXParParams(BufferParams const &, std::ostream &) const;
128 int endTeXParParams(BufferParams const &, std::ostream &) const;
132 bool simpleTeXOnePar(Buffer const *, BufferParams const &,
133 std::ostream &, TexRow & texrow, bool moving_arg);
136 Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
137 std::ostream &, TexRow & texrow);
139 bool hasSameLayout(Paragraph const * par) const;
142 void makeSameLayout(Paragraph const * par);
144 /// Is it the first par with same depth and layout?
145 bool isFirstInSequence() const;
147 /** Check if the current paragraph is the last paragraph in a
149 int getEndLabel(BufferParams const &) const;
151 Inset * inInset() const;
153 void setInsetOwner(Inset * i);
155 void deleteInsetsLyXText(BufferView *);
157 void resizeInsetsLyXText(BufferView *);
160 lyx::pos_type size() const;
162 void setContentsFromPar(Paragraph * par);
164 void clearContents();
167 string const & layout() const;
169 void layout(string const & new_layout);
172 void setCounter(int i, int v);
174 int getCounter(int i) const;
176 void incCounter(int i);
185 InsetBibKey * bibkey; // ale970302
188 void next(Paragraph *);
189 /** these function are able to hide closed footnotes
193 Paragraph const * next() const;
196 void previous(Paragraph *);
198 Paragraph * previous();
200 Paragraph const * previous() const;
202 /// for the environments
203 Paragraph * depthHook(depth_type depth);
204 /// for the environments
205 Paragraph const * depthHook(depth_type depth) const;
207 Paragraph * outerHook();
209 Paragraph const * outerHook() const;
211 int beginningOfMainBody() const;
213 string const & getLabelstring() const;
215 /// the next two functions are for the manual labels
216 string const getLabelWidthString() const;
218 void setLabelWidthString(string const & s);
220 char getAlign() const;
221 /// The nesting depth of a paragraph
222 depth_type getDepth() const;
223 /// The maximal possible depth of a paragraph after this one
224 depth_type getMaxDepthAfter(Buffer const *) const;
226 void applyLayout(string const & new_layout);
228 int getFirstCounter(int i) const;
230 void erase(lyx::pos_type pos);
231 /** the flag determines wether the layout should be copied
233 void breakParagraph(BufferParams const &, lyx::pos_type pos, int flag);
235 void breakParagraphConservative(BufferParams const &, lyx::pos_type pos);
236 /** Get unistantiated font setting. Returns the difference
237 between the characters font and the layoutfont.
238 This is what is stored in the fonttable
241 getFontSettings(BufferParams const &, lyx::pos_type pos) const;
243 LyXFont const getFirstFontSettings() const;
245 /** Get fully instantiated font. If pos == -1, use the layout
246 font attached to this paragraph.
247 If pos == -2, use the label font of the layout attached here.
248 In all cases, the font is instantiated, i.e. does not have any
249 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
252 LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const;
253 LyXFont const getLayoutFont(BufferParams const &) const;
254 LyXFont const getLabelFont(BufferParams const &) const;
256 value_type getChar(lyx::pos_type pos) const;
258 value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
259 /// The position must already exist.
260 void setChar(lyx::pos_type pos, value_type c);
261 /// pos <= size() (there is a dummy font change at the end of each par)
262 void setFont(lyx::pos_type pos, LyXFont const & font);
263 /// Returns the height of the highest font in range
264 LyXFont::FONT_SIZE highestFontInRange(lyx::pos_type startpos,
265 lyx::pos_type endpos,
266 LyXFont::FONT_SIZE const def_size) const;
268 void insertChar(lyx::pos_type pos, value_type c);
270 void insertChar(lyx::pos_type pos, value_type c, LyXFont const &);
272 bool checkInsertChar(LyXFont &);
274 void insertInset(lyx::pos_type pos, Inset * inset);
276 void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &);
278 bool insetAllowed(Inset::Code code);
280 Inset * getInset(lyx::pos_type pos);
282 Inset const * getInset(lyx::pos_type pos) const;
283 /** important for cut and paste
284 Temporary change from BufferParams to Buffer. Will revert when we
285 get rid of the argument to Inset::clone(Buffer const &) */
286 void copyIntoMinibuffer(Buffer const &, lyx::pos_type pos) const;
288 void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
290 bool insertFromMinibuffer(lyx::pos_type pos);
293 bool isHfill(lyx::pos_type pos) const;
295 bool isInset(lyx::pos_type pos) const;
297 bool isNewline(lyx::pos_type pos) const;
299 bool isSeparator(lyx::pos_type pos) const;
301 bool isLineSeparator(lyx::pos_type pos) const;
303 bool isKomma(lyx::pos_type pos) const;
304 /// Used by the spellchecker
305 bool isLetter(lyx::pos_type pos) const;
307 bool isWord(lyx::pos_type pos) const;
309 /** paste this paragraph with the next one
310 be carefull, this doesent make any check at all
312 void pasteParagraph(BufferParams const &);
314 /// returns -1 if inset not found
315 int getPositionOfInset(Inset const * inset) const;
317 /// some good comment here John?
318 Paragraph * getParFromID(int id) const;
321 int stripLeadingSpaces(lyx::textclass_type tclass);
323 #ifndef NO_PEXTRA_REALLY
324 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
325 I have to set it on each of it's elements */
327 void setPExtraType(BufferParams const &, int type,
328 string const & width, string const & widthp);
330 void unsetPExtraType(BufferParams const &);
333 bool sgmlConvertChar(char c, string & sgml_string);
335 bool isFreeSpacing() const;
337 ParagraphParameters & params();
338 ParagraphParameters const & params() const;
343 /** Both these definitions must be made public to keep Compaq cxx 6.5
353 InsetTable(lyx::pos_type p, Inset * i) : pos(p), inset(i) {}
357 typedef std::vector<InsetTable> InsetList;
363 class inset_iterator {
368 inset_iterator(InsetList::iterator const & iter);
370 inset_iterator & operator++() {
375 Inset * operator*() { return it->inset; }
377 Inset * operator->() { return it->inset; }
380 lyx::pos_type getPos() const { return it->pos; }
382 bool operator==(inset_iterator const & iter) const {
383 return it == iter.it;
386 bool operator!=(inset_iterator const & iter) const {
387 return it != iter.it;
391 InsetList::iterator it;
394 friend class inset_iterator;
397 inset_iterator inset_iterator_begin();
399 inset_iterator inset_iterator_end();
400 /// returns inset iterator of the first inset at or after pos.
401 inset_iterator InsetIterator(lyx::pos_type pos);
404 /// if anything uses this we don't want it to.
405 Paragraph(Paragraph const &);
409 Paragraph * previous_;
413 friend struct Paragraph::Pimpl;