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"
21 #include <boost/array.hpp>
23 struct Paragraph::Pimpl {
25 Pimpl(Paragraph * owner);
27 Pimpl(Pimpl const &, Paragraph * owner, bool same_ids = false);
29 Paragraph::size_type size() const {
35 void setContentsFromPar(Paragraph const * par);
38 getChar(Paragraph::size_type pos) const;
40 void setChar(Paragraph::size_type pos, Paragraph::value_type c);
42 void insertChar(Paragraph::size_type pos,
43 Paragraph::value_type c,
44 LyXFont const & font);
46 void insertInset(Paragraph::size_type pos,
48 LyXFont const & font);
50 void erase(Paragraph::size_type pos);
54 boost::array<int, 10> counter_;
57 friend struct matchIT;
60 /// used by lower_bound and upper_bound
62 int operator()(Paragraph::InsetTable const & a,
63 Paragraph::InsetTable const & b) const {
67 /** A font entry covers a range of positions. Notice that the
68 entries in the list are inserted in random order.
69 I don't think it's worth the effort to implement a more effective
70 datastructure, because the number of different fonts in a paragraph
72 Nevertheless, I decided to store fontlist using a sorted vector:
73 fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
74 pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
75 and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
76 (font_1 covers the chars 0,...,pos_1) (Dekel)
80 FontTable(size_type p, LyXFont const & f)
83 font_ = container.get(f);
86 size_type pos() const { return pos_; }
88 void pos(size_type p) { pos_ = p; }
90 LyXFont const & font() const { return *font_; }
92 void font(LyXFont const & f) { font_ = container.get(f);}
94 /// End position of paragraph this font attribute covers
96 /** Font. Interpretation of the font values:
97 If a value is LyXFont::INHERIT_*, it means that the font
98 attribute is inherited from either the layout of this
99 paragraph or, in the case of nested paragraphs, from the
100 layout in the environment one level up until completely
102 The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
103 allowed in these font tables.
105 boost::shared_ptr<LyXFont> font_;
107 static ShareContainer<LyXFont> container;
110 friend struct matchFT;
113 /// used by lower_bound and upper_bound
115 int operator()(Paragraph::Pimpl::FontTable const & a,
116 Paragraph::Pimpl::FontTable const & b) const {
117 return a.pos() < b.pos();
122 typedef std::vector<FontTable> FontList;
126 Paragraph * TeXDeeper(Buffer const *, BufferParams const &,
127 std::ostream &, TexRow & texrow);
129 void simpleTeXBlanks(std::ostream &, TexRow & texrow,
131 int & column, LyXFont const & font,
132 LyXLayout const & style);
134 void simpleTeXSpecialChars(Buffer const *, BufferParams const &,
135 std::ostream &, TexRow & texrow,
137 LyXFont & font, LyXFont & running_font,
138 LyXFont & basefont, bool & open_font,
139 LyXLayout const & style,
141 int & column, value_type const c);
143 Paragraph * getParFromID(int id) const;
147 static unsigned int paragraph_id;
149 ParagraphParameters params;