]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
InsetTabular.cpp:
[lyx.git] / src / insets / InsetTabular.cpp
index 35720b87eb78ac49cc3deb5caabdf1f44404de46..8367da719c9bbedd817543985c3b832b6920aa7a 100644 (file)
@@ -514,6 +514,9 @@ string const featureAsString(Tabular::Feature action)
 Tabular::CellData::CellData(Buffer * buf)
        : cellno(0),
          width(0),
+         height(0),
+         ascent(0),
+         descent(0),
          multicolumn(Tabular::CELL_NORMAL),
          multirow(Tabular::CELL_NORMAL),
          alignment(LYX_ALIGN_CENTER),
@@ -586,7 +589,9 @@ Tabular::RowData::RowData()
          endfoot(false),
          endlastfoot(false),
          newpage(false),
-         caption(false)
+         caption(false),
+         valignment(LYX_VALIGN_TOP),
+         maxheight(0)
 {}
 
 
@@ -696,8 +701,8 @@ void Tabular::deleteRow(row_type const row)
                // Care about multirow cells
                if (row + 1 < nrows() &&
                    cell_info[row][c].multirow == CELL_BEGIN_OF_MULTIROW &&
-                   cell_info[row][c + 1].multirow == CELL_PART_OF_MULTIROW) {
-                               cell_info[row][c + 1].multirow = CELL_BEGIN_OF_MULTIROW;
+                   cell_info[row + 1][c].multirow == CELL_PART_OF_MULTIROW) {
+                               cell_info[row + 1][c].multirow = CELL_BEGIN_OF_MULTIROW;
                }
        }
        row_info.erase(row_info.begin() + row);
@@ -891,21 +896,18 @@ int Tabular::columnWidth(idx_type cell) const
 }
 
 
-int Tabular::rowHeight(idx_type cell) const
+int Tabular::cellHeight(idx_type cell) const
 {
-       row_type const span = rowSpan(cell);
-       row_type const row = cellRow(cell);
-       int h = rowAscent(row) + rowDescent(row);
+       row_type const span = rowSpan(cell);
+       row_type const row = cellRow(cell);
+       int h = 0;
+       for(row_type r = row; r < row + span ; ++r) {
+               h += rowAscent(r) + rowDescent(r);
+               if (r != row + span - 1)
+                       h += interRowSpace(r + 1);
+       }
 
-       for(row_type r = row; r < row + span ; ++r) {
-               if (r > row) {
-                       h += rowAscent(r);
-                       h += interRowSpace(r);
-               }
-               if (r < row + span - 1)
-                       h += rowDescent(r);
-       }
-       return h;
+       return h;
 }
 
 
@@ -1180,7 +1182,7 @@ LyXAlignment Tabular::getAlignment(idx_type cell, bool onlycolumn) const
 Tabular::VAlignment
 Tabular::getVAlignment(idx_type cell, bool onlycolumn) const
 {
-       if (!onlycolumn && isMultiColumn(cell))
+       if (!onlycolumn && (isMultiColumn(cell) || isMultiRow(cell)))
                return cellInfo(cell).valignment;
        return column_info[cellColumn(cell)].valignment;
 }
@@ -1224,20 +1226,19 @@ int Tabular::textHOffset(idx_type cell) const
 
 int Tabular::textVOffset(idx_type cell) const
 {
-       int h = rowHeight(cell);
-       
-       int y = 0;
+       row_type const r = cellRow(cell);
+       int y = cellHeight(cell) - rowDescent(r) - rowAscent(r);
        switch (getVAlignment(cell)) {
           case LYX_VALIGN_TOP:
+                  y = 0;
                   break;
           case LYX_VALIGN_MIDDLE:
-                  y += h/2;
+                  y = y/2;
                   break;
           case LYX_VALIGN_BOTTOM:
-                  y += h;
                   break;
        }
-       
+
        return y;
 }
 
@@ -1503,17 +1504,20 @@ Tabular::CellData & Tabular::cellInfo(idx_type cell) const
 }
 
 
