]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathStream.cpp
MathML for MathBox and such.
[lyx.git] / src / mathed / MathStream.cpp
index ffc91c4f42667cd611d2fc749cda76f4b9af7630..c9f7ef54a50df772ff4164f936c548ed8a04d765 100644 (file)
@@ -338,14 +338,14 @@ MathStream & operator<<(MathStream & ms, docstring const & s)
 
 
 SetMode::SetMode(MathStream & os, bool text)
-       : os_(os)
+       : os_(os), opened_(false)
 {
        init(text, from_ascii(""));
 }
 
 
 SetMode::SetMode(MathStream & os, bool text, docstring attrs)
-       : os_(os)
+       : os_(os), opened_(false)
 {
        init(text, attrs);
 }
@@ -362,9 +362,12 @@ void SetMode::init(bool text, docstring attrs)
                if (!attrs.empty())
                        os_ << " " << attrs;
                os_ << ">";
+               opened_ = true;
        } else {
-               if (!attrs.empty())
+               if (!attrs.empty()) {
                        os_ << "<mstyle " << attrs << ">";
+                       opened_ = true;
+               }
                os_.setMathMode();
        }
 }
@@ -372,8 +375,12 @@ void SetMode::init(bool text, docstring attrs)
 
 SetMode::~SetMode()
 {
-       if (os_.inText())
-               os_ << "</mtext>";
+       if (opened_) {
+               if (os_.inText())
+                       os_ << "</mtext>";
+               else
+                       os_ << "</mstyle>";
+       }
        if (was_text_) {
                os_.setTextMode();
                os_ << "<mtext>";