int Tabular::rowHeight(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;
}
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;
}
int Tabular::textVOffset(idx_type cell) const
{
int h = rowHeight(cell);
-
+
+ row_type const r = cellRow(cell);
+ if (rowSpan(cell) > 1)
+ h -= rowDescent(r) + rowAscent(r);
+
int y = 0;
switch (getVAlignment(cell)) {
case LYX_VALIGN_TOP:
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;
// set the bottom row of the last selected cell
setBottomLine(cell, bottomLine(cell + (number - 1)*ncols()));
if (!isMultiRow(cell))
return;
+ cellInfo(cell).valignment = LYX_VALIGN_TOP;
row_type const row = cellRow(cell);
col_type const col = cellColumn(cell);
row_type const span = rowSpan(cell);
// 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);
xx += w;
}
if (r + 1 < tabular.nrows())
- y += tabular.rowDescent(r) + tabular.rowAscent(r + 1)
+ y += tabular.rowDescent(r) + tabular.rowAscent(r)
+ tabular.interRowSpace(r + 1);
}
{
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;
}
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;
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.rowAscent(r + 1) + tabular.rowDescent(r)
+ + tabular.interRowSpace(r + 1);
}
y += tabular.textVOffset(sl.idx());
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.rowHeight(cell);
if (x < xbeg)
xx = xbeg - x;
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);