]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathXYMatrix.cpp
Prepare for mutlicolumn lines
[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 "MathStream.h"
16
17 #include "LaTeXFeatures.h"
18 #include "MetricsInfo.h"
19
20 #include <ostream>
21
22 namespace lyx {
23
24
25 InsetMathXYMatrix::InsetMathXYMatrix(Buffer * buf, Length const & s, char c,
26         bool e) : InsetMathGrid(buf, 1, 1), spacing_(s), spacing_code_(c),
27         equal_spacing_(e)
28 {
29 }
30
31
32 Inset * InsetMathXYMatrix::clone() const
33 {
34         return new InsetMathXYMatrix(*this);
35 }
36
37
38 int InsetMathXYMatrix::colsep() const
39 {
40         return 40;
41 }
42
43
44 int InsetMathXYMatrix::rowsep() const
45 {
46         return 40;
47 }
48
49
50 void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
51 {
52         if (mi.base.style == LM_ST_DISPLAY)
53                 mi.base.style = LM_ST_TEXT;
54         InsetMathGrid::metrics(mi, dim);
55 }
56
57
58 void InsetMathXYMatrix::write(WriteStream & os) const
59 {
60         MathEnsurer ensurer(os);
61         os << "\\xymatrix";
62         bool open = os.startOuterRow();
63         if (equal_spacing_) {
64                 os << "@!";
65                 switch (spacing_code_) {
66                 case '0':
67                 case 'R':
68                 case 'C':
69                         os << spacing_code_;
70                 }
71         } else {
72                 switch (spacing_code_) {
73                 case 'R':
74                 case 'C':
75                 case 'M':
76                 case 'W':
77                 case 'H':
78                 case 'L':
79                         os << '@' << spacing_code_ << '='
80                            << from_ascii(spacing_.asLatexString());
81                         break;
82                 default:
83                         if (!spacing_.empty())
84                                 os << "@=" << from_ascii(spacing_.asLatexString());
85                 }
86         }
87         os << '{';
88         InsetMathGrid::write(os);
89         os << "}";
90         if (open)
91                 os.startOuterRow();
92         os << "\n";
93 }
94
95
96 void InsetMathXYMatrix::infoize(odocstream & os) const
97 {
98         os << "xymatrix ";
99         if (equal_spacing_) {
100                 switch (spacing_code_) {
101                 case '0':
102                 case 'R':
103                 case 'C':
104                         os << '!' << spacing_code_ << ' ';
105                 }
106         } else {
107                 switch (spacing_code_) {
108                 case 'R':
109                 case 'C':
110                 case 'M':
111                 case 'W':
112                 case 'H':
113                 case 'L':
114                         os << spacing_code_ << ' '
115                            << from_ascii(spacing_.asLatexString()) << ' ';
116                         break;
117                 default:
118                         if (!spacing_.empty())
119                                 os << from_ascii(spacing_.asLatexString()) << ' ';
120                 }
121         }
122         InsetMathGrid::infoize(os);
123 }
124
125
126 void InsetMathXYMatrix::normalize(NormalStream & os) const
127 {
128         os << "[xymatrix ";
129         InsetMathGrid::normalize(os);
130         os << ']';
131 }
132
133
134 void InsetMathXYMatrix::maple(MapleStream & os) const
135 {
136         os << "xymatrix(";
137         InsetMathGrid::maple(os);
138         os << ')';
139 }
140
141
142 void InsetMathXYMatrix::validate(LaTeXFeatures & features) const
143 {
144         features.require("xy");
145         InsetMathGrid::validate(features);
146 }
147
148
149 void InsetMathXYMatrix::mathmlize(MathStream &) const
150 {
151         throw MathExportException();
152 }
153
154
155 void InsetMathXYMatrix::htmlize(HtmlStream &) const 
156 {
157         throw MathExportException(); 
158 }
159
160
161 } // namespace lyx