Fix some issues with textmode. We'll let SetMode() handle as much of

this as possible for us.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32708 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-12-31 19:35:56 +00:00
parent 8990b1d0ee
commit 3915c2d01a
4 changed files with 47 additions and 27 deletions

View 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>";
}
}

View 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");
}
}

View 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();
}
}
//////////////////////////////////////////////////////////////////////

View 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_;