X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathMatrix.cpp;h=7f6700f62447a102480e2fd8a4cb87999b9c67b3;hb=a59301eaff51c63db706e17bd5496b8e02928f14;hp=b4cecfa6c3785871f3b86c3e0913d2b9de9921a9;hpb=f1cba8ff64b369792fd49f5ddf90e8126ab476ac;p=lyx.git
diff --git a/src/mathed/InsetMathMatrix.cpp b/src/mathed/InsetMathMatrix.cpp
index b4cecfa6c3..7f6700f624 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)
{}
@@ -90,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';
}