X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathMatrix.cpp;h=620f20f961fdfcbec4f41c0721d116b7bd137ea9;hb=ecbd047cffa1c4af95cf4ab91a7d2fded4a5584c;hp=ef1ac7d8dcf8b3fa06a138ea92fa7f6fd4434d27;hpb=32871c1284f15265f652ff01c438e539a7c8181f;p=lyx.git diff --git a/src/mathed/InsetMathMatrix.cpp b/src/mathed/InsetMathMatrix.cpp index ef1ac7d8dc..620f20f961 100644 --- a/src/mathed/InsetMathMatrix.cpp +++ b/src/mathed/InsetMathMatrix.cpp @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author André Pönitz + * \author André Pönitz * * Full author contact details are available in file CREDITS. */ @@ -14,20 +14,21 @@ #include "MathData.h" #include "MathStream.h" +#include "support/convert.h" -namespace lyx { - -using std::auto_ptr; +using namespace std; +namespace lyx { -InsetMathMatrix::InsetMathMatrix(InsetMathGrid const & p) - : InsetMathGrid(p) +InsetMathMatrix::InsetMathMatrix(InsetMathGrid const & p, + docstring const & left, docstring const & right) + : InsetMathGrid(p), left_(left), right_(right) {} -auto_ptr InsetMathMatrix::doClone() const +Inset * InsetMathMatrix::clone() const { - return auto_ptr(new InsetMathMatrix(*this)); + return new InsetMathMatrix(*this); } @@ -93,7 +94,63 @@ void InsetMathMatrix::mathematica(MathematicaStream & os) const void InsetMathMatrix::mathmlize(MathStream & os) const { - InsetMathGrid::mathmlize(os); + os << "" + << convertDelimToXMLEscape(left_) + << "" + << MTag("mtable"); + for (row_type row = 0; row < nrows(); ++row) { + os << MTag("mtr"); + for (col_type col = 0; col < ncols(); ++col) { + idx_type const i = index(row, col); + if (cellinfo_[i].multi_ != CELL_PART_OF_MULTICOLUMN) { + col_type const cellcols = ncellcols(i); + ostringstream attr; + if (cellcols > 1) + attr << "columnspan='" << cellcols << '\''; + os << MTag("mtd", attr.str()) << cell(i) << ETag("mtd"); + } + } + os << ETag("mtr"); + } + os << ETag("mtable"); + os << "" + << convertDelimToXMLEscape(right_) + << ""; +} + + +void InsetMathMatrix::htmlize(HtmlStream & os) const +{ + os << MTag("table", "class='matrix'") << '\n'; + + // we do not print the delimiters but instead try to hack them + string const rows = convert(nrows()); + string const lattrib = + "class='ldelim' rowspan='" + rows + "'"; + string const rattrib = + "class='rdelim' rowspan='" + rows + "'"; + + for (row_type row = 0; row < nrows(); ++row) { + os << MTag("tr") << '\n'; + if (row == 0) + os << MTag("td", lattrib) << ETag("td") << '\n'; + for (col_type col = 0; col < ncols(); ++col) { + idx_type const i = index(row, col); + if (cellinfo_[i].multi_ != CELL_PART_OF_MULTICOLUMN) { + col_type const cellcols = ncellcols(i); + ostringstream attr; + if (cellcols > 1) + attr << "colspan='" << cellcols + << '\''; + os << MTag("td", attr.str()) << cell(i) + << ETag("td") << '\n'; + } + } + if (row == 0) + os << MTag("td", rattrib) << ETag("td") << '\n'; + os << ETag("tr") << '\n'; + } + os << ETag("table") << '\n'; }