2 * \file InsetMathMatrix.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathMatrix.h"
15 #include "MathStream.h"
17 #include "support/convert.h"
23 InsetMathMatrix::InsetMathMatrix(InsetMathGrid const & p,
24 docstring const & left, docstring const & right)
25 : InsetMathGrid(p), left_(left), right_(right)
29 Inset * InsetMathMatrix::clone() const
31 return new InsetMathMatrix(*this);
35 void InsetMathMatrix::write(WriteStream & os) const
37 InsetMathGrid::write(os);
41 void InsetMathMatrix::normalize(NormalStream & os) const
43 InsetMathGrid::normalize(os);
47 void InsetMathMatrix::maple(MapleStream & os) const
49 os << "matrix(" << int(nrows()) << ',' << int(ncols()) << ",[";
50 for (idx_type idx = 0; idx < nargs(); ++idx) {
59 void InsetMathMatrix::maxima(MaximaStream & os) const
62 for (row_type row = 0; row < nrows(); ++row) {
66 for (col_type col = 0; col < ncols(); ++col) {
69 os << cell(index(row, col));
77 void InsetMathMatrix::mathematica(MathematicaStream & os) const
80 for (row_type row = 0; row < nrows(); ++row) {
84 for (col_type col = 0; col < ncols(); ++col) {
87 os << cell(index(row, col));
95 void InsetMathMatrix::mathmlize(MathStream & os) const
97 os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
100 for (row_type row = 0; row < nrows(); ++row) {
102 for (col_type col = 0; col < ncols(); ++col)
103 os << MTag("mtd") << cell(index(row, col)) << ETag("mtd");
106 os << ETag("mtable");
107 os << "<mo form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
108 << right_ << "</mo>";
112 void InsetMathMatrix::htmlize(HtmlStream & os) const
114 os << MTag("table", "class='matrix'") << '\n';
116 // we do not print the delimiters but instead try to hack them
117 string const rows = convert<string>(nrows());
118 string const lattrib =
119 "class='ldelim' rowspan='" + rows + "'";
120 string const rattrib =
121 "class='rdelim' rowspan='" + rows + "'";
123 for (row_type row = 0; row < nrows(); ++row) {
124 os << MTag("tr") << '\n';
126 os << MTag("td", lattrib) << ETag("td") << '\n';
127 for (col_type col = 0; col < ncols(); ++col)
128 os << MTag("td") << cell(index(row, col)) << ETag("td") << '\n';
130 os << MTag("td", rattrib) << ETag("td") << '\n';
131 os << ETag("tr") << '\n';
133 os << ETag("table") << '\n';
137 void InsetMathMatrix::octave(OctaveStream & os) const
140 for (row_type row = 0; row < nrows(); ++row) {
144 for (col_type col = 0; col < ncols(); ++col)
145 os << cell(index(row, col)) << ' ';