]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathXYMatrix.cpp
Get MathML output for XHTML working a bit.
[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         : InsetMathGrid(buf, 1, 1), spacing_(s), spacing_code_(c)
25 {
26 }
27
28
29 Inset * InsetMathXYMatrix::clone() const
30 {
31         return new InsetMathXYMatrix(*this);
32 }
33
34
35 int InsetMathXYMatrix::colsep() const
36 {
37         return 40;
38 }
39
40
41 int InsetMathXYMatrix::rowsep() const
42 {
43         return 40;
44 }
45
46
47 void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
48 {
49         if (mi.base.style == LM_ST_DISPLAY)
50                 mi.base.style = LM_ST_TEXT;
51         InsetMathGrid::metrics(mi, dim);
52 }
53
54
55 void InsetMathXYMatrix::write(WriteStream & os) const
56 {
57         MathEnsurer ensurer(os);
58         os << "\\xymatrix";
59         switch (spacing_code_) {
60         case 'R':
61         case 'C':
62         case 'M':
63         case 'W':
64         case 'H':
65         case 'L':
66                 os << '@' << spacing_code_ << '='
67                    << from_ascii(spacing_.asLatexString());
68                 break;
69         default:
70                 if (!spacing_.empty())
71                         os << "@=" << from_ascii(spacing_.asLatexString());
72         }
73         os << '{';
74         InsetMathGrid::write(os);
75         os << "}\n";
76 }
77
78
79 void InsetMathXYMatrix::infoize(odocstream & os) const
80 {
81         os << "xymatrix ";
82         switch (spacing_code_) {
83         case 'R':
84         case 'C':
85         case 'M':
86         case 'W':
87         case 'H':
88         case 'L':
89                 os << spacing_code_ << ' '
90                    << from_ascii(spacing_.asLatexString()) << ' ';
91                 break;
92         default:
93                 if (!spacing_.empty())
94                         os << from_ascii(spacing_.asLatexString()) << ' ';
95         }
96         InsetMathGrid::infoize(os);
97 }
98
99
100 void InsetMathXYMatrix::normalize(NormalStream & os) const
101 {
102         os << "[xymatrix ";
103         InsetMathGrid::normalize(os);
104         os << ']';
105 }
106
107
108 void InsetMathXYMatrix::maple(MapleStream & os) const
109 {
110         os << "xymatrix(";
111         InsetMathGrid::maple(os);
112         os << ')';
113 }
114
115
116 void InsetMathXYMatrix::validate(LaTeXFeatures & features) const
117 {
118         features.require("xy");
119         InsetMathGrid::validate(features);
120 }
121
122
123 } // namespace lyx