commit a4b8094aac6d8b8ad498c02b4f762ee727c43144
Author: Georg Baum <[email protected]>
Date: Mon Jun 20 22:00:05 2016 +0200
const correctness
It is dangerous to hand out non-const pointers to members from a const
method.
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 7ad8663..54b4158 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -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);
for (; dit; dit.forwardChar())
@@ -2308,7 +2308,7 @@ void Tabular::TeXCellPreamble(otexstream & os, idx_type
cell,
// we center in multicol when no decimal point
if (column_info[c].alignment == LYX_ALIGN_DECIMAL) {
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;
}
@@ -2533,7 +2533,7 @@ void Tabular::TeXRow(otexstream & os, row_type row,
OutputParams const & runparams) const
{
idx_type cell = cellIndex(row, 0);
- shared_ptr<InsetTableCell> inset = cellInset(cell);
+ InsetTableCell const * inset = cellInset(cell);
Paragraph const & par = inset->paragraphs().front();
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);
- shared_ptr<InsetTableCell> inset = cellInset(cell);
+ InsetTableCell const * inset = cellInset(cell);
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;
}
-shared_ptr<InsetTableCell> Tabular::cellInset(row_type row,
- col_type column) const
+shared_ptr<InsetTableCell> Tabular::cellInset(row_type row, col_type column)
{
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,
- shared_ptr<InsetTableCell> ins) const
+ shared_ptr<InsetTableCell> ins)
{
CellData & cd = cell_info[row][column];
cd.inset = ins;
diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index b23fc85..ee5cffc 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -612,13 +612,13 @@ public:
/// 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
/// multirow or multicell.
- shared_ptr<InsetTableCell> cellInset(idx_type cell) const;
- shared_ptr<InsetTableCell> cellInset(row_type row,
- col_type column) const;
+ shared_ptr<InsetTableCell> cellInset(idx_type cell);
+ shared_ptr<InsetTableCell> cellInset(row_type row, col_type column);
+ InsetTableCell const * cellInset(idx_type cell) const;
//@}
///
void setCellInset(row_type row, col_type column,
- shared_ptr<InsetTableCell>) const;
+ shared_ptr<InsetTableCell>);
/// Search for \param inset in the tabular, with the
///
void validate(LaTeXFeatures &) const;