2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team.
10 * ====================================================== */
12 #ifndef PARAGRAPH_PIMPL_H
13 #define PARAGRAPH_PIMPL_H
19 #include "paragraph.h"
20 #include "ParagraphParameters.h"
23 #include <boost/array.hpp>
27 struct Paragraph::Pimpl {
29 typedef std::vector<value_type> TextContainer;
32 Pimpl(Paragraph * owner);
34 Pimpl(Pimpl const &, Paragraph * owner, bool same_ids = false);
36 lyx::pos_type size() const {
42 void setContentsFromPar(Paragraph const * par);
44 value_type getChar(lyx::pos_type pos) const;
46 void setChar(lyx::pos_type pos, value_type c);
48 void insertChar(lyx::pos_type pos, value_type c, LyXFont const & font);
50 void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const & font);
52 void erase(lyx::pos_type pos);
54 LyXFont const realizeFont(LyXFont const & font,
55 BufferParams const & bparams) const;
59 boost::array<int, 10> counter_;
62 friend struct matchIT;
65 /// used by lower_bound and upper_bound
67 int operator()(InsetTable const & a, InsetTable const & b) const {
71 /** A font entry covers a range of positions. Notice that the
72 entries in the list are inserted in random order.
73 I don't think it's worth the effort to implement a more effective
74 datastructure, because the number of different fonts in a paragraph
76 Nevertheless, I decided to store fontlist using a sorted vector:
77 fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
78 pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
79 and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
80 (font_1 covers the chars 0,...,pos_1) (Dekel)
84 FontTable(lyx::pos_type p, LyXFont const & f)
87 font_ = container.get(f);
90 lyx::pos_type pos() const { return pos_; }
92 void pos(lyx::pos_type p) { pos_ = p; }
94 LyXFont const & font() const { return *font_; }
96 void font(LyXFont const & f) { font_ = container.get(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.
109 boost::shared_ptr<LyXFont> font_;
111 static ShareContainer<LyXFont> container;
114 friend struct matchFT;
117 /// used by lower_bound and upper_bound
119 int operator()(FontTable const & a, FontTable const & b) const {
120 return a.pos() < b.pos();
125 typedef std::vector<FontTable> FontList;
129 Paragraph * TeXDeeper(Buffer const *, BufferParams const &,
130 std::ostream &, TexRow & texrow);
132 void simpleTeXBlanks(std::ostream &, TexRow & texrow,
133 lyx::pos_type const i,
134 int & column, LyXFont const & font,
135 LyXLayout const & style);
137 void simpleTeXSpecialChars(Buffer const *, BufferParams const &,
138 std::ostream &, TexRow & texrow,
140 LyXFont & font, LyXFont & running_font,
141 LyXFont & basefont, bool & open_font,
142 LyXLayout const & style,
144 int & column, value_type const c);
147 void validate(LaTeXFeatures & features,
148 LyXLayout const & layout) const;
151 Paragraph * getParFromID(int id) const;
155 static unsigned int paragraph_id;
157 ParagraphParameters params;
162 /// match a string against a particular point in the paragraph
163 bool isTextAt(string const & str, lyx::pos_type pos) const;