Author: rgheck
Date: Wed Jan 12 00:18:56 2011
New Revision: 37179
URL: http://www.lyx.org/trac/changeset/37179

Log:
Fix equation number output for XHTML+MathML. HTML to come.

Modified:
   lyx-devel/trunk/src/mathed/InsetMathHull.cpp
   lyx-devel/trunk/src/mathed/InsetMathHull.h

Modified: lyx-devel/trunk/src/mathed/InsetMathHull.cpp
==============================================================================
--- lyx-devel/trunk/src/mathed/InsetMathHull.cpp        Tue Jan 11 22:36:41 
2011        (r37178)
+++ lyx-devel/trunk/src/mathed/InsetMathHull.cpp        Wed Jan 12 00:18:56 
2011        (r37179)
@@ -243,7 +243,8 @@
                if (numbered(i) && cnts.hasCounter(eqstr)) {
                        cnts.step(eqstr, utype);
                        numbers_[i] = cnts.theCounter(eqstr, lang);
-               }
+               } else
+                       numbers_[i] = empty_docstring();
                if (label_[i])
                        label_[i]->updateBuffer(it, utype);
        }
@@ -1182,12 +1183,6 @@
 }
 
 
-void InsetMathHull::mathmlize(MathStream & os) const
-{
-       InsetMathGrid::mathmlize(os);
-}
-
-
 void InsetMathHull::infoize(odocstream & os) const
 {
        os << "Type: " << hullName(type_);
@@ -1915,6 +1910,51 @@
 }
 
 
+// this duplicates code from InsetMathGrid, but
+// we need access here to label and number information,
+// and we simply do not have that in InsetMathGrid.
+void InsetMathHull::mathmlize(MathStream & os) const
+{
+       bool havenumbers = false;
+       for (size_t i = 0; i != numbered_.size(); ++i) {
+               if (numbered_[i]) {
+                       havenumbers = true;
+                       break;
+               }
+       }
+       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");
+}
+
+
 docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
 {
        BufferParams::MathOutput const mathtype = 
@@ -1926,7 +1966,7 @@
                odocstringstream os;
                MathStream ms(os);
                try {
-                       InsetMathGrid::mathmlize(ms);
+                       mathmlize(ms);
                        success = true;
                } catch (MathExportException const &) {}
                if (success) {

Modified: lyx-devel/trunk/src/mathed/InsetMathHull.h
==============================================================================
--- lyx-devel/trunk/src/mathed/InsetMathHull.h  Tue Jan 11 22:36:41 2011        
(r37178)
+++ lyx-devel/trunk/src/mathed/InsetMathHull.h  Wed Jan 12 00:18:56 2011        
(r37179)
@@ -108,8 +108,6 @@
        ///
        void write(WriteStream & os) const;
        ///
-       void mathmlize(MathStream &) const;
-       ///
        void normalize(NormalStream &) const;
        ///
        void infoize(odocstream & os) const;
@@ -130,6 +128,8 @@
        int docbook(odocstream &, OutputParams const &) const;
        ///
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       ///
+       void mathmlize(MathStream &) const;
        /// 
        void toString(odocstream &) const;
        ///

Reply via email to