-void Tabular::setMultiColumn(idx_type cell, idx_type number)
+Tabular::idx_type Tabular::setMultiColumn(idx_type cell, idx_type number)
 {
        idx_type const col = cellColumn(cell);
        idx_type const row = cellRow(cell);
        for (idx_type i = 0; i < number; ++i)
                unsetMultiRow(cellIndex(row, col + i));
 
+       // unsetting of multirow may have invalidated cell index
+       cell = cellIndex(row, col);
        CellData & cs = cellInfo(cell);
        cs.multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
-       cs.alignment = column_info[cellColumn(cell)].alignment;
-       setRightLine(cell, rightLine(cell + number - 1));
+       cs.alignment = column_info[col].alignment;
+       if (col > 0)
+               setRightLine(cell, rightLine(cellIndex(row, col - 1)));
 
        for (idx_type i = 1; i < number; ++i) {
                CellData & cs1 = cellInfo(cell + i);
@@ -1522,6 +1526,7 @@ void Tabular::setMultiColumn(idx_type cell, idx_type number)
                cs1.inset->clear();
        }
        updateIndexes();
+       return cell;
 }
 
 
@@ -1532,24 +1537,25 @@ bool Tabular::isMultiRow(idx_type cell) const
 }
 
 
-void Tabular::setMultiRow(idx_type cell, idx_type number)
+Tabular::idx_type Tabular::setMultiRow(idx_type cell, idx_type number)
 {
        idx_type const col = cellColumn(cell);
        idx_type const row = cellRow(cell);
        for (idx_type i = 0; i < number; ++i)
                unsetMultiColumn(cellIndex(row + i, col));
 
+       // unsetting of multicol may have invalidated cell index
+       cell = cellIndex(row, col);
        CellData & cs = cellInfo(cell);
        cs.multirow = CELL_BEGIN_OF_MULTIROW;
-       // reset the vertical alignment to top because multirows cells
-       // cannot be vertically aligned (they can also only have one paragraph)
-       column_info[col].valignment = LYX_VALIGN_TOP;
-
-       // FIXME: the horizontal alignment can only be changed for
-       // the whole table, support for this needs to be implemented
-       // (assigning this to uwestoehr)
-       // until LyX supports this, the alignment is always left
-       column_info[col].alignment = LYX_ALIGN_LEFT;
+       cs.valignment = LYX_VALIGN_MIDDLE;
+       // FIXME: the horizontal alignment of multirow cells can only
+       // be changed for the whole table,
+       // support for this needs to be implemented but us a fileformat
+       // change (assigning this to uwestoehr)
+       // until LyX supports this, use the deault alignment of multirow
+       // cells: left
+       cs.alignment = LYX_ALIGN_LEFT; 
 
        // set the bottom row of the last selected cell
        setBottomLine(cell, bottomLine(cell + (number - 1)*ncols()));
@@ -1561,6 +1567,7 @@ void Tabular::setMultiRow(idx_type cell, idx_type number)
                cs1.inset->clear();
        }
        updateIndexes();
+       return cell;
 }
 
 
@@ -1605,6 +1612,8 @@ void Tabular::unsetMultiRow(idx_type cell)
        if (!isMultiRow(cell))
                return;
 
+       cellInfo(cell).valignment = LYX_VALIGN_TOP;
+       cellInfo(cell).alignment = LYX_ALIGN_CENTER;
        row_type const row = cellRow(cell);
        col_type const col = cellColumn(cell);
        row_type const span = rowSpan(cell);
@@ -2116,7 +2125,7 @@ int Tabular::TeXCellPreamble(odocstream & os, idx_type cell,
                else
                        // we need to set a default value
                        // needs to be discussed
-                       os << "2.0cm";
+                       os << "*";
                os << "}{";
                } // end if ismultirow
 
@@ -3180,7 +3189,7 @@ int InsetTabular::rowFromY(Cursor & cur, int y) const
        // top y coordinate of tabular
        int h = yo(cur.bv()) - tabular.rowAscent(0);
        row_type r = 0;
-       for (; r < nrows() && y > h; ++r)
+       for (; r < tabular.nrows() && y > h; ++r)
                h += tabular.rowAscent(r) + tabular.rowDescent(r)
                + tabular.interRowSpace(r);
 
