]> git.lyx.org Git - lyx.git/blob - src/paragraph_pimpl.h
Fix language of error insets
[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 #include <boost/array.hpp>
22
23 struct Paragraph::Pimpl {
24         ///
25         typedef std::vector<value_type> TextContainer;
26
27         ///
28         Pimpl(Paragraph * owner);
29         /// Copy constructor
30         Pimpl(Pimpl const &, Paragraph * owner, bool same_ids = false);
31         ///
32         pos_type size() const {
33                 return text.size();
34         }
35         ///
36         void clear();
37         ///
38         void setContentsFromPar(Paragraph const * par);
39         ///
40         value_type getChar(pos_type pos) const;
41         ///
42         void setChar(pos_type pos, value_type c);
43         ///
44         void insertChar(pos_type pos, value_type c, LyXFont const & font);
45         ///
46         void insertInset(pos_type pos, Inset * inset, LyXFont const & font);
47         ///
48         void erase(pos_type pos);
49         ///
50         LyXFont const realizeFont(LyXFont const & font,
51                                   BufferParams const & bparams) const;
52         ///
53         Inset * inset_owner;
54         ///
55         boost::array<int, 10> counter_;
56
57         ///
58         friend struct matchIT;
59         ///
60         struct matchIT {
61                 /// used by lower_bound and upper_bound
62                 inline
63                 int operator()(InsetTable const & a, InsetTable const & b) const {
64                         return a.pos < b.pos;
65                 }
66         };
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
71             is limited. (Asger)
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)
77         */
78         struct FontTable  {
79                 ///
80                 FontTable(pos_type p, LyXFont const & f)
81                         : pos_(p)
82                         {
83                                 font_ = container.get(f);
84                         }
85                 ///
86                 pos_type pos() const { return pos_; }
87                 ///
88                 void pos(pos_type p) { pos_ = p; }
89                 ///
90                 LyXFont const & font() const { return *font_; }
91                 ///
92                 void font(LyXFont const & f) { font_ = container.get(f);}
93         private:
94                 /// End position of paragraph this font attribute covers
95                 pos_type pos_;
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 
101                     resolved.
102                     The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT 
103                     allowed in these font tables.
104                 */
105                 boost::shared_ptr<LyXFont> font_;
106                 ///
107                 static ShareContainer<LyXFont> container;
108         };
109         ///
110         friend struct matchFT;
111         ///
112         struct matchFT {
113                 /// used by lower_bound and upper_bound
114                 inline
115                 int operator()(FontTable const & a, FontTable const & b) const {
116                         return a.pos() < b.pos();
117                 }
118         };
119
120         ///
121         typedef std::vector<FontTable> FontList;
122         ///
123         FontList fontlist;
124         ///
125         Paragraph * TeXDeeper(Buffer const *, BufferParams const &,
126                                  std::ostream &, TexRow & texrow);
127         ///
128         void simpleTeXBlanks(std::ostream &, TexRow & texrow,
129                              pos_type const i,
130                              int & column, LyXFont const & font,
131                              LyXLayout const & style);
132         ///
133         void simpleTeXSpecialChars(Buffer const *, BufferParams const &,
134                                    std::ostream &, TexRow & texrow,
135                                    bool moving_arg,
136                                    LyXFont & font, LyXFont & running_font,
137                                    LyXFont & basefont, bool & open_font,
138                                    LyXLayout const & style,
139                                    pos_type & i,
140                                    int & column, value_type const c);
141         ///
142         Paragraph * getParFromID(int id) const;
143         ///
144         unsigned int id_;
145         ///
146         static unsigned int paragraph_id;
147         ///
148         ParagraphParameters params;
149 private:
150         /// match a string against a particular point in the paragraph
151         bool isTextAt(string const & str, pos_type pos);
152  
153         /// Who owns us?
154         Paragraph * owner_;
155         ///
156         TextContainer text;
157 };
158
159 #endif