+ if (data_.nargs() == 1) {
+ // single cell/part of cell
+ cursor.paste(data_.cell(0));
+ } else {
+ // mulitple cells
+ idx_type idx; // index of upper left cell
+ MathGridInset * p = cursor.enclosingGrid(idx);
+ col_type const numcols = min(data_.ncols(), p->ncols() - p->col(idx));
+ row_type const numrows = min(data_.nrows(), p->nrows() - p->row(idx));
+ for (row_type row = 0; row < numrows; ++row) {
+ for (col_type col = 0; col < numcols; ++col) {
+ idx_type i = p->index(row + p->row(idx), col + p->col(idx));
+ p->cell(i).push_back(data_.cell(data_.index(row, col)));
+ }
+ // append the left over horizontal cells to the last column
+ idx_type i = p->index(row + p->row(idx), p->ncols() - 1);
+ for (col_type col = numcols; col < data_.ncols(); ++col)
+ p->cell(i).push_back(data_.cell(data_.index(row, col)));
+ }
+ // append the left over vertical cells to the last _cell_
+ idx_type i = p->nargs() - 1;
+ for (row_type row = numrows; row < data_.nrows(); ++row)
+ for (col_type col = 0; col < data_.ncols(); ++col)
+ p->cell(i).push_back(data_.cell(data_.index(row, col)));
+ }