]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathMBox.cpp
Fix #7549, due to a problem in exporting to plaintext a
[lyx.git] / src / mathed / InsetMathMBox.cpp
index 698eedcf6712a63cff37d2a156c848f3b0ba23e7..8b38755f0485eb9d98ecc698596837d64fdd7019 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author André Pönitz
+ * \author André Pönitz
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -18,7 +18,6 @@
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "Cursor.h"
-#include "debug.h"
 #include "MetricsInfo.h"
 #include "output_latex.h"
 #include "OutputParams.h"
 #include "TexRow.h"
 #include "TextMetrics.h"
 
-namespace lyx {
+#include "support/debug.h"
 
-//using support::odocstream;
+using namespace std;
 
-using std::auto_ptr;
-using std::endl;
+namespace lyx {
 
 
-InsetMathMBox::InsetMathMBox()
+InsetMathMBox::InsetMathMBox(Buffer * buffer) : InsetMath(buffer), text_(buffer)
 {
        text_.paragraphs().clear();
        text_.paragraphs().push_back(Paragraph());
 }
 
 
-InsetMathMBox::InsetMathMBox(Layout_ptr const & layout)
+InsetMathMBox::InsetMathMBox(Buffer * buffer, Layout const & layout)
+       : InsetMath(buffer), text_(buffer)
 {
        text_.paragraphs().clear();
        text_.paragraphs().push_back(Paragraph());
-       text_.paragraphs().back().layout(layout);
+       text_.paragraphs().back().setLayout(layout);
 }
 
 
-auto_ptr<Inset> InsetMathMBox::doClone() const
+Inset * InsetMathMBox::clone() const
 {
-       return auto_ptr<Inset>(new InsetMathMBox(*this));
+       return new InsetMathMBox(*this);
 }
 
 
-bool InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       TextMetrics & tm = mi.base.bv->textMetrics(&text_);
+       TextMetrics & tm = mi.base.bv->textMetrics(&text_.text());
        tm.metrics(mi, dim);
        metricsMarkers2(dim);
-       if (dim_ == dim)
-               return false;
-       dim_ = dim;
-       return true;
 }
 
 
 void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
 {
-       text_.draw(pi, x + 1, y);
+       pi.base.bv->textMetrics(&text_.text()).draw(pi, x + 1, y);
        drawMarkers(pi, x, y);
 }
 
 
-void InsetMathMBox::write(Buffer const & buf, WriteStream & ws) const
+void InsetMathMBox::write(WriteStream & ws) const
 {
        if (ws.latex()) {
                ws << "\\mbox{\n";
                TexRow texrow;
-               OutputParams runparams(&buf.params().encoding());
-               latexParagraphs(buf, text_.paragraphs(), ws.os(), texrow, runparams);
+               OutputParams runparams(&buffer().params().encoding());
+               otexstream os(ws.os(), texrow);
+               latexParagraphs(buffer(), text_.text(), os, runparams);
                ws.addlines(texrow.rows());
                ws << "}";
        } else {
                ws << "\\mbox{\n";
-               std::ostringstream os;
-               text_.write(buf, os);
+               ostringstream os;
+               text_.text().write(os);
                ws.os() << from_utf8(os.str());
                ws << "}";
        }
 }
 
 
-int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
-                       OutputParams const & runparams) const
+void InsetMathMBox::latex(otexstream & os, OutputParams const & runparams) const
 {
        os << "\\mbox{\n";
-       TexRow texrow;
-       latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
+       latexParagraphs(buffer(), text_.text(), os, runparams);
        os << "}";
-       return texrow.rows();
 }
 
 
 void InsetMathMBox::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
-       text_.dispatch(cur, cmd);
+       text_.text().dispatch(cur, cmd);
 }
 
 
-LyXText * InsetMathMBox::getText(int) const
+Text * InsetMathMBox::getText(int) const
 {
-       return &text_;
+       return &text_.text();
 }
 
 
 void InsetMathMBox::cursorPos(BufferView const & bv,
                CursorSlice const & sl, bool boundary, int & x, int & y) const
 {
-       x = text_.cursorX(bv, sl, boundary);
-       y = text_.cursorY(bv, sl, boundary);
+       x = bv.textMetrics(&text_.text()).cursorX(sl, boundary);
+       y = bv.textMetrics(&text_.text()).cursorY(sl, boundary);
 }
 
 
-void InsetMathMBox::drawSelection(PainterInfo & pi, int x, int y) const
-{
-       text_.drawSelection(pi, x, y);
+void InsetMathMBox::mathmlize(MathStream & ms) const
+{      
+       SetMode textmode(ms, true);
+       ms << cell(0);
 }
 
+void InsetMathMBox::htmlize(HtmlStream & ms) const
+{      
+       SetHTMLMode textmode(ms, true);
+       ms << cell(0);
+}
 
 } // namespace lyx