const correctness

It is dangerous to hand out non-const pointers to members from a const method.
This commit is contained in:
Georg Baum 2016-06-20 22:00:05 +02:00
parent a9af5333b2
commit a4b8094aac
2 changed files with 17 additions and 12 deletions

View File

@ -525,7 +525,7 @@ string const featureAsString(Tabular::Feature action)
} }
DocIterator separatorPos(InsetTableCell * cell, docstring const & align_d) DocIterator separatorPos(InsetTableCell const * cell, docstring const & align_d)
{ {
DocIterator dit = doc_iterator_begin(&(cell->buffer()), cell); DocIterator dit = doc_iterator_begin(&(cell->buffer()), cell);
for (; dit; dit.forwardChar()) for (; dit; dit.forwardChar())
@ -2308,7 +2308,7 @@ void Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
// we center in multicol when no decimal point // we center in multicol when no decimal point
if (column_info[c].alignment == LYX_ALIGN_DECIMAL) { if (column_info[c].alignment == LYX_ALIGN_DECIMAL) {
docstring const align_d = column_info[c].decimal_point; docstring const align_d = column_info[c].decimal_point;
DocIterator const dit = separatorPos(cellInset(cell).get(), align_d); DocIterator const dit = separatorPos(cellInset(cell), align_d);
ismulticol |= !dit; ismulticol |= !dit;
} }
@ -2533,7 +2533,7 @@ void Tabular::TeXRow(otexstream & os, row_type row,
OutputParams const & runparams) const OutputParams const & runparams) const
{ {
idx_type cell = cellIndex(row, 0); idx_type cell = cellIndex(row, 0);
shared_ptr<InsetTableCell> inset = cellInset(cell); InsetTableCell const * inset = cellInset(cell);
Paragraph const & par = inset->paragraphs().front(); Paragraph const & par = inset->paragraphs().front();
string const lang = par.getParLanguage(buffer().params())->lang(); string const lang = par.getParLanguage(buffer().params())->lang();
@ -2572,7 +2572,7 @@ void Tabular::TeXRow(otexstream & os, row_type row,
} }
TeXCellPreamble(os, cell, ismulticol, ismultirow); TeXCellPreamble(os, cell, ismulticol, ismultirow);
shared_ptr<InsetTableCell> inset = cellInset(cell); InsetTableCell const * inset = cellInset(cell);
Paragraph const & par = inset->paragraphs().front(); Paragraph const & par = inset->paragraphs().front();
@ -3321,21 +3321,26 @@ void Tabular::plaintext(odocstringstream & os,
} }
shared_ptr<InsetTableCell> Tabular::cellInset(idx_type cell) const shared_ptr<InsetTableCell> Tabular::cellInset(idx_type cell)
{ {
return cell_info[cellRow(cell)][cellColumn(cell)].inset; return cell_info[cellRow(cell)][cellColumn(cell)].inset;
} }
shared_ptr<InsetTableCell> Tabular::cellInset(row_type row, shared_ptr<InsetTableCell> Tabular::cellInset(row_type row, col_type column)
col_type column) const
{ {
return cell_info[row][column].inset; return cell_info[row][column].inset;
} }
InsetTableCell const * Tabular::cellInset(idx_type cell) const
{
return cell_info[cellRow(cell)][cellColumn(cell)].inset.get();
}
void Tabular::setCellInset(row_type row, col_type column, void Tabular::setCellInset(row_type row, col_type column,
shared_ptr<InsetTableCell> ins) const shared_ptr<InsetTableCell> ins)
{ {
CellData & cd = cell_info[row][column]; CellData & cd = cell_info[row][column];
cd.inset = ins; cd.inset = ins;

View File

@ -612,13 +612,13 @@ public:
/// returns the VISIBLE cell at r,c, which may be the same as the /// returns the VISIBLE cell at r,c, which may be the same as the
/// cell at the previous row or column, if we're dealing with some /// cell at the previous row or column, if we're dealing with some
/// multirow or multicell. /// multirow or multicell.
shared_ptr<InsetTableCell> cellInset(idx_type cell) const; shared_ptr<InsetTableCell> cellInset(idx_type cell);
shared_ptr<InsetTableCell> cellInset(row_type row, shared_ptr<InsetTableCell> cellInset(row_type row, col_type column);
col_type column) const; InsetTableCell const * cellInset(idx_type cell) const;
//@} //@}
/// ///
void setCellInset(row_type row, col_type column, void setCellInset(row_type row, col_type column,
shared_ptr<InsetTableCell>) const; shared_ptr<InsetTableCell>);
/// Search for \param inset in the tabular, with the /// Search for \param inset in the tabular, with the
/// ///
void validate(LaTeXFeatures &) const; void validate(LaTeXFeatures &) const;