]> git.lyx.org Git - lyx.git/blob - src/paragraph_pimpl.h
fix typo that put too many include paths for most people
[lyx.git] / src / paragraph_pimpl.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *
7  *          Copyright 1995 Matthias Ettrich
8  *          Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef PARAGRAPH_PIMPL_H
13 #define PARAGRAPH_PIMPL_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "paragraph.h"
20 #include "ParagraphParameters.h"
21
22 #include <boost/array.hpp>
23
24 class LyXLayout;
25
26 struct Paragraph::Pimpl {
27         ///
28         typedef std::vector<value_type> TextContainer;
29
30         ///
31         Pimpl(Paragraph * owner);
32         /// Copy constructor
33         Pimpl(Pimpl const &, Paragraph * owner, bool same_ids = false);
34         ///
35         lyx::pos_type size() const {
36                 return text.size();
37         }
38         ///
39         void clear();
40         ///
41         void setContentsFromPar(Paragraph const * par);
42         ///
43         value_type getChar(lyx::pos_type pos) const;
44         ///
45         void setChar(lyx::pos_type pos, value_type c);
46         ///
47         void insertChar(lyx::pos_type pos, value_type c, LyXFont const & font);
48         ///
49         void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const & font);
50         ///
51         void erase(lyx::pos_type pos);
52         ///
53         LyXFont const realizeFont(LyXFont const & font,
54                                   BufferParams const & bparams) const;
55         ///
56         Inset * inset_owner;
57         ///
58         boost::array<int, 10> counter_;
59
60         ///
61         friend struct matchIT;
62         ///
63         struct matchIT {
64                 /// used by lower_bound and upper_bound
65                 inline
66                 int operator()(InsetTable const & a, InsetTable const & b) const {
67                         return a.pos < b.pos;
68                 }
69         };
70         /** A font entry covers a range of positions. Notice that the
71             entries in the list are inserted in random order.
72             I don't think it's worth the effort to implement a more effective
73             datastructure, because the number of different fonts in a paragraph
74             is limited. (Asger)
75             Nevertheless, I decided to store fontlist using a sorted vector:
76             fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
77             pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
78             and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
79             (font_1 covers the chars 0,...,pos_1) (Dekel)
80         */
81         struct FontTable  {
82                 ///
83                 FontTable(lyx::pos_type p, LyXFont const & f)
84                         : pos_(p)
85                         {
86                                 font_ = container.get(f);
87                         }
88                 ///
89                 lyx::pos_type pos() const { return pos_; }
90                 ///
91                 void pos(lyx::pos_type p) { pos_ = p; }
92                 ///
93                 LyXFont const & font() const { return *font_; }
94                 ///
95                 void font(LyXFont const & f) { font_ = container.get(f);}
96         private:
97                 /// End position of paragraph this font attribute covers
98                 lyx::pos_type pos_;
99                 /** Font. Interpretation of the font values:
100                     If a value is LyXFont::INHERIT_*, it means that the font
101                     attribute is inherited from either the layout of this
102                     paragraph or, in the case of nested paragraphs, from the
103                     layout in the environment one level up until completely
104                     resolved.
105                     The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
106                     allowed in these font tables.
107                 */
108                 boost::shared_ptr<LyXFont> font_;
109                 ///
110                 static ShareContainer<LyXFont> container;
111         };
112         ///
113         friend struct matchFT;
114         ///
115         struct matchFT {
116                 /// used by lower_bound and upper_bound
117                 inline
118                 int operator()(FontTable const & a, FontTable const & b) const {
119                         return a.pos() < b.pos();
120                 }
121         };
122
123         ///
124         typedef std::vector<FontTable> FontList;
125         ///
126         FontList fontlist;
127         ///
128         Paragraph * TeXDeeper(Buffer const *, BufferParams const &,
129                                  std::ostream &, TexRow & texrow);
130         ///
131         void simpleTeXBlanks(std::ostream &, TexRow & texrow,
132                              lyx::pos_type const i,
133                              int & column, LyXFont const & font,
134                              LyXLayout const & style);
135         ///
136         void simpleTeXSpecialChars(Buffer const *, BufferParams const &,
137                                    std::ostream &, TexRow & texrow,
138                                    bool moving_arg,
139                                    LyXFont & font, LyXFont & running_font,
140                                    LyXFont & basefont, bool & open_font,
141                                    LyXLayout const & style,
142                                    lyx::pos_type & i,
143                                    int & column, value_type const c);
144         ///
145         Paragraph * getParFromID(int id) const;
146         ///
147         unsigned int id_;
148         ///
149         static unsigned int paragraph_id;
150         ///
151         ParagraphParameters params;
152 private:
153         /// match a string against a particular point in the paragraph
154         bool isTextAt(BufferParams const &,
155                       string const & str, lyx::pos_type pos);
156
157         /// Who owns us?
158         Paragraph * owner_;
159         ///
160         TextContainer text;
161 };
162
163 #endif