#include "MathData.h"
#include "MathExtern.h"
-#include "support/textutils.h"
#include "support/docstring.h"
+#include "support/RefChanger.h"
+#include "support/textutils.h"
#include <algorithm>
#include <cstring>
}
ws.os() << s.substr(first);
int lf = 0;
- char_type lastchar;
+ char_type lastchar = 0;
docstring::const_iterator dit = s.begin() + first;
docstring::const_iterator end = s.end();
for (; dit != end; ++dit) {
}
-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)
+ line_(0), encoding_(encoding), row_entry_(TexRow::row_none)
{}
}
+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);
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_ << "</mtext>";
- if (text) {
- os_.setTextMode();
- os_ << "<mtext";
- if (!attrs.empty())
- os_ << " " << from_utf8(attrs);
- os_ << ">";
- opened_ = true;
- } else {
- if (!attrs.empty()) {
- os_ << "<mstyle " << from_utf8(attrs) << ">";
- opened_ = true;
- }
- os_.setMathMode();
- }
+ os_.setTextMode(text);
}
SetMode::~SetMode()
{
- if (opened_) {
- if (os_.inText())
- os_ << "</mtext>";
- else
- os_ << "</mstyle>";
- }
- if (was_text_) {
- os_.setTextMode();
- os_ << "<mtext>";
- } else {
- os_.setMathMode();
- }
+ os_.setTextMode(was_text_);
}
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_);
}