From 71487ff1ff4e1e017f853eef74a52d24a85ba9a7 Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Fri, 28 Mar 2008 12:00:53 +0000 Subject: [PATCH] fix bug http://bugzilla.lyx.org/show_bug.cgi?id=4677 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24016 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetTabular.cpp | 57 ++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index dce654ac3e..5ac32bc6f4 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -626,11 +626,23 @@ void Tabular::appendRow(idx_type const cell) for (row_type i = row + 2; i < nrows; ++i) swap(cell_info[i], old[i - 1]); - if (bp.trackChanges) - for (col_type j = 0; j < ncols; ++j) - cell_info[row + 1][j].inset->setChange(Change(Change::INSERTED)); - updateIndexes(); + for (col_type c = 0; c < ncols; ++c) { + // inherit line settings + idx_type const i = cellIndex(row + 1, c); + idx_type const j = cellIndex(row, c); + setLeftLine(i, isPartOfMultiColumn(row, c) ? false : leftLine(j)); + if (cell_info[row][c].multicolumn == CELL_NORMAL || c == ncols - 1 + || (c + 1 < ncols + && cell_info[row][c].multicolumn != CELL_NORMAL + && cell_info[row][c + 1].multicolumn == CELL_NORMAL)) + setRightLine(i, rightLine(j)); + else + setRightLine(i, false); + // mark track changes + if (bp.trackChanges) + cellInfo(i).inset->setChange(Change(Change::INSERTED)); + } } @@ -664,26 +676,33 @@ void Tabular::appendColumn(idx_type const cell) col_type const column = cellColumn(cell); column_vector::iterator cit = column_info.begin() + column + 1; column_info.insert(cit, ColumnData()); + row_type const nrows = rowCount(); col_type const ncols = columnCount(); // set the column values of the column before column_info[column + 1] = column_info[column]; - for (row_type i = 0; i < rowCount(); ++i) { - cell_info[i].insert(cell_info[i].begin() + column + 1, CellData(buffer(), *this)); + for (row_type r = 0; r < nrows; ++r) { + cell_info[r].insert(cell_info[r].begin() + column + 1, + CellData(buffer(), *this)); col_type c = column + 2; while (c < ncols - && cell_info[i][c].multicolumn == CELL_PART_OF_MULTICOLUMN) { - cell_info[i][c].multicolumn = CELL_NORMAL; + && cell_info[r][c].multicolumn == CELL_PART_OF_MULTICOLUMN) { + cell_info[r][c].multicolumn = CELL_NORMAL; ++c; } } - //++column; - for (row_type i = 0; i < rowCount(); ++i) { - cell_info[i][column + 1].inset->clear(); + updateIndexes(); + for (row_type r = 0; r < nrows; ++r) { + // inherit line settings + idx_type const i = cellIndex(r, column + 1); + idx_type const j = cellIndex(r, column); + setBottomLine(i, bottomLine(j)); + setTopLine(i, topLine(j)); + // + cellInfo(i).inset->clear(); if (buffer().params().trackChanges) - cell_info[i][column + 1].inset->setChange(Change(Change::INSERTED)); + cellInfo(i).inset->setChange(Change(Change::INSERTED)); } - updateIndexes(); } @@ -1444,13 +1463,13 @@ void Tabular::setMultiColumn(idx_type cell, idx_type number) CellData & cs = cellInfo(cell); cs.multicolumn = CELL_BEGIN_OF_MULTICOLUMN; cs.alignment = column_info[cellColumn(cell)].alignment; + setRightLine(cell, rightLine(cell + number - 1)); for (idx_type i = 1; i < number; ++i) { CellData & cs1 = cellInfo(cell + i); cs1.multicolumn = CELL_PART_OF_MULTICOLUMN; cs.inset->appendParagraphs(cs1.inset->paragraphs()); cs1.inset->clear(); } - setRightLine(cell, rightLine(cell + number - 1)); updateIndexes(); } @@ -1859,20 +1878,18 @@ int Tabular::TeXCellPreamble(odocstream & os, idx_type cell, bool & ismulticol) row_type const r = cellRow(cell); col_type const c = cellColumn(cell); col_type const nextcol = c + columnSpan(cell); - bool prevmulticol = ismulticol; bool prevcellright = c > 0 && rightLine(cellIndex(r, c - 1)); - bool nextcellleft = nextcol < columnCount() - && leftLine(cellIndex(r, nextcol)); + bool forceleft = ismulticol && !prevcellright && leftLine(cell); bool nextcolleft = nextcol < columnCount() && columnLeftLine(nextcol); bool coldouble = columnRightLine(c) && nextcolleft; + bool nextcellleft = nextcol < columnCount() + && leftLine(cellIndex(r, nextcol)); bool celldouble = rightLine(cell) && nextcellleft; - bool forceleft = prevmulticol && !prevcellright && leftLine(cell); bool doubleright = celldouble && (isMultiColumn(cell) || !coldouble); ismulticol = isMultiColumn(cell) || (leftLine(cell) && !columnLeftLine(c)) || (rightLine(cell) && !columnRightLine(c)) - || (!celldouble && coldouble) - || doubleright || forceleft; + || (!celldouble && coldouble) || doubleright || forceleft; if (ismulticol) { os << "\\multicolumn{" << columnSpan(cell) << "}{"; if (leftLine(cell) || forceleft) -- 2.39.2