revert my faulty fix of bug 2380 and use one by Jean-Marc instead:

* insets/insettabular.C
        (InsetTabular::insertAsciiString): set BufferView cache of cell


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13524 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-03-29 10:13:40 +00:00
parent c0b204c0a8
commit a7ec02ea03
3 changed files with 18 additions and 21 deletions

View File

@ -168,7 +168,7 @@ bool InsetTabular::hasPasteBuffer() const
InsetTabular::InsetTabular(Buffer const & buf, row_type rows, InsetTabular::InsetTabular(Buffer const & buf, row_type rows,
col_type columns) col_type columns)
: tabular(buf.params(), max(rows, row_type(1)), : tabular(buf.params(), max(rows, row_type(1)),
max(columns, col_type(1)), buf.text().bv()), buffer_(&buf), scx_(0) max(columns, col_type(1))), buffer_(&buf), scx_(0)
{} {}
@ -692,7 +692,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
maxCols = max(cols, maxCols); maxCols = max(cols, maxCols);
paste_tabular.reset( paste_tabular.reset(
new LyXTabular(cur.buffer().params(), rows, maxCols, &cur.bv())); new LyXTabular(cur.buffer().params(), rows, maxCols));
string::size_type op = 0; string::size_type op = 0;
idx_type cell = 0; idx_type cell = 0;
@ -1885,7 +1885,7 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
row_type row = 0; row_type row = 0;
if (usePaste) { if (usePaste) {
paste_tabular.reset( paste_tabular.reset(
new LyXTabular(bv.buffer()->params(), rows, maxCols, &bv)); new LyXTabular(bv.buffer()->params(), rows, maxCols));
loctab = paste_tabular.get(); loctab = paste_tabular.get();
cols = 0; cols = 0;
dirtyTabularStack(true); dirtyTabularStack(true);
@ -1913,6 +1913,7 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
// we can only set this if we are not too far right // we can only set this if we are not too far right
if (cols < columns) { if (cols < columns) {
shared_ptr<InsetText> inset = loctab->getCellInset(cell); shared_ptr<InsetText> inset = loctab->getCellInset(cell);
inset->setViewCache(&bv);
Paragraph & par = inset->text_.getPar(0); Paragraph & par = inset->text_.getPar(0);
LyXFont const font = inset->text_.getFont(par, 0); LyXFont const font = inset->text_.getFont(par, 0);
inset->setText(buf.substr(op, p - op), font); inset->setText(buf.substr(op, p - op), font);
@ -1924,6 +1925,7 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
// we can only set this if we are not too far right // we can only set this if we are not too far right
if (cols < columns) { if (cols < columns) {
shared_ptr<InsetText> inset = tabular.getCellInset(cell); shared_ptr<InsetText> inset = tabular.getCellInset(cell);
inset->setViewCache(&bv);
Paragraph & par = inset->text_.getPar(0); Paragraph & par = inset->text_.getPar(0);
LyXFont const font = inset->text_.getFont(par, 0); LyXFont const font = inset->text_.getFont(par, 0);
inset->setText(buf.substr(op, p - op), font); inset->setText(buf.substr(op, p - op), font);
@ -1940,6 +1942,7 @@ bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
// check for the last cell if there is no trailing '\n' // check for the last cell if there is no trailing '\n'
if (cell < cells && op < len) { if (cell < cells && op < len) {
shared_ptr<InsetText> inset = loctab->getCellInset(cell); shared_ptr<InsetText> inset = loctab->getCellInset(cell);
inset->setViewCache(&bv);
Paragraph & par = inset->text_.getPar(0); Paragraph & par = inset->text_.getPar(0);
LyXFont const font = inset->text_.getFont(par, 0); LyXFont const font = inset->text_.getFont(par, 0);
inset->setText(buf.substr(op, len - op), font); inset->setText(buf.substr(op, len - op), font);

View File

@ -313,8 +313,7 @@ void l_getline(istream & is, string & str)
/// Define a few methods for the inner structs /// Define a few methods for the inner structs
LyXTabular::cellstruct::cellstruct(BufferParams const & bp, LyXTabular::cellstruct::cellstruct(BufferParams const & bp)
BufferView const * bv)
: cellno(0), : cellno(0),
width_of_cell(0), width_of_cell(0),
multicolumn(LyXTabular::CELL_NORMAL), multicolumn(LyXTabular::CELL_NORMAL),
@ -327,9 +326,7 @@ LyXTabular::cellstruct::cellstruct(BufferParams const & bp,
usebox(BOX_NONE), usebox(BOX_NONE),
rotate(false), rotate(false),
inset(new InsetText(bp)) inset(new InsetText(bp))
{ {}
inset->setViewCache(bv);
}
LyXTabular::cellstruct::cellstruct(cellstruct const & cs) LyXTabular::cellstruct::cellstruct(cellstruct const & cs)
@ -409,21 +406,21 @@ LyXTabular::ltType::ltType()
LyXTabular::LyXTabular(BufferParams const & bp, row_type rows_arg, LyXTabular::LyXTabular(BufferParams const & bp, row_type rows_arg,
col_type columns_arg, BufferView const * bv) col_type columns_arg)
{ {
init(bp, rows_arg, columns_arg, bv); init(bp, rows_arg, columns_arg);
} }
// activates all lines and sets all widths to 0 // activates all lines and sets all widths to 0
void LyXTabular::init(BufferParams const & bp, row_type rows_arg, void LyXTabular::init(BufferParams const & bp, row_type rows_arg,
col_type columns_arg, BufferView const * bv) col_type columns_arg)
{ {
rows_ = rows_arg; rows_ = rows_arg;
columns_ = columns_arg; columns_ = columns_arg;
row_info = row_vector(rows_); row_info = row_vector(rows_);
column_info = column_vector(columns_); column_info = column_vector(columns_);
cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp, bv))); cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp)));
row_info.reserve(10); row_info.reserve(10);
column_info.reserve(10); column_info.reserve(10);
cell_info.reserve(100); cell_info.reserve(100);
@ -457,7 +454,6 @@ void LyXTabular::fixCellNums()
void LyXTabular::appendRow(BufferParams const & bp, idx_type const cell) void LyXTabular::appendRow(BufferParams const & bp, idx_type const cell)
{ {
BufferView const * const bv = getCellInset(0)->getText(0)->bv();
++rows_; ++rows_;
row_type const row = row_of_cell(cell); row_type const row = row_of_cell(cell);
@ -471,7 +467,7 @@ void LyXTabular::appendRow(BufferParams const & bp, idx_type const cell)
for (row_type i = 0; i < rows_ - 1; ++i) for (row_type i = 0; i < rows_ - 1; ++i)
swap(cell_info[i], old[i]); swap(cell_info[i], old[i]);
cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp, bv))); cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp)));
for (row_type i = 0; i <= row; ++i) for (row_type i = 0; i <= row; ++i)
swap(cell_info[i], old[i]); swap(cell_info[i], old[i]);
@ -501,7 +497,6 @@ void LyXTabular::deleteRow(row_type const row)
void LyXTabular::appendColumn(BufferParams const & bp, idx_type const cell) void LyXTabular::appendColumn(BufferParams const & bp, idx_type const cell)
{ {
BufferView const * const bv = getCellInset(0)->getText(0)->bv();
++columns_; ++columns_;
col_type const column = column_of_cell(cell); col_type const column = column_of_cell(cell);
@ -511,7 +506,7 @@ void LyXTabular::appendColumn(BufferParams const & bp, idx_type const cell)
column_info[column + 1] = column_info[column]; column_info[column + 1] = column_info[column];
for (row_type i = 0; i < rows_; ++i) { for (row_type i = 0; i < rows_; ++i) {
cell_info[i].insert(cell_info[i].begin() + column + 1, cellstruct(bp, bv)); cell_info[i].insert(cell_info[i].begin() + column + 1, cellstruct(bp));
// care about multicolumns // care about multicolumns
if (cell_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) if (cell_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN)
@ -1278,7 +1273,7 @@ void LyXTabular::read(Buffer const & buf, LyXLex & lex)
int columns_arg; int columns_arg;
if (!getTokenValue(line, "columns", columns_arg)) if (!getTokenValue(line, "columns", columns_arg))
return; return;
init(buf.params(), rows_arg, columns_arg, buf.text().bv()); init(buf.params(), rows_arg, columns_arg);
l_getline(is, line); l_getline(is, line);
if (!prefixIs(line, "<features")) { if (!prefixIs(line, "<features")) {
lyxerr << "Wrong tabular format (expected <features ...> got" lyxerr << "Wrong tabular format (expected <features ...> got"

View File

@ -23,7 +23,6 @@
#include <iosfwd> #include <iosfwd>
#include <vector> #include <vector>
class BufferView;
class InsetTabular; class InsetTabular;
class LCursor; class LCursor;
class OutputParams; class OutputParams;
@ -186,7 +185,7 @@ public:
/// constructor /// constructor
LyXTabular(BufferParams const &, col_type columns_arg, LyXTabular(BufferParams const &, col_type columns_arg,
row_type rows_arg, BufferView const *); row_type rows_arg);
/// Returns true if there is a topline, returns false if not /// Returns true if there is a topline, returns false if not
bool topLine(idx_type cell, bool onlycolumn = false) const; bool topLine(idx_type cell, bool onlycolumn = false) const;
@ -404,7 +403,7 @@ public:
class cellstruct { class cellstruct {
public: public:
/// ///
cellstruct(BufferParams const &, BufferView const *); cellstruct(BufferParams const &);
/// ///
cellstruct(cellstruct const &); cellstruct(cellstruct const &);
/// ///
@ -532,7 +531,7 @@ public:
/// ///
void init(BufferParams const &, row_type rows_arg, void init(BufferParams const &, row_type rows_arg,
col_type columns_arg, BufferView const *); col_type columns_arg);
/// ///
void set_row_column_number_info(); void set_row_column_number_info();
/// Returns true if a complete update is necessary, otherwise false /// Returns true if a complete update is necessary, otherwise false