git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24016 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Edwin Leuven 2008-03-28 12:00:53 +00:00
parent 99a6fbfbe7
commit 71487ff1ff

View File

@ -626,11 +626,23 @@ void Tabular::appendRow(idx_type const cell)
for (row_type i = row + 2; i < nrows; ++i) for (row_type i = row + 2; i < nrows; ++i)
swap(cell_info[i], old[i - 1]); 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(); 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); col_type const column = cellColumn(cell);
column_vector::iterator cit = column_info.begin() + column + 1; column_vector::iterator cit = column_info.begin() + column + 1;
column_info.insert(cit, ColumnData()); column_info.insert(cit, ColumnData());
row_type const nrows = rowCount();
col_type const ncols = columnCount(); col_type const ncols = columnCount();
// set the column values of the column before // set the column values of the column before
column_info[column + 1] = column_info[column]; column_info[column + 1] = column_info[column];
for (row_type i = 0; i < rowCount(); ++i) { for (row_type r = 0; r < nrows; ++r) {
cell_info[i].insert(cell_info[i].begin() + column + 1, CellData(buffer(), *this)); cell_info[r].insert(cell_info[r].begin() + column + 1,
CellData(buffer(), *this));
col_type c = column + 2; col_type c = column + 2;
while (c < ncols while (c < ncols
&& cell_info[i][c].multicolumn == CELL_PART_OF_MULTICOLUMN) { && cell_info[r][c].multicolumn == CELL_PART_OF_MULTICOLUMN) {
cell_info[i][c].multicolumn = CELL_NORMAL; cell_info[r][c].multicolumn = CELL_NORMAL;
++c; ++c;
} }
} }
//++column;
for (row_type i = 0; i < rowCount(); ++i) {
cell_info[i][column + 1].inset->clear();
if (buffer().params().trackChanges)
cell_info[i][column + 1].inset->setChange(Change(Change::INSERTED));
}
updateIndexes(); 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)
cellInfo(i).inset->setChange(Change(Change::INSERTED));
}
} }
@ -1444,13 +1463,13 @@ void Tabular::setMultiColumn(idx_type cell, idx_type number)
CellData & cs = cellInfo(cell); CellData & cs = cellInfo(cell);
cs.multicolumn = CELL_BEGIN_OF_MULTICOLUMN; cs.multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
cs.alignment = column_info[cellColumn(cell)].alignment; cs.alignment = column_info[cellColumn(cell)].alignment;
setRightLine(cell, rightLine(cell + number - 1));
for (idx_type i = 1; i < number; ++i) { for (idx_type i = 1; i < number; ++i) {
CellData & cs1 = cellInfo(cell + i); CellData & cs1 = cellInfo(cell + i);
cs1.multicolumn = CELL_PART_OF_MULTICOLUMN; cs1.multicolumn = CELL_PART_OF_MULTICOLUMN;
cs.inset->appendParagraphs(cs1.inset->paragraphs()); cs.inset->appendParagraphs(cs1.inset->paragraphs());
cs1.inset->clear(); cs1.inset->clear();
} }
setRightLine(cell, rightLine(cell + number - 1));
updateIndexes(); updateIndexes();
} }
@ -1859,20 +1878,18 @@ int Tabular::TeXCellPreamble(odocstream & os, idx_type cell, bool & ismulticol)
row_type const r = cellRow(cell); row_type const r = cellRow(cell);
col_type const c = cellColumn(cell); col_type const c = cellColumn(cell);
col_type const nextcol = c + columnSpan(cell); col_type const nextcol = c + columnSpan(cell);
bool prevmulticol = ismulticol;
bool prevcellright = c > 0 && rightLine(cellIndex(r, c - 1)); bool prevcellright = c > 0 && rightLine(cellIndex(r, c - 1));
bool nextcellleft = nextcol < columnCount() bool forceleft = ismulticol && !prevcellright && leftLine(cell);
&& leftLine(cellIndex(r, nextcol));
bool nextcolleft = nextcol < columnCount() && columnLeftLine(nextcol); bool nextcolleft = nextcol < columnCount() && columnLeftLine(nextcol);
bool coldouble = columnRightLine(c) && nextcolleft; bool coldouble = columnRightLine(c) && nextcolleft;
bool nextcellleft = nextcol < columnCount()
&& leftLine(cellIndex(r, nextcol));
bool celldouble = rightLine(cell) && nextcellleft; bool celldouble = rightLine(cell) && nextcellleft;
bool forceleft = prevmulticol && !prevcellright && leftLine(cell);
bool doubleright = celldouble && (isMultiColumn(cell) || !coldouble); bool doubleright = celldouble && (isMultiColumn(cell) || !coldouble);
ismulticol = isMultiColumn(cell) ismulticol = isMultiColumn(cell)
|| (leftLine(cell) && !columnLeftLine(c)) || (leftLine(cell) && !columnLeftLine(c))
|| (rightLine(cell) && !columnRightLine(c)) || (rightLine(cell) && !columnRightLine(c))
|| (!celldouble && coldouble) || (!celldouble && coldouble) || doubleright || forceleft;
|| doubleright || forceleft;
if (ismulticol) { if (ismulticol) {
os << "\\multicolumn{" << columnSpan(cell) << "}{"; os << "\\multicolumn{" << columnSpan(cell) << "}{";
if (leftLine(cell) || forceleft) if (leftLine(cell) || forceleft)