Fix MathML output for MathBox, as suggested in the FIXME.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32711 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-12-31 19:49:29 +00:00
parent 31d6e4a9fc
commit 19cd5f0e82
4 changed files with 34 additions and 22 deletions

View File

@ -54,7 +54,6 @@ Math
isues, and not all the insets work. Here are the ones I know still need work: isues, and not all the insets work. Here are the ones I know still need work:
- AMSArray - AMSArray
- Array - Array
- Box
- Cases - Cases
- Diff: Code exists, but I do not know if it is right. - Diff: Code exists, but I do not know if it is right.
- Binom (in Frac): None of these tags exist in MathML 2.0. We'll - Binom (in Frac): None of these tags exist in MathML 2.0. We'll

View File

@ -54,12 +54,8 @@ void InsetMathBox::normalize(NormalStream & os) const
void InsetMathBox::mathmlize(MathStream & ms) const void InsetMathBox::mathmlize(MathStream & ms) const
{ {
// FIXME This doesn't actually work yet. We need to be able to signal SetMode textmode(ms, true);
// that we are in text mode and then just call ms << cell(0). So we ms << cell(0);
// need something like ModeSpecifier for MathStream.
ms << MTag("mtext");
ms.os() << cell(0);
ms << ETag("mtext");
} }

View File

@ -337,22 +337,35 @@ MathStream & operator<<(MathStream & ms, docstring const & s)
} }
SetMode::SetMode(MathStream & os, bool text)
: os_(os)
{
init(text, from_ascii(""));
}
SetMode::SetMode(MathStream & os, bool text, docstring attrs) SetMode::SetMode(MathStream & os, bool text, docstring attrs)
: os_(os) : os_(os)
{ {
was_text_ = os.inText(); init(text, attrs);
}
void SetMode::init(bool text, docstring attrs)
{
was_text_ = os_.inText();
if (was_text_) if (was_text_)
os << "</mtext>"; os_ << "</mtext>";
if (text) { if (text) {
os.setTextMode(); os_.setTextMode();
os << "<mtext"; os_ << "<mtext";
if (!attrs.empty()) if (!attrs.empty())
os << " " << attrs; os_ << " " << attrs;
os << ">"; os_ << ">";
} else { } else {
if (!attrs.empty()) if (!attrs.empty())
os << "<mstyle " << attrs << ">"; os_ << "<mstyle " << attrs << ">";
os.setMathMode(); os_.setMathMode();
} }
} }

View File

@ -263,13 +263,13 @@ public:
void defer(std::string const &); void defer(std::string const &);
/// ///
docstring deferred() const; docstring deferred() const;
///
bool inText() const { return in_text_; }
private:
/// ///
void setTextMode() { in_text_ = true; } void setTextMode() { in_text_ = true; }
/// ///
void setMathMode() { in_text_ = false; } void setMathMode() { in_text_ = false; }
///
bool inText() const { return in_text_; }
private:
/// ///
odocstream & os_; odocstream & os_;
/// ///
@ -282,6 +282,8 @@ private:
bool in_text_; bool in_text_;
/// ///
odocstringstream deferred_; odocstringstream deferred_;
///
friend class SetMode;
}; };
/// ///
@ -307,11 +309,13 @@ class SetMode {
public: public:
/// ///
explicit SetMode(MathStream & os, bool text, docstring attrs); explicit SetMode(MathStream & os, bool text, docstring attrs);
// not clear yet precisely what we need... ///
// explicit SetMode(MathStream & os, bool text); explicit SetMode(MathStream & os, bool text);
/// ///
~SetMode(); ~SetMode();
private: private:
///
void init(bool, docstring);
/// ///
MathStream & os_; MathStream & os_;
/// ///