2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team.
10 * ====================================================== */
21 #include "insets/inset.h" // Just for Inset::Code
23 #include "support/types.h"
25 class ParagraphParameters;
33 // After 1.2.0 is released, during 1.3.0cvs, we enable this. And after
34 // a while we verify that reading of 1.2.x files work perfectly we remove
35 // this code completely. (Lgb)
36 //#define NO_PEXTRA_REALLY 1
38 // Define this if you want to try out the new storage container for
39 // paragraphs. std::container instead of obfuscated homegrown
41 // This is non working and far from finished.
44 /// A Paragraph holds all text, attributes and insets in a text paragraph
47 #ifndef NO_PEXTRA_REALLY
60 enum MINIPAGE_ALIGNMENT {
64 MINIPAGE_ALIGN_MIDDLE,
79 typedef char value_type;
80 /// The same as ParameterStruct::depth_type
81 typedef unsigned int depth_type;
82 /// a position in the paragraph
83 typedef lyx::pos_type pos_type;
85 typedef lyx::layout_type layout_type;
89 /// this constructor inserts the new paragraph in a list
91 Paragraph(Paragraph * par);
93 Paragraph(Paragraph const &, bool same_ids);
94 /// the destructor removes the new paragraph from the list
98 Language const * getParLanguage(BufferParams const &) const;
100 bool isRightToLeftPar(BufferParams const &) const;
102 void changeLanguage(BufferParams const & bparams,
103 Language const * from, Language const * to);
105 bool isMultiLingual(BufferParams const &);
108 string const asString(Buffer const *, bool label);
110 string const asString(Buffer const *, pos_type beg, pos_type end,
114 void writeFile(Buffer const *, std::ostream &, BufferParams const &,
117 void validate(LaTeXFeatures &) const;
127 Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
128 std::ostream &, TexRow & texrow,
131 bool simpleTeXOnePar(Buffer const *, BufferParams const &,
132 std::ostream &, TexRow & texrow, bool moving_arg);
135 Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
136 std::ostream &, TexRow & texrow);
138 bool hasSameLayout(Paragraph const * par) const;
141 void makeSameLayout(Paragraph const * par);
143 /// Is it the first par with same depth and layout?
144 bool isFirstInSequence() const;
146 /** Check if the current paragraph is the last paragraph in a
148 int getEndLabel(BufferParams const &) const;
150 Inset * inInset() const;
152 void setInsetOwner(Inset * i);
154 void deleteInsetsLyXText(BufferView *);
156 void resizeInsetsLyXText(BufferView *);
159 pos_type size() const;
161 void setContentsFromPar(Paragraph * par);
163 void clearContents();
169 void setCounter(int i, int v);
171 int getCounter(int i) const;
173 void incCounter(int i);
182 InsetBibKey * bibkey; // ale970302
185 void next(Paragraph *);
186 /** these function are able to hide closed footnotes
190 Paragraph const * next() const;
193 void previous(Paragraph *);
195 Paragraph * previous();
197 Paragraph const * previous() const;
199 /// for the environments
200 Paragraph * depthHook(depth_type depth);
201 /// for the environments
202 Paragraph const * depthHook(depth_type depth) const;
204 Paragraph * outerHook();
206 Paragraph const * outerHook() const;
208 int beginningOfMainBody() const;
210 string const & getLabelstring() const;
212 /// the next two functions are for the manual labels
213 string const getLabelWidthString() const;
215 void setLabelWidthString(string const & s);
217 layout_type getLayout() const;
219 char getAlign() const;
221 depth_type getDepth() const;
223 void setLayout(layout_type new_layout);
225 void setOnlyLayout(layout_type new_layout);
227 int getFirstCounter(int i) const;
229 void erase(pos_type pos);
230 /** the flag determines wether the layout should be copied
232 void breakParagraph(BufferParams const &, pos_type pos, int flag);
234 void breakParagraphConservative(BufferParams const &, pos_type pos);
235 /** Get unistantiated font setting. Returns the difference
236 between the characters font and the layoutfont.
237 This is what is stored in the fonttable
240 getFontSettings(BufferParams const &, pos_type pos) const;
242 LyXFont const getFirstFontSettings() const;
244 /** Get fully instantiated font. If pos == -1, use the layout
245 font attached to this paragraph.
246 If pos == -2, use the label font of the layout attached here.
247 In all cases, the font is instantiated, i.e. does not have any
248 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
251 LyXFont const getFont(BufferParams const &, pos_type pos) const;
252 LyXFont const getLayoutFont(BufferParams const &) const;
253 LyXFont const getLabelFont(BufferParams const &) const;
255 value_type getChar(pos_type pos) const;
257 value_type getUChar(BufferParams const &, pos_type pos) const;
258 /// The position must already exist.
259 void setChar(pos_type pos, value_type c);
261 void setFont(pos_type pos, LyXFont const & font);
262 /// Returns the height of the highest font in range
263 LyXFont::FONT_SIZE highestFontInRange(pos_type startpos,
265 LyXFont::FONT_SIZE const def_size) const;
267 void insertChar(pos_type pos, value_type c);
269 void insertChar(pos_type pos, value_type c, LyXFont const &);
271 bool checkInsertChar(LyXFont &);
273 void insertInset(pos_type pos, Inset * inset);
275 void insertInset(pos_type pos, Inset * inset, LyXFont const &);
277 bool insetAllowed(Inset::Code code);
279 Inset * getInset(pos_type pos);
281 Inset const * getInset(pos_type pos) const;
282 /** important for cut and paste
283 Temporary change from BufferParams to Buffer. Will revert when we
284 get rid of the argument to Inset::clone(Buffer const &) */
285 void copyIntoMinibuffer(Buffer const &, pos_type pos) const;
287 void cutIntoMinibuffer(BufferParams const &, pos_type pos);
289 bool insertFromMinibuffer(pos_type pos);
292 bool isHfill(pos_type pos) const;
294 bool isInset(pos_type pos) const;
296 bool isNewline(pos_type pos) const;
298 bool isSeparator(pos_type pos) const;
300 bool isLineSeparator(pos_type pos) const;
302 bool isKomma(pos_type pos) const;
303 /// Used by the spellchecker
304 bool isLetter(pos_type pos) const;
306 bool isWord(pos_type pos) const;
308 /** This one resets all layout and dtp switches but not the font
309 of the single characters
313 /** paste this paragraph with the next one
314 be carefull, this doesent make any check at all
316 void pasteParagraph(BufferParams const &);
318 /// used to remove the error messages
319 int autoDeleteInsets();
321 /// returns -1 if inset not found
322 int getPositionOfInset(Inset * inset) const;
324 /// some good comment here John?
325 Paragraph * getParFromID(int id) const;
328 int stripLeadingSpaces(LyXTextClassList::size_type tclass);
330 #ifndef NO_PEXTRA_REALLY
331 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
332 I have to set it on each of it's elements */
334 void setPExtraType(BufferParams const &, int type,
335 string const & width, string const & widthp);
337 void unsetPExtraType(BufferParams const &);
340 bool sgmlConvertChar(char c, string & sgml_string);
342 ParagraphParameters & params();
343 ParagraphParameters const & params() const;
353 InsetTable(pos_type p, Inset * i) : pos(p), inset(i) {}
357 typedef std::vector<InsetTable> InsetList;
362 class inset_iterator {
367 inset_iterator(InsetList::iterator const & iter);
369 inset_iterator & operator++() {
374 Inset * operator*() { return it->inset; }
376 pos_type getPos() const { return it->pos; }
378 bool operator==(inset_iterator const & iter) const {
379 return it == iter.it;
382 bool operator!=(inset_iterator const & iter) const {
383 return it != iter.it;
387 InsetList::iterator it;
390 friend class inset_iterator;
393 inset_iterator inset_iterator_begin();
395 inset_iterator inset_iterator_end();
397 inset_iterator InsetIterator(pos_type pos);
400 /// if anything uses this we don't want it to.
401 Paragraph(Paragraph const &);
405 Paragraph * previous_;
409 friend struct Paragraph::Pimpl;