]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathXYMatrix.cpp
MathML and HTML definitely can't handle XYMatrix.
[lyx.git] / src / mathed / InsetMathXYMatrix.cpp
1 /**
2  * \file InsetMathXYMatrix.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathXYMatrix.h"
14
15 #include "LaTeXFeatures.h"
16 #include "MathStream.h"
17
18 #include <ostream>
19
20 namespace lyx {
21
22
23 InsetMathXYMatrix::InsetMathXYMatrix(Buffer * buf, Length const & s, char c,
24         bool e) : InsetMathGrid(buf, 1, 1), spacing_(s), spacing_code_(c),
25         equal_spacing_(e)
26 {
27 }
28
29
30 Inset * InsetMathXYMatrix::clone() const
31 {
32         return new InsetMathXYMatrix(*this);
33 }
34
35
36 int InsetMathXYMatrix::colsep() const
37 {
38         return 40;
39 }
40
41
42 int InsetMathXYMatrix::rowsep() const
43 {
44         return 40;
45 }
46
47
48 void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
49 {
50         if (mi.base.style == LM_ST_DISPLAY)
51                 mi.base.style = LM_ST_TEXT;
52         InsetMathGrid::metrics(mi, dim);
53 }
54
55
56 void InsetMathXYMatrix::write(WriteStream & os) const
57 {
58         MathEnsurer ensurer(os);
59         os << "\\xymatrix";
60         if (equal_spacing_) {
61                 os << "@!";
62                 switch (spacing_code_) {
63                 case '0':
64                 case 'R':
65                 case 'C':
66                         os << spacing_code_;
67                 }
68         } else {
69                 switch (spacing_code_) {
70                 case 'R':
71                 case 'C':
72                 case 'M':
73                 case 'W':
74                 case 'H':
75                 case 'L':
76                         os << '@' << spacing_code_ << '='
77                            << from_ascii(spacing_.asLatexString());
78                         break;
79                 default:
80                         if (!spacing_.empty())
81                                 os << "@=" << from_ascii(spacing_.asLatexString());
82                 }
83         }
84         os << '{';
85         InsetMathGrid::write(os);
86         os << "}\n";
87 }
88
89
90 void InsetMathXYMatrix::infoize(odocstream & os) const
91 {
92         os << "xymatrix ";
93         if (equal_spacing_) {
94                 switch (spacing_code_) {
95                 case '0':
96                 case 'R':
97                 case 'C':
98                         os << '!' << spacing_code_ << ' ';
99                 }
100         } else {
101                 switch (spacing_code_) {
102                 case 'R':
103                 case 'C':
104                 case 'M':
105                 case 'W':
106                 case 'H':
107                 case 'L':
108                         os << spacing_code_ << ' '
109                            << from_ascii(spacing_.asLatexString()) << ' ';
110                         break;
111                 default:
112                         if (!spacing_.empty())
113                                 os << from_ascii(spacing_.asLatexString()) << ' ';
114                 }
115         }
116         InsetMathGrid::infoize(os);
117 }
118
119
120 void InsetMathXYMatrix::normalize(NormalStream & os) const
121 {
122         os << "[xymatrix ";
123         InsetMathGrid::normalize(os);
124         os << ']';
125 }
126
127
128 void InsetMathXYMatrix::maple(MapleStream & os) const
129 {
130         os << "xymatrix(";
131         InsetMathGrid::maple(os);
132         os << ')';
133 }
134
135
136 void InsetMathXYMatrix::validate(LaTeXFeatures & features) const
137 {
138         features.require("xy");
139         InsetMathGrid::validate(features);
140 }
141
142
143 void InsetMathXYMatrix::mathmlize(MathStream &) const
144 {
145         throw MathExportException();
146 }
147
148
149 void InsetMathXYMatrix::htmlize(HtmlStream &) const 
150 {
151         throw MathExportException(); 
152 }
153
154
155 } // namespace lyx