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) && RenderPreview::activated()) {
236 lyx::graphics::PreviewImage const * pimage =
237 preview_->getPreviewImage(*mi.base.bv->buffer());
238 use_preview = pimage && pimage->image();
242 preview_->metrics(mi, dim);
243 // insert a one pixel gap in front of the formula
251 FontSetChanger dummy1(mi.base, standardFont());
252 StyleChanger dummy2(mi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
254 // let the cells adjust themselves
255 MathGridInset::metrics(mi, dim);
262 if (numberedType()) {
263 FontSetChanger dummy(mi.base, "mathbf");
265 for (row_type row = 0; row < nrows(); ++row)
266 l = max(l, mathed_string_width(mi.base.font, nicelabel(row)));
272 // make it at least as high as the current font
275 math_font_max_dim(mi.base.font, asc, des);
276 dim.asc = max(dim.asc, asc);
277 dim.des = max(dim.des, des);
283 void MathHullInset::draw(PainterInfo & pi, int x, int y) const
285 BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer());
287 bool use_preview = false;
288 if (!editing(pi.base.bv) && RenderPreview::activated()) {
289 lyx::graphics::PreviewImage const * pimage =
290 preview_->getPreviewImage(*pi.base.bv->buffer());
291 use_preview = pimage && pimage->image();
295 // one pixel gap in front
296 preview_->draw(pi, x + 1, y);
297 setPosCache(pi, x, y);
301 FontSetChanger dummy1(pi.base, standardFont());
302 StyleChanger dummy2(pi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
303 MathGridInset::draw(pi, x + 1, y);
305 if (numberedType()) {
306 int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
307 for (row_type row = 0; row < nrows(); ++row) {
308 int const yy = y + rowinfo_[row].offset_;
309 FontSetChanger dummy(pi.base, "mathrm");
310 drawStr(pi, pi.base.font, xx, yy, nicelabel(row));
313 setPosCache(pi, x, y);
317 void MathHullInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
320 MathGridInset::metricsT(mi, dim);
323 WriteStream wi(os, false, true);
325 dim.wid = os.str().size();
332 void MathHullInset::drawT(TextPainter & pain, int x, int y) const
335 MathGridInset::drawT(pain, x, y);
338 WriteStream wi(os, false, true);
340 pain.draw(x, y, os.str().c_str());
347 string const latex_string(MathHullInset const & inset)
350 WriteStream wi(ls, false, false);
358 void MathHullInset::addPreview(lyx::graphics::PreviewLoader & ploader) const
360 string const snippet = latex_string(*this);
361 preview_->addPreview(snippet, ploader);
365 void MathHullInset::notifyCursorLeaves(LCursor & cur)
367 if (!RenderPreview::activated())
370 Buffer const & buffer = cur.buffer();
371 string const snippet = latex_string(*this);
372 preview_->addPreview(snippet, buffer);
373 preview_->startLoading(buffer);
377 string MathHullInset::label(row_type row) const
379 row_type n = nrows();
380 BOOST_ASSERT(row < n);
385 void MathHullInset::label(row_type row, string const & label)
387 //lyxerr << "setting label '" << label << "' for row " << row << endl;
392 void MathHullInset::numbered(row_type row, bool num)
398 bool MathHullInset::numbered(row_type row) const
404 bool MathHullInset::ams() const
408 type_ == "flalign" ||
409 type_ == "multline" ||
411 type_ == "alignat" ||
412 type_ == "xalignat" ||
413 type_ == "xxalignat";
417 bool MathHullInset::display() const
419 return type_ != "simple" && type_ != "none";
423 void MathHullInset::getLabelList(Buffer const &, vector<string> & labels) const
425 for (row_type row = 0; row < nrows(); ++row)
426 if (!label_[row].empty() && nonum_[row] != 1)
427 labels.push_back(label_[row]);
431 bool MathHullInset::numberedType() const
435 if (type_ == "simple")
437 if (type_ == "xxalignat")
439 for (row_type row = 0; row < nrows(); ++row)
446 void MathHullInset::validate(LaTeXFeatures & features) const
449 features.require("amsmath");
452 // Validation is necessary only if not using AMS math.
453 // To be safe, we will always run mathedvalidate.
454 //if (features.amsstyle)
457 features.require("boldsymbol");
458 //features.binom = true;
460 MathGridInset::validate(features);
464 void MathHullInset::header_write(WriteStream & os) const
466 bool n = numberedType();
471 else if (type_ == "simple") {
477 else if (type_ == "equation") {
479 os << "\\begin{equation" << star(n) << "}\n";
484 else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
485 || type_ == "gather" || type_ == "multline")
486 os << "\\begin{" << type_ << star(n) << "}\n";
488 else if (type_ == "alignat" || type_ == "xalignat")
489 os << "\\begin{" << type_ << star(n) << '}'
490 << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
492 else if (type_ == "xxalignat")
493 os << "\\begin{" << type_ << '}'
494 << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
497 os << "\\begin{unknown" << star(n) << '}';
501 void MathHullInset::footer_write(WriteStream & os) const
503 bool n = numberedType();
508 else if (type_ == "simple")
511 else if (type_ == "equation")
513 os << "\\end{equation" << star(n) << "}\n";
517 else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
518 || type_ == "alignat" || type_ == "xalignat"
519 || type_ == "gather" || type_ == "multline")
520 os << "\\end{" << type_ << star(n) << "}\n";
522 else if (type_ == "xxalignat")
523 os << "\\end{" << type_ << "}\n";
526 os << "\\end{unknown" << star(n) << '}';
530 bool MathHullInset::colChangeOK() const
533 type_ == "align" || type_ == "flalign" ||type_ == "alignat" ||
534 type_ == "xalignat" || type_ == "xxalignat";
538 void MathHullInset::addRow(row_type row)
540 nonum_.insert(nonum_.begin() + row + 1, !numberedType());
541 label_.insert(label_.begin() + row + 1, string());
542 MathGridInset::addRow(row);
546 void MathHullInset::swapRow(row_type row)
550 if (row + 1 == nrows())
552 swap(nonum_[row], nonum_[row + 1]);
553 swap(label_[row], label_[row + 1]);
554 MathGridInset::swapRow(row);
558 void MathHullInset::delRow(row_type row)
562 MathGridInset::delRow(row);
563 nonum_.erase(nonum_.begin() + row);
564 label_.erase(label_.begin() + row);
568 void MathHullInset::addCol(col_type col)
571 MathGridInset::addCol(col);
573 lyxerr << "Can't change number of columns in '" << type_ << "'" << endl;
577 void MathHullInset::delCol(col_type col)
580 MathGridInset::delCol(col);
582 lyxerr << "Can't change number of columns in '" << type_ << "'" << endl;
586 string MathHullInset::nicelabel(row_type row) const
590 if (label_[row].empty())
591 return string("(#)");
592 return '(' + label_[row] + ')';
596 void MathHullInset::glueall()
599 for (idx_type i = 0; i < nargs(); ++i)
601 *this = MathHullInset("simple");
607 string const & MathHullInset::getType() const
613 void MathHullInset::setType(string const & type)
621 void MathHullInset::mutate(string const & newtype)
623 lyxerr << "mutating from '" << type_ << "' to '" << newtype << "'" << endl;
625 // we try to move along the chain
626 // none <-> simple <-> equation <-> eqnarray
628 if (newtype == "dump") {
632 else if (newtype == type_) {
636 else if (type_ == "none") {
642 else if (type_ == "simple") {
643 if (newtype == "none") {
652 else if (type_ == "equation") {
653 if (smaller(newtype, type_)) {
656 } else if (newtype == "eqnarray") {
657 MathGridInset::addCol(1);
658 MathGridInset::addCol(1);
660 // split it "nicely" on the firest relop
661 pos_type pos = firstRelOp(cell(0));
662 cell(1) = MathArray(cell(0).begin() + pos, cell(0).end());
663 cell(0).erase(pos, cell(0).size());
665 if (cell(1).size()) {
666 cell(2) = MathArray(cell(1).begin() + 1, cell(1).end());
667 cell(1).erase(1, cell(1).size());
671 } else if (newtype == "multline" || newtype == "gather") {
675 MathGridInset::addCol(1);
677 pos_type pos = firstRelOp(cell(0));
679 cell(0).erase(pos, cell(0).size());
680 cell(1).erase(0, pos);
686 else if (type_ == "eqnarray") {
687 if (smaller(newtype, type_)) {
688 // set correct (no)numbering
689 bool allnonum = true;
690 for (row_type row = 0; row < nrows(); ++row)
694 // set first non-empty label
696 for (row_type row = 0; row < nrows(); ++row) {
697 if (!label_[row].empty()) {
704 nonum_[0] = allnonum;
707 } else { // align & Co.
708 for (row_type row = 0; row < nrows(); ++row) {
709 idx_type c = 3 * row + 1;
710 cell(c).append(cell(c + 1));
712 MathGridInset::delCol(2);
718 else if (type_ == "align") {
719 if (smaller(newtype, type_)) {
720 MathGridInset::addCol(1);
728 else if (type_ == "multline") {
729 if (newtype == "gather" || newtype == "align" ||
730 newtype == "xalignat" || newtype == "xxalignat" || newtype == "flalign")
732 else if (newtype == "eqnarray") {
733 MathGridInset::addCol(1);
734 MathGridInset::addCol(1);
737 lyxerr << "mutation from '" << type_
738 << "' to '" << newtype << "' not implemented" << endl;
742 else if (type_ == "gather") {
743 if (newtype == "multline") {
746 lyxerr << "mutation from '" << type_
747 << "' to '" << newtype << "' not implemented" << endl;
752 lyxerr << "mutation from '" << type_
753 << "' to '" << newtype << "' not implemented" << endl;
758 string MathHullInset::eolString(row_type row, bool fragile) const
761 if (numberedType()) {
762 if (!label_[row].empty() && !nonum_[row])
763 res += "\\label{" + label_[row] + '}';
764 if (nonum_[row] && (type_ != "multline"))
765 res += "\\nonumber ";
767 return res + MathGridInset::eolString(row, fragile);
771 void MathHullInset::write(WriteStream & os) const
774 MathGridInset::write(os);
779 void MathHullInset::normalize(NormalStream & os) const
781 os << "[formula " << type_ << ' ';
782 MathGridInset::normalize(os);
787 void MathHullInset::mathmlize(MathMLStream & os) const
789 MathGridInset::mathmlize(os);
793 void MathHullInset::infoize(ostream & os) const
795 os << "Type: " << type_;
799 void MathHullInset::check() const
801 BOOST_ASSERT(nonum_.size() == nrows());
802 BOOST_ASSERT(label_.size() == nrows());
806 void MathHullInset::doExtern(LCursor & cur, FuncRequest & func)
810 istringstream iss(func.argument.c_str());
811 iss >> lang >> extra;
816 #warning temporarily disabled
817 //if (cur.selection()) {
820 // lyxerr << "use selection: " << ar << endl;
821 // insert(pipeThroughExtern(lang, extra, ar));
827 eq.push_back(MathAtom(new MathCharInset('=')));
829 // go to first item in line
830 cur.idx() -= cur.idx() % ncols();
833 if (getType() == "simple") {
834 size_type pos = cur.cell().find_last(eq);
836 if (cur.inMathed() && cur.selection()) {
837 asArray(grabAndEraseSelection(cur), ar);
838 } else if (pos == cur.cell().size()) {
840 lyxerr << "use whole cell: " << ar << endl;
842 ar = MathArray(cur.cell().begin() + pos + 1, cur.cell().end());
843 lyxerr << "use partial cell form pos: " << pos << endl;
845 cur.cell().append(eq);
846 cur.cell().append(pipeThroughExtern(lang, extra, ar));
847 cur.pos() = cur.lastpos();
851 if (getType() == "equation") {
852 lyxerr << "use equation inset" << endl;
854 MathArray & ar = cur.cell();
855 lyxerr << "use cell: " << ar << endl;
859 cur.cell() = pipeThroughExtern(lang, extra, ar);
860 // move to end of line
861 cur.pos() = cur.lastpos();
866 lyxerr << "use eqnarray" << endl;
867 cur.idx() += 2 - cur.idx() % ncols();
869 MathArray ar = cur.cell();
870 lyxerr << "use cell: " << ar << endl;
872 #warning temporarily disabled
879 cur.cell() = pipeThroughExtern(lang, extra, ar);
880 cur.pos() = cur.lastpos();
885 void MathHullInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
887 switch (cmd.action) {
889 case LFUN_FINISHED_LEFT:
890 case LFUN_FINISHED_RIGHT:
891 case LFUN_FINISHED_UP:
892 case LFUN_FINISHED_DOWN:
893 MathGridInset::priv_dispatch(cur, cmd);
894 notifyCursorLeaves(cur);
897 case LFUN_BREAKPARAGRAPH:
902 if (type_ == "simple" || type_ == "equation") {
903 recordUndoInset(cur);
906 cur.pos() = cur.lastpos();
909 MathGridInset::priv_dispatch(cur, cmd);
912 case LFUN_MATH_NUMBER:
913 //lyxerr << "toggling all numbers" << endl;
915 recordUndoInset(cur);
916 bool old = numberedType();
917 if (type_ == "multline")
918 numbered(nrows() - 1, !old);
920 for (row_type row = 0; row < nrows(); ++row)
922 cur.message(old ? _("No number") : _("Number"));
926 case LFUN_MATH_NONUMBER:
928 recordUndoInset(cur);
929 row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
930 bool old = numbered(r);
931 cur.message(old ? _("No number") : _("Number"));
936 case LFUN_INSERT_LABEL: {
937 recordUndoInset(cur);
938 row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
939 string old_label = label(r);
940 string new_label = cmd.argument;
942 if (new_label.empty()) {
943 string const default_label =
944 (lyxrc.label_init_length >= 0) ? "eq:" : "";
945 pair<bool, string> const res = old_label.empty()
946 ? Alert::askForText(_("Enter new label to insert:"), default_label)
947 : Alert::askForText(_("Enter label:"), old_label);
948 new_label = lyx::support::trim(res.second);
951 if (!new_label.empty())
957 case LFUN_MATH_EXTERN:
958 recordUndoInset(cur);
962 case LFUN_MATH_MUTATE: {
963 recordUndoInset(cur);
964 row_type row = cur.row();
965 col_type col = cur.col();
966 mutate(cmd.argument);
967 cur.idx() = row * ncols() + col;
968 if (cur.idx() > cur.lastidx()) {
969 cur.idx() = cur.lastidx();
970 cur.pos() = cur.lastpos();
972 if (cur.pos() > cur.lastpos())
973 cur.pos() = cur.lastpos();
974 //cur.dispatched(FINISHED);
978 case LFUN_MATH_DISPLAY: {
979 recordUndoInset(cur);
980 mutate(type_ == "simple" ? "equation" : "simple");
982 cur.pos() = cur.lastpos();
983 //cur.dispatched(FINISHED);
988 MathGridInset::priv_dispatch(cur, cmd);
994 bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
995 FuncStatus & flag) const
997 switch (cmd.action) {
999 case LFUN_MATH_NUMBER:
1000 case LFUN_MATH_NONUMBER:
1001 case LFUN_INSERT_LABEL:
1002 case LFUN_MATH_EXTERN:
1003 case LFUN_MATH_MUTATE:
1004 case LFUN_MATH_DISPLAY:
1008 return MathGridInset::getStatus(cur, cmd, flag);
1013 /////////////////////////////////////////////////////////////////////
1015 #include "math_arrayinset.h"
1016 #include "math_deliminset.h"
1017 #include "math_factory.h"
1018 #include "math_parser.h"
1019 #include "math_spaceinset.h"
1020 #include "ref_inset.h"
1022 #include "bufferview_funcs.h"
1023 #include "lyxtext.h"
1025 #include "frontends/LyXView.h"
1026 #include "frontends/Dialogs.h"
1028 #include "support/lstrings.h"
1029 #include "support/lyxlib.h"
1032 // simply scrap this function if you want
1033 void MathHullInset::mutateToText()
1036 // translate to latex
1038 latex(NULL, os, false, false);
1039 string str = os.str();
1042 LyXText * lt = view_->getLyXText();
1043 string::const_iterator cit = str.begin();
1044 string::const_iterator end = str.end();
1045 for (; cit != end; ++cit)
1046 view_->owner()->getIntl()->getTransManager().TranslateAndInsert(*cit, lt);
1049 //view_->owner()->dispatch(LFUN_ESCAPE);
1054 void MathHullInset::handleFont(LCursor & cur, string const & arg,
1055 string const & font)
1057 // this whole function is a hack and won't work for incremental font
1060 if (cur.inset().asMathInset()->name() == font)
1061 cur.handleFont(font);
1063 cur.handleNest(createMathInset(font));
1069 void MathHullInset::handleFont2(LCursor & cur, string const & arg)
1074 bv_funcs::string2font(arg, font, b);
1075 if (font.color() != LColor::inherit) {
1076 MathAtom at = createMathInset("color");
1077 asArray(lcolor.getGUIName(font.color()), at.nucleus()->cell(0));
1078 cur.handleNest(at, 1);
1083 void MathHullInset::edit(LCursor & cur, bool left)
1086 left ? idxFirst(cur) : idxLast(cur);
1090 string const MathHullInset::editMessage() const
1092 return _("Math editor mode");
1096 void MathHullInset::getCursorDim(int & asc, int & desc) const
1100 //math_font_max_dim(font_, asc, des);
1104 void MathHullInset::revealCodes(LCursor & cur) const
1106 if (!cur.inMathed())
1110 cur.message(os.str());
1112 // write something to the minibuffer
1113 // translate to latex
1117 string str = os.str();
1119 string::size_type pos = 0;
1121 for (string::iterator it = str.begin(); it != str.end(); ++it) {
1124 else if (*it == '\0') {
1126 pos = it - str.begin();
1132 res = res.substr(pos - 30);
1133 if (res.size() > 60)
1134 res = res.substr(0, 60);
1140 InsetBase::Code MathHullInset::lyxCode() const
1146 /////////////////////////////////////////////////////////////////////
1150 bool MathHullInset::searchForward(BufferView * bv, string const & str,
1153 #warning completely broken
1154 static MathHullInset * lastformula = 0;
1155 static CursorBase current = DocIterator(ibegin(nucleus()));
1156 static MathArray ar;
1157 static string laststr;
1159 if (lastformula != this || laststr != str) {
1160 //lyxerr << "reset lastformula to " << this << endl;
1163 current = ibegin(nucleus());
1165 mathed_parse_cell(ar, str);
1169 //lyxerr << "searching '" << str << "' in " << this << ar << endl;
1171 for (DocIterator it = current; it != iend(nucleus()); increment(it)) {
1172 CursorSlice & top = it.back();
1173 MathArray const & a = top.asMathInset()->cell(top.idx_);
1174 if (a.matchpart(ar, top.pos_)) {
1175 bv->cursor().setSelection(it, ar.size());
1177 top.pos_ += ar.size();
1183 //lyxerr << "not found!" << endl;
1190 void MathHullInset::write(Buffer const &, std::ostream & os) const
1192 WriteStream wi(os, false, false);
1198 void MathHullInset::read(Buffer const &, LyXLex & lex)
1201 mathed_parse_normal(at, lex);
1202 operator=(*at->asHullInset());
1206 int MathHullInset::plaintext(Buffer const &, ostream & os,
1207 OutputParams const &) const
1209 if (0 && display()) {
1213 TextPainter tpain(dim.width(), dim.height());
1214 drawT(tpain, 0, dim.ascent());
1216 // reset metrics cache to "real" values
1218 return tpain.textheight();
1220 WriteStream wi(os, false, true);
1221 wi << ' ' << cell(0) << ' ';
1227 int MathHullInset::linuxdoc(Buffer const & buf, ostream & os,
1228 OutputParams const & runparams) const
1230 return docbook(buf, os, runparams);
1234 int MathHullInset::docbook(Buffer const & buf, ostream & os,
1235 OutputParams const & runparams) const
1237 MathMLStream ms(os);
1238 ms << MTag("equation");
1241 int res = plaintext(buf, ms.os(), runparams);
1245 MathGridInset::mathmlize(ms);
1247 ms << ETag("equation");
1248 return ms.line() + res;