Try to fix a problem noted by Dov. There are design problems that prevent a really good solution. Please see the FIXME in InsetTabular.h for a description of the problem and a plea for a better solution.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25752 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-07-21 02:07:54 +00:00
parent b2ec31a7f7
commit 951d0dc28d
2 changed files with 39 additions and 0 deletions

View File

@ -760,6 +760,7 @@ void Tabular::updateIndexes()
continue; continue;
rowofcell[i] = row; rowofcell[i] = row;
columnofcell[i] = column; columnofcell[i] = column;
setFixedWidth(row, column);
++i; ++i;
} }
} }
@ -994,6 +995,18 @@ void Tabular::setColumnPWidth(Cursor & cur, idx_type cell,
} }
bool Tabular::setFixedWidth(row_type r, col_type c)
{
if (!column_info[c].p_width.zero() ||
(cell_info[r][c].multicolumn != CELL_NORMAL &&
!cell_info[r][c].p_width.zero())) {
cell_info[r][c].inset->toggleFixedWidth(true);
return true;
}
return false;
}
bool Tabular::setMColumnPWidth(Cursor & cur, idx_type cell, bool Tabular::setMColumnPWidth(Cursor & cur, idx_type cell,
Length const & width) Length const & width)
{ {
@ -1404,6 +1417,7 @@ void Tabular::read(Lexer & lex)
getTokenValue(line, "rotate", cell_info[i][j].rotate); getTokenValue(line, "rotate", cell_info[i][j].rotate);
getTokenValue(line, "usebox", cell_info[i][j].usebox); getTokenValue(line, "usebox", cell_info[i][j].usebox);
getTokenValue(line, "width", cell_info[i][j].p_width); getTokenValue(line, "width", cell_info[i][j].p_width);
setFixedWidth(i,j);
getTokenValue(line, "special", cell_info[i][j].align_special); getTokenValue(line, "special", cell_info[i][j].align_special);
l_getline(is, line); l_getline(is, line);
if (prefixIs(line, "\\begin_inset")) { if (prefixIs(line, "\\begin_inset")) {

View File

@ -575,6 +575,8 @@ public:
col_type columns_arg); col_type columns_arg);
/// ///
void updateIndexes(); void updateIndexes();
///
bool setFixedWidth(row_type r, col_type c);
/// return true of update is needed /// return true of update is needed
bool updateColumnWidths(); bool updateColumnWidths();
/// ///
@ -654,6 +656,29 @@ private:
InsetTableCell(); InsetTableCell();
/// unimplemented /// unimplemented
void operator=(InsetTableCell const &); void operator=(InsetTableCell const &);
// FIXME
// This boolean is supposed to track whether the cell has had its
// width explicitly set. We need to know this to determine whether
// layout changes and paragraph customization are allowed---that is,
// we need it in forcePlainLayout() and allowParagraphCustomization().
// Unfortunately, that information is not readily available in
// InsetTableCell. In the case of multicolumn cells, it is present
// in CellData, and so would be available here if CellData were to
// become a member of InsetTableCell. But in the other case, it isn't
// even available there, but is held in Tabular::ColumnData.
// So, the present solution uses this boolean to track the information
// we need to track, and tries to keep it updated. This is not ideal,
// but the other solutions are no better. These are:
// (i) Keep a pointer in InsetTableCell to the table;
// (ii) Find the table by iterating over the Buffer's insets.
// Solution (i) raises the problem of updating the pointer when an
// InsetTableCell is copied, and we'd therefore need a copy constructor
// in InsetTabular and then in Tabular, which seems messy, given how
// complicated those classes are. Solution (ii) involves a lot of
// iterating, since this information is needed quite often, and so may
// be quite slow.
// So, well, if someone can do better, please do!
// --rgh
/// ///
bool isFixedWidth; bool isFixedWidth;
}; };