]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
fix the <...> delimiters
[lyx.git] / src / mathed / math_inset.C
1 /*
2  *  File:        math_inset.C
3  *  Purpose:     Implementation of insets for mathed
4  *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
5  *  Created:     January 1996
6  *  Description:
7  *
8  *  Dependencies: Xlib, XForms
9  *
10  *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
11  *
12  *   Version: 0.8beta.
13  *
14  *   You are free to use and modify this code under the terms of
15  *   the GNU General Public Licence version 2 or later.
16  */
17
18 #ifdef __GNUG__
19 #pragma implementation
20 #endif
21
22 #include <config.h>
23
24 #include "Lsstream.h"
25 #include "math_inset.h"
26 #include "math_scriptinset.h"
27 #include "math_charinset.h"
28 #include "math_mathmlstream.h"
29 #include "debug.h"
30
31
32 using std::ostream;
33 using std::vector;
34
35
36 int MathInset::height() const
37 {
38         return ascent() + descent();
39 }
40
41
42 ostream & operator<<(ostream & os, MathAtom const & at)
43 {
44         if (at.nucleus())
45                 os << *(at.nucleus());
46         else
47                 os << "(nil)";
48         return os;
49 }
50
51
52 ostream & operator<<(ostream & os, MathInset const & inset)
53 {
54         WriteStream wi(os, false, false);
55         inset.write(wi);
56         return os;
57 }
58
59 MathInset::size_type MathInset::nargs() const
60 {
61         return 0;
62 }
63
64
65 MathXArray dummyCell;
66
67 MathXArray & MathInset::xcell(idx_type)
68 {
69         lyxerr << "I don't have a cell 1\n";
70         return dummyCell;
71 }
72
73
74 MathXArray const & MathInset::xcell(idx_type) const
75 {
76         lyxerr << "I don't have a cell 2\n";
77         return dummyCell;
78 }
79
80
81 MathArray & MathInset::cell(idx_type)
82 {
83         lyxerr << "I don't have a cell 3\n";
84         return dummyCell.data_;
85 }
86
87
88 MathArray const & MathInset::cell(idx_type) const
89 {
90         lyxerr << "I don't have a cell 4\n";
91         return dummyCell.data_;
92 }
93
94
95 MathInset::idx_type MathInset::index(row_type row, col_type col) const
96 {
97         if (row != 0)
98                 lyxerr << "illegal row: " << row << "\n";
99         if (col != 0)
100                 lyxerr << "illegal col: " << col << "\n";
101         return 0;
102 }
103
104 void MathInset::substitute(MathMacro const &)
105 {}
106
107
108 bool MathInset::idxNext(idx_type &, pos_type &) const
109 {
110         return false;
111 }
112
113
114 bool MathInset::idxRight(idx_type &, pos_type &) const
115 {
116         return false;
117 }
118
119
120 bool MathInset::idxPrev(idx_type &, pos_type &) const
121 {
122         return false;
123 }
124
125
126 bool MathInset::idxLeft(idx_type &, pos_type &) const
127 {
128         return false;
129 }
130
131
132 bool MathInset::idxUpDown(idx_type &, bool) const
133 {
134         return false;
135 }
136
137
138 bool MathInset::idxFirst(idx_type &, pos_type &) const
139 {
140         return false;
141 }
142
143
144 bool MathInset::idxLast(idx_type &, pos_type &) const
145 {
146         return false;
147 }
148
149
150 bool MathInset::idxHome(idx_type &, pos_type &) const
151 {
152         return false;
153 }
154
155
156 bool MathInset::idxEnd(idx_type &, pos_type &) const
157 {
158         return false;
159 }
160
161
162 void MathInset::normalize(NormalStream & os) const
163 {
164         os << "[unknown ";
165         WriteStream wi(os.os(), false, true);
166         write(wi);
167         os << "] ";
168 }
169
170
171 void MathInset::dump() const
172 {
173         lyxerr << "---------------------------------------------\n";
174         WriteStream wi(lyxerr, false, true);
175         write(wi);
176         lyxerr << "\n---------------------------------------------\n";
177 }
178
179
180 void MathInset::validate(LaTeXFeatures &) const
181 {}
182
183
184 vector<MathInset::idx_type>
185         MathInset::idxBetween(idx_type from, idx_type to) const
186 {
187         vector<idx_type> res;
188         for (idx_type i = from; i <= to; ++i)
189                 res.push_back(i);
190         return res;
191 }
192
193
194 void MathInset::metrics(MathMetricsInfo &) const
195 {
196         lyxerr << "MathInset::metrics() called directly!\n";
197 }
198
199
200 void MathInset::draw(MathPainterInfo &, int, int) const
201 {
202         lyxerr << "MathInset::draw() called directly!\n";
203 }
204
205
206 void MathInset::metricsT(TextMetricsInfo const &) const
207 {
208 #ifdef WITH_WARNINGS
209         lyxerr << "MathInset::metricsT(Text) called directly!\n";
210 #endif
211 }
212
213
214 void MathInset::drawT(TextPainter &, int, int) const
215 {
216 #ifdef WITH_WARNINGS
217         lyxerr << "MathInset::drawT(Text) called directly!\n";
218 #endif
219 }
220
221
222
223 void MathInset::write(WriteStream &) const
224 {
225         lyxerr << "MathInset::write() called directly!\n";
226 }
227
228
229 void MathInset::octavize(OctaveStream & os) const
230 {
231         NormalStream ns(os.os());
232         normalize(ns);
233 }
234
235
236 void MathInset::maplize(MapleStream & os) const
237 {
238         NormalStream ns(os.os());
239         normalize(ns);
240 }
241
242
243 void MathInset::mathmlize(MathMLStream & os) const
244 {
245         NormalStream ns(os.os());
246         normalize(ns);
247 }
248
249
250 int MathInset::ascii(std::ostream &, int) const
251 {
252         return 0;
253 }
254
255
256 int MathInset::linuxdoc(std::ostream &) const
257 {
258         return 0;
259 }
260
261
262 int MathInset::docbook(std::ostream &, bool) const
263 {
264         return 0;
265 }
266
267
268 int MathInset::dispatch(string const &, idx_type, pos_type) 
269 {
270         return 0; // undispatched
271 }
272
273
274 string asString(MathArray const & ar)
275 {
276         string res;
277         for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
278                 if ((*it)->getChar())
279                         res += (*it)->getChar();
280         return res;
281 }
282
283
284 MathArray asArray(string const & str)
285 {
286         MathArray ar;
287         for (string::const_iterator it = str.begin(); it != str.end(); ++it)
288                 ar.push_back(MathAtom(new MathCharInset(*it)));
289         return ar;
290 }