]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMath.cpp
* src/frontends/controllers/Dialog.{cpp,h}:
[lyx.git] / src / mathed / InsetMath.cpp
1 /**
2  * \file InsetMath.cpp
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 "gettext.h"
18 #include "debug.h"
19
20 #include "support/lstrings.h"
21 #include "support/textutils.h"
22
23 #include <boost/current_function.hpp>
24
25 using std::endl;
26
27 namespace lyx {
28
29
30
31 MathData & InsetMath::cell(idx_type)
32 {
33         static MathData dummyCell;
34         lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
35         return dummyCell;
36 }
37
38
39 MathData const & InsetMath::cell(idx_type) const
40 {
41         static MathData dummyCell;
42         lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
43         return dummyCell;
44 }
45
46
47 void InsetMath::dump() const
48 {
49         lyxerr << "---------------------------------------------" << endl;
50         odocstringstream os;
51         WriteStream wi(os, false, true);
52         write(wi);
53         lyxerr << to_utf8(os.str());
54         lyxerr << "\n---------------------------------------------" << endl;
55 }
56
57
58 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
59 {
60 #ifdef WITH_WARNINGS
61         lyxerr << "InsetMath::metricsT(Text) called directly!" << endl;
62 #endif
63 }
64
65
66 void InsetMath::drawT(TextPainter &, int, int) const
67 {
68 #ifdef WITH_WARNINGS
69         lyxerr << "InsetMath::drawT(Text) called directly!" << endl;
70 #endif
71 }
72
73
74
75 void InsetMath::write(WriteStream & os) const
76 {
77         docstring const s = name();
78         os << "\\" << s;
79         // We need an extra ' ' unless this is a single-char-non-ASCII name
80         // or anything non-ASCII follows
81         if (s.size() != 1 || isAlphaASCII(s[0]))
82                 os.pendingSpace(true);
83 }
84
85
86 int InsetMath::plaintext(Buffer const &, odocstream &,
87                          OutputParams const &) const
88 {
89         // all math plain text output shall take place in InsetMathHull
90         BOOST_ASSERT(false);
91         return 0;
92 }
93
94
95 void InsetMath::normalize(NormalStream & os) const
96 {
97         os << '[' << name() << "] ";
98 }
99
100
101 void InsetMath::octave(OctaveStream & os) const
102 {
103         NormalStream ns(os.os());
104         normalize(ns);
105 }
106
107
108 void InsetMath::maple(MapleStream & os) const
109 {
110         NormalStream ns(os.os());
111         normalize(ns);
112 }
113
114
115 void InsetMath::maxima(MaximaStream & os) const
116 {
117         MapleStream ns(os.os());
118         maple(ns);
119 }
120
121
122 void InsetMath::mathematica(MathematicaStream & os) const
123 {
124         NormalStream ns(os.os());
125         normalize(ns);
126 }
127
128
129 void InsetMath::mathmlize(MathStream & os) const
130 {
131         NormalStream ns(os.os());
132         normalize(ns);
133 }
134
135
136 HullType InsetMath::getType() const
137 {
138         return hullNone;
139 }
140
141
142 std::ostream & operator<<(std::ostream & os, MathAtom const & at)
143 {
144         odocstringstream oss;
145         WriteStream wi(oss, false, false);
146         at->write(wi);
147         return os << to_utf8(oss.str());
148 }
149
150
151 odocstream & operator<<(odocstream & os, MathAtom const & at)
152 {
153         WriteStream wi(os, false, false);
154         at->write(wi);
155         return os;
156 }
157
158
159 } // namespace lyx