+bool InsetMathHull::haveNumbers() const
+{
+ bool havenumbers = false;
+ // inline formulas are never numbered (bug 7351 part 3)
+ if (getType() == hullSimple)
+ return havenumbers;
+ for (size_t i = 0; i != numbered_.size(); ++i) {
+ if (numbered(i)) {
+ havenumbers = true;
+ break;
+ }
+ }
+ return havenumbers;
+}
+
+
+// FIXME XHTML
+// We need to do something about alignment here.
+//
+// This duplicates code from InsetMathGrid, but
+// we need access here to number information,
+// and we simply do not have that in InsetMathGrid.
+void InsetMathHull::htmlize(HtmlStream & os) const
+{
+ bool const havenumbers = haveNumbers();
+ bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
+
+ if (!havetable) {
+ os << cell(index(0, 0));
+ return;
+ }
+
+ os << MTag("table", "class='mathtable'");
+ for (row_type row = 0; row < nrows(); ++row) {
+ os << MTag("tr");
+ for (col_type col = 0; col < ncols(); ++col) {
+ os << MTag("td");
+ os << cell(index(row, col));
+ os << ETag("td");
+ }
+ if (havenumbers) {
+ os << MTag("td");
+ docstring const & num = numbers_[row];
+ if (!num.empty())
+ os << '(' << num << ')';
+ os << ETag("td");
+ }
+ os << ETag("tr");
+ }
+ os << ETag("table");
+}
+
+
+// this duplicates code from InsetMathGrid, but
+// we need access here to number information,
+// and we simply do not have that in InsetMathGrid.
+void InsetMathHull::mathmlize(MathStream & os) const
+{
+ bool const havenumbers = haveNumbers();
+ bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
+
+ if (havetable)
+ os << MTag("mtable");
+ char const * const celltag = havetable ? "mtd" : "mrow";
+ // FIXME There does not seem to be wide support at the moment
+ // for mlabeledtr, so we have to use just mtr for now.
+ // char const * const rowtag = havenumbers ? "mlabeledtr" : "mtr";
+ char const * const rowtag = "mtr";
+ for (row_type row = 0; row < nrows(); ++row) {
+ if (havetable)
+ os << MTag(rowtag);
+ for (col_type col = 0; col < ncols(); ++col) {
+ os << MTag(celltag)
+ << cell(index(row, col))
+ << ETag(celltag);
+ }
+ // fleqn?
+ if (havenumbers) {
+ os << MTag("mtd");
+ docstring const & num = numbers_[row];
+ if (!num.empty())
+ os << '(' << num << ')';
+ os << ETag("mtd");
+ }
+ if (havetable)
+ os << ETag(rowtag);
+ }
+ if (havetable)
+ os << ETag("mtable");
+}
+
+
+void InsetMathHull::mathAsLatex(WriteStream & os) const
+{
+ MathEnsurer ensurer(os, false);
+ bool havenumbers = haveNumbers();
+ bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
+
+ if (!havetable) {
+ os << cell(index(0, 0));
+ return;
+ }
+
+ os << "<table class='mathtable'>";
+ for (row_type row = 0; row < nrows(); ++row) {
+ os << "<tr>";
+ for (col_type col = 0; col < ncols(); ++col) {
+ os << "<td class='math'>";
+ os << cell(index(row, col));
+ os << "</td>";
+ }
+ if (havenumbers) {
+ os << "<td>";
+ docstring const & num = numbers_[row];
+ if (!num.empty())
+ os << '(' << num << ')';
+ os << "</td>";
+ }
+ os << "</tr>";
+ }
+ os << "</table>";
+}
+
+