1 #include "math_gridinset.h"
2 #include "math_mathmlstream.h"
3 #include "math_streamstr.h"
5 #include "funcrequest.h"
6 #include "frontends/Painter.h"
11 #include "insets/mailinset.h"
20 class GridInsetMailer : public MailInset {
22 GridInsetMailer(MathGridInset & inset) : inset_(inset) {}
24 virtual string const & name() const
26 static const string theName = "tabular";
30 virtual string const inset2string() const
33 //data << name() << " active_cell " << inset.getActCell() << '\n';
34 data << name() << " active_cell " << 0 << '\n';
41 InsetBase & inset() const { return inset_; }
42 MathGridInset & inset_;
46 void mathed_parse_normal(MathGridInset &, string const & argument);
50 string verboseHLine(int n)
53 for (int i = 0; i < n; ++i)
61 int extractInt(istream & is)
65 return (num == 0) ? 1 : num;
71 int MathGridInset::RowInfo::skipPixels() const
73 return crskip_.inBP();
78 //////////////////////////////////////////////////////////////
81 MathGridInset::MathGridInset(char v, string const & h)
82 : MathNestInset(1), rowinfo_(1), colinfo_(1), cellinfo_(1)
87 //lyxerr << "created grid with " << ncols() << " columns\n";
91 MathGridInset::MathGridInset()
92 : MathNestInset(1), rowinfo_(1), colinfo_(1), cellinfo_(1), v_align_('c')
98 MathGridInset::MathGridInset(col_type m, row_type n)
99 : MathNestInset(m * n),
100 rowinfo_(n), colinfo_(m), cellinfo_(m * n), v_align_('c')
106 MathGridInset::MathGridInset(col_type m, row_type n, char v, string const & h)
107 : MathNestInset(m * n),
108 rowinfo_(n), colinfo_(m), cellinfo_(m * n), v_align_(v)
116 MathGridInset::~MathGridInset()
118 GridInsetMailer mailer(*this);
123 MathInset * MathGridInset::clone() const
125 return new MathGridInset(*this);
129 MathInset::idx_type MathGridInset::index(row_type row, col_type col) const
131 return col + ncols() * row;
135 void MathGridInset::setDefaults()
138 lyxerr << "positive number of columns expected\n";
140 // lyxerr << "positive number of rows expected\n";
141 for (col_type col = 0; col < ncols(); ++col) {
142 colinfo_[col].align = defaultColAlign(col);
143 colinfo_[col].skip_ = defaultColSpace(col);
148 void MathGridInset::halign(string const & hh)
151 for (string::const_iterator it = hh.begin(); it != hh.end(); ++it) {
156 colinfo_[col].lines_++;
157 } else if (c == 'c' || c == 'l' || c == 'r') {
158 colinfo_[col].align = c;
160 colinfo_[col].lines_ = 0;
162 lyxerr << "unknown column separator: '" << c << "'\n";
167 col_type n = hh.size();
170 for (col_type col = 0; col < n; ++col)
171 colinfo_[col].align_ = hh[col];
177 void MathGridInset::halign(char h, col_type col)
179 colinfo_[col].align = h;
183 char MathGridInset::halign(col_type col) const
185 return colinfo_[col].align;
189 string MathGridInset::halign() const
192 for (col_type col = 0; col < ncols(); ++col) {
193 res += string(colinfo_[col].lines_, '|');
194 res += colinfo_[col].align;
196 return res + string(colinfo_[ncols()].lines_, '|');
200 void MathGridInset::valign(char c)
206 char MathGridInset::valign() const
212 MathGridInset::col_type MathGridInset::ncols() const
214 return colinfo_.size();
218 MathGridInset::row_type MathGridInset::nrows() const
220 return rowinfo_.size();
224 MathGridInset::col_type MathGridInset::col(idx_type idx) const
226 return idx % ncols();
230 MathGridInset::row_type MathGridInset::row(idx_type idx) const
232 return idx / ncols();
236 void MathGridInset::vcrskip(LyXLength const & crskip, row_type row)
238 rowinfo_[row].crskip_ = crskip;
242 LyXLength MathGridInset::vcrskip(row_type row) const
244 return rowinfo_[row].crskip_;
248 void MathGridInset::metrics(MetricsInfo & mi) const
250 // let the cells adjust themselves
251 MathNestInset::metrics(mi);
253 // compute absolute sizes of vertical structure
254 for (row_type row = 0; row < nrows(); ++row) {
257 for (col_type col = 0; col < ncols(); ++col) {
258 MathArray const & c = cell(index(row, col));
259 asc = max(asc, c.ascent());
260 desc = max(desc, c.descent());
262 rowinfo_[row].ascent_ = asc;
263 rowinfo_[row].descent_ = desc;
265 rowinfo_[0].ascent_ += hlinesep() * rowinfo_[0].lines_;
267 // compute vertical offsets
268 rowinfo_[0].offset_ = 0;
269 for (row_type row = 1; row < nrows(); ++row) {
270 rowinfo_[row].offset_ =
271 rowinfo_[row - 1].offset_ +
272 rowinfo_[row - 1].descent_ +
273 rowinfo_[row - 1].skipPixels() +
275 rowinfo_[row].lines_ * hlinesep() +
276 rowinfo_[row].ascent_;
279 // adjust vertical offset
286 h = rowinfo_[nrows() - 1].offset_;
289 h = rowinfo_[nrows() - 1].offset_ / 2;
291 for (row_type row = 0; row < nrows(); ++row)
292 rowinfo_[row].offset_ -= h;
295 // compute absolute sizes of horizontal structure
296 for (col_type col = 0; col < ncols(); ++col) {
298 for (row_type row = 0; row < nrows(); ++row)
299 wid = max(wid, cell(index(row, col)).width());
300 colinfo_[col].width_ = wid;
303 // compute horizontal offsets
304 colinfo_[0].offset_ = border();
305 for (col_type col = 1; col < ncols(); ++col) {
306 colinfo_[col].offset_ =
307 colinfo_[col - 1].offset_ +
308 colinfo_[col - 1].width_ +
309 colinfo_[col - 1].skip_ +
311 colinfo_[col].lines_ * vlinesep();
315 dim_.w = colinfo_[ncols() - 1].offset_
316 + colinfo_[ncols() - 1].width_
317 //+ vlinesep() * colinfo_[ncols()].lines_
320 dim_.a = - rowinfo_[0].offset_
321 + rowinfo_[0].ascent_
322 + hlinesep() * rowinfo_[0].lines_
325 dim_.d = rowinfo_[nrows() - 1].offset_
326 + rowinfo_[nrows() - 1].descent_
327 //+ hlinesep() * rowinfo_[nrows()].lines_
332 // Increase ws_[i] for 'R' columns (except the first one)
333 for (int i = 1; i < nc_; ++i)
334 if (align_[i] == 'R')
335 ws_[i] += 10 * df_width;
336 // Increase ws_[i] for 'C' column
337 if (align_[0] == 'C')
338 if (ws_[0] < 7 * workwidth / 8)
339 ws_[0] = 7 * workwidth / 8;
343 for (cxrow = row_.begin(); cxrow; ++cxrow) {
346 for (int i = 0; i < nc_; ++i) {
348 if (cxrow->getTab(i) <= 0) {
349 cxrow->setTab(i, df_width);
357 lf = (ws_[i] - cxrow->getTab(i))/2;
361 lf = ws_[i] - cxrow->getTab(i);
364 if (cxrow == row_.begin())
366 else if (cxrow.is_last())
367 lf = ws_[i] - cxrow->getTab(i);
369 lf = (ws_[i] - cxrow->getTab(i))/2;
372 int const ww = (isvoid) ? lf : lf + cxrow->getTab(i);
373 cxrow->setTab(i, lf + rg);
374 rg = ws_[i] - ww + colsep();
375 if (cxrow == row_.begin())
376 width += ws_[i] + colsep();
378 cxrow->setBaseline(cxrow->getBaseline() - ascent);
384 void MathGridInset::draw(PainterInfo & pi, int x, int y) const
386 for (idx_type idx = 0; idx < nargs(); ++idx)
387 cell(idx).draw(pi, x + cellXOffset(idx), y + cellYOffset(idx));
389 for (row_type row = 0; row < nrows(); ++row)
390 for (int i = 0; i < rowinfo_[row].lines_; ++i) {
391 int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
392 - i * hlinesep() - hlinesep()/2 - rowsep()/2;
393 pi.pain.line(x + 1, yy, x + width() - 1, yy);
396 for (col_type col = 0; col < ncols(); ++col)
397 for (int i = 0; i < colinfo_[col].lines_; ++i) {
398 int xx = x + colinfo_[col].offset_
399 - i * vlinesep() - vlinesep()/2 - colsep()/2;
400 pi.pain.line(xx, y - ascent() + 1, xx, y + descent() - 1);
405 void MathGridInset::metricsT(TextMetricsInfo const & mi) const
407 // let the cells adjust themselves
408 //MathNestInset::metrics(mi);
409 for (idx_type i = 0; i < nargs(); ++i)
410 cell(i).metricsT(mi);
412 // compute absolute sizes of vertical structure
413 for (row_type row = 0; row < nrows(); ++row) {
416 for (col_type col = 0; col < ncols(); ++col) {
417 MathArray const & c = cell(index(row, col));
418 asc = max(asc, c.ascent());
419 desc = max(desc, c.descent());
421 rowinfo_[row].ascent_ = asc;
422 rowinfo_[row].descent_ = desc;
424 //rowinfo_[0].ascent_ += hlinesep() * rowinfo_[0].lines_;
425 rowinfo_[nrows()].ascent_ = 0;
426 rowinfo_[nrows()].descent_ = 0;
428 // compute vertical offsets
429 rowinfo_[0].offset_ = 0;
430 for (row_type row = 1; row < nrows(); ++row) {
431 rowinfo_[row].offset_ =
432 rowinfo_[row - 1].offset_ +
433 rowinfo_[row - 1].descent_ +
434 //rowinfo_[row - 1].skipPixels() +
436 //rowinfo_[row].lines_ * hlinesep() +
437 rowinfo_[row].ascent_;
440 // adjust vertical offset
447 h = rowinfo_[nrows() - 1].offset_;
450 h = rowinfo_[nrows() - 1].offset_ / 2;
452 for (row_type row = 0; row < nrows(); ++row)
453 rowinfo_[row].offset_ -= h;
456 // compute absolute sizes of horizontal structure
457 for (col_type col = 0; col < ncols(); ++col) {
459 for (row_type row = 0; row < nrows(); ++row)
460 wid = max(wid, cell(index(row, col)).width());
461 colinfo_[col].width_ = wid;
463 colinfo_[ncols()].width_ = 0;
465 // compute horizontal offsets
466 colinfo_[0].offset_ = border();
467 for (col_type col = 1; col < ncols(); ++col) {
468 colinfo_[col].offset_ =
469 colinfo_[col - 1].offset_ +
470 colinfo_[col - 1].width_ +
471 colinfo_[col - 1].skip_ +
473 //colinfo_[col].lines_ * vlinesep();
477 dim_.w = colinfo_[ncols() - 1].offset_
478 + colinfo_[ncols() - 1].width_
479 //+ vlinesep() * colinfo_[ncols()].lines_
482 dim_.a = -rowinfo_[0].offset_
483 + rowinfo_[0].ascent_
484 //+ hlinesep() * rowinfo_[0].lines_
487 dim_.d = rowinfo_[nrows() - 1].offset_
488 + rowinfo_[nrows() - 1].descent_
489 //+ hlinesep() * rowinfo_[nrows()].lines_
495 void MathGridInset::drawT(TextPainter & pain, int x, int y) const
497 for (idx_type idx = 0; idx < nargs(); ++idx)
498 cell(idx).drawT(pain, x + cellXOffset(idx), y + cellYOffset(idx));
502 string MathGridInset::eolString(row_type row, bool fragile) const
506 if (!rowinfo_[row].crskip_.zero())
507 eol += '[' + rowinfo_[row].crskip_.asLatexString() + ']';
509 // make sure an upcoming '[' does not break anything
510 if (row + 1 < nrows()) {
511 MathArray const & c = cell(index(row + 1, 0));
512 if (c.size() && c.front()->getChar() == '[')
517 // only add \\ if necessary
518 if (eol.empty() && row + 1 == nrows())
521 return (fragile ? "\\protect\\\\" : "\\\\") + eol;
525 string MathGridInset::eocString(col_type col, col_type lastcol) const
527 if (col + 1 == lastcol)
533 void MathGridInset::addRow(row_type row)
535 rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
537 (cells_.begin() + (row + 1) * ncols(), ncols(), MathArray());
539 (cellinfo_.begin() + (row + 1) * ncols(), ncols(), CellInfo());
543 void MathGridInset::appendRow()
545 rowinfo_.push_back(RowInfo());
546 //cells_.insert(cells_.end(), ncols(), MathArray());
547 for (col_type col = 0; col < ncols(); ++col) {
548 cells_.push_back(cells_type::value_type());
549 cellinfo_.push_back(CellInfo());
554 void MathGridInset::delRow(row_type row)
559 cells_type::iterator it = cells_.begin() + row * ncols();
560 cells_.erase(it, it + ncols());
562 vector<CellInfo>::iterator jt = cellinfo_.begin() + row * ncols();
563 cellinfo_.erase(jt, jt + ncols());
565 rowinfo_.erase(rowinfo_.begin() + row);
569 void MathGridInset::copyRow(row_type row)
572 for (col_type col = 0; col < ncols(); ++col)
573 cells_[(row + 1) * ncols() + col] = cells_[row * ncols() + col];
577 void MathGridInset::swapRow(row_type row)
581 if (row + 1 == nrows())
583 for (col_type col = 0; col < ncols(); ++col)
584 swap(cells_[row * ncols() + col], cells_[(row + 1) * ncols() + col]);
588 void MathGridInset::addCol(col_type newcol)
590 const col_type nc = ncols();
591 const row_type nr = nrows();
592 cells_type new_cells((nc + 1) * nr);
593 vector<CellInfo> new_cellinfo((nc + 1) * nr);
595 for (row_type row = 0; row < nr; ++row)
596 for (col_type col = 0; col < nc; ++col) {
597 new_cells[row * (nc + 1) + col + (col > newcol)]
598 = cells_[row * nc + col];
599 new_cellinfo[row * (nc + 1) + col + (col > newcol)]
600 = cellinfo_[row * nc + col];
602 swap(cells_, new_cells);
603 swap(cellinfo_, new_cellinfo);
606 inf.skip_ = defaultColSpace(newcol);
607 inf.align = defaultColAlign(newcol);
608 colinfo_.insert(colinfo_.begin() + newcol, inf);
612 void MathGridInset::delCol(col_type col)
618 vector<CellInfo> tmpcellinfo;
619 for (col_type i = 0; i < nargs(); ++i)
620 if (i % ncols() != col) {
621 tmpcells.push_back(cells_[i]);
622 tmpcellinfo.push_back(cellinfo_[i]);
624 swap(cells_, tmpcells);
625 swap(cellinfo_, tmpcellinfo);
627 colinfo_.erase(colinfo_.begin() + col);
631 void MathGridInset::copyCol(col_type col)
634 for (row_type row = 0; row < nrows(); ++row)
635 cells_[row * ncols() + col + 1] = cells_[row * ncols() + col];
639 void MathGridInset::swapCol(col_type col)
643 if (col + 1 == ncols())
645 for (row_type row = 0; row < nrows(); ++row)
646 swap(cells_[row * ncols() + col], cells_[row * ncols() + col + 1]);
650 int MathGridInset::cellXOffset(idx_type idx) const
652 col_type c = col(idx);
653 int x = colinfo_[c].offset_;
654 char align = colinfo_[c].align;
655 if (align == 'r' || align == 'R')
656 x += colinfo_[c].width_ - cell(idx).width();
657 if (align == 'c' || align == 'C')
658 x += (colinfo_[c].width_ - cell(idx).width()) / 2;
663 int MathGridInset::cellYOffset(idx_type idx) const
665 return rowinfo_[row(idx)].offset_;
669 bool MathGridInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
676 pos = cell(idx).x2pos(targetx - cell(idx).xo());
679 if (idx >= ncols() * (nrows() - 1))
682 pos = cell(idx).x2pos(targetx - cell(idx).xo());
688 bool MathGridInset::idxLeft(idx_type & idx, pos_type & pos) const
690 // leave matrix if on the left hand edge
694 pos = cell(idx).size();
699 bool MathGridInset::idxRight(idx_type & idx, pos_type & pos) const
701 // leave matrix if on the right hand edge
702 if (col(idx) + 1 == ncols())
710 bool MathGridInset::idxFirst(idx_type & idx, pos_type & pos) const
717 idx = (nrows() - 1) * ncols();
720 idx = ((nrows() - 1) / 2) * ncols();
727 bool MathGridInset::idxLast(idx_type & idx, pos_type & pos) const
737 idx = ((nrows() - 1) / 2 + 1) * ncols() - 1;
739 pos = cell(idx).size();
744 bool MathGridInset::idxHome(idx_type & idx, pos_type & pos) const
751 idx -= idx % ncols();
764 bool MathGridInset::idxEnd(idx_type & idx, pos_type & pos) const
766 if (pos < cell(idx).size()) {
767 pos = cell(idx).size();
770 if (col(idx) < ncols() - 1) {
771 idx = idx - idx % ncols() + ncols() - 1;
772 pos = cell(idx).size();
775 if (idx < nargs() - 1) {
777 pos = cell(idx).size();
784 bool MathGridInset::idxDelete(idx_type & idx)
786 // nothing to do if we have just one row
790 // nothing to do if we are in the middle of the last row of the inset
791 if (idx + ncols() > nargs())
794 // try to delete entire sequence of ncols() empty cells if possible
795 for (idx_type i = idx; i < idx + ncols(); ++i)
799 // move cells if necessary
800 for (idx_type i = index(row(idx), 0); i < idx; ++i)
801 std::swap(cell(i), cell(i + ncols()));
808 // undo effect of Ctrl-Tab (i.e. pull next cell)
809 //if (idx + 1 != nargs())
810 // cell(idx).swap(cell(idx + 1));
812 // we handled the event..
817 // reimplement old behaviour when pressing Delete in the last position
819 void MathGridInset::idxGlue(idx_type idx)
821 col_type c = col(idx);
822 if (c + 1 == ncols()) {
823 if (row(idx) + 1 != nrows()) {
824 for (col_type cc = 0; cc < ncols(); ++cc)
825 cell(idx).append(cell(idx + cc + 1));
826 delRow(row(idx) + 1);
829 cell(idx).append(cell(idx + 1));
830 for (col_type cc = c + 2; cc < ncols(); ++cc)
831 cell(idx - c + cc - 1) = cell(idx - c + cc);
832 cell(idx - c + ncols() - 1).clear();
837 MathGridInset::RowInfo const & MathGridInset::rowinfo(row_type row) const
839 return rowinfo_[row];
843 MathGridInset::RowInfo & MathGridInset::rowinfo(row_type row)
845 return rowinfo_[row];
849 bool MathGridInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
851 row_type const ri = row(idx);
852 row_type const r1 = min(row(from), row(to));
853 row_type const r2 = max(row(from), row(to));
854 col_type const ci = col(idx);
855 col_type const c1 = min(col(from), col(to));
856 col_type const c2 = max(col(from), col(to));
857 return r1 <= ri && ri <= r2 && c1 <= ci && ci <= c2;
862 void MathGridInset::normalize(NormalStream & os) const
865 for (row_type row = 0; row < nrows(); ++row) {
867 for (col_type col = 0; col < ncols(); ++col)
868 os << "[cell " << cell(index(row, col)) << ']';
875 void MathGridInset::mathmlize(MathMLStream & os) const
877 os << MTag("mtable");
878 for (row_type row = 0; row < nrows(); ++row) {
880 for (col_type col = 0; col < ncols(); ++col)
881 os << cell(index(row, col));
884 os << ETag("mtable");
888 void MathGridInset::write(WriteStream & os) const
890 for (row_type row = 0; row < nrows(); ++row) {
891 os << verboseHLine(rowinfo_[row].lines_);
892 // don't write & and empty cells at end of line
893 col_type lastcol = 0;
894 bool emptyline = true;
895 for (col_type col = 0; col < ncols(); ++col)
896 if (!cell(index(row, col)).empty()) {
900 for (col_type col = 0; col < lastcol; ++col)
901 os << cell(index(row, col)) << eocString(col, lastcol);
902 os << eolString(row, os.fragile());
903 // append newline only if line wasn't completely empty
904 // and this was not the last line in the grid
905 if (!emptyline && row + 1 < nrows())
908 //string const s = verboseHLine(rowinfo_[nrows()].lines_);
909 //if (!s.empty() && s != " ") {
911 // os << "\\protect";
912 // os << "\\\\" << s;
917 int MathGridInset::colsep() const
923 int MathGridInset::rowsep() const
929 int MathGridInset::hlinesep() const
935 int MathGridInset::vlinesep() const
941 int MathGridInset::border() const
947 void MathGridInset::splitCell(idx_type & idx, pos_type & pos)
949 if (idx + 1 == nargs())
951 MathArray ar = cell(idx);
953 cell(idx).erase(pos, cell(idx).size());
956 cell(idx).insert(0, ar);
960 dispatch_result MathGridInset::dispatch
961 (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
963 switch (cmd.action) {
965 case LFUN_MOUSE_RELEASE:
966 //if (cmd.button() == mouse_button::button3) {
967 // GridInsetMailer mailer(*this);
968 // mailer.showDialog();
969 // return DISPATCHED;
973 case LFUN_INSET_DIALOG_UPDATE: {
974 GridInsetMailer mailer(*this);
975 mailer.updateDialog(cmd.view());
979 // insert file functions
980 case LFUN_DELETE_LINE_FORWARD:
981 //autocorrect_ = false;
991 if (pos > cell(idx).size())
992 pos = cell(idx).size();
993 return DISPATCHED_POP;
995 case LFUN_CELL_SPLIT:
996 //bv->lockedInsetStoreUndo(Undo::EDIT);
998 return DISPATCHED_POP;
1000 case LFUN_BREAKLINE: {
1001 //bv->lockedInsetStoreUndo(Undo::INSERT);
1002 row_type const r = row(idx);
1006 for (col_type c = col(idx) + 1; c < ncols(); ++c)
1007 std::swap(cell(index(r, c)), cell(index(r + 1, c)));
1010 splitCell(idx, pos);
1011 std::swap(cell(idx), cell(idx + ncols() - 1));
1014 pos = cell(idx).size();
1016 //mathcursor->normalize();
1017 return DISPATCHED_POP;
1020 case LFUN_TABULAR_FEATURE: {
1021 //lyxerr << "handling tabular-feature " << cmd.argument << "\n";
1022 istringstream is(cmd.argument);
1025 if (s == "valign-top")
1027 else if (s == "valign-center")
1029 else if (s == "valign-bottom")
1031 else if (s == "align-left")
1032 halign('l', col(idx));
1033 else if (s == "align-right")
1034 halign('r', col(idx));
1035 else if (s == "align-center")
1036 halign('c', col(idx));
1037 else if (s == "append-row")
1038 for (int i = 0, n = extractInt(is); i < n; ++i)
1040 else if (s == "delete-row")
1041 for (int i = 0, n = extractInt(is); i < n; ++i) {
1046 else if (s == "copy-row")
1047 for (int i = 0, n = extractInt(is); i < n; ++i)
1049 else if (s == "swap-row")
1051 else if (s == "append-column")
1052 for (int i = 0, n = extractInt(is); i < n; ++i) {
1053 row_type r = row(idx);
1054 col_type c = col(idx);
1058 else if (s == "delete-column")
1059 for (int i = 0, n = extractInt(is); i < n; ++i) {
1060 row_type r = row(idx);
1061 col_type c = col(idx);
1067 else if (s == "copy-column")
1069 else if (s == "swap-column")
1072 return UNDISPATCHED;
1073 lyxerr << "returning DISPATCHED_POP\n";
1074 return DISPATCHED_POP;
1078 //lyxerr << "pasting '" << cmd.argument << "'\n";
1079 MathGridInset grid(1, 1);
1080 mathed_parse_normal(grid, cmd.argument);
1081 if (grid.nargs() == 1) {
1082 // single cell/part of cell
1083 cell(idx).insert(pos, grid.cell(0));
1084 pos += grid.cell(0).size();
1087 col_type const numcols = min(grid.ncols(), ncols() - col(idx));
1088 row_type const numrows = min(grid.nrows(), nrows() - row(idx));
1089 for (row_type r = 0; r < numrows; ++r) {
1090 for (col_type c = 0; c < numcols; ++c) {
1091 idx_type i = index(r + row(idx), c + col(idx));
1092 cell(i).append(grid.cell(grid.index(r, c)));
1094 // append the left over horizontal cells to the last column
1095 idx_type i = index(r + row(idx), ncols() - 1);
1096 for (MathInset::col_type c = numcols; c < grid.ncols(); ++c)
1097 cell(i).append(grid.cell(grid.index(r, c)));
1099 // append the left over vertical cells to the last _cell_
1100 idx_type i = nargs() - 1;
1101 for (row_type r = numrows; r < grid.nrows(); ++r)
1102 for (col_type c = 0; c < grid.ncols(); ++c)
1103 cell(i).append(grid.cell(grid.index(r, c)));
1105 return DISPATCHED_POP;
1109 return MathNestInset::dispatch(cmd, idx, pos);
1111 return UNDISPATCHED;