branch: Fix bug #7644: Crash when copying table column or row

see r40656.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@40683 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2012-01-27 21:44:30 +00:00
parent 4833479817
commit 8016aebdf1
2 changed files with 49 additions and 8 deletions

View File

@ -759,14 +759,37 @@ void Tabular::deleteRow(row_type const row)
void Tabular::copyRow(row_type const row) void Tabular::copyRow(row_type const row)
{ {
row_info.insert(row_info.begin() + row, row_info[row]); row_info.insert(row_info.begin() + row + 1, RowData(row_info[row]));
cell_info.insert(cell_info.begin() + row, cell_info[row]); cell_info.insert(cell_info.begin() + row + 1,
cell_vector(0, CellData(buffer_)));
if (buffer().params().trackChanges)
for (col_type c = 0; c < ncols(); ++c) for (col_type c = 0; c < ncols(); ++c) {
cell_info[row + 1].insert(cell_info[row + 1].begin() + c,
CellData(cell_info[row][c]));
if (buffer().params().trackChanges)
cell_info[row + 1][c].inset->setChange(Change(Change::INSERTED)); cell_info[row + 1][c].inset->setChange(Change(Change::INSERTED));
if (cell_info[row][c].multirow == CELL_BEGIN_OF_MULTIROW)
cell_info[row + 1][c].multirow = CELL_PART_OF_MULTIROW;
}
updateIndexes(); updateIndexes();
for (col_type c = 0; c < ncols(); ++c) {
if (isPartOfMultiRow(row, c))
continue;
// inherit line settings
idx_type const i = cellIndex(row + 1, c);
idx_type const j = cellIndex(row, c);
setLeftLine(i, leftLine(j));
setRightLine(i, rightLine(j));
setTopLine(i, topLine(j));
if (topLine(j) && bottomLine(j)) {
setBottomLine(i, true);
setBottomLine(j, false);
}
// mark track changes
if (buffer().params().trackChanges)
cellInfo(i).inset->setChange(Change(Change::INSERTED));
}
} }
@ -826,14 +849,30 @@ void Tabular::deleteColumn(col_type const col)
void Tabular::copyColumn(col_type const col) void Tabular::copyColumn(col_type const col)
{ {
BufferParams const & bp = buffer().params(); BufferParams const & bp = buffer().params();
column_info.insert(column_info.begin() + col, column_info[col]); column_info.insert(column_info.begin() + col + 1, ColumnData(column_info[col]));
for (row_type r = 0; r < nrows(); ++r) { for (row_type r = 0; r < nrows(); ++r) {
cell_info[r].insert(cell_info[r].begin() + col, cell_info[r][col]); cell_info[r].insert(cell_info[r].begin() + col + 1, CellData(cell_info[r][col]));
if (bp.trackChanges) if (bp.trackChanges)
cell_info[r][col + 1].inset->setChange(Change(Change::INSERTED)); cell_info[r][col + 1].inset->setChange(Change(Change::INSERTED));
if (cell_info[r][col].multicolumn == CELL_BEGIN_OF_MULTICOLUMN)
cell_info[r][col + 1].multicolumn = CELL_PART_OF_MULTICOLUMN;
} }
updateIndexes(); updateIndexes();
for (row_type r = 0; r < nrows(); ++r) {
// inherit line settings
idx_type const i = cellIndex(r, col + 1);
idx_type const j = cellIndex(r, col);
setBottomLine(i, bottomLine(j));
setTopLine(i, topLine(j));
setLeftLine(i, leftLine(j));
if (rightLine(j) && rightLine(j)) {
setRightLine(i, true);
setRightLine(j, false);
}
if (buffer().params().trackChanges)
cellInfo(i).inset->setChange(Change(Change::INSERTED));
}
} }

View File

@ -181,6 +181,8 @@ What's new
- Fix crash when inserting a float around multiple display maths (bug 7974). - Fix crash when inserting a float around multiple display maths (bug 7974).
- Fix crash when copying table columns or rows (bug 7644).
- Update citation labels when the BibTeX file changes (bug 7499). - Update citation labels when the BibTeX file changes (bug 7499).
- Mark Buffer dirty when changing branch activation status (bug 7872). Sadly, - Mark Buffer dirty when changing branch activation status (bug 7872). Sadly,