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);
31 /// "Copy constructor"
32 Pimpl(Pimpl const &, Paragraph * owner);
34 void setContentsFromPar(Paragraph const & par);
40 void trackChanges(Change::Type type = Change::UNCHANGED);
42 void untrackChanges();
43 /// set all text as new for change mode
45 /// look up change type at given pos
46 Change::Type lookupChange(lyx::pos_type pos) const;
47 /// look up change at given pos
48 Change const lookupChangeFull(lyx::pos_type pos) const;
49 /// is there a change in the given range ?
50 bool isChanged(lyx::pos_type start, lyx::pos_type end) const;
51 /// is there a non-addition in this range ?
52 bool isChangeEdited(lyx::pos_type start, lyx::pos_type end) const;
54 void setChange(lyx::pos_type pos, Change::Type type);
58 void acceptChange(lyx::pos_type start, lyx::pos_type end);
60 void rejectChange(lyx::pos_type start, lyx::pos_type end);
61 /// are we tracking changes ?
62 bool tracking() const { return changes_.get(); }
65 value_type getChar(lyx::pos_type pos) const;
67 void setChar(lyx::pos_type pos, value_type c);
69 void insertChar(lyx::pos_type pos, value_type c,
70 LyXFont const & font, Change change = Change(Change::INSERTED));
72 void insertInset(lyx::pos_type pos, InsetBase * inset,
73 LyXFont const & font, Change change = Change(Change::INSERTED));
75 void eraseIntern(lyx::pos_type pos);
76 /// erase the given position. Returns true if it was actually erased
77 bool erase(lyx::pos_type pos);
78 /// erase the given range
79 int erase(lyx::pos_type start, lyx::pos_type end);
81 UpdatableInset * inset_owner;
83 /** A font entry covers a range of positions. Notice that the
84 entries in the list are inserted in random order.
85 I don't think it's worth the effort to implement a more effective
86 datastructure, because the number of different fonts in a paragraph
88 Nevertheless, I decided to store fontlist using a sorted vector:
89 fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
90 pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
91 and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
92 (font_1 covers the chars 0,...,pos_1) (Dekel)
96 FontTable(lyx::pos_type p, LyXFont const & f)
99 font_ = container.get(f);
102 lyx::pos_type pos() const { return pos_; }
104 void pos(lyx::pos_type p) { pos_ = p; }
106 LyXFont const & font() const { return *font_; }
108 void font(LyXFont const & f) { font_ = container.get(f);}
110 /// End position of paragraph this font attribute covers
112 /** Font. Interpretation of the font values:
113 If a value is LyXFont::INHERIT_*, it means that the font
114 attribute is inherited from either the layout of this
115 paragraph or, in the case of nested paragraphs, from the
116 layout in the environment one level up until completely
118 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
119 allowed in these font tables.
121 boost::shared_ptr<LyXFont> font_;
123 static ShareContainer<LyXFont> container;
126 friend struct matchFT;
129 /// used by lower_bound and upper_bound
131 int operator()(FontTable const & a, FontTable const & b) const {
132 return a.pos() < b.pos();
137 typedef std::vector<FontTable> FontList;
142 void simpleTeXBlanks(std::ostream &, TexRow & texrow,
143 lyx::pos_type const i,
144 unsigned int & column,
145 LyXFont const & font,
146 LyXLayout const & style);
148 void simpleTeXSpecialChars(Buffer const &, BufferParams const &,
149 std::ostream &, TexRow & texrow,
150 OutputParams const &,
151 LyXFont & font, LyXFont & running_font,
153 LyXFont const & outerfont,
155 Change::Type & running_change,
156 LyXLayout const & style,
158 unsigned int & column, value_type const c);
161 void validate(LaTeXFeatures & features,
162 LyXLayout const & layout) const;
167 static unsigned int paragraph_id;
169 ParagraphParameters params;
173 lyx::pos_type size() const { return owner_->size(); }
174 /// match a string against a particular point in the paragraph
175 bool isTextAt(std::string const & str, lyx::pos_type pos) const;
177 /// for recording and looking up changes in revision tracking mode
178 boost::scoped_ptr<Changes> changes_;