]> git.lyx.org Git - features.git/commitdiff
Fix equation number output for XHTML+MathML. HTML to come.
authorRichard Heck <rgheck@comcast.net>
Tue, 11 Jan 2011 23:18:56 +0000 (23:18 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 11 Jan 2011 23:18:56 +0000 (23:18 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37179 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathHull.cpp
src/mathed/InsetMathHull.h

index 062935197df642e698c4048c8af10703702cf8ce..8129508774b50f650424f646a49d7fba9b518c12 100644 (file)
@@ -243,7 +243,8 @@ void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype)
                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::normalize(NormalStream & os) const
 }
 
 
-void InsetMathHull::mathmlize(MathStream & os) const
-{
-       InsetMathGrid::mathmlize(os);
-}
-
-
 void InsetMathHull::infoize(odocstream & os) const
 {
        os << "Type: " << hullName(type_);
@@ -1915,6 +1910,51 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
 }
 
 
+// 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 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
                odocstringstream os;
                MathStream ms(os);
                try {
-                       InsetMathGrid::mathmlize(ms);
+                       mathmlize(ms);
                        success = true;
                } catch (MathExportException const &) {}
                if (success) {
index 2fd936916af9a34837b4c90034ec1017992edc0e..6635d8be997ea41aeca44a57dc7a4288958b1f41 100644 (file)
@@ -108,8 +108,6 @@ public:
        ///
        void write(WriteStream & os) const;
        ///
-       void mathmlize(MathStream &) const;
-       ///
        void normalize(NormalStream &) const;
        ///
        void infoize(odocstream & os) const;
@@ -130,6 +128,8 @@ public:
        int docbook(odocstream &, OutputParams const &) const;
        ///
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       ///
+       void mathmlize(MathStream &) const;
        /// 
        void toString(odocstream &) const;
        ///