2 * \file math_hullinset.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 "math_charinset.h"
14 #include "math_data.h"
15 #include "math_extern.h"
16 #include "math_hullinset.h"
17 #include "math_mathmlstream.h"
18 #include "math_streamstr.h"
19 #include "math_support.h"
21 #include "BufferView.h"
22 #include "CutAndPaste.h"
24 #include "LaTeXFeatures.h"
27 #include "dispatchresult.h"
28 #include "funcrequest.h"
32 #include "outputparams.h"
33 #include "textpainter.h"
36 #include "insets/render_preview.h"
38 #include "frontends/Alert.h"
40 #include "graphics/PreviewImage.h"
41 #include "graphics/PreviewLoader.h"
43 #include "support/std_sstream.h"
45 #include <boost/bind.hpp>
47 using lyx::cap::grabAndEraseSelection;
54 using std::istringstream;
56 using std::ostringstream;
64 int getCols(string const & type)
66 if (type == "eqnarray")
70 if (type == "flalign")
72 if (type == "alignat")
74 if (type == "xalignat")
76 if (type == "xxalignat")
82 // returns position of first relation operator in the array
83 // used for "intelligent splitting"
84 size_t firstRelOp(MathArray const & ar)
86 for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
88 return it - ar.begin();
93 char const * star(bool numbered)
95 return numbered ? "" : "*";
99 int typecode(string const & s)
101 if (s == "none") return 0;
102 if (s == "simple") return 1;
103 if (s == "equation") return 2;
104 if (s == "eqnarray") return 3;
105 if (s == "align") return 4;
106 if (s == "alignat") return 5;
107 if (s == "xalignat") return 6;
108 if (s == "xxalignat") return 7;
109 if (s == "multline") return 8;
110 if (s == "gather") return 9;
111 if (s == "flalign") return 10;
112 lyxerr << "unknown hull type '" << s << "'" << endl;
116 bool smaller(string const & s, string const & t)
118 return typecode(s) < typecode(t);
122 } // end anon namespace
126 MathHullInset::MathHullInset()
127 : MathGridInset(1, 1), type_("none"), nonum_(1), label_(1),
128 preview_(new RenderPreview(this))
130 //lyxerr << "sizeof MathInset: " << sizeof(MathInset) << endl;
131 //lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
132 //lyxerr << "sizeof MathCharInset: " << sizeof(MathCharInset) << endl;
133 //lyxerr << "sizeof LyXFont: " << sizeof(LyXFont) << endl;
138 MathHullInset::MathHullInset(string const & type)
139 : MathGridInset(getCols(type), 1), type_(type), nonum_(1), label_(1),
140 preview_(new RenderPreview(this))
146 MathHullInset::MathHullInset(MathHullInset const & other)
147 : MathGridInset(other),
148 type_(other.type_), nonum_(other.nonum_), label_(other.label_),
149 preview_(new RenderPreview(this))
153 MathHullInset::~MathHullInset()
157 auto_ptr<InsetBase> MathHullInset::clone() const
159 return auto_ptr<InsetBase>(new MathHullInset(*this));
163 void MathHullInset::operator=(MathHullInset const & other)
167 *static_cast<MathGridInset*>(this) = MathGridInset(other);
169 nonum_ = other.nonum_;
170 label_ = other.label_;
171 preview_.reset(new RenderPreview(*other.preview_, this));
175 MathInset::mode_type MathHullInset::currentMode() const
178 return UNDECIDED_MODE;
179 // definitely math mode ...
184 bool MathHullInset::idxFirst(LCursor & cur) const
192 bool MathHullInset::idxLast(LCursor & cur) const
194 cur.idx() = nargs() - 1;
195 cur.pos() = cur.lastpos();
200 char MathHullInset::defaultColAlign(col_type col)
202 if (type_ == "eqnarray")
204 if (typecode(type_) >= typecode("align"))
205 return "rl"[col & 1];
210 int MathHullInset::defaultColSpace(col_type col)
212 if (type_ == "align" || type_ == "alignat")
214 if (type_ == "xalignat")
215 return (col & 1) ? 20 : 0;
216 if (type_ == "xxalignat" || type_ == "flalign")
217 return (col & 1) ? 40 : 0;
222 char const * MathHullInset::standardFont() const
225 return "lyxnochange";
230 void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
232 BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer());
234 bool use_preview = false;
235 if (!editing(mi.base.bv) &&
236 RenderPreview::status() == LyXRC::PREVIEW_ON) {
237 lyx::graphics::PreviewImage const * pimage =
238 preview_->getPreviewImage(*mi.base.bv->buffer());
239 use_preview = pimage && pimage->image();
243 preview_->metrics(mi, dim);
244 // insert a one pixel gap in front of the formula
252 FontSetChanger dummy1(mi.base, standardFont());
253 StyleChanger dummy2(mi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
255 // let the cells adjust themselves
256 MathGridInset::metrics(mi, dim);
263 if (numberedType()) {
264 FontSetChanger dummy(mi.base, "mathbf");
266 for (row_type row = 0; row < nrows(); ++row)
267 l = max(l, mathed_string_width(mi.base.font, nicelabel(row)));
273 // make it at least as high as the current font
276 math_font_max_dim(mi.base.font, asc, des);
277 dim.asc = max(dim.asc, asc);
278 dim.des = max(dim.des, des);
284 void MathHullInset::draw(PainterInfo & pi, int x, int y) const
286 BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer());
288 bool use_preview = false;
289 if (!editing(pi.base.bv) &&
290 RenderPreview::status() == LyXRC::PREVIEW_ON) {
291 lyx::graphics::PreviewImage const * pimage =
292 preview_->getPreviewImage(*pi.base.bv->buffer());
293 use_preview = pimage && pimage->image();
297 // one pixel gap in front
298 preview_->draw(pi, x + 1, y);
299 setPosCache(pi, x, y);
303 FontSetChanger dummy1(pi.base, standardFont());
304 StyleChanger dummy2(pi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
305 MathGridInset::draw(pi, x + 1, y);
307 if (numberedType()) {
308 int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
309 for (row_type row = 0; row < nrows(); ++row) {
310 int const yy = y + rowinfo_[row].offset_;
311 FontSetChanger dummy(pi.base, "mathrm");
312 drawStr(pi, pi.base.font, xx, yy, nicelabel(row));
315 setPosCache(pi, x, y);
319 void MathHullInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
322 MathGridInset::metricsT(mi, dim);
325 WriteStream wi(os, false, true);
327 dim.wid = os.str().size();
334 void MathHullInset::drawT(TextPainter & pain, int x, int y) const
337 MathGridInset::drawT(pain, x, y);
340 WriteStream wi(os, false, true);
342 pain.draw(x, y, os.str().c_str());
349 string const latex_string(MathHullInset const & inset)
352 WriteStream wi(ls, false, false);
360 void MathHullInset::addPreview(lyx::graphics::PreviewLoader & ploader) const
362 string const snippet = latex_string(*this);
363 preview_->addPreview(snippet, ploader);
367 void MathHullInset::notifyCursorLeaves(LCursor & cur)
369 if (RenderPreview::status() != LyXRC::PREVIEW_ON)
372 Buffer const & buffer = cur.buffer();
373 string const snippet = latex_string(*this);
374 preview_->addPreview(snippet, buffer);
375 preview_->startLoading(buffer);
379 string MathHullInset::label(row_type row) const
381 row_type n = nrows();
382 BOOST_ASSERT(row < n);
387 void MathHullInset::label(row_type row, string const & label)
389 //lyxerr << "setting label '" << label << "' for row " << row << endl;
394 void MathHullInset::numbered(row_type row, bool num)
400 bool MathHullInset::numbered(row_type row) const
406 bool MathHullInset::ams() const
410 type_ == "flalign" ||
411 type_ == "multline" ||
413 type_ == "alignat" ||
414 type_ == "xalignat" ||
415 type_ == "xxalignat";
419 bool MathHullInset::display() const
421 return type_ != "simple" && type_ != "none";
425 void MathHullInset::getLabelList(Buffer const &, vector<string> & labels) const
427 for (row_type row = 0; row < nrows(); ++row)
428 if (!label_[row].empty() && nonum_[row] != 1)
429 labels.push_back(label_[row]);
433 bool MathHullInset::numberedType() const
437 if (type_ == "simple")
439 if (type_ == "xxalignat")
441 for (row_type row = 0; row < nrows(); ++row)
448 void MathHullInset::validate(LaTeXFeatures & features) const
451 features.require("amsmath");
454 // Validation is necessary only if not using AMS math.
455 // To be safe, we will always run mathedvalidate.
456 //if (features.amsstyle)
459 features.require("boldsymbol");
460 //features.binom = true;
462 MathGridInset::validate(features);
466 void MathHullInset::header_write(WriteStream & os) const
468 bool n = numberedType();
473 else if (type_ == "simple") {
479 else if (type_ == "equation") {
481 os << "\\begin{equation" << star(n) << "}\n";
486 else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
487 || type_ == "gather" || type_ == "multline")
488 os << "\\begin{" << type_ << star(n) << "}\n";
490 else if (type_ == "alignat" || type_ == "xalignat")
491 os << "\\begin{" << type_ << star(n) << '}'
492 << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
494 else if (type_ == "xxalignat")
495 os << "\\begin{" << type_ << '}'
496 << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
499 os << "\\begin{unknown" << star(n) << '}';
503 void MathHullInset::footer_write(WriteStream & os) const
505 bool n = numberedType();
510 else if (type_ == "simple")
513 else if (type_ == "equation")
515 os << "\\end{equation" << star(n) << "}\n";
519 else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
520 || type_ == "alignat" || type_ == "xalignat"
521 || type_ == "gather" || type_ == "multline")
522 os << "\\end{" << type_ << star(n) << "}\n";
524 else if (type_ == "xxalignat")
525 os << "\\end{" << type_ << "}\n";
528 os << "\\end{unknown" << star(n) << '}';
532 bool MathHullInset::colChangeOK() const
535 type_ == "align" || type_ == "flalign" ||type_ == "alignat" ||
536 type_ == "xalignat" || type_ == "xxalignat";
540 void MathHullInset::addRow(row_type row)
542 nonum_.insert(nonum_.begin() + row + 1, !numberedType());
543 label_.insert(label_.begin() + row + 1, string());
544 MathGridInset::addRow(row);
548 void MathHullInset::swapRow(row_type row)
552 if (row + 1 == nrows())
554 swap(nonum_[row], nonum_[row + 1]);
555 swap(label_[row], label_[row + 1]);
556 MathGridInset::swapRow(row);
560 void MathHullInset::delRow(row_type row)
564 MathGridInset::delRow(row);
565 nonum_.erase(nonum_.begin() + row);
566 label_.erase(label_.begin() + row);
570 void MathHullInset::addCol(col_type col)
573 MathGridInset::addCol(col);
575 lyxerr << "Can't change number of columns in '" << type_ << "'" << endl;
579 void MathHullInset::delCol(col_type col)
582 MathGridInset::delCol(col);
584 lyxerr << "Can't change number of columns in '" << type_ << "'" << endl;
588 string MathHullInset::nicelabel(row_type row) const
592 if (label_[row].empty())
593 return string("(#)");
594 return '(' + label_[row] + ')';
598 void MathHullInset::glueall()
601 for (idx_type i = 0; i < nargs(); ++i)
603 *this = MathHullInset("simple");
609 string const & MathHullInset::getType() const
615 void MathHullInset::setType(string const & type)
623 void MathHullInset::mutate(string const & newtype)
625 lyxerr << "mutating from '" << type_ << "' to '" << newtype << "'" << endl;
627 // we try to move along the chain
628 // none <-> simple <-> equation <-> eqnarray
630 if (newtype == "dump") {
634 else if (newtype == type_) {
638 else if (type_ == "none") {
644 else if (type_ == "simple") {
645 if (newtype == "none") {
654 else if (type_ == "equation") {
655 if (smaller(newtype, type_)) {
658 } else if (newtype == "eqnarray") {
659 MathGridInset::addCol(1);
660 MathGridInset::addCol(1);
662 // split it "nicely" on the firest relop
663 pos_type pos = firstRelOp(cell(0));
664 cell(1) = MathArray(cell(0).begin() + pos, cell(0).end());
665 cell(0).erase(pos, cell(0).size());
667 if (cell(1).size()) {
668 cell(2) = MathArray(cell(1).begin() + 1, cell(1).end());
669 cell(1).erase(1, cell(1).size());
673 } else if (newtype == "multline" || newtype == "gather") {
677 MathGridInset::addCol(1);
679 pos_type pos = firstRelOp(cell(0));
681 cell(0).erase(pos, cell(0).size());
682 cell(1).erase(0, pos);
688 else if (type_ == "eqnarray") {
689 if (smaller(newtype, type_)) {
690 // set correct (no)numbering
691 bool allnonum = true;
692 for (row_type row = 0; row < nrows(); ++row)
696 // set first non-empty label
698 for (row_type row = 0; row < nrows(); ++row) {
699 if (!label_[row].empty()) {
706 nonum_[0] = allnonum;
709 } else { // align & Co.
710 for (row_type row = 0; row < nrows(); ++row) {
711 idx_type c = 3 * row + 1;
712 cell(c).append(cell(c + 1));
714 MathGridInset::delCol(2);
720 else if (type_ == "align") {
721 if (smaller(newtype, type_)) {
722 MathGridInset::addCol(1);
730 else if (type_ == "multline") {
731 if (newtype == "gather" || newtype == "align" ||
732 newtype == "xalignat" || newtype == "xxalignat" || newtype == "flalign")
734 else if (newtype == "eqnarray") {
735 MathGridInset::addCol(1);
736 MathGridInset::addCol(1);
739 lyxerr << "mutation from '" << type_
740 << "' to '" << newtype << "' not implemented" << endl;
744 else if (type_ == "gather") {
745 if (newtype == "multline") {
748 lyxerr << "mutation from '" << type_
749 << "' to '" << newtype << "' not implemented" << endl;
754 lyxerr << "mutation from '" << type_
755 << "' to '" << newtype << "' not implemented" << endl;
760 string MathHullInset::eolString(row_type row, bool fragile) const
763 if (numberedType()) {
764 if (!label_[row].empty() && !nonum_[row])
765 res += "\\label{" + label_[row] + '}';
766 if (nonum_[row] && (type_ != "multline"))
767 res += "\\nonumber ";
769 return res + MathGridInset::eolString(row, fragile);
773 void MathHullInset::write(WriteStream & os) const
776 MathGridInset::write(os);
781 void MathHullInset::normalize(NormalStream & os) const
783 os << "[formula " << type_ << ' ';
784 MathGridInset::normalize(os);
789 void MathHullInset::mathmlize(MathMLStream & os) const
791 MathGridInset::mathmlize(os);
795 void MathHullInset::infoize(ostream & os) const
797 os << "Type: " << type_;
801 void MathHullInset::check() const
803 BOOST_ASSERT(nonum_.size() == nrows());
804 BOOST_ASSERT(label_.size() == nrows());
808 void MathHullInset::doExtern(LCursor & cur, FuncRequest & func)
812 istringstream iss(func.argument.c_str());
813 iss >> lang >> extra;
818 #warning temporarily disabled
819 //if (cur.selection()) {
822 // lyxerr << "use selection: " << ar << endl;
823 // insert(pipeThroughExtern(lang, extra, ar));
829 eq.push_back(MathAtom(new MathCharInset('=')));
831 // go to first item in line
832 cur.idx() -= cur.idx() % ncols();
835 if (getType() == "simple") {
836 size_type pos = cur.cell().find_last(eq);
838 if (cur.inMathed() && cur.selection()) {
839 asArray(grabAndEraseSelection(cur), ar);
840 } else if (pos == cur.cell().size()) {
842 lyxerr << "use whole cell: " << ar << endl;
844 ar = MathArray(cur.cell().begin() + pos + 1, cur.cell().end());
845 lyxerr << "use partial cell form pos: " << pos << endl;
847 cur.cell().append(eq);
848 cur.cell().append(pipeThroughExtern(lang, extra, ar));
849 cur.pos() = cur.lastpos();
853 if (getType() == "equation") {
854 lyxerr << "use equation inset" << endl;
856 MathArray & ar = cur.cell();
857 lyxerr << "use cell: " << ar << endl;
861 cur.cell() = pipeThroughExtern(lang, extra, ar);
862 // move to end of line
863 cur.pos() = cur.lastpos();
868 lyxerr << "use eqnarray" << endl;
869 cur.idx() += 2 - cur.idx() % ncols();
871 MathArray ar = cur.cell();
872 lyxerr << "use cell: " << ar << endl;
874 #warning temporarily disabled
881 cur.cell() = pipeThroughExtern(lang, extra, ar);
882 cur.pos() = cur.lastpos();
887 void MathHullInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
889 switch (cmd.action) {
891 case LFUN_FINISHED_LEFT:
892 case LFUN_FINISHED_RIGHT:
893 case LFUN_FINISHED_UP:
894 case LFUN_FINISHED_DOWN:
895 MathGridInset::priv_dispatch(cur, cmd);
896 notifyCursorLeaves(cur);
899 case LFUN_BREAKPARAGRAPH:
904 if (type_ == "simple" || type_ == "equation") {
905 recordUndoInset(cur);
908 cur.pos() = cur.lastpos();
911 MathGridInset::priv_dispatch(cur, cmd);
914 case LFUN_MATH_NUMBER:
915 //lyxerr << "toggling all numbers" << endl;
917 recordUndoInset(cur);
918 bool old = numberedType();
919 if (type_ == "multline")
920 numbered(nrows() - 1, !old);
922 for (row_type row = 0; row < nrows(); ++row)
924 cur.message(old ? _("No number") : _("Number"));
928 case LFUN_MATH_NONUMBER:
930 recordUndoInset(cur);
931 row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
932 bool old = numbered(r);
933 cur.message(old ? _("No number") : _("Number"));
938 case LFUN_INSERT_LABEL: {
939 recordUndoInset(cur);
940 row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
941 string old_label = label(r);
942 string new_label = cmd.argument;
944 if (new_label.empty()) {
945 string const default_label =
946 (lyxrc.label_init_length >= 0) ? "eq:" : "";
947 pair<bool, string> const res = old_label.empty()
948 ? Alert::askForText(_("Enter new label to insert:"), default_label)
949 : Alert::askForText(_("Enter label:"), old_label);
950 new_label = lyx::support::trim(res.second);
953 if (!new_label.empty())
959 case LFUN_MATH_EXTERN:
960 recordUndoInset(cur);
964 case LFUN_MATH_MUTATE: {
965 recordUndoInset(cur);
966 row_type row = cur.row();
967 col_type col = cur.col();
968 mutate(cmd.argument);
969 cur.idx() = row * ncols() + col;
970 if (cur.idx() > cur.lastidx()) {
971 cur.idx() = cur.lastidx();
972 cur.pos() = cur.lastpos();
974 if (cur.pos() > cur.lastpos())
975 cur.pos() = cur.lastpos();
976 //cur.dispatched(FINISHED);
980 case LFUN_MATH_DISPLAY: {
981 recordUndoInset(cur);
982 mutate(type_ == "simple" ? "equation" : "simple");
984 cur.pos() = cur.lastpos();
985 //cur.dispatched(FINISHED);
990 MathGridInset::priv_dispatch(cur, cmd);
996 bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
997 FuncStatus & flag) const
999 switch (cmd.action) {
1000 case LFUN_BREAKLINE:
1001 case LFUN_MATH_NUMBER:
1002 case LFUN_MATH_NONUMBER:
1003 case LFUN_INSERT_LABEL:
1004 case LFUN_MATH_EXTERN:
1005 case LFUN_MATH_MUTATE:
1006 case LFUN_MATH_DISPLAY:
1010 return MathGridInset::getStatus(cur, cmd, flag);
1015 /////////////////////////////////////////////////////////////////////
1017 #include "math_arrayinset.h"
1018 #include "math_deliminset.h"
1019 #include "math_factory.h"
1020 #include "math_parser.h"
1021 #include "math_spaceinset.h"
1022 #include "ref_inset.h"
1024 #include "bufferview_funcs.h"
1025 #include "lyxtext.h"
1027 #include "frontends/LyXView.h"
1028 #include "frontends/Dialogs.h"
1030 #include "support/lstrings.h"
1031 #include "support/lyxlib.h"
1034 // simply scrap this function if you want
1035 void MathHullInset::mutateToText()
1038 // translate to latex
1040 latex(NULL, os, false, false);
1041 string str = os.str();
1044 LyXText * lt = view_->getLyXText();
1045 string::const_iterator cit = str.begin();
1046 string::const_iterator end = str.end();
1047 for (; cit != end; ++cit)
1048 view_->owner()->getIntl()->getTransManager().TranslateAndInsert(*cit, lt);
1051 //view_->owner()->dispatch(LFUN_ESCAPE);
1056 void MathHullInset::handleFont(LCursor & cur, string const & arg,
1057 string const & font)
1059 // this whole function is a hack and won't work for incremental font
1062 if (cur.inset().asMathInset()->name() == font)
1063 cur.handleFont(font);
1065 cur.handleNest(createMathInset(font));
1071 void MathHullInset::handleFont2(LCursor & cur, string const & arg)
1076 bv_funcs::string2font(arg, font, b);
1077 if (font.color() != LColor::inherit) {
1078 MathAtom at = createMathInset("color");
1079 asArray(lcolor.getGUIName(font.color()), at.nucleus()->cell(0));
1080 cur.handleNest(at, 1);
1085 void MathHullInset::edit(LCursor & cur, bool left)
1088 left ? idxFirst(cur) : idxLast(cur);
1092 string const MathHullInset::editMessage() const
1094 return _("Math editor mode");
1098 void MathHullInset::getCursorDim(int & asc, int & desc) const
1102 //math_font_max_dim(font_, asc, des);
1106 void MathHullInset::revealCodes(LCursor & cur) const
1108 if (!cur.inMathed())
1112 cur.message(os.str());
1114 // write something to the minibuffer
1115 // translate to latex
1119 string str = os.str();
1121 string::size_type pos = 0;
1123 for (string::iterator it = str.begin(); it != str.end(); ++it) {
1126 else if (*it == '\0') {
1128 pos = it - str.begin();
1134 res = res.substr(pos - 30);
1135 if (res.size() > 60)
1136 res = res.substr(0, 60);
1142 InsetBase::Code MathHullInset::lyxCode() const
1148 /////////////////////////////////////////////////////////////////////
1152 bool MathHullInset::searchForward(BufferView * bv, string const & str,
1155 #warning completely broken
1156 static MathHullInset * lastformula = 0;
1157 static CursorBase current = DocIterator(ibegin(nucleus()));
1158 static MathArray ar;
1159 static string laststr;
1161 if (lastformula != this || laststr != str) {
1162 //lyxerr << "reset lastformula to " << this << endl;
1165 current = ibegin(nucleus());
1167 mathed_parse_cell(ar, str);
1171 //lyxerr << "searching '" << str << "' in " << this << ar << endl;
1173 for (DocIterator it = current; it != iend(nucleus()); increment(it)) {
1174 CursorSlice & top = it.back();
1175 MathArray const & a = top.asMathInset()->cell(top.idx_);
1176 if (a.matchpart(ar, top.pos_)) {
1177 bv->cursor().setSelection(it, ar.size());
1179 top.pos_ += ar.size();
1185 //lyxerr << "not found!" << endl;
1192 void MathHullInset::write(Buffer const &, std::ostream & os) const
1194 WriteStream wi(os, false, false);
1200 void MathHullInset::read(Buffer const &, LyXLex & lex)
1203 mathed_parse_normal(at, lex);
1204 operator=(*at->asHullInset());
1208 int MathHullInset::plaintext(Buffer const &, ostream & os,
1209 OutputParams const &) const
1211 if (0 && display()) {
1215 TextPainter tpain(dim.width(), dim.height());
1216 drawT(tpain, 0, dim.ascent());
1218 // reset metrics cache to "real" values
1220 return tpain.textheight();
1222 WriteStream wi(os, false, true);
1223 wi << ' ' << cell(0) << ' ';
1229 int MathHullInset::linuxdoc(Buffer const & buf, ostream & os,
1230 OutputParams const & runparams) const
1232 return docbook(buf, os, runparams);
1236 int MathHullInset::docbook(Buffer const & buf, ostream & os,
1237 OutputParams const & runparams) const
1239 MathMLStream ms(os);
1240 ms << MTag("equation");
1243 int res = plaintext(buf, ms.os(), runparams);
1247 MathGridInset::mathmlize(ms);
1249 ms << ETag("equation");
1250 return ms.line() + res;