mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
InsetTabular.cpp: correct alignment for multirows:
- if column of multirow has no width, the alignment is that of the column - otherwise multirows are fix left-aligned git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36403 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9672f432f2
commit
08f49bc27a
@ -171,8 +171,10 @@ GuiTabular::GuiTabular(QWidget * parent)
|
||||
|
||||
void GuiTabular::checkEnabled()
|
||||
{
|
||||
// multirows don't have their own alignment
|
||||
hAlignCB->setEnabled(!multirowCB->isChecked());
|
||||
// if the column has a width, multirows are always left-aligned
|
||||
// therefore disable hAlignCB in this case
|
||||
hAlignCB->setEnabled(!(multirowCB->isChecked()
|
||||
&& !widgetsToLength(widthED, widthUnitCB).empty()));
|
||||
bool dalign =
|
||||
hAlignCB->itemData(hAlignCB->currentIndex()).toString() == QString("decimal");
|
||||
decimalPointLE->setEnabled(dalign);
|
||||
@ -366,6 +368,19 @@ docstring GuiTabular::dialogToParams() const
|
||||
{
|
||||
// FIXME: We should use Tabular directly.
|
||||
string param_str = "tabular";
|
||||
|
||||
// apply the fixed width values
|
||||
// this must be done before applying the column alignment
|
||||
// because its value influences the alignment of multirow cells
|
||||
string width = widgetsToLength(widthED, widthUnitCB);
|
||||
if (width.empty())
|
||||
width = "0pt";
|
||||
if (multicolumnCB->isChecked())
|
||||
setParam(param_str, Tabular::SET_MPWIDTH, width);
|
||||
else
|
||||
setParam(param_str, Tabular::SET_PWIDTH, width);
|
||||
|
||||
// apply the column alignment
|
||||
setHAlign(param_str);
|
||||
|
||||
// SET_DECIMAL_POINT must come after setHAlign() (ALIGN_DECIMAL)
|
||||
@ -456,15 +471,6 @@ docstring GuiTabular::dialogToParams() const
|
||||
else
|
||||
setParam(param_str, Tabular::SET_SPECIAL_COLUMN, special);
|
||||
|
||||
// apply the fixed width values
|
||||
string width = widgetsToLength(widthED, widthUnitCB);
|
||||
if (width.empty())
|
||||
width = "0pt";
|
||||
if (multicolumnCB->isChecked())
|
||||
setParam(param_str, Tabular::SET_MPWIDTH, width);
|
||||
else
|
||||
setParam(param_str, Tabular::SET_PWIDTH, width);
|
||||
|
||||
//
|
||||
if (multicolumnCB->isChecked())
|
||||
setParam(param_str, Tabular::SET_MULTICOLUMN);
|
||||
|
@ -1024,18 +1024,25 @@ int Tabular::width() const
|
||||
|
||||
|
||||
void Tabular::setAlignment(idx_type cell, LyXAlignment align,
|
||||
bool onlycolumn)
|
||||
bool has_width)
|
||||
{
|
||||
col_type const col = cellColumn(cell);
|
||||
// set alignment for the whole row of if we are not in a multicolumn cell
|
||||
// exclude possible multicolumn cells in the row
|
||||
if (!isMultiColumn(cell)) {
|
||||
for (row_type r = 0; r < nrows(); ++r) {
|
||||
if (!isMultiRow(cellIndex(r, col))
|
||||
// only if the column has no width the multirow inherits the
|
||||
// alignment of the column, otherwise it is left aligned
|
||||
if (!(isMultiRow(cellIndex(r, col)) && has_width)
|
||||
&& !isMultiColumn(cellIndex(r, col))) {
|
||||
cell_info[r][col].alignment = align;
|
||||
cell_info[r][col].inset->setContentAlignment(align);
|
||||
}
|
||||
if ((isMultiRow(cellIndex(r, col)) && has_width)
|
||||
&& !isMultiColumn(cellIndex(r, col))) {
|
||||
cell_info[r][col].alignment = LYX_ALIGN_LEFT;
|
||||
cell_info[r][col].inset->setContentAlignment(LYX_ALIGN_LEFT);
|
||||
}
|
||||
}
|
||||
column_info[col].alignment = align;
|
||||
docstring & dpoint = column_info[col].decimal_point;
|
||||
@ -4308,7 +4315,9 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
status.setOnOff(tabular.rightLine(cur.idx()));
|
||||
break;
|
||||
|
||||
// multirow cells are alwas left aligned
|
||||
// multirow cells only inherit the alignment of the column if the column has
|
||||
// no width, otherwise they are left-aligned
|
||||
// therefore allow always left but right and center only if there is no width
|
||||
case Tabular::M_ALIGN_LEFT:
|
||||
flag = false;
|
||||
case Tabular::ALIGN_LEFT:
|
||||
@ -4318,14 +4327,16 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
case Tabular::M_ALIGN_RIGHT:
|
||||
flag = false;
|
||||
case Tabular::ALIGN_RIGHT:
|
||||
status.setEnabled(!tabular.isMultiRow(cur.idx()));
|
||||
status.setEnabled(!(tabular.isMultiRow(cur.idx())
|
||||
&& !tabular.getPWidth(cur.idx()).zero()));
|
||||
status.setOnOff(tabular.getAlignment(cur.idx(), flag) == LYX_ALIGN_RIGHT);
|
||||
break;
|
||||
|
||||
case Tabular::M_ALIGN_CENTER:
|
||||
flag = false;
|
||||
case Tabular::ALIGN_CENTER:
|
||||
status.setEnabled(!tabular.isMultiRow(cur.idx()));
|
||||
status.setEnabled(!(tabular.isMultiRow(cur.idx())
|
||||
&& !tabular.getPWidth(cur.idx()).zero()));
|
||||
status.setOnOff(tabular.getAlignment(cur.idx(), flag) == LYX_ALIGN_CENTER);
|
||||
break;
|
||||
|
||||
@ -5193,7 +5204,8 @@ void InsetTabular::tabularFeatures(Cursor & cur,
|
||||
case Tabular::ALIGN_DECIMAL:
|
||||
for (row_type r = sel_row_start; r <= sel_row_end; ++r)
|
||||
for (col_type c = sel_col_start; c <= sel_col_end; ++c)
|
||||
tabular.setAlignment(tabular.cellIndex(r, c), setAlign);
|
||||
tabular.setAlignment(tabular.cellIndex(r, c), setAlign,
|
||||
!tabular.getPWidth(c).zero());
|
||||
break;
|
||||
|
||||
case Tabular::M_VALIGN_TOP:
|
||||
|
Loading…
Reference in New Issue
Block a user