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);
39 void setContentsFromPar(Paragraph const & par);
44 /// look up change at given pos
45 Change const lookupChange(pos_type pos) const;
46 /// is there a change within the given range ?
47 bool isChanged(pos_type start, pos_type end) const;
48 /// set change for the entire par
49 void setChange(Change const & change);
50 /// set change at given pos
51 void setChange(pos_type pos, Change const & change);
53 void acceptChange(pos_type start, pos_type end);
55 void rejectChange(pos_type start, pos_type end);
58 value_type getChar(pos_type pos) const;
60 void insertChar(pos_type pos, value_type c, Change const & change);
62 void insertInset(pos_type pos, InsetBase * inset, Change const & change);
64 void erase(pos_type pos);
65 /// erase the given position. Returns true if it was actually erased
66 bool erase(pos_type pos, bool trackChanges);
67 /// erase the given range
68 int erase(pos_type start, pos_type end, bool trackChanges);
70 InsetBase * inset_owner;
72 /** A font entry covers a range of positions. Notice that the
73 entries in the list are inserted in random order.
74 I don't think it's worth the effort to implement a more effective
75 datastructure, because the number of different fonts in a paragraph
77 Nevertheless, I decided to store fontlist using a sorted vector:
78 fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
79 pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
80 and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
81 (font_1 covers the chars 0,...,pos_1) (Dekel)
86 FontTable(pos_type p, LyXFont const & f)
90 pos_type pos() const { return pos_; }
92 void pos(pos_type p) { pos_ = p; }
94 LyXFont const & font() const { return font_; }
96 void font(LyXFont const & f) { font_ = f;}
98 /// End position of paragraph this font attribute covers
100 /** Font. Interpretation of the font values:
101 If a value is LyXFont::INHERIT_*, it means that the font
102 attribute is inherited from either the layout of this
103 paragraph or, in the case of nested paragraphs, from the
104 layout in the environment one level up until completely
106 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
107 allowed in these font tables.
112 friend class matchFT;
116 /// used by lower_bound and upper_bound
117 int operator()(FontTable const & a, FontTable const & b) const {
118 return a.pos() < b.pos();
123 typedef std::vector<FontTable> FontList;
128 void simpleTeXBlanks(odocstream &, TexRow & texrow,
130 unsigned int & column,
131 LyXFont const & font,
132 LyXLayout const & style);
134 void simpleTeXSpecialChars(Buffer const &, BufferParams const &,
135 odocstream &, TexRow & texrow,
136 OutputParams const &,
137 LyXFont & font, LyXFont & running_font,
139 LyXFont const & outerfont,
141 Change::Type & running_change,
142 LyXLayout const & style,
144 unsigned int & column, value_type const c);
147 void validate(LaTeXFeatures & features,
148 LyXLayout const & layout) const;
153 static unsigned int paragraph_id;
155 ParagraphParameters params;
159 pos_type size() const { return owner_->size(); }
160 /// match a string against a particular point in the paragraph
161 bool isTextAt(std::string const & str, pos_type pos) const;
163 /// for recording and looking up changes