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 {
46 void setContentsFromPar(Paragraph const * par);
48 value_type getChar(lyx::pos_type pos) const;
50 void setChar(lyx::pos_type pos, value_type c);
52 void insertChar(lyx::pos_type pos, value_type c, LyXFont const & font);
54 void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const & font);
56 void erase(lyx::pos_type pos);
58 LyXFont const realizeFont(LyXFont const & font,
59 BufferParams const & bparams) const;
63 boost::array<int, 10> counter_;
66 friend struct matchIT;
69 /// used by lower_bound and upper_bound
71 int operator()(InsetTable const & a, InsetTable const & b) const {
75 /** A font entry covers a range of positions. Notice that the
76 entries in the list are inserted in random order.
77 I don't think it's worth the effort to implement a more effective
78 datastructure, because the number of different fonts in a paragraph
80 Nevertheless, I decided to store fontlist using a sorted vector:
81 fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
82 pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
83 and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
84 (font_1 covers the chars 0,...,pos_1) (Dekel)
88 FontTable(lyx::pos_type p, LyXFont const & f)
91 font_ = container.get(f);
94 lyx::pos_type pos() const { return pos_; }
96 void pos(lyx::pos_type p) { pos_ = p; }
98 LyXFont const & font() const { return *font_; }
100 void font(LyXFont const & f) { font_ = container.get(f);}
102 /// End position of paragraph this font attribute covers
104 /** Font. Interpretation of the font values:
105 If a value is LyXFont::INHERIT_*, it means that the font
106 attribute is inherited from either the layout of this
107 paragraph or, in the case of nested paragraphs, from the
108 layout in the environment one level up until completely
110 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
111 allowed in these font tables.
113 boost::shared_ptr<LyXFont> font_;
115 static ShareContainer<LyXFont> container;
118 friend struct matchFT;
121 /// used by lower_bound and upper_bound
123 int operator()(FontTable const & a, FontTable const & b) const {
124 return a.pos() < b.pos();
129 typedef std::vector<FontTable> FontList;
133 Paragraph * TeXDeeper(Buffer const *, BufferParams const &,
134 std::ostream &, TexRow & texrow);
136 void simpleTeXBlanks(std::ostream &, TexRow & texrow,
137 lyx::pos_type const i,
138 int & column, LyXFont const & font,
139 LyXLayout const & style);
141 void simpleTeXSpecialChars(Buffer const *, BufferParams const &,
142 std::ostream &, TexRow & texrow,
144 LyXFont & font, LyXFont & running_font,
145 LyXFont & basefont, bool & open_font,
146 LyXLayout const & style,
148 int & column, value_type const c);
151 void validate(LaTeXFeatures & features,
152 LyXLayout const & layout) const;
155 Paragraph * getParFromID(int id) const;
159 static unsigned int paragraph_id;
161 ParagraphParameters params;
166 /// match a string against a particular point in the paragraph
167 bool isTextAt(string const & str, lyx::pos_type pos) const;