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>
28 struct Paragraph::Pimpl {
30 Pimpl(Paragraph * owner);
32 Pimpl(Pimpl const &, Paragraph * owner);
34 void setContentsFromPar(Paragraph const & par);
36 void trackChanges(Change::Type type = Change::UNCHANGED);
38 void untrackChanges();
39 /// set all text as new for change mode
41 /// look up change type at given pos
42 Change::Type lookupChange(lyx::pos_type pos) const;
43 /// look up change at given pos
44 Change const lookupChangeFull(lyx::pos_type pos) const;
45 /// is there a change in the given range ?
46 bool isChanged(lyx::pos_type start, lyx::pos_type end) const;
47 /// is there a non-addition in this range ?
48 bool isChangeEdited(lyx::pos_type start, lyx::pos_type end) const;
51 void setChange(lyx::pos_type pos, Change::Type type);
57 void acceptChange(lyx::pos_type start, lyx::pos_type end);
60 void rejectChange(lyx::pos_type start, lyx::pos_type end);
62 /// are we tracking changes ?
63 bool tracking() const {
64 return changes_.get();
68 value_type getChar(lyx::pos_type pos) const;
70 void setChar(lyx::pos_type pos, value_type c);
72 void insertChar(lyx::pos_type pos, value_type c, LyXFont const & font, Change change = Change(Change::INSERTED));
74 void insertInset(lyx::pos_type pos, InsetOld * inset, LyXFont const & font, Change change = Change(Change::INSERTED));
76 void eraseIntern(lyx::pos_type pos);
77 /// erase the given position. Returns true if it was actually erased
78 bool erase(lyx::pos_type pos);
79 /// erase the given range
80 int erase(lyx::pos_type start, lyx::pos_type end);
82 UpdatableInset * inset_owner;
84 /** A font entry covers a range of positions. Notice that the
85 entries in the list are inserted in random order.
86 I don't think it's worth the effort to implement a more effective
87 datastructure, because the number of different fonts in a paragraph
89 Nevertheless, I decided to store fontlist using a sorted vector:
90 fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
91 pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
92 and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
93 (font_1 covers the chars 0,...,pos_1) (Dekel)
97 FontTable(lyx::pos_type p, LyXFont const & f)
100 font_ = container.get(f);
103 lyx::pos_type pos() const { return pos_; }
105 void pos(lyx::pos_type p) { pos_ = p; }
107 LyXFont const & font() const { return *font_; }
109 void font(LyXFont const & f) { font_ = container.get(f);}
111 /// End position of paragraph this font attribute covers
113 /** Font. Interpretation of the font values:
114 If a value is LyXFont::INHERIT_*, it means that the font
115 attribute is inherited from either the layout of this
116 paragraph or, in the case of nested paragraphs, from the
117 layout in the environment one level up until completely
119 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
120 allowed in these font tables.
122 boost::shared_ptr<LyXFont> font_;
124 static ShareContainer<LyXFont> container;
127 friend struct matchFT;
130 /// used by lower_bound and upper_bound
132 int operator()(FontTable const & a, FontTable const & b) const {
133 return a.pos() < b.pos();
138 typedef std::vector<FontTable> FontList;
143 void simpleTeXBlanks(std::ostream &, TexRow & texrow,
144 lyx::pos_type const i,
145 unsigned int & column,
146 LyXFont const & font,
147 LyXLayout const & style);
149 void simpleTeXSpecialChars(Buffer const &, BufferParams const &,
150 std::ostream &, TexRow & texrow,
151 LatexRunParams const &,
152 LyXFont & font, LyXFont & running_font,
154 LyXFont const & outerfont,
156 Change::Type & running_change,
157 LyXLayout const & style,
159 unsigned int & column, value_type const c);
162 void validate(LaTeXFeatures & features,
163 LyXLayout const & layout) const;
168 static unsigned int paragraph_id;
170 ParagraphParameters params;
174 lyx::pos_type size() const { return owner_->size(); }
175 /// match a string against a particular point in the paragraph
176 bool isTextAt(string const & str, lyx::pos_type pos) const;
178 /// for recording and looking up changes in revision tracking mode
179 boost::scoped_ptr<Changes> changes_;