Tabular::idx_type Tabular::getFirstCellInRow(row_type row) const
{
col_type c = 0;
- while (cell_info[row][c].multirow == CELL_PART_OF_MULTIROW)
+ idx_type const numcells = numberOfCellsInRow(row);
+ // we check against numcells to make sure we do not crash if all the
+ // cells are multirow (bug #7535), but in that case our return value
+ // is really invalid, i.e., it is NOT the first cell in the row. but
+ // i do not know what to do here. (rgh)
+ while (c < numcells - 1
+ && cell_info[row][c].multirow == CELL_PART_OF_MULTIROW)
++c;
return cell_info[row][c].cellno;
}
Tabular::idx_type Tabular::getLastCellInRow(row_type row) const
{
col_type c = ncols() - 1;
+ // of course we check against 0 so we don't crash. but we have the same
+ // problem as in the previous routine: if all the cells are part of a
+ // multirow or part of a multi column, then our return value is invalid.
while (c > 0
&& (cell_info[row][c].multirow == CELL_PART_OF_MULTIROW
|| cell_info[row][c].multicolumn == CELL_PART_OF_MULTICOLUMN))
}
-Tabular::idx_type Tabular::setMultiRow(idx_type cell, idx_type number)
+Tabular::idx_type Tabular::setMultiRow(idx_type cell, idx_type number,
+ bool const bottom_border)
{
idx_type const col = cellColumn(cell);
idx_type const row = cellRow(cell);
// cells: left
cs.alignment = LYX_ALIGN_LEFT;
- // set the bottom row of the last selected cell
- setBottomLine(cell, bottomLine(cell + (number - 1)*ncols()));
+ // set the bottom line of the last selected cell
+ setBottomLine(cell, bottom_border);
for (idx_type i = 1; i < number; ++i) {
CellData & cs1 = cell_info[row + i][col];
// multirow, no line must be drawn.
if (row != 0)
if (isMultiRow(cellIndex(row, c))
- && isMultiRow(cellIndex(row - 1, c)))
- topline[c] = false;
+ && cell_info[row][c].multirow != CELL_BEGIN_OF_MULTIROW)
+ topline[c] = false;
if (topline[c])
++nset;
}
for (col_type c = 0; c < ncols(); ++c) {
bottomline.push_back(bottomLine(cellIndex(row, c)));
topline.push_back(!lastrow && topLine(cellIndex(row + 1, c)));
- // If cell is part of a multirow and not the last or first cell of the
+ // If cell is part of a multirow and not the last cell of the
// multirow, no line must be drawn.
if (!lastrow)
if (isMultiRow(cellIndex(row, c))
- && isMultiRow(cellIndex(row + 1, c))) {
- bottomline[c] = false;
- topline[c] = false;
+ && isMultiRow(cellIndex(row + 1, c))
+ && cell_info[row + 1][c].multirow != CELL_BEGIN_OF_MULTIROW) {
+ bottomline[c] = false;
+ topline[c] = false;
}
nextrowset &= topline[c];
}
xs << html::StartTag("tr");
for (col_type c = 0; c < ncols(); ++c) {
- if (isPartOfMultiColumn(row, c))
+ if (isPartOfMultiColumn(row, c) || isPartOfMultiRow(row, c))
continue;
stringstream attr;
if (isMultiColumn(cell))
attr << " colspan='" << columnSpan(cell) << "'";
+ else if (isMultiRow(cell))
+ attr << " rowspan='" << rowSpan(cell) << "'";
xs << html::StartTag(celltag, attr.str()) << html::CR();
ret += cellInset(cell)->xhtml(xs, runparams);
// just multirow for one single cell
// check whether we are completely in a multirow
if (!tabular.isMultiRow(cur.idx()))
- tabular.setMultiRow(cur.idx(), 1);
+ tabular.setMultiRow(cur.idx(), 1,
+ tabular.bottomLine(cur.idx()));
break;
}
// we have a selection so this means we just add all this
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());
- cur.idx() = tabular.setMultiRow(s_start, row_end - row_start + 1);
+ cur.idx() = tabular.setMultiRow(s_start, row_end - row_start + 1,
+ tabular.bottomLine(cur.selEnd().idx()));
cur.pit() = 0;
cur.pos() = 0;
cur.setSelection(false);