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
22 #include "lyxfont.h" // Just for LyXFont::FONT_SIZE
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,
128 int startTeXParParams(BufferParams const &, std::ostream &) const;
131 int endTeXParParams(BufferParams const &, std::ostream &) const;
135 bool simpleTeXOnePar(Buffer const *, BufferParams const &,
136 std::ostream &, TexRow & texrow, bool moving_arg);
139 Paragraph * TeXEnvironment(Buffer const *, BufferParams const &,
140 std::ostream &, TexRow & texrow);
142 bool hasSameLayout(Paragraph const * par) const;
145 void makeSameLayout(Paragraph const * par);
147 /// Is it the first par with same depth and layout?
148 bool isFirstInSequence() const;
150 /** Check if the current paragraph is the last paragraph in a
152 int getEndLabel(BufferParams const &) const;
154 Inset * inInset() const;
156 void setInsetOwner(Inset * i);
158 void deleteInsetsLyXText(BufferView *);
160 void resizeInsetsLyXText(BufferView *);
163 lyx::pos_type size() const;
165 void setContentsFromPar(Paragraph * par);
167 void clearContents();
170 lyx::layout_type layout;
173 void setCounter(int i, int v);
175 int getCounter(int i) const;
177 void incCounter(int i);
186 InsetBibKey * bibkey; // ale970302
189 void next(Paragraph *);
190 /** these function are able to hide closed footnotes
194 Paragraph const * next() const;
197 void previous(Paragraph *);
199 Paragraph * previous();
201 Paragraph const * previous() const;
203 /// for the environments
204 Paragraph * depthHook(depth_type depth);
205 /// for the environments
206 Paragraph const * depthHook(depth_type depth) const;
208 Paragraph * outerHook();
210 Paragraph const * outerHook() const;
212 int beginningOfMainBody() const;
214 string const & getLabelstring() const;
216 /// the next two functions are for the manual labels
217 string const getLabelWidthString() const;
219 void setLabelWidthString(string const & s);
221 lyx::layout_type getLayout() const;
223 char getAlign() const;
224 /// The nesting depth of a paragraph
225 depth_type getDepth() const;
226 /// The maximal possible depth of a paragraph after this one
227 depth_type getMaxDepthAfter(Buffer const *) const;
229 void setLayout(lyx::layout_type new_layout);
231 void setOnlyLayout(lyx::layout_type new_layout);
233 int getFirstCounter(int i) const;
235 void erase(lyx::pos_type pos);
236 /** the flag determines wether the layout should be copied
238 void breakParagraph(BufferParams const &, lyx::pos_type pos, int flag);
240 void breakParagraphConservative(BufferParams const &, lyx::pos_type pos);
241 /** Get unistantiated font setting. Returns the difference
242 between the characters font and the layoutfont.
243 This is what is stored in the fonttable
246 getFontSettings(BufferParams const &, lyx::pos_type pos) const;
248 LyXFont const getFirstFontSettings() const;
250 /** Get fully instantiated font. If pos == -1, use the layout
251 font attached to this paragraph.
252 If pos == -2, use the label font of the layout attached here.
253 In all cases, the font is instantiated, i.e. does not have any
254 attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
257 LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const;
258 LyXFont const getLayoutFont(BufferParams const &) const;
259 LyXFont const getLabelFont(BufferParams const &) const;
261 value_type getChar(lyx::pos_type pos) const;
263 value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
264 /// The position must already exist.
265 void setChar(lyx::pos_type pos, value_type c);
267 void setFont(lyx::pos_type pos, LyXFont const & font);
268 /// Returns the height of the highest font in range
269 LyXFont::FONT_SIZE highestFontInRange(lyx::pos_type startpos,
270 lyx::pos_type endpos,
271 LyXFont::FONT_SIZE const def_size) const;
273 void insertChar(lyx::pos_type pos, value_type c);
275 void insertChar(lyx::pos_type pos, value_type c, LyXFont const &);
277 bool checkInsertChar(LyXFont &);
279 void insertInset(lyx::pos_type pos, Inset * inset);
281 void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const &);
283 bool insetAllowed(Inset::Code code);
285 Inset * getInset(lyx::pos_type pos);
287 Inset const * getInset(lyx::pos_type pos) const;
288 /** important for cut and paste
289 Temporary change from BufferParams to Buffer. Will revert when we
290 get rid of the argument to Inset::clone(Buffer const &) */
291 void copyIntoMinibuffer(Buffer const &, lyx::pos_type pos) const;
293 void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
295 bool insertFromMinibuffer(lyx::pos_type pos);
298 bool isHfill(lyx::pos_type pos) const;
300 bool isInset(lyx::pos_type pos) const;
302 bool isNewline(lyx::pos_type pos) const;
304 bool isSeparator(lyx::pos_type pos) const;
306 bool isLineSeparator(lyx::pos_type pos) const;
308 bool isKomma(lyx::pos_type pos) const;
309 /// Used by the spellchecker
310 bool isLetter(lyx::pos_type pos) const;
312 bool isWord(lyx::pos_type pos) const;
314 /** This one resets all layout and dtp switches but not the font
315 of the single characters
319 /** paste this paragraph with the next one
320 be carefull, this doesent make any check at all
322 void pasteParagraph(BufferParams const &);
324 /// returns -1 if inset not found
325 int getPositionOfInset(Inset const * inset) const;
327 /// some good comment here John?
328 Paragraph * getParFromID(int id) const;
331 int stripLeadingSpaces(lyx::textclass_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 sgmlConvertChar(char c, string & sgml_string);
345 bool isFreeSpacing() const;
347 ParagraphParameters & params();
348 ParagraphParameters const & params() const;
358 InsetTable(lyx::pos_type p, Inset * i) : pos(p), inset(i) {}
362 typedef std::vector<InsetTable> InsetList;
367 class inset_iterator {
372 inset_iterator(InsetList::iterator const & iter);
374 inset_iterator & operator++() {
379 Inset * operator*() { return it->inset; }
381 Inset * operator->() { return it->inset; }
384 lyx::pos_type getPos() const { return it->pos; }
386 bool operator==(inset_iterator const & iter) const {
387 return it == iter.it;
390 bool operator!=(inset_iterator const & iter) const {
391 return it != iter.it;
395 InsetList::iterator it;
398 friend class inset_iterator;
401 inset_iterator inset_iterator_begin();
403 inset_iterator inset_iterator_end();
405 inset_iterator InsetIterator(lyx::pos_type pos);
408 /// if anything uses this we don't want it to.
409 Paragraph(Paragraph const &);
413 Paragraph * previous_;
417 friend struct Paragraph::Pimpl;