]> git.lyx.org Git - lyx.git/blob - src/mathed/math_hullinset.C
5c376e051cd86f9c1f25f75adf46bb28d2af8fe1
[lyx.git] / src / mathed / math_hullinset.C
1 /**
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.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_hullinset.h"
14 #include "math_mathmlstream.h"
15 #include "math_streamstr.h"
16 #include "math_cursor.h"
17 #include "math_support.h"
18 #include "math_extern.h"
19 #include "math_charinset.h"
20 #include "textpainter.h"
21 #include "debug.h"
22 #include "funcrequest.h"
23 #include "gettext.h"
24 #include "LaTeXFeatures.h"
25 #include "LColor.h"
26 #include "lyxrc.h"
27
28 #include "frontends/Alert.h"
29
30 #include "support/std_sstream.h"
31
32
33 using lyx::support::trim;
34
35 using std::endl;
36 using std::max;
37
38 using std::auto_ptr;
39 using std::istringstream;
40 using std::ostringstream;
41 using std::pair;
42
43
44 namespace {
45
46         int getCols(string const & type)
47         {
48                 if (type == "eqnarray")
49                         return 3;
50                 if (type == "align")
51                         return 2;
52                 if (type == "flalign")
53                         return 2;
54                 if (type == "alignat")
55                         return 2;
56                 if (type == "xalignat")
57                         return 2;
58                 if (type == "xxalignat")
59                         return 2;
60                 return 1;
61         }
62
63
64         // returns position of first relation operator in the array
65         // used for "intelligent splitting"
66         MathArray::size_type firstRelOp(MathArray const & ar)
67         {
68                 for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
69                         if ((*it)->isRelOp())
70                                 return it - ar.begin();
71                 return ar.size();
72         }
73
74
75         char const * star(bool numbered)
76         {
77                 return numbered ? "" : "*";
78         }
79
80
81         int typecode(string const & s)
82         {
83                 if (s == "none")      return 0;
84                 if (s == "simple")    return 1;
85                 if (s == "equation")  return 2;
86                 if (s == "eqnarray")  return 3;
87                 if (s == "align")     return 4;
88                 if (s == "alignat")   return 5;
89                 if (s == "xalignat")  return 6;
90                 if (s == "xxalignat") return 7;
91                 if (s == "multline")  return 8;
92                 if (s == "gather")    return 9;
93                 if (s == "flalign")   return 10;
94                 lyxerr << "unknown hull type '" << s << "'" << endl;
95                 return 0;
96         }
97
98         bool smaller(string const & s, string const & t)
99         {
100                 return typecode(s) < typecode(t);
101         }
102
103
104 } // end anon namespace
105
106
107 MathHullInset::MathHullInset()
108         : MathGridInset(1, 1), type_("none"), nonum_(1), label_(1)
109 {
110         setDefaults();
111 }
112
113
114 MathHullInset::MathHullInset(string const & type)
115         : MathGridInset(getCols(type), 1), type_(type), nonum_(1), label_(1)
116 {
117         setDefaults();
118 }
119
120
121 auto_ptr<InsetBase> MathHullInset::clone() const
122 {
123         return auto_ptr<InsetBase>(new MathHullInset(*this));
124 }
125
126
127 MathInset::mode_type MathHullInset::currentMode() const
128 {
129         if (type_ == "none")
130                 return UNDECIDED_MODE;
131         // definitely math mode ...
132         return MATH_MODE;
133 }
134
135
136 bool MathHullInset::idxFirst(idx_type & idx, pos_type & pos) const
137 {
138         idx = 0;
139         pos = 0;
140         return true;
141 }
142
143
144 bool MathHullInset::idxLast(idx_type & idx, pos_type & pos) const
145 {
146         idx = nargs() - 1;
147         pos = cell(idx).size();
148         return true;
149 }
150
151
152 char MathHullInset::defaultColAlign(col_type col)
153 {
154         if (type_ == "eqnarray")
155                 return "rcl"[col];
156         if (typecode(type_) >= typecode("align"))
157                 return "rl"[col & 1];
158         return 'c';
159 }
160
161
162 int MathHullInset::defaultColSpace(col_type col)
163 {
164         if (type_ == "align" || type_ == "alignat")
165                 return 0;
166         if (type_ == "xalignat")
167                 return (col & 1) ? 20 : 0;
168         if (type_ == "xxalignat" || type_ == "flalign")
169                 return (col & 1) ? 40 : 0;
170         return 0;
171 }
172
173
174 char const * MathHullInset::standardFont() const
175 {
176         if (type_ == "none")
177                 return "lyxnochange";
178         return "mathnormal";
179 }
180
181
182 void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
183 {
184         FontSetChanger dummy1(mi.base, standardFont());
185         StyleChanger dummy2(mi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
186
187         // let the cells adjust themselves
188         MathGridInset::metrics(mi);
189
190         if (display()) {
191                 dim_.asc += 12;
192                 dim_.des += 12;
193         }
194
195         if (numberedType()) {
196                 FontSetChanger dummy(mi.base, "mathbf");
197                 int l = 0;
198                 for (row_type row = 0; row < nrows(); ++row)
199                         l = max(l, mathed_string_width(mi.base.font, nicelabel(row)));
200
201                 if (l)
202                         dim_.wid += 30 + l;
203         }
204
205         // make it at least as high as the current font
206         int asc = 0;
207         int des = 0;
208         math_font_max_dim(mi.base.font, asc, des);
209         dim_.asc = max(dim_.asc, asc);
210         dim_.des = max(dim_.des, des);
211
212         // for markers
213         metricsMarkers2();
214         dim = dim_;
215 }
216
217
218 void MathHullInset::draw(PainterInfo & pi, int x, int y) const
219 {
220         FontSetChanger dummy1(pi.base, standardFont());
221         StyleChanger dummy2(pi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
222         MathGridInset::draw(pi, x + 1, y);
223
224         if (numberedType()) {
225                 int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
226                 for (row_type row = 0; row < nrows(); ++row) {
227                         int const yy = y + rowinfo_[row].offset_;
228                         FontSetChanger dummy(pi.base, "mathrm");
229                         drawStr(pi, pi.base.font, xx, yy, nicelabel(row));
230                 }
231         }
232
233         drawMarkers2(pi, x, y);
234 }
235
236
237 void MathHullInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
238 {
239         if (display()) {
240                 MathGridInset::metricsT(mi, dim);
241         } else {
242                 ostringstream os;
243                 WriteStream wi(os, false, true);
244                 write(wi);
245                 dim.wid = os.str().size();
246                 dim.asc = 1;
247                 dim.des = 0;
248         }
249 }
250
251
252 void MathHullInset::drawT(TextPainter & pain, int x, int y) const
253 {
254         if (display()) {
255                 MathGridInset::drawT(pain, x, y);
256         } else {
257                 ostringstream os;
258                 WriteStream wi(os, false, true);
259                 write(wi);
260                 pain.draw(x, y, os.str().c_str());
261         }
262 }
263
264
265 string MathHullInset::label(row_type row) const
266 {
267         row_type n = nrows();
268         BOOST_ASSERT(row < n);
269         return label_[row];
270 }
271
272
273 void MathHullInset::label(row_type row, string const & label)
274 {
275         //lyxerr << "setting label '" << label << "' for row " << row << endl;
276         label_[row] = label;
277 }
278
279
280 void MathHullInset::numbered(row_type row, bool num)
281 {
282         nonum_[row] = !num;
283 }
284
285
286 bool MathHullInset::numbered(row_type row) const
287 {
288         return !nonum_[row];
289 }
290
291
292 bool MathHullInset::ams() const
293 {
294         return
295                 type_ == "align" ||
296                 type_ == "flalign" ||
297                 type_ == "multline" ||
298                 type_ == "gather" ||
299                 type_ == "alignat" ||
300                 type_ == "xalignat" ||
301                 type_ == "xxalignat";
302 }
303
304
305 bool MathHullInset::display() const
306 {
307         return type_ != "simple" && type_ != "none";
308 }
309
310
311 void MathHullInset::getLabelList(Buffer const &,
312                                  std::vector<string> & labels) const
313 {
314         for (row_type row = 0; row < nrows(); ++row)
315                 if (!label_[row].empty() && nonum_[row] != 1)
316                         labels.push_back(label_[row]);
317 }
318
319
320 bool MathHullInset::numberedType() const
321 {
322         if (type_ == "none")
323                 return false;
324         if (type_ == "simple")
325                 return false;
326         if (type_ == "xxalignat")
327                 return false;
328         for (row_type row = 0; row < nrows(); ++row)
329                 if (!nonum_[row])
330                         return true;
331         return false;
332 }
333
334
335 void MathHullInset::validate(LaTeXFeatures & features) const
336 {
337         if (ams())
338                 features.require("amsmath");
339
340
341         // Validation is necessary only if not using AMS math.
342         // To be safe, we will always run mathedvalidate.
343         //if (features.amsstyle)
344         //  return;
345
346         features.require("boldsymbol");
347         //features.binom      = true;
348
349         MathGridInset::validate(features);
350 }
351
352
353 void MathHullInset::header_write(WriteStream & os) const
354 {
355         bool n = numberedType();
356
357         if (type_ == "none")
358                 ;
359
360         else if (type_ == "simple") {
361                 os << '$';
362                 if (cell(0).empty())
363                         os << ' ';
364         }
365
366         else if (type_ == "equation") {
367                 if (n)
368                         os << "\\begin{equation" << star(n) << "}\n";
369                 else
370                         os << "\\[\n";
371         }
372
373         else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
374                  || type_ == "gather" || type_ == "multline")
375                         os << "\\begin{" << type_ << star(n) << "}\n";
376
377         else if (type_ == "alignat" || type_ == "xalignat")
378                 os << "\\begin{" << type_ << star(n) << '}'
379                   << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
380
381         else if (type_ == "xxalignat")
382                 os << "\\begin{" << type_ << '}'
383                   << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
384
385         else
386                 os << "\\begin{unknown" << star(n) << '}';
387 }
388
389
390 void MathHullInset::footer_write(WriteStream & os) const
391 {
392         bool n = numberedType();
393
394         if (type_ == "none")
395                 os << "\n";
396
397         else if (type_ == "simple")
398                 os << '$';
399
400         else if (type_ == "equation")
401                 if (n)
402                         os << "\\end{equation" << star(n) << "}\n";
403                 else
404                         os << "\\]\n";
405
406         else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
407                  || type_ == "alignat" || type_ == "xalignat"
408                  || type_ == "gather" || type_ == "multline")
409                 os << "\\end{" << type_ << star(n) << "}\n";
410
411         else if (type_ == "xxalignat")
412                 os << "\\end{" << type_ << "}\n";
413
414         else
415                 os << "\\end{unknown" << star(n) << '}';
416 }
417
418
419 bool MathHullInset::colChangeOK() const
420 {
421         return
422                 type_ == "align" || type_ == "flalign" ||type_ == "alignat" ||
423                 type_ == "xalignat" || type_ == "xxalignat";
424 }
425
426
427 void MathHullInset::addRow(row_type row)
428 {
429         nonum_.insert(nonum_.begin() + row + 1, !numberedType());
430         label_.insert(label_.begin() + row + 1, string());
431         MathGridInset::addRow(row);
432 }
433
434
435 void MathHullInset::swapRow(row_type row)
436 {
437         if (nrows() == 1)
438                 return;
439         if (row + 1 == nrows())
440                 --row;
441         std::swap(nonum_[row], nonum_[row + 1]);
442         std::swap(label_[row], label_[row + 1]);
443         MathGridInset::swapRow(row);
444 }
445
446
447 void MathHullInset::delRow(row_type row)
448 {
449         if (nrows() <= 1)
450                 return;
451         MathGridInset::delRow(row);
452         nonum_.erase(nonum_.begin() + row);
453         label_.erase(label_.begin() + row);
454 }
455
456
457 void MathHullInset::addCol(col_type col)
458 {
459         if (colChangeOK())
460                 MathGridInset::addCol(col);
461         else
462                 lyxerr << "Can't change number of columns in '" << type_ << "'" << endl;
463 }
464
465
466 void MathHullInset::delCol(col_type col)
467 {
468         if (colChangeOK())
469                 MathGridInset::delCol(col);
470         else
471                 lyxerr << "Can't change number of columns in '" << type_ << "'" << endl;
472 }
473
474
475 string MathHullInset::nicelabel(row_type row) const
476 {
477         if (nonum_[row])
478                 return string();
479         if (label_[row].empty())
480                 return string("(#)");
481         return '(' + label_[row] + ')';
482 }
483
484
485 void MathHullInset::glueall()
486 {
487         MathArray ar;
488         for (idx_type i = 0; i < nargs(); ++i)
489                 ar.append(cell(i));
490         *this = MathHullInset("simple");
491         cell(0) = ar;
492         setDefaults();
493 }
494
495
496 string const & MathHullInset::getType() const
497 {
498         return type_;
499 }
500
501
502 void MathHullInset::setType(string const & type)
503 {
504         type_ = type;
505         setDefaults();
506 }
507
508
509
510 void MathHullInset::mutate(string const & newtype)
511 {
512         //lyxerr << "mutating from '" << type_ << "' to '" << newtype << "'" << endl;
513
514         // we try to move along the chain
515         // none <-> simple <-> equation <-> eqnarray
516
517         if (newtype == "dump") {
518                 dump();
519         }
520
521         else if (newtype == type_) {
522                 // done
523         }
524
525         else if (type_ == "none") {
526                 setType("simple");
527                 numbered(0, false);
528                 mutate(newtype);
529         }
530
531         else if (type_ == "simple") {
532                 if (newtype == "none") {
533                         setType("none");
534                 } else {
535                         setType("equation");
536                         numbered(0, false);
537                         mutate(newtype);
538                 }
539         }
540
541         else if (type_ == "equation") {
542                 if (smaller(newtype, type_)) {
543                         setType("simple");
544                         mutate(newtype);
545                 } else if (newtype == "eqnarray") {
546                         MathGridInset::addCol(1);
547                         MathGridInset::addCol(1);
548
549                         // split it "nicely" on the firest relop
550                         pos_type pos = firstRelOp(cell(0));
551                         cell(1) = MathArray(cell(0).begin() + pos, cell(0).end());
552                         cell(0).erase(pos, cell(0).size());
553
554                         if (cell(1).size()) {
555                                 cell(2) = MathArray(cell(1).begin() + 1, cell(1).end());
556                                 cell(1).erase(1, cell(1).size());
557                         }
558                         setType("eqnarray");
559                         mutate(newtype);
560                 } else if (newtype == "multline" || newtype == "gather") {
561                         setType(newtype);
562                         numbered(0, false);
563                 } else {
564                         MathGridInset::addCol(1);
565                         // split it "nicely"
566                         pos_type pos = firstRelOp(cell(0));
567                         cell(1) = cell(0);
568                         cell(0).erase(pos, cell(0).size());
569                         cell(1).erase(0, pos);
570                         setType("align");
571                         mutate(newtype);
572                 }
573         }
574
575         else if (type_ == "eqnarray") {
576                 if (smaller(newtype, type_)) {
577                         // set correct (no)numbering
578                         bool allnonum = true;
579                         for (row_type row = 0; row < nrows(); ++row)
580                                 if (!nonum_[row])
581                                         allnonum = false;
582
583                         // set first non-empty label
584                         string label;
585                         for (row_type row = 0; row < nrows(); ++row) {
586                                 if (!label_[row].empty()) {
587                                         label = label_[row];
588                                         break;
589                                 }
590                         }
591
592                         glueall();
593                         nonum_[0] = allnonum;
594                         label_[0] = label;
595                         mutate(newtype);
596                 } else { // align & Co.
597                         for (row_type row = 0; row < nrows(); ++row) {
598                                 idx_type c = 3 * row + 1;
599                                 cell(c).append(cell(c + 1));
600                         }
601                         MathGridInset::delCol(2);
602                         setType("align");
603                         mutate(newtype);
604                 }
605         }
606
607         else if (type_ == "align") {
608                 if (smaller(newtype, type_)) {
609                         MathGridInset::addCol(1);
610                         setType("eqnarray");
611                         mutate(newtype);
612                 } else {
613                         setType(newtype);
614                 }
615         }
616
617         else if (type_ == "multline") {
618                 if (newtype == "gather" || newtype == "align" ||
619                     newtype == "xalignat" || newtype == "xxalignat" || newtype == "flalign")
620                         setType(newtype);
621                 else if (newtype == "eqnarray") {
622                         MathGridInset::addCol(1);
623                         MathGridInset::addCol(1);
624                         setType("eqnarray");
625                 } else {
626                         lyxerr << "mutation from '" << type_
627                                 << "' to '" << newtype << "' not implemented" << endl;
628                 }
629         }
630
631         else if (type_ == "gather") {
632                 if (newtype == "multline") {
633                         setType("multline");
634                 } else {
635                         lyxerr << "mutation from '" << type_
636                                 << "' to '" << newtype << "' not implemented" << endl;
637                 }
638         }
639
640         else {
641                 lyxerr << "mutation from '" << type_
642                                          << "' to '" << newtype << "' not implemented" << endl;
643         }
644 }
645
646
647 string MathHullInset::eolString(row_type row, bool fragile) const
648 {
649         string res;
650         if (numberedType()) {
651                 if (!label_[row].empty() && !nonum_[row])
652                         res += "\\label{" + label_[row] + '}';
653                 if (nonum_[row] && (type_ != "multline"))
654                         res += "\\nonumber ";
655         }
656         return res + MathGridInset::eolString(row, fragile);
657 }
658
659
660 void MathHullInset::write(WriteStream & os) const
661 {
662         header_write(os);
663         MathGridInset::write(os);
664         footer_write(os);
665 }
666
667
668 void MathHullInset::normalize(NormalStream & os) const
669 {
670         os << "[formula " << type_ << ' ';
671         MathGridInset::normalize(os);
672         os << "] ";
673 }
674
675
676 void MathHullInset::mathmlize(MathMLStream & os) const
677 {
678         MathGridInset::mathmlize(os);
679 }
680
681
682 void MathHullInset::infoize(std::ostream & os) const
683 {
684         os << "Type: " << type_;
685 }
686
687
688 void MathHullInset::check() const
689 {
690         BOOST_ASSERT(nonum_.size() == nrows());
691         BOOST_ASSERT(label_.size() == nrows());
692 }
693
694
695 void MathHullInset::doExtern
696         (FuncRequest const & func, idx_type & idx, pos_type & pos)
697 {
698         string lang;
699         string extra;
700         istringstream iss(func.argument.c_str());
701         iss >> lang >> extra;
702         if (extra.empty())
703                 extra = "noextra";
704
705 #ifdef WITH_WARNINGS
706 #warning temporarily disabled
707         //if (selection()) {
708         //      MathArray ar;
709         //      selGet(ar);
710         //      lyxerr << "use selection: " << ar << endl;
711         //      insert(pipeThroughExtern(lang, extra, ar));
712         //      return;
713         //}
714 #endif
715
716         MathArray eq;
717         eq.push_back(MathAtom(new MathCharInset('=')));
718
719         // go to first item in line
720         idx -= idx % ncols();
721         pos = 0;
722
723         if (getType() == "simple") {
724                 size_type pos = cell(idx).find_last(eq);
725                 MathArray ar;
726                 if (mathcursor && mathcursor->selection()) {
727                         asArray(mathcursor->grabAndEraseSelection(), ar);
728                 } else if (pos == cell(idx).size()) {
729                         ar = cell(idx);
730                         lyxerr << "use whole cell: " << ar << endl;
731                 } else {
732                         ar = MathArray(cell(idx).begin() + pos + 1, cell(idx).end());
733                         lyxerr << "use partial cell form pos: " << pos << endl;
734                 }
735                 cell(idx).append(eq);
736                 cell(idx).append(pipeThroughExtern(lang, extra, ar));
737                 pos = cell(idx).size();
738                 return;
739         }
740
741         if (getType() == "equation") {
742                 lyxerr << "use equation inset" << endl;
743                 mutate("eqnarray");
744                 MathArray & ar = cell(idx);
745                 lyxerr << "use cell: " << ar << endl;
746                 cell(idx + 1) = eq;
747                 cell(idx + 2) = pipeThroughExtern(lang, extra, ar);
748                 // move to end of line
749                 idx += 2;
750                 pos = cell(idx).size();
751                 return;
752         }
753
754         {
755                 lyxerr << "use eqnarray" << endl;
756                 idx -= idx % ncols();
757                 idx += 2;
758                 pos = 0;
759                 MathArray ar = cell(idx);
760                 lyxerr << "use cell: " << ar << endl;
761 #ifdef WITH_WARNINGS
762 #warning temporarily disabled
763 #endif
764                 addRow(row(idx));
765                 cell(idx + 2) = eq;
766                 cell(idx + 3) = pipeThroughExtern(lang, extra, ar);
767                 idx += 3;
768                 pos = cell(idx).size();
769         }
770 }
771
772
773 dispatch_result MathHullInset::dispatch
774         (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
775 {
776         switch (cmd.action) {
777
778                 case LFUN_BREAKLINE:
779                         if (type_ == "simple" || type_ == "equation") {
780                                 mutate("eqnarray");
781                                 idx = 1;
782                                 pos = 0;
783                                 return DISPATCHED_POP;
784                         }
785                         return MathGridInset::dispatch(cmd, idx, pos);
786
787                 case LFUN_MATH_NUMBER:
788                         //lyxerr << "toggling all numbers" << endl;
789                         if (display()) {
790                                 //recordUndo(bv, Undo::INSERT);
791                                 bool old = numberedType();
792                                 if (type_ == "multline")
793                                         numbered(nrows() - 1, !old);
794                                 else
795                                         for (row_type row = 0; row < nrows(); ++row)
796                                                 numbered(row, !old);
797                                 //bv->owner()->message(old ? _("No number") : _("Number"));
798                         }
799                         return DISPATCHED;
800
801                 case LFUN_MATH_NONUMBER:
802                         if (display()) {
803                                 row_type r = (type_ == "multline") ? nrows() - 1 : row(idx);
804                                 //recordUndo(bv, Undo::INSERT);
805                                 bool old = numbered(r);
806                                 //bv->owner()->message(old ? _("No number") : _("Number"));
807                                 numbered(r, !old);
808                         }
809                         return DISPATCHED;
810
811                 case LFUN_INSERT_LABEL: {
812                         row_type r = (type_ == "multline") ? nrows() - 1 : row(idx);
813                         string old_label = label(r);
814                         string new_label = cmd.argument;
815
816                         if (new_label.empty()) {
817                                 string const default_label =
818                                         (lyxrc.label_init_length >= 0) ? "eq:" : "";
819                                 pair<bool, string> const res = old_label.empty()
820                                         ? Alert::askForText(_("Enter new label to insert:"), default_label)
821                                         : Alert::askForText(_("Enter label:"), old_label);
822                                 if (!res.first)
823                                         return UNDISPATCHED;
824                                 new_label = trim(res.second);
825                         }
826
827                         //if (new_label == old_label)
828                         //      break;  // Nothing to do
829
830                         if (!new_label.empty())
831                                 numbered(r, true);
832                         label(r, new_label);
833                         return DISPATCHED;
834                 }
835
836                 case LFUN_MATH_EXTERN:
837                         doExtern(cmd, idx, pos);
838                         return DISPATCHED_POP;
839
840                 case LFUN_MATH_MUTATE: {
841                         row_type r = row(idx);
842                         col_type c = col(idx);
843                         mutate(cmd.argument);
844                         idx = r * ncols() + c;
845                         if (idx >= nargs())
846                                 idx = nargs() - 1;
847                         if (pos > cell(idx).size())
848                                 pos = cell(idx).size();
849                         return DISPATCHED_POP;
850                 }
851
852                 case LFUN_MATH_DISPLAY: {
853                         mutate(type_ == "simple" ? "equation" : "simple");
854                         idx = 0;
855                         pos = cell(idx).size();
856                         return DISPATCHED_POP;
857                 }
858
859                 default:
860                         return MathGridInset::dispatch(cmd, idx, pos);
861         }
862 }
863
864
865 string MathHullInset::fileInsetLabel() const
866 {
867         return "Formula";
868 }