Fix alignment rendering of multirow in LyX (#8976)

Multirow cells now have the same alignment rendering in LyX
as in the output. The alignment of a multirow can change as
long as the column is not of fixed width. If the column is
of fixed width, the multirow is left-aligned.

When setting a multirow, the alignment is copied from
the last cell in the selection.
This commit is contained in:
Scott Kostyshak 2014-02-13 21:17:20 -05:00
parent 936773c4f7
commit 43d464cca0
2 changed files with 15 additions and 9 deletions

View File

@ -1154,7 +1154,7 @@ void Tabular::setColumnPWidth(Cursor & cur, idx_type cell,
col_type const c = cellColumn(cell); col_type const c = cellColumn(cell);
column_info[c].p_width = width; column_info[c].p_width = width;
// reset the vertical alignment to top if the fixed with // reset the vertical alignment to top if the fixed width
// is removed or zero because only fixed width columns can // is removed or zero because only fixed width columns can
// have a vertical alignment // have a vertical alignment
if (column_info[c].p_width.zero()) if (column_info[c].p_width.zero())
@ -1164,6 +1164,8 @@ void Tabular::setColumnPWidth(Cursor & cur, idx_type cell,
// because of multicolumns // because of multicolumns
toggleFixedWidth(cur, cellInset(cell).get(), toggleFixedWidth(cur, cellInset(cell).get(),
!getPWidth(cell).zero()); !getPWidth(cell).zero());
if (isMultiRow(cell))
setAlignment(cell, LYX_ALIGN_LEFT, false);
} }
// cur paragraph can become invalid after paragraphs were merged // cur paragraph can become invalid after paragraphs were merged
if (cur.pit() > cur.lastpit()) if (cur.pit() > cur.lastpit())
@ -1715,7 +1717,8 @@ bool Tabular::hasMultiRow(row_type r) const
} }
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) bool const bottom_border,
LyXAlignment const halign)
{ {
idx_type const col = cellColumn(cell); idx_type const col = cellColumn(cell);
idx_type const row = cellRow(cell); idx_type const row = cellRow(cell);
@ -1731,10 +1734,10 @@ Tabular::idx_type Tabular::setMultiRow(idx_type cell, idx_type number,
// be changed for the whole table row, // be changed for the whole table row,
// support changing this only for the multirow cell can be done via // support changing this only for the multirow cell can be done via
// \multirowsetup // \multirowsetup
// this feature would be a fileformat change if (getPWidth(cell).zero())
// until LyX supports this, use the deault alignment of multirow cs.alignment = halign;
// cells: left else
cs.alignment = LYX_ALIGN_LEFT; cs.alignment = LYX_ALIGN_LEFT;
// set the bottom line of the last selected cell // set the bottom line of the last selected cell
setBottomLine(cell, bottom_border); setBottomLine(cell, bottom_border);
@ -5704,7 +5707,8 @@ void InsetTabular::tabularFeatures(Cursor & cur,
// check whether we are completely in a multirow // check whether we are completely in a multirow
if (!tabular.isMultiRow(cur.idx())) if (!tabular.isMultiRow(cur.idx()))
tabular.setMultiRow(cur.idx(), 1, tabular.setMultiRow(cur.idx(), 1,
tabular.bottomLine(cur.idx())); tabular.bottomLine(cur.idx()),
tabular.getAlignment(cur.idx()));
break; break;
} }
// we have a selection so this means we just add all this // we have a selection so this means we just add all this
@ -5713,7 +5717,8 @@ void InsetTabular::tabularFeatures(Cursor & cur,
row_type const row_start = tabular.cellRow(s_start); row_type const row_start = tabular.cellRow(s_start);
row_type const row_end = tabular.cellRow(cur.selEnd().idx()); 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())); tabular.bottomLine(cur.selEnd().idx()),
tabular.getAlignment(cur.selEnd().idx()));
cur.pit() = 0; cur.pit() = 0;
cur.pos() = 0; cur.pos() = 0;
cur.setSelection(false); cur.setSelection(false);

View File

@ -525,7 +525,8 @@ public:
bool hasMultiRow(row_type r) const; bool hasMultiRow(row_type r) const;
/// ///
idx_type setMultiRow(idx_type cell, idx_type number, idx_type setMultiRow(idx_type cell, idx_type number,
bool const bottom_border); bool const bottom_border,
LyXAlignment const halign);
/// ///
void unsetMultiRow(idx_type cell); void unsetMultiRow(idx_type cell);
/// ///