2 * \file InsetMathMBox.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathMBox.h"
15 #include "MathMLStream.h"
17 #include "BufferView.h"
19 #include "bufferparams.h"
22 #include "metricsinfo.h"
23 #include "output_latex.h"
24 #include "outputparams.h"
25 #include "paragraph.h"
28 using lyx::odocstream;
34 InsetMathMBox::InsetMathMBox(BufferView & bv)
35 : text_(&bv), bv_(&bv)
37 text_.paragraphs().clear();
38 text_.paragraphs().push_back(Paragraph());
39 text_.paragraphs().back().
40 layout(bv.buffer()->params().getLyXTextClass().defaultLayout());
41 text_.redoParagraph(0);
45 auto_ptr<InsetBase> InsetMathMBox::doClone() const
47 return auto_ptr<InsetBase>(new InsetMathMBox(*this));
51 void InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
53 text_.metrics(mi, dim);
59 void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
61 text_.draw(pi, x + 1, y);
62 drawMarkers(pi, x, y);
66 void InsetMathMBox::write(WriteStream & ws) const
71 OutputParams runparams;
72 latexParagraphs(*bv_->buffer(), text_.paragraphs(),
73 ws.os(), texrow, runparams);
74 ws.addlines(texrow.rows());
78 std::ostringstream os;
79 text_.write(*bv_->buffer(), os);
80 ws.os() << lyx::from_utf8(os.str());
86 int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
87 OutputParams const & runparams) const
91 latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
97 void InsetMathMBox::doDispatch(LCursor & cur, FuncRequest & cmd)
99 text_.dispatch(cur, cmd);
103 LyXText * InsetMathMBox::getText(int) const
109 void InsetMathMBox::cursorPos(BufferView const & bv,
110 CursorSlice const & sl, bool boundary, int & x, int & y) const
112 x = text_.cursorX(sl, boundary);
113 y = text_.cursorY(sl, boundary);
117 void InsetMathMBox::drawSelection(PainterInfo & pi, int x, int y) const
119 text_.drawSelection(pi, x, y);