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_;
65 /** A font entry covers a range of positions. Notice that the
66 entries in the list are inserted in random order.
67 I don't think it's worth the effort to implement a more effective
68 datastructure, because the number of different fonts in a paragraph
70 Nevertheless, I decided to store fontlist using a sorted vector:
71 fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
72 pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
73 and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
74 (font_1 covers the chars 0,...,pos_1) (Dekel)
78 FontTable(lyx::pos_type p, LyXFont const & f)
81 font_ = container.get(f);
84 lyx::pos_type pos() const { return pos_; }
86 void pos(lyx::pos_type p) { pos_ = p; }
88 LyXFont const & font() const { return *font_; }
90 void font(LyXFont const & f) { font_ = container.get(f);}
92 /// End position of paragraph this font attribute covers
94 /** Font. Interpretation of the font values:
95 If a value is LyXFont::INHERIT_*, it means that the font
96 attribute is inherited from either the layout of this
97 paragraph or, in the case of nested paragraphs, from the
98 layout in the environment one level up until completely
100 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
101 allowed in these font tables.
103 boost::shared_ptr<LyXFont> font_;
105 static ShareContainer<LyXFont> container;
108 friend struct matchFT;
111 /// used by lower_bound and upper_bound
113 int operator()(FontTable const & a, FontTable const & b) const {
114 return a.pos() < b.pos();
119 typedef std::vector<FontTable> FontList;
123 Paragraph * TeXDeeper(Buffer const *, BufferParams const &,
124 std::ostream &, TexRow & texrow);
126 void simpleTeXBlanks(std::ostream &, TexRow & texrow,
127 lyx::pos_type const i,
128 int & column, LyXFont const & font,
129 LyXLayout const & style);
131 void simpleTeXSpecialChars(Buffer const *, BufferParams const &,
132 std::ostream &, TexRow & texrow,
134 LyXFont & font, LyXFont & running_font,
135 LyXFont & basefont, bool & open_font,
136 LyXLayout const & style,
138 int & column, value_type const c);
141 void validate(LaTeXFeatures & features,
142 LyXLayout const & layout) const;
145 Paragraph * getParFromID(int id) const;
149 static unsigned int paragraph_id;
151 ParagraphParameters params;
156 /// match a string against a particular point in the paragraph
157 bool isTextAt(string const & str, lyx::pos_type pos) const;