mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Make sure inset buffer is correctly set in math grid
Make MathData::setBuffer set the buffer of insets that it contains. Remove corresponding code from InsetMathNest. update the buffer() property in the following tabular-feature actions : copy-row, add-row, copy-col, add-col.
This commit is contained in:
parent
a569aeaf66
commit
837bcbb043
@ -809,7 +809,7 @@ void InsetMathGrid::addRow(row_type row)
|
|||||||
{
|
{
|
||||||
rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
|
rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
|
||||||
cells_.insert
|
cells_.insert
|
||||||
(cells_.begin() + (row + 1) * ncols(), ncols(), MathData());
|
(cells_.begin() + (row + 1) * ncols(), ncols(), MathData(buffer_));
|
||||||
cellinfo_.insert
|
cellinfo_.insert
|
||||||
(cellinfo_.begin() + (row + 1) * ncols(), ncols(), CellInfo());
|
(cellinfo_.begin() + (row + 1) * ncols(), ncols(), CellInfo());
|
||||||
}
|
}
|
||||||
@ -833,8 +833,11 @@ void InsetMathGrid::delRow(row_type row)
|
|||||||
void InsetMathGrid::copyRow(row_type row)
|
void InsetMathGrid::copyRow(row_type row)
|
||||||
{
|
{
|
||||||
addRow(row);
|
addRow(row);
|
||||||
for (col_type col = 0; col < ncols(); ++col)
|
for (col_type col = 0; col < ncols(); ++col) {
|
||||||
cells_[(row + 1) * ncols() + col] = cells_[row * ncols() + col];
|
cells_[(row + 1) * ncols() + col] = cells_[row * ncols() + col];
|
||||||
|
// copying the cell does not set the buffer
|
||||||
|
cells_[(row + 1) * ncols() + col].setBuffer(*buffer_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -864,6 +867,8 @@ void InsetMathGrid::addCol(col_type newcol)
|
|||||||
= cellinfo_[row * nc + col];
|
= cellinfo_[row * nc + col];
|
||||||
}
|
}
|
||||||
swap(cells_, new_cells);
|
swap(cells_, new_cells);
|
||||||
|
// copying cells loses the buffer reference
|
||||||
|
setBuffer(*buffer_);
|
||||||
swap(cellinfo_, new_cellinfo);
|
swap(cellinfo_, new_cellinfo);
|
||||||
|
|
||||||
ColInfo inf;
|
ColInfo inf;
|
||||||
@ -895,8 +900,11 @@ void InsetMathGrid::delCol(col_type col)
|
|||||||
void InsetMathGrid::copyCol(col_type col)
|
void InsetMathGrid::copyCol(col_type col)
|
||||||
{
|
{
|
||||||
addCol(col+1);
|
addCol(col+1);
|
||||||
for (row_type row = 0; row < nrows(); ++row)
|
for (row_type row = 0; row < nrows(); ++row) {
|
||||||
cells_[row * ncols() + col + 1] = cells_[row * ncols() + col];
|
cells_[row * ncols() + col + 1] = cells_[row * ncols() + col];
|
||||||
|
// copying the cell does not set the buffer
|
||||||
|
cells_[row * ncols() + col + 1].setBuffer(*buffer_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,11 +118,8 @@ InsetMathNest & InsetMathNest::operator=(InsetMathNest const & inset)
|
|||||||
void InsetMathNest::setBuffer(Buffer & buffer)
|
void InsetMathNest::setBuffer(Buffer & buffer)
|
||||||
{
|
{
|
||||||
InsetMath::setBuffer(buffer);
|
InsetMath::setBuffer(buffer);
|
||||||
for (idx_type i = 0, n = nargs(); i != n; ++i) {
|
for (MathData & data : cells_)
|
||||||
MathData & data = cell(i);
|
data.setBuffer(buffer);
|
||||||
for (size_t j = 0; j != data.size(); ++j)
|
|
||||||
data[j].nucleus()->setBuffer(buffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,6 +52,14 @@ MathData::MathData(Buffer * buf, const_iterator from, const_iterator to)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
void MathData::setBuffer(Buffer & b)
|
||||||
|
{
|
||||||
|
buffer_ = &b;
|
||||||
|
for (MathAtom & at : *this)
|
||||||
|
at.nucleus()->setBuffer(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MathAtom & MathData::operator[](pos_type pos)
|
MathAtom & MathData::operator[](pos_type pos)
|
||||||
{
|
{
|
||||||
LBUFERR(pos < size());
|
LBUFERR(pos < size());
|
||||||
|
@ -184,7 +184,7 @@ public:
|
|||||||
///
|
///
|
||||||
void updateBuffer(ParIterator const &, UpdateType);
|
void updateBuffer(ParIterator const &, UpdateType);
|
||||||
///
|
///
|
||||||
void setBuffer(Buffer & b) { buffer_ = &b; }
|
void setBuffer(Buffer & b);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// cached values for super/subscript placement
|
/// cached values for super/subscript placement
|
||||||
|
Loading…
Reference in New Issue
Block a user