X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathMatrix.cpp;h=620f20f961fdfcbec4f41c0721d116b7bd137ea9;hb=a48581f48c93b3981ffd3e058f57e3ed95b53641;hp=0460a9443ffd2dc14e992f596ef5f1b10002dfe5;hpb=05336422a4d708adebef1fbd861b74086befbe5a;p=lyx.git diff --git a/src/mathed/InsetMathMatrix.cpp b/src/mathed/InsetMathMatrix.cpp index 0460a9443f..620f20f961 100644 --- a/src/mathed/InsetMathMatrix.cpp +++ b/src/mathed/InsetMathMatrix.cpp @@ -14,11 +14,15 @@ #include "MathData.h" #include "MathStream.h" +#include "support/convert.h" + +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) {} @@ -88,24 +92,65 @@ void InsetMathMatrix::mathematica(MathematicaStream & os) const } -// FIXME XHTML -// We need more information here, so we can output the correct -// delimiters, which will not always be "[". To do this, we need -// to make some changes to InsetMathMatrix, adding a member to -// record the type of delimiter, and then make the extractMatrices -// routine in MathExtern give us this information. void InsetMathMatrix::mathmlize(MathStream & os) const { - os << "["; - os << MTag("mtable"); + os << "" + << convertDelimToXMLEscape(left_) + << "" + << MTag("mtable"); for (row_type row = 0; row < nrows(); ++row) { os << MTag("mtr"); - for (col_type col = 0; col < ncols(); ++col) - os << MTag("mtd") << cell(index(row, col)) << ETag("mtd"); + 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 << "]"; + 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'; }