]> git.lyx.org Git - lyx.git/commitdiff
Fix some issues with textmode. We'll let SetMode() handle as much of
authorRichard Heck <rgheck@comcast.net>
Thu, 31 Dec 2009 19:35:56 +0000 (19:35 +0000)
committerRichard Heck <rgheck@comcast.net>
Thu, 31 Dec 2009 19:35:56 +0000 (19:35 +0000)
this as possible for us.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32708 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathFont.cpp
src/mathed/MathExtern.cpp
src/mathed/MathStream.cpp
src/mathed/MathStream.h

index 5909c14c9bd630e8d153b8814fcc3ec8b4f1198c..35f58c00f3eff877562b2ac6c9c9faeb4045b9fc 100644 (file)
@@ -127,25 +127,22 @@ void InsetMathFont::mathmlize(MathStream & os) const
        else if (tag == "mathcal")
                variant == "script";
        else if (tag == "mathit" || tag == "textsl"
-                || tag == "emph")
+                || tag == "emph" || tag == "textit")
                variant = "italic";
-       else if (tag == "mathsf" || tag == "textit"
-                || tag == "textsf")
+       else if (tag == "mathsf" || tag == "textsf")
                variant = "sans-serif";
        else if (tag == "mathtt" || tag == "texttt")
                variant = "monospace";
        // no support at present for textipa, textsc, noun
        
-       // FIXME We need some kind of "mode tracker", so we can
-       // just output verbatim text in some cases.
        docstring const beg = (tag.size() < 4) ? from_ascii("") : tag.substr(0, 4);
        bool const textmode = (beg == "text");
        if (!variant.empty()) {
-               os << "<mstyle mathvariant='" << from_utf8(variant) << "'>";
-               SetMode sm(os, textmode);
+               docstring const attrs = from_ascii("mathvariant='" + variant + "'");
+               SetMode sm(os, textmode, attrs);
+               os << cell(0);
+       } else
                os << cell(0);
-               os << "</mstyle>";
-       }
 }
 
 
index 2e43c117198d115d48596256589fcb045034cea6..afeba3ebe2519ba1fb89ca57a4464ed2f0e698ce 100644 (file)
@@ -1423,10 +1423,12 @@ void mathmlize(MathData const & dat, MathStream & os)
        } else if (ar.size() == 1)
                os << ar.front();
        else {
-               os << (os.inText() ? MTag("mtext") : MTag("mrow"));
+               if (!os.inText())
+                       os << MTag("mrow");
                for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
                        (*it)->mathmlize(os);
-               os << (os.inText() ? ETag("mtext") : ETag("mrow"));
+               if (!os.inText())
+                       os << ETag("mrow");
        }
 }
 
index a638052a87c7a3063c83f0a6ce064395f19449a3..81a89dc6d3af7e28c74512306408d36c4ada75fa 100644 (file)
@@ -337,6 +337,39 @@ MathStream & operator<<(MathStream & ms, docstring const & s)
 }
 
 
+SetMode::SetMode(MathStream & os, bool text, docstring attrs)
+               : os_(os)
+{
+       was_text_ = os.inText();
+       if (was_text_)
+               os << "</mtext>";
+       if (text) {
+               os.setTextMode();
+               os << "<mtext";
+               if (!attrs.empty())
+                       os << " " << attrs;
+               os << ">";
+       } else {
+               if (!attrs.empty())
+                       os << "<mstyle " << attrs << ">";
+               os.setMathMode();
+       }
+}
+
+
+SetMode::~SetMode()
+{
+       if (os_.inText())
+               os_ << "</mtext>";
+       if (was_text_) {
+               os_.setTextMode();
+               os_ << "<mtext>";
+       } else {
+               os_.setMathMode();
+       }
+}
+
+
 //////////////////////////////////////////////////////////////////////
 
 
index 8dc9c4628da69595636616c9f96a1dd9ffe9fdc0..df97ce303a7d73aaeb1d92ccda7009ad865e20e5 100644 (file)
@@ -306,23 +306,11 @@ MathStream & operator<<(MathStream &, ETag const &);
 class SetMode {
 public:
        ///
-       explicit SetMode(MathStream & os, bool text)
-               : os_(os)
-       {
-               was_text_ = os.inText();
-               if (text)
-                       os.setTextMode();
-               else
-                       os.setMathMode();
-       }
+       explicit SetMode(MathStream & os, bool text, docstring attrs);
+       // not clear yet precisely what we need...
+       // explicit SetMode(MathStream & os, bool text);
        ///
-       ~SetMode()
-       {
-               if (was_text_)
-                       os_.setTextMode();
-               else
-                       os_.setMathMode();
-       }
+       ~SetMode();
 private:
        ///
        MathStream & os_;