From 951d0dc28d743ecd927ca65fecc15b1113363700 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 21 Jul 2008 02:07:54 +0000 Subject: [PATCH] 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 --- src/insets/InsetTabular.cpp | 14 ++++++++++++++ src/insets/InsetTabular.h | 25 +++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index e14c5562d8..4b2ac51268 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -760,6 +760,7 @@ void Tabular::updateIndexes() continue; rowofcell[i] = row; columnofcell[i] = column; + setFixedWidth(row, column); ++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, Length const & width) { @@ -1404,6 +1417,7 @@ void Tabular::read(Lexer & lex) getTokenValue(line, "rotate", cell_info[i][j].rotate); getTokenValue(line, "usebox", cell_info[i][j].usebox); getTokenValue(line, "width", cell_info[i][j].p_width); + setFixedWidth(i,j); getTokenValue(line, "special", cell_info[i][j].align_special); l_getline(is, line); if (prefixIs(line, "\\begin_inset")) { diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 84bec94c96..60664a49ff 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -575,6 +575,8 @@ public: col_type columns_arg); /// void updateIndexes(); + /// + bool setFixedWidth(row_type r, col_type c); /// return true of update is needed bool updateColumnWidths(); /// @@ -654,6 +656,29 @@ private: InsetTableCell(); /// unimplemented 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; }; -- 2.39.5