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;
85 /// this constructor inserts the new paragraph in a list
87 Paragraph(Paragraph * par);
89 Paragraph(Paragraph const &, bool same_ids);
90 /// the destructor removes the new paragraph from the list
94 Language const * getParLanguage(BufferParams const &) const;
96 bool isRightToLeftPar(BufferParams const &) const;
98 void changeLanguage(BufferParams const & bparams,
99 Language const * from, Language const * to);
101 bool isMultiLingual(BufferParams const &);
104 string const asString(Buffer const *, bool label);
106 string const asString(Buffer const *, lyx::pos_type beg, lyx::pos_type end,
110 void writeFile(Buffer const *, std::ostream &, BufferParams const &,
113 void validate(LaTeXFeatures &) const;
123 Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
124 std::ostream &, TexRow & texrow,
127 bool simpleTeXOnePar(Buffer const *, BufferParams const &,
128 std::ostream &, TexRow & texrow, bool moving_arg);
131 Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
132 std::ostream &, TexRow & texrow);
134 bool hasSameLayout(Paragraph const * par) const;
137 void makeSameLayout(Paragraph const * par);
139 /// Is it the first par with same depth and layout?
140 bool isFirstInSequence() const;
142 /** Check if the current paragraph is the last paragraph in a
144 int getEndLabel(BufferParams const &) const;
146 Inset * inInset() const;
148 void setInsetOwner(Inset * i);
150 void deleteInsetsLyXText(BufferView *);
152 void resizeInsetsLyXText(BufferView *);
155 lyx::pos_type size() const;
157 void setContentsFromPar(Paragraph * par);
159 void clearContents();
162 lyx::layout_type layout;
165 void setCounter(int i, int v);
167 int getCounter(int i) const;
169 void incCounter(int i);
178 InsetBibKey * bibkey; // ale970302
181 void next(Paragraph *);
182 /** these function are able to hide closed footnotes
186 Paragraph const * next() const;
189 void previous(Paragraph *);
191 Paragraph * previous();
193 Paragraph const * previous() const;
195 /// for the environments
196 Paragraph * depthHook(depth_type depth);
197 /// for the environments
198 Paragraph const * depthHook(depth_type depth) const;
200 Paragraph * outerHook();
202 Paragraph const * outerHook() const;
204 int beginningOfMainBody() const;
206 string const & getLabelstring() const;
208 /// the next two functions are for the manual labels
209 string const getLabelWidthString() const;
211 void setLabelWidthString(string const & s);
213 lyx::layout_type getLayout() const;
215 char getAlign() const;
217 depth_type getDepth() const;
219 void setLayout(lyx::layout_type new_layout);
221 void setOnlyLayout(lyx::layout_type new_layout);
223 int getFirstCounter(int i) const;
225 void erase(lyx::pos_type pos);
226 /** the flag determines wether the layout should be copied
228 void breakParagraph(BufferParams const &, lyx::pos_type pos, int flag);
230 void breakParagraphConservative(BufferParams const &, lyx::pos_type pos);
231 /** Get unistantiated font setting. Returns the difference
232 between the characters font and the layoutfont.
233 This is what is stored in the fonttable
236 getFontSettings(BufferParams const &, lyx::pos_type pos) const;
238 LyXFont const getFirstFontSettings() const;
240 /** Get fully instantiated font. If pos == -1, use the layout
241 font attached to this paragraph.
242 If pos == -2, use the label font of the layout attached here.
243 In all cases, the font is instantiated, i.e. does not have any
244 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
247 LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const;
248 LyXFont const getLayoutFont(BufferParams const &) const;
249 LyXFont const getLabelFont(BufferParams const &) const;
251 value_type getChar(lyx::pos_type pos) const;
253 value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
254 /// The position must already exist.
255 void setChar(lyx::pos_type pos, value_type c);
257 void setFont(lyx::pos_type pos, LyXFont const & font);
258 /// Returns the height of the highest font in range
259 LyXFont::FONT_SIZE highestFontInRange(lyx::pos_type startpos,
260 lyx::pos_type endpos,
261 LyXFont::FONT_SIZE const def_size) const;
263 void insertChar(lyx::pos_type pos, value_type c);
265 void insertChar(lyx::pos_type pos, value_type c, LyXFont const &);
267 bool checkInsertChar(LyXFont &);
269 void insertInset(lyx::pos_type pos, Inset * inset);
271 void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &);
273 bool insetAllowed(Inset::Code code);
275 Inset * getInset(lyx::pos_type pos);
277 Inset const * getInset(lyx::pos_type pos) const;
278 /** important for cut and paste
279 Temporary change from BufferParams to Buffer. Will revert when we
280 get rid of the argument to Inset::clone(Buffer const &) */
281 void copyIntoMinibuffer(Buffer const &, lyx::pos_type pos) const;
283 void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
285 bool insertFromMinibuffer(lyx::pos_type pos);
288 bool isHfill(lyx::pos_type pos) const;
290 bool isInset(lyx::pos_type pos) const;
292 bool isNewline(lyx::pos_type pos) const;
294 bool isSeparator(lyx::pos_type pos) const;
296 bool isLineSeparator(lyx::pos_type pos) const;
298 bool isKomma(lyx::pos_type pos) const;
299 /// Used by the spellchecker
300 bool isLetter(lyx::pos_type pos) const;
302 bool isWord(lyx::pos_type pos) const;
304 /** This one resets all layout and dtp switches but not the font
305 of the single characters
309 /** paste this paragraph with the next one
310 be carefull, this doesent make any check at all
312 void pasteParagraph(BufferParams const &);
314 /// used to remove the error messages
315 int autoDeleteInsets();
317 /// returns -1 if inset not found
318 int getPositionOfInset(Inset * inset) const;
320 /// some good comment here John?
321 Paragraph * getParFromID(int id) const;
324 int stripLeadingSpaces(LyXTextClassList::size_type tclass);
326 #ifndef NO_PEXTRA_REALLY
327 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
328 I have to set it on each of it's elements */
330 void setPExtraType(BufferParams const &, int type,
331 string const & width, string const & widthp);
333 void unsetPExtraType(BufferParams const &);
336 bool sgmlConvertChar(char c, string & sgml_string);
338 ParagraphParameters & params();
339 ParagraphParameters const & params() const;
349 InsetTable(lyx::pos_type p, Inset * i) : pos(p), inset(i) {}
353 typedef std::vector<InsetTable> InsetList;
358 class inset_iterator {
363 inset_iterator(InsetList::iterator const & iter);
365 inset_iterator & operator++() {
370 Inset * operator*() { return it->inset; }
372 lyx::pos_type getPos() const { return it->pos; }
374 bool operator==(inset_iterator const & iter) const {
375 return it == iter.it;
378 bool operator!=(inset_iterator const & iter) const {
379 return it != iter.it;
383 InsetList::iterator it;
386 friend class inset_iterator;
389 inset_iterator inset_iterator_begin();
391 inset_iterator inset_iterator_end();
393 inset_iterator InsetIterator(lyx::pos_type pos);
396 /// if anything uses this we don't want it to.
397 Paragraph(Paragraph const &);
401 Paragraph * previous_;
405 friend struct Paragraph::Pimpl;