@@ -3233,6 +3242,17 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
                        tabular.setCellWidth(cell, dim.wid);
                        maxAsc  = max(maxAsc, dim.asc);
                        maxDesc = max(maxDesc, dim.des);
+
+                       // store the height for every cell
+                       // this is later needed in InsetTabular::draw to determine the valignment
+                       int const top_space_cell = tabular.row_info[r].top_space_default ?
+                       default_line_space :
+                       tabular.row_info[r].top_space.inPixels(mi.base.textwidth);
+                       int const bottom_space_cell = tabular.row_info[r].bottom_space_default ?
+                       default_line_space :
+                       tabular.cell_info[r][c].height = dim.asc + dim.des;
+                       tabular.cell_info[r][c].ascent = dim.asc;
+                       tabular.cell_info[r][c].descent = dim.des;
                }
                int const top_space = tabular.row_info[r].top_space_default ?
                        default_line_space :
@@ -3249,6 +3269,7 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
        dim.wid = tabular.width() + 2 * ADD_TO_TABULAR_WIDTH;
 }
 
+
 bool InsetTabular::isCellSelected(Cursor & cur, row_type row, col_type col) 
        const
 {
@@ -3258,7 +3279,11 @@ bool InsetTabular::isCellSelected(Cursor & cur, row_type row, col_type col)
                        col_type cs, ce;
                        getSelection(cur, rs, re, cs, ce);
                        
-                       if (col >= cs && col <= ce && row >= rs && row <= re)
+                       idx_type const cell = tabular.cellIndex(row, col);
+                       col_type const cspan = tabular.columnSpan(cell);
+                       row_type const rspan = tabular.rowSpan(cell);
+                       if (col + cspan - 1 >= cs && col <= ce 
+                               && row + rspan - 1 >= rs && row <= re)
                                return true;
                } else 
                        if (col == tabular.cellColumn(cur.idx()) 
@@ -3291,7 +3316,32 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
        bool const original_selection_state = pi.selected;
 
        idx_type idx = 0;
+       int cy = 0;
        first_visible_cell = Tabular::npos;
+
+       // determine the highest cell because its valignment sets the row valignment
+       // also store its height
+       for (row_type r = 0; r < tabular.nrows(); ++r) {
+               int nx = x;
+               for (col_type c = 0; c < tabular.ncols(); ++c) {
+                       if (tabular.cell_info[r][c].height >= tabular.row_info[r].maxheight) {
+                               tabular.row_info[r].maxheight = tabular.cell_info[r][c].height;
+                               switch (tabular.getVAlignment(tabular.cellIndex(r, c))) {
+                                       case Tabular::LYX_VALIGN_TOP:
+                                               tabular.row_info[r].valignment = Tabular::LYX_VALIGN_TOP;
+                                               break;
+                                       case Tabular::LYX_VALIGN_MIDDLE:
+                                               tabular.row_info[r].valignment = Tabular::LYX_VALIGN_MIDDLE;
+                                               break;
+                                       case Tabular::LYX_VALIGN_BOTTOM:
+                                               tabular.row_info[r].valignment = Tabular::LYX_VALIGN_BOTTOM;
+                                               break;
+                               }
+                       }
+               }
+       }
+
+       // step over all cells
        for (row_type r = 0; r < tabular.nrows(); ++r) {
                int nx = x;
                for (col_type c = 0; c < tabular.ncols(); ++c) {
@@ -3309,10 +3359,77 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
                                first_visible_cell = idx;
 
                        pi.selected |= isCellSelected(cur, r, c);
+
+                       // set the position for the vertical alignment
+                       // if the cell is not the highest, align it according to the row valignment
+                       // and according to its own valignment
+                       // Note: The fractions of the scent values were found by testing
+                       // there is no bettwer way for the calculation because of LyX's definition
+                       // of ascent and descent. The correct way would be to calculate based
+                       // on the text height, the line space and paragraph separation.
+                       cy = y;
+                       if (tabular.cell_info[r][c].height < tabular.row_info[r].maxheight) {
+                               switch (tabular.row_info[r].valignment) {
+                                       case Tabular::LYX_VALIGN_TOP:
+                                               switch (tabular.getVAlignment(idx)) {
+                                                       case Tabular::LYX_VALIGN_TOP:
+                                                               break;
+                                                       case Tabular::LYX_VALIGN_MIDDLE:
+                                                               cy += - tabular.cell_info[r][c].descent / 2
+                                                                       + 0.3 * tabular.cell_info[r][c].ascent;
+                                                               // FIXME the row also needs to be increased at the upper border
+                                                               break;
+                                                       case Tabular::LYX_VALIGN_BOTTOM:
+                                                               cy += - tabular.cell_info[r][c].descent
+                                                                       + 0.6 * tabular.cell_info[r][c].ascent;
+                                                               // FIXME the row also needs to be increased at the upper border
+                                                               break;
+                                               }
+                                               break;
+                                       case Tabular::LYX_VALIGN_MIDDLE:
+                                               switch (tabular.getVAlignment(idx)) {
+                                                       case Tabular::LYX_VALIGN_TOP:
+                                                               cy += tabular.row_info[r].maxheight / 2
+                                                                       - 0.75 * tabular.cell_info[r][c].ascent;
+                                                               break;
+                                                       case Tabular::LYX_VALIGN_MIDDLE:
+                                                               cy += tabular.row_info[r].maxheight / 2
+                                                                       - tabular.cell_info[r][c].descent / 2
+                                                                       - 0.5 * tabular.cell_info[r][c].ascent;
+                                                               break;
+                                                       case Tabular::LYX_VALIGN_BOTTOM:
+                                                               cy += tabular.row_info[r].maxheight / 2
+                                                                       - tabular.cell_info[r][c].descent
+                                                                       - 0.2 * tabular.cell_info[r][c].ascent;
+                                                               break;
+                                               }
+                                               break;
+                                       case Tabular::LYX_VALIGN_BOTTOM:
+                                               switch (tabular.getVAlignment(idx)) {
+                                                       case Tabular::LYX_VALIGN_TOP:
+                                                               cy += tabular.row_info[r].maxheight
+                                                                       - 1.5 * tabular.cell_info[r][c].ascent;
+                                                               break;
+                                                       case Tabular::LYX_VALIGN_MIDDLE:
+                                                               cy += tabular.row_info[r].maxheight
+                                                                       - tabular.cell_info[r][c].descent / 2
+                                                                       - 1.2 * tabular.cell_info[r][c].ascent;
+                                                               // FIXME the row also needs to be increased at the lower border
+                                                               break;
+                                                       case Tabular::LYX_VALIGN_BOTTOM:
+                                                               cy += tabular.row_info[r].maxheight
+                                                                       - tabular.cell_info[r][c].descent
+                                                                       - 0.9 * tabular.cell_info[r][c].ascent;
+                                                               // FIXME the row also needs to be increased at the lower border
+                                                               break;
+                                               }
+                                               break;
+                               }
+                       }
+
                        int const cx = nx + tabular.textHOffset(idx);
-                       int const cy = y  + tabular.textVOffset(idx);
                        // Cache the Inset position.
-                       bv->coordCache().insets().add(cell(idx).get(), cx, y);
+                       bv->coordCache().insets().add(cell(idx).get(), cx, cy);
                        cell(idx)->draw(pi, cx, cy);
                        drawCellLines(pi.pain, nx, y, r, idx, pi.change_);
                        nx += tabular.columnWidth(idx);
@@ -3320,8 +3437,8 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
                }
 
                if (r + 1 < tabular.nrows())
-                       y += tabular.rowDescent(r) + tabular.rowAscent(r + 1)
-                            + tabular.interRowSpace(r + 1);
+                       y += tabular.rowDescent(r) + tabular.rowAscent(r + 1) 
+                               + tabular.interRowSpace(r + 1);
        }
 }
 
@@ -3353,7 +3470,6 @@ void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
                tabular.cellRow(cur.idx()), tabular.cellColumn(cur.idx()));
 
        if (cur.selIsMultiCell() || full_cell_selected) {
-               y -= tabular.rowAscent(0);
                for (row_type r = 0; r < tabular.nrows(); ++r) {
                        int xx = x;
                        for (col_type c = 0; c < tabular.ncols(); ++c) {
@@ -3367,9 +3483,10 @@ void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
                                        continue;
                                }
                                int const w = tabular.columnWidth(cell);
-                               int const h = tabular.rowHeight(cell);
+                               int const h = tabular.cellHeight(cell);
+                               int const yy = y - tabular.rowAscent(r);
                                if (isCellSelected(cur, r, c))
-                                       pi.pain.fillRectangle(xx, y, w, h, Color_selection);
+                                       pi.pain.fillRectangle(xx, yy, w, h, Color_selection);
                                xx += w;
                        }
                        if (r + 1 < tabular.nrows())
@@ -3386,49 +3503,42 @@ void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
 
 
 void InsetTabular::drawCellLines(Painter & pain, int x, int y,
-                                row_type row, idx_type cell, Change const & change) const
+                                                                row_type row, idx_type cell, Change const & change) const
 {
-       y = y - tabular.rowAscent(row);
+       y -= tabular.rowAscent(row);
        int const w = tabular.columnWidth(cell);
-       int const h = tabular.rowHeight(cell);
-       bool on_off = false;
-       Color col = Color_tabularline;
-       Color onoffcol = Color_tabularonoffline;
-
-       if (change.changed()) {
-               col = change.color();
-               onoffcol = change.color();
-       }
+       int const h = tabular.cellHeight(cell);
+       Color linecolor = change.changed() ? change.color() : Color_tabularline;
+       Color gridcolor = change.changed() ? change.color() : Color_tabularonoffline;
 
-       bool topalreadydrawn = row > 0 && !tabular.rowTopLine(row) 
+       // Top
+       bool drawline = tabular.topLine(cell) || row > 0
                && tabular.bottomLine(tabular.cellAbove(cell));
+       pain.line(x, y, x + w, y,
+               drawline ? linecolor : gridcolor,
+               drawline ? Painter::line_solid : Painter::line_onoffdash);
 
-       if (!topalreadydrawn) {
-               on_off = !tabular.topLine(cell);
-               pain.line(x, y, x + w, y,
-                       on_off ? onoffcol : col,
-                       on_off ? Painter::line_onoffdash : Painter::line_solid);
-       }
-       on_off = !tabular.bottomLine(cell);
+       // Bottom
+       drawline = tabular.bottomLine(cell);
        pain.line(x, y + h, x + w, y + h,
-               on_off ? onoffcol : col,
-               on_off ? Painter::line_onoffdash : Painter::line_solid);
+               drawline ? linecolor : gridcolor,
+               drawline ? Painter::line_solid : Painter::line_onoffdash);
 
-       col_type const column = tabular.cellColumn(cell);
-       bool leftalreadydrawn = column > 0  && !tabular.leftLine(cell)
-               && tabular.rightLine(tabular.cellIndex(row, column - 1));
+       // Left
+       col_type const col = tabular.cellColumn(cell);
+       drawline = tabular.leftLine(cell) || col > 0
+               && tabular.rightLine(tabular.cellIndex(row, col - 1));
+       pain.line(x, y, x, y + h,
+               drawline ? linecolor : gridcolor,
+               drawline ? Painter::line_solid : Painter::line_onoffdash);
 
-       if (!leftalreadydrawn) {
-               on_off = !tabular.leftLine(cell);
-               pain.line(x, y, x, y + h,
-                       on_off ? onoffcol : col,
-                       on_off ? Painter::line_onoffdash : Painter::line_solid);
-       }
-       on_off = !tabular.rightLine(cell);
-       pain.line(x + w - tabular.interColumnSpace(cell), y,
-               x + w - tabular.interColumnSpace(cell), y + h,
-               on_off ? onoffcol : col,
-               on_off ? Painter::line_onoffdash : Painter::line_solid);
+       // Right
+       x -= tabular.interColumnSpace(cell);
+       drawline = tabular.rightLine(cell) || col + 1 < tabular.ncols() 
+               && tabular.leftLine(tabular.cellIndex(row, col + 1));
+       pain.line(x + w, y, x + w, y + h,
+               drawline ? linecolor : gridcolor,
+               drawline ? Painter::line_solid : Painter::line_onoffdash);
 }
 
 
@@ -3971,21 +4081,15 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
-               istringstream is(to_utf8(cmd.argument()));
-               string s;
-               is >> s;
-               if (insetCode(s) != TABULAR_CODE) {
-                       status.clear();
-                       status.setEnabled(false);
+               if (&cur.inset() != this || cmd.getArg(0) != "tabular") 
                        break;
-               }
-               is >> s;
+
+               string const s = cmd.getArg(1);
                // FIXME: We only check for the very first argument...
                int action = Tabular::LAST_ACTION;
                int i = 0;
                for (; tabularFeature[i].action != Tabular::LAST_ACTION; ++i) {
-                       string const tmp = tabularFeature[i].feature;
-                       if (tmp == s.substr(0, tmp.length())) {
+                       if (tabularFeature[i].feature == s) {
                                action = tabularFeature[i].action;
                                break;
                        }
@@ -3996,8 +4100,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                        return true;
                }
 
-               string const argument
-                       = ltrim(s.substr(tabularFeature[i].feature.length()));
+               string const argument = cmd.getLongArg(2);
 
                row_type sel_row_start = 0;
                row_type sel_row_end = 0;
@@ -4447,16 +4550,10 @@ void InsetTabular::cursorPos(BufferView const & bv,
        int const col = tabular.cellColumn(sl.idx());
 
        // y offset     correction
-       for (int r = 0; r <= row; ++r) {
-               if (tabular.isPartOfMultiRow(r, col))
-                       continue;
-               if (r != 0) {
-                       y += tabular.rowAscent(r);
-                       y += tabular.interRowSpace(r);
-               }
-               if (r != row)
-                       y += tabular.rowDescent(r);
-       }
+       for (int r = 0; r < row; ++r)
+               y += tabular.rowDescent(r) + tabular.rowAscent(r + 1) 
+                       + tabular.interRowSpace(r + 1);
+
        y += tabular.textVOffset(sl.idx());
 
        // x offset correction
@@ -4480,7 +4577,7 @@ int InsetTabular::dist(BufferView & bv, idx_type const cell, int x, int y) const
        row_type const row = tabular.cellRow(cell);
        int const ybeg = o.y_ - tabular.rowAscent(row)
                - tabular.interRowSpace(row);
-       int const yend = o.y_ + tabular.rowDescent(row);
+       int const yend = ybeg + tabular.cellHeight(cell);
 
        if (x < xbeg)
                xx = xbeg - x;
@@ -4599,8 +4696,10 @@ void InsetTabular::moveNextCell(Cursor & cur, EntryDirection entry_from)
                        return;
                if (cur.idx() == tabular.getLastCellInRow(row))
                        cur.idx() = tabular.cellIndex(row + 1, 0);
-               else
-                       cur.idx() = tabular.cellIndex(row, col + 1);
+               else {
+                       col_type const colnextcell = col + tabular.columnSpan(cur.idx());
+                       cur.idx() = tabular.cellIndex(row, colnextcell);
+               }
        }
 
        cur.boundary(false);
@@ -4975,8 +5074,7 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                idx_type const s_start = cur.selBegin().idx();
                row_type const col_start = tabular.cellColumn(s_start);
                row_type const col_end = tabular.cellColumn(cur.selEnd().idx());
-               tabular.setMultiColumn(s_start, col_end - col_start + 1);
-               cur.idx() = s_start;
+               cur.idx() = tabular.setMultiColumn(s_start, col_end - col_start + 1);
                cur.pit() = 0;
                cur.pos() = 0;
                cur.setSelection(false);
@@ -4998,8 +5096,7 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                idx_type const s_start = cur.selBegin().idx();
                row_type const row_start = tabular.cellRow(s_start);
                row_type const row_end = tabular.cellRow(cur.selEnd().idx());
-               tabular.setMultiRow(s_start, row_end - row_start + 1);
-               cur.idx() = s_start;
+               cur.idx() = tabular.setMultiRow(s_start, row_end - row_start + 1);
                cur.pit() = 0;
                cur.pos() = 0;
                cur.setSelection(false);