]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathMatrix.cpp
Remove unneccessary uses of dynamic_cast from the code.
[lyx.git] / src / mathed / InsetMathMatrix.cpp
index feb56cb3df61249d8c9c4c37488e872c1daa231f..4d309d13e88dba668401e28dd6b23e4562f17149 100644 (file)
@@ -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.
  */
 #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<InsetBase> InsetMathMatrix::doClone() const
+Inset * InsetMathMatrix::clone() const
 {
-       return auto_ptr<InsetBase>(new InsetMathMatrix(*this));
+       return new InsetMathMatrix(*this);
 }
 
 
@@ -93,7 +94,43 @@ void InsetMathMatrix::mathematica(MathematicaStream & os) const
 
 void InsetMathMatrix::mathmlize(MathStream & os) const
 {
-       InsetMathGrid::mathmlize(os);
+       os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
+          << left_ << "</mo>";
+       os << 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");
+               os << ETag("mtr");
+       }
+       os << ETag("mtable");
+       os << "<mo form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
+          << 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)
+                       os << MTag("td") << cell(index(row, col)) << ETag("td") << '\n';
+               if (row == 0)
+                       os << MTag("td", rattrib) << ETag("td") << '\n';
+               os << ETag("tr") << '\n';
+       }
+       os << ETag("table") << '\n';
 }