]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMath.C
2a6d4462a43b9dc5432e719dd8af726445e56432
[lyx.git] / src / mathed / InsetMath.C
1 /**
2  * \file InsetMath.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "InsetMath.h"
15 #include "MathData.h"
16 #include "MathStream.h"
17 #include "debug.h"
18
19 #include "support/lstrings.h"
20
21 #include <boost/current_function.hpp>
22
23
24 namespace lyx {
25
26 using std::endl;
27
28
29 MathArray & InsetMath::cell(idx_type)
30 {
31         static MathArray dummyCell;
32         lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
33         return dummyCell;
34 }
35
36
37 MathArray const & InsetMath::cell(idx_type) const
38 {
39         static MathArray dummyCell;
40         lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
41         return dummyCell;
42 }
43
44
45 void InsetMath::dump() const
46 {
47         lyxerr << "---------------------------------------------" << endl;
48         odocstringstream os;
49         WriteStream wi(os, false, true);
50         write(wi);
51         lyxerr << to_utf8(os.str());
52         lyxerr << "\n---------------------------------------------" << endl;
53 }
54
55
56 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
57 {
58 #ifdef WITH_WARNINGS
59         lyxerr << "InsetMath::metricsT(Text) called directly!" << endl;
60 #endif
61 }
62
63
64 void InsetMath::drawT(TextPainter &, int, int) const
65 {
66 #ifdef WITH_WARNINGS
67         lyxerr << "InsetMath::drawT(Text) called directly!" << endl;
68 #endif
69 }
70
71
72
73 void InsetMath::write(WriteStream & os) const
74 {
75         docstring const s = name();
76         os << "\\" << s;
77         // We need an extra ' ' unless this is a single-char-non-ASCII name
78         // or anything non-ASCII follows
79         if (s.size() != 1 || isalpha(s[0]))
80                 os.pendingSpace(true);
81 }
82
83
84 void InsetMath::normalize(NormalStream & os) const
85 {
86         os << '[' << name() << "] ";
87 }
88
89
90 void InsetMath::octave(OctaveStream & os) const
91 {
92         NormalStream ns(os.os());
93         normalize(ns);
94 }
95
96
97 void InsetMath::maple(MapleStream & os) const
98 {
99         NormalStream ns(os.os());
100         normalize(ns);
101 }
102
103
104 void InsetMath::maxima(MaximaStream & os) const
105 {
106         MapleStream ns(os.os());
107         maple(ns);
108 }
109
110
111 void InsetMath::mathematica(MathematicaStream & os) const
112 {
113         NormalStream ns(os.os());
114         normalize(ns);
115 }
116
117
118 void InsetMath::mathmlize(MathStream & os) const
119 {
120         NormalStream ns(os.os());
121         normalize(ns);
122 }
123
124
125 HullType InsetMath::getType() const
126 {
127         return hullNone;
128 }
129
130
131 docstring InsetMath::name() const
132 {
133         return from_ascii("unknown");
134 }
135
136
137 std::ostream & operator<<(std::ostream & os, MathAtom const & at)
138 {
139         odocstringstream oss;
140         WriteStream wi(oss, false, false);
141         at->write(wi);
142         return os << to_utf8(oss.str());
143 }
144
145
146 odocstream & operator<<(odocstream & os, MathAtom const & at)
147 {
148         WriteStream wi(os, false, false);
149         at->write(wi);
150         return os;
151 }
152
153
154 } // namespace lyx