]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathMatrix.cpp
Linearize macros in box edit mode too.
[lyx.git] / src / mathed / InsetMathMatrix.cpp
index d368f217b7b1493485c0ebbc652f5bd487824ae4..620f20f961fdfcbec4f41c0721d116b7bd137ea9 100644 (file)
@@ -14,6 +14,9 @@
 #include "MathData.h"
 #include "MathStream.h"
 
+#include "support/convert.h"
+
+using namespace std;
 
 namespace lyx {
 
@@ -92,17 +95,62 @@ void InsetMathMatrix::mathematica(MathematicaStream & os) const
 void InsetMathMatrix::mathmlize(MathStream & os) const
 {
        os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
-          << left_ << "</mo>";
-       os << MTag("mtable");
+          << convertDelimToXMLEscape(left_) 
+          << "</mo>"
+          << 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 << "<mo form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
-          << right_ << "</mo>";
+          << convertDelimToXMLEscape(right_) 
+          << "</mo>";
+}
+
+
+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<string>(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';
 }