X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FMathStream.cpp;h=cf3fb51f1f0ba484be79ef9dc7567570b20c3afd;hb=28be7d552f62cc02fa86d7f79201d089bfb2d7b5;hp=7a13955779b6028438f3f6dbc15f2f405d2020d3;hpb=ff79d11bb78ac7ed0b912be3224ce450fbabdcfa;p=lyx.git diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp index 7a13955779..cf3fb51f1f 100644 --- a/src/mathed/MathStream.cpp +++ b/src/mathed/MathStream.cpp @@ -12,11 +12,15 @@ #include "MathStream.h" +#include "MathFactory.h" #include "MathData.h" #include "MathExtern.h" -#include "support/textutils.h" +#include "TexRow.h" + #include "support/docstring.h" +#include "support/RefChanger.h" +#include "support/textutils.h" #include #include @@ -121,20 +125,13 @@ WriteStream & operator<<(WriteStream & ws, docstring const & s) } -WriteStream::WriteStream(odocstream & os, bool fragile, bool latex, OutputType output, - Encoding const * encoding) +WriteStream::WriteStream(otexrowstream & os, bool fragile, bool latex, + OutputType output, Encoding const * encoding) : os_(os), fragile_(fragile), firstitem_(false), latex_(latex), - output_(output), pendingspace_(false), pendingbrace_(false), - textmode_(false), locked_(0), ascii_(0), canbreakline_(true), - line_(0), encoding_(encoding) -{} - - -WriteStream::WriteStream(odocstream & os) - : os_(os), fragile_(false), firstitem_(false), latex_(false), - output_(wsDefault), pendingspace_(false), pendingbrace_(false), - textmode_(false), locked_(0), ascii_(0), canbreakline_(true), - line_(0), encoding_(0) + output_(output), insidemacro_(false), pendingspace_(false), + pendingbrace_(false), textmode_(false), locked_(0), ascii_(0), + canbreakline_(true), mathsout_(false), ulemcmd_(NONE), line_(0), + encoding_(encoding), row_entry_(TexRow::row_none) {} @@ -183,6 +180,20 @@ void WriteStream::asciiOnly(bool ascii) } +Changer WriteStream::changeRowEntry(TexRow::RowEntry entry) +{ + return make_change(row_entry_, entry); +} + + +bool WriteStream::startOuterRow() +{ + if (TexRow::isNone(row_entry_)) + return false; + return texrow().start(row_entry_); +} + + WriteStream & operator<<(WriteStream & ws, MathAtom const & at) { at->write(ws); @@ -442,55 +453,16 @@ HtmlStream & operator<<(HtmlStream & ms, docstring const & s) SetMode::SetMode(MathStream & os, bool text) - : os_(os), opened_(false) -{ - init(text, ""); -} - - -SetMode::SetMode(MathStream & os, bool text, string const & attrs) - : os_(os), opened_(false) -{ - init(text, attrs); -} - - -void SetMode::init(bool text, string const & attrs) + : os_(os) { was_text_ = os_.inText(); - if (was_text_) - os_ << ""; - if (text) { - os_.setTextMode(); - os_ << ""; - opened_ = true; - } else { - if (!attrs.empty()) { - os_ << ""; - opened_ = true; - } - os_.setMathMode(); - } + os_.setTextMode(text); } SetMode::~SetMode() { - if (opened_) { - if (os_.inText()) - os_ << ""; - else - os_ << ""; - } - if (was_text_) { - os_.setTextMode(); - os_ << ""; - } else { - os_.setMathMode(); - } + os_.setTextMode(was_text_); } @@ -498,42 +470,16 @@ SetMode::~SetMode() SetHTMLMode::SetHTMLMode(HtmlStream & os, bool text) - : os_(os), opened_(false) -{ - init(text, ""); -} - - -SetHTMLMode::SetHTMLMode(HtmlStream & os, bool text, string attrs) - : os_(os), opened_(true) -{ - init(text, attrs); -} - - -void SetHTMLMode::init(bool text, string const & attrs) + : os_(os) { was_text_ = os_.inText(); - if (text) { - os_.setTextMode(); - if (attrs.empty()) - os_ << MTag("span"); - else - os_ << MTag("span", attrs); - opened_ = true; - } else - os_.setMathMode(); + os_.setTextMode(text); } SetHTMLMode::~SetHTMLMode() { - if (opened_) - os_ << ETag("span"); - if (was_text_) - os_.setTextMode(); - else - os_.setMathMode(); + os_.setTextMode(was_text_); } @@ -752,4 +698,25 @@ OctaveStream & operator<<(OctaveStream & os, string const & s) } +docstring convertDelimToXMLEscape(docstring const & name) +{ + if (name.size() == 1) { + char_type const c = name[0]; + if (c == '<') + return from_ascii("<"); + else if (c == '>') + return from_ascii(">"); + else + return name; + } + MathWordList const & words = mathedWordList(); + MathWordList::const_iterator it = words.find(name); + if (it != words.end()) { + docstring const escape = it->second.xmlname; + return escape; + } + LYXERR0("Unable to find `" << name <<"' in the mathWordList."); + return name; +} + } // namespace lyx