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 * ====================================================== */
23 #include "insets/inset.h" // Just for Inset::Code
26 class ParagraphParameters;
34 // After 1.2.0 is released, during 1.3.0cvs, we enable this. And after
35 // a while we verify that reading of 1.2.x files work perfectly we remove
36 // this code completely. (Lgb)
37 //#define NO_PEXTRA_REALLY 1
39 // Define this if you want to try out the new storage container for
40 // paragraphs. std::container instead of obfuscated homegrown
42 // This is non working and far from finished.
45 /// A Paragraph holds all text, attributes and insets in a text paragraph
48 #ifndef NO_PEXTRA_REALLY
61 enum MINIPAGE_ALIGNMENT {
65 MINIPAGE_ALIGN_MIDDLE,
80 typedef char value_type;
81 /// The same as ParameterStruct::depth_type
82 typedef unsigned int depth_type;
84 typedef std::vector<value_type> TextContainer;
86 /* This should be TextContainer::size_type, but we need
87 signed values for now.
89 typedef TextContainer::difference_type size_type;
93 /// this constructor inserts the new paragraph in a list
95 Paragraph(Paragraph * par);
97 Paragraph(Paragraph const &, bool same_ids = false);
98 /// the destructor removes the new paragraph from the list
102 Language const * getParLanguage(BufferParams const &) const;
104 bool isRightToLeftPar(BufferParams const &) const;
106 void changeLanguage(BufferParams const & bparams,
107 Language const * from, Language const * to);
109 bool isMultiLingual(BufferParams const &);
112 string const asString(Buffer const *, bool label);
114 string const asString(Buffer const *, size_type beg, size_type end);
117 void writeFile(Buffer const *, std::ostream &, BufferParams const &,
120 void validate(LaTeXFeatures &) const;
130 Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
131 std::ostream &, TexRow & texrow,
134 bool simpleTeXOnePar(Buffer const *, BufferParams const &,
135 std::ostream &, TexRow & texrow, bool moving_arg);
138 Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
139 std::ostream &, TexRow & texrow);
141 bool hasSameLayout(Paragraph const * par) const;
144 void makeSameLayout(Paragraph const * par);
146 /// Is it the first par with same depth and layout?
147 bool isFirstInSequence() const;
149 /** Check if the current paragraph is the last paragraph in a
151 int getEndLabel(BufferParams const &) const;
153 Inset * inInset() const;
155 void setInsetOwner(Inset * i);
157 void deleteInsetsLyXText(BufferView *);
159 void resizeInsetsLyXText(BufferView *);
162 size_type size() const;
164 void setContentsFromPar(Paragraph * par);
166 void clearContents();
169 LyXTextClass::LayoutList::size_type 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 LyXTextClass::LayoutList::size_type getLayout() const;
222 char getAlign() const;
224 depth_type getDepth() const;
226 void setLayout(LyXTextClass::LayoutList::size_type new_layout);
228 void setOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
230 int getFirstCounter(int i) const;
232 void erase(size_type pos);
233 /** the flag determines wether the layout should be copied
235 void breakParagraph(BufferParams const &, size_type pos, int flag);
237 void breakParagraphConservative(BufferParams const &, size_type pos);
238 /** Get unistantiated font setting. Returns the difference
239 between the characters font and the layoutfont.
240 This is what is stored in the fonttable
243 getFontSettings(BufferParams const &, size_type pos) const;
245 LyXFont const getFirstFontSettings() const;
247 /** Get fully instantiated font. If pos == -1, use the layout
248 font attached to this paragraph.
249 If pos == -2, use the label font of the layout attached here.
250 In all cases, the font is instantiated, i.e. does not have any
251 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
254 LyXFont const getFont(BufferParams const &, size_type pos) const;
255 LyXFont const getLayoutFont(BufferParams const &) const;
256 LyXFont const getLabelFont(BufferParams const &) const;
258 value_type getChar(size_type pos) const;
260 value_type getUChar(BufferParams const &, size_type pos) const;
261 /// The position must already exist.
262 void setChar(size_type pos, value_type c);
264 void setFont(size_type pos, LyXFont const & font);
265 /// Returns the height of the highest font in range
266 LyXFont::FONT_SIZE highestFontInRange(size_type startpos,
268 LyXFont::FONT_SIZE const def_size) const;
270 void insertChar(size_type pos, value_type c);
272 void insertChar(size_type pos, value_type c, LyXFont const &);
274 bool checkInsertChar(LyXFont &);
276 void insertInset(size_type pos, Inset * inset);
278 void insertInset(size_type pos, Inset * inset, LyXFont const &);
280 bool insetAllowed(Inset::Code code);
282 Inset * getInset(size_type pos);
284 Inset const * getInset(size_type pos) const;
285 /** important for cut and paste
286 Temporary change from BufferParams to Buffer. Will revert when we
287 get rid of the argument to Inset::clone(Buffer const &) */
288 void copyIntoMinibuffer(Buffer const &, size_type pos) const;
290 void cutIntoMinibuffer(BufferParams const &, size_type pos);
292 bool insertFromMinibuffer(size_type pos);
295 bool isHfill(size_type pos) const;
297 bool isInset(size_type pos) const;
299 bool isNewline(size_type pos) const;
301 bool isSeparator(size_type pos) const;
303 bool isLineSeparator(size_type pos) const;
305 bool isKomma(size_type pos) const;
306 /// Used by the spellchecker
307 bool isLetter(size_type pos) const;
309 bool isWord(size_type pos) const;
311 /** This one resets all layout and dtp switches but not the font
312 of the single characters
316 /** paste this paragraph with the next one
317 be carefull, this doesent make any check at all
319 void pasteParagraph(BufferParams const &);
321 /// used to remove the error messages
322 int autoDeleteInsets();
324 /// returns -1 if inset not found
325 int getPositionOfInset(Inset * inset) const;
327 /// some good comment here John?
328 Paragraph * getParFromID(int id) const;
331 int stripLeadingSpaces(LyXTextClassList::size_type tclass);
333 #ifndef NO_PEXTRA_REALLY
334 /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
335 I have to set it on each of it's elements */
337 void setPExtraType(BufferParams const &, int type,
338 string const & width, string const & widthp);
340 void unsetPExtraType(BufferParams const &);
343 bool linuxDocConvertChar(char c, string & sgml_string);
345 ParagraphParameters & params();
346 ParagraphParameters const & params() const;
356 InsetTable(size_type p, Inset * i) : pos(p), inset(i) {}
360 typedef std::vector<InsetTable> InsetList;
365 class inset_iterator {
370 inset_iterator(InsetList::iterator const & iter);
372 inset_iterator & operator++() {
377 Inset * operator*() { return it->inset; }
379 size_type getPos() const {return it->pos; }
381 bool operator==(inset_iterator const & iter) const {
382 return it == iter.it;
385 bool operator!=(inset_iterator const & iter) const {
386 return it != iter.it;
390 InsetList::iterator it;
393 friend class inset_iterator;
396 inset_iterator inset_iterator_begin();
398 inset_iterator inset_iterator_end();
400 inset_iterator InsetIterator(size_type pos);
406 Paragraph * previous_;
410 friend struct Paragraph::Pimpl;