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"
19 #include "ParagraphParameters.h"
23 #include <boost/scoped_ptr.hpp>
27 struct Paragraph::Pimpl {
29 typedef std::vector<value_type> TextContainer;
32 Pimpl(Paragraph * owner);
34 Pimpl(Pimpl const &, Paragraph * owner);
36 lyx::pos_type size() const {
46 void setContentsFromPar(Paragraph const & par);
48 void trackChanges(Change::Type type = Change::UNCHANGED);
50 void untrackChanges();
51 /// set all text as new for change mode
53 /// look up change type at given pos
54 Change::Type lookupChange(lyx::pos_type pos) const;
55 /// look up change at given pos
56 Change const lookupChangeFull(lyx::pos_type pos) const;
57 /// is there a change in the given range ?
58 bool isChanged(lyx::pos_type start, lyx::pos_type end) const;
59 /// is there a non-addition in this range ?
60 bool isChangeEdited(lyx::pos_type start, lyx::pos_type end) const;
63 void setChange(lyx::pos_type pos, Change::Type type);
69 void acceptChange(lyx::pos_type start, lyx::pos_type end);
72 void rejectChange(lyx::pos_type start, lyx::pos_type end);
74 /// are we tracking changes ?
75 bool tracking() const {
76 return changes_.get();
80 value_type getChar(lyx::pos_type pos) const;
82 void setChar(lyx::pos_type pos, value_type c);
84 void insertChar(lyx::pos_type pos, value_type c, LyXFont const & font, Change change = Change(Change::INSERTED));
86 void insertInset(lyx::pos_type pos, InsetOld * inset, LyXFont const & font, Change change = Change(Change::INSERTED));
88 void eraseIntern(lyx::pos_type pos);
89 /// erase the given position. Returns true if it was actually erased
90 bool erase(lyx::pos_type pos);
91 /// erase the given range
92 int erase(lyx::pos_type start, lyx::pos_type end);
94 UpdatableInset * inset_owner;
96 /** A font entry covers a range of positions. Notice that the
97 entries in the list are inserted in random order.
98 I don't think it's worth the effort to implement a more effective
99 datastructure, because the number of different fonts in a paragraph
101 Nevertheless, I decided to store fontlist using a sorted vector:
102 fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
103 pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
104 and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
105 (font_1 covers the chars 0,...,pos_1) (Dekel)
109 FontTable(lyx::pos_type p, LyXFont const & f)
112 font_ = container.get(f);
115 lyx::pos_type pos() const { return pos_; }
117 void pos(lyx::pos_type p) { pos_ = p; }
119 LyXFont const & font() const { return *font_; }
121 void font(LyXFont const & f) { font_ = container.get(f);}
123 /// End position of paragraph this font attribute covers
125 /** Font. Interpretation of the font values:
126 If a value is LyXFont::INHERIT_*, it means that the font
127 attribute is inherited from either the layout of this
128 paragraph or, in the case of nested paragraphs, from the
129 layout in the environment one level up until completely
131 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
132 allowed in these font tables.
134 boost::shared_ptr<LyXFont> font_;
136 static ShareContainer<LyXFont> container;
139 friend struct matchFT;
142 /// used by lower_bound and upper_bound
144 int operator()(FontTable const & a, FontTable const & b) const {
145 return a.pos() < b.pos();
150 typedef std::vector<FontTable> FontList;
155 void simpleTeXBlanks(std::ostream &, TexRow & texrow,
156 lyx::pos_type const i,
157 unsigned int & column,
158 LyXFont const & font,
159 LyXLayout const & style);
161 void simpleTeXSpecialChars(Buffer const *, BufferParams const &,
162 std::ostream &, TexRow & texrow,
163 LatexRunParams const &,
164 LyXFont & font, LyXFont & running_font,
166 LyXFont const & outerfont,
168 Change::Type & running_change,
169 LyXLayout const & style,
171 unsigned int & column, value_type const c);
174 void validate(LaTeXFeatures & features,
175 LyXLayout const & layout) const;
180 static unsigned int paragraph_id;
182 ParagraphParameters params;
185 /// match a string against a particular point in the paragraph
186 bool isTextAt(string const & str, lyx::pos_type pos) const;
188 /// for recording and looking up changes in revision tracking mode
189 boost::scoped_ptr<Changes> changes_;