]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMath.C
57fed3d60425a14a195ea698cc9e3b48f3203923
[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 "MathMLStream.h"
17 #include "debug.h"
18
19 #include "support/lstrings.h"
20
21 #include <boost/current_function.hpp>
22
23 using std::string;
24 using std::ostream;
25 using std::endl;
26
27
28 MathArray & InsetMath::cell(idx_type)
29 {
30         static MathArray dummyCell;
31         lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
32         return dummyCell;
33 }
34
35
36 MathArray const & InsetMath::cell(idx_type) const
37 {
38         static MathArray dummyCell;
39         lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
40         return dummyCell;
41 }
42
43
44 void InsetMath::dump() const
45 {
46         lyxerr << "---------------------------------------------" << endl;
47         WriteStream wi(lyxerr, false, true);
48         write(wi);
49         lyxerr << "\n---------------------------------------------" << endl;
50 }
51
52
53 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
54 {
55 #ifdef WITH_WARNINGS
56         lyxerr << "InsetMath::metricsT(Text) called directly!" << endl;
57 #endif
58 }
59
60
61 void InsetMath::drawT(TextPainter &, int, int) const
62 {
63 #ifdef WITH_WARNINGS
64         lyxerr << "InsetMath::drawT(Text) called directly!" << endl;
65 #endif
66 }
67
68
69
70 void InsetMath::write(WriteStream & os) const
71 {
72         string const s = name();
73         os << '\\' << s.c_str();
74         // We need an extra ' ' unless this is a single-char-non-ASCII name
75         // or anything non-ASCII follows
76         if (s.size() != 1 || isalpha(s[0]))
77                 os.pendingSpace(true);
78 }
79
80
81 void InsetMath::normalize(NormalStream & os) const
82 {
83         os << '[' << name().c_str() << "] ";
84 }
85
86
87 void InsetMath::octave(OctaveStream & os) const
88 {
89         NormalStream ns(os.os());
90         normalize(ns);
91 }
92
93
94 void InsetMath::maple(MapleStream & os) const
95 {
96         NormalStream ns(os.os());
97         normalize(ns);
98 }
99
100
101 void InsetMath::maxima(MaximaStream & os) const
102 {
103         MapleStream ns(os.os());
104         maple(ns);
105 }
106
107
108 void InsetMath::mathematica(MathematicaStream & os) const
109 {
110         NormalStream ns(os.os());
111         normalize(ns);
112 }
113
114
115 void InsetMath::mathmlize(MathMLStream & os) const
116 {
117         NormalStream ns(os.os());
118         normalize(ns);
119 }
120
121
122 HullType InsetMath::getType() const
123 {
124         return hullNone;
125 }
126
127
128 string InsetMath::name() const
129 {
130         return "unknown";
131 }
132
133
134 ostream & operator<<(ostream & os, MathAtom const & at)
135 {
136         WriteStream wi(os, false, false);
137         at->write(wi);
138         return os;
139 }