3 * \file paragraph_pimpl.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * \author André Pönitz
12 * Full author contact details are available in file CREDITS.
15 #ifndef PARAGRAPH_PIMPL_H
16 #define PARAGRAPH_PIMPL_H
18 #include "paragraph.h"
22 #include "ParagraphParameters.h"
24 #include <boost/scoped_ptr.hpp>
32 class Paragraph::Pimpl {
35 Pimpl(Paragraph * owner);
36 /// "Copy constructor"
37 Pimpl(Pimpl const &, Paragraph * owner);
42 /// look up change at given pos
43 Change const lookupChange(pos_type pos) const;
44 /// is there a change within the given range ?
45 bool isChanged(pos_type start, pos_type end) const;
46 /// set change for the entire par
47 void setChange(Change const & change);
48 /// set change at given pos
49 void setChange(pos_type pos, Change const & change);
50 /// accept changes within the given range
51 void acceptChanges(pos_type start, pos_type end);
52 /// reject changes within the given range
53 void rejectChanges(pos_type start, pos_type end);
56 value_type getChar(pos_type pos) const;
58 void insertChar(pos_type pos, value_type c, Change const & change);
60 void insertInset(pos_type pos, InsetBase * inset, Change const & change);
61 /// (logically) erase the char at pos; return true if it was actually erased
62 bool eraseChar(pos_type pos, bool trackChanges);
63 /// (logically) erase the given range; return the number of chars actually erased
64 int eraseChars(pos_type start, pos_type end, bool trackChanges);
66 InsetBase * inset_owner;
68 /** A font entry covers a range of positions. Notice that the
69 entries in the list are inserted in random order.
70 I don't think it's worth the effort to implement a more effective
71 datastructure, because the number of different fonts in a paragraph
73 Nevertheless, I decided to store fontlist using a sorted vector:
74 fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
75 pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
76 and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
77 (font_1 covers the chars 0,...,pos_1) (Dekel)
82 FontTable(pos_type p, LyXFont const & f)
86 pos_type pos() const { return pos_; }
88 void pos(pos_type p) { pos_ = p; }
90 LyXFont const & font() const { return font_; }
92 void font(LyXFont const & f) { font_ = f;}
94 /// End position of paragraph this font attribute covers
96 /** Font. Interpretation of the font values:
97 If a value is LyXFont::INHERIT_*, it means that the font
98 attribute is inherited from either the layout of this
99 paragraph or, in the case of nested paragraphs, from the
100 layout in the environment one level up until completely
102 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
103 allowed in these font tables.
108 friend class matchFT;
112 /// used by lower_bound and upper_bound
113 int operator()(FontTable const & a, FontTable const & b) const {
114 return a.pos() < b.pos();
119 typedef std::vector<FontTable> FontList;
124 void simpleTeXBlanks(odocstream &, TexRow & texrow,
126 unsigned int & column,
127 LyXFont const & font,
128 LyXLayout const & style);
130 void simpleTeXSpecialChars(Buffer const &, BufferParams const &,
131 odocstream &, TexRow & texrow,
132 OutputParams const &,
133 LyXFont & font, LyXFont & running_font,
135 LyXFont const & outerfont,
137 Change::Type & running_change,
138 LyXLayout const & style,
140 unsigned int & column, value_type const c);
143 void validate(LaTeXFeatures & features,
144 LyXLayout const & layout) const;
149 static unsigned int paragraph_id;
151 ParagraphParameters params;
155 pos_type size() const { return owner_->size(); }
156 /// match a string against a particular point in the paragraph
157 bool isTextAt(std::string const & str, pos_type pos) const;
159 /// for recording and looking up changes