From c4ab6210883a5e4a973b5ad2d887aebdf98f131a Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Tue, 21 Jun 2016 21:09:50 +0200 Subject: [PATCH] more const correctness The const_cast shows the place where const correctness is violated, this is no longer hidden by lying member functions. --- src/insets/InsetTabular.cpp | 10 ++++++++-- src/insets/InsetTabular.h | 10 +++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 54b4158b41..7728a1abd4 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -1668,7 +1668,13 @@ bool Tabular::hasMultiColumn(col_type c) const } -Tabular::CellData & Tabular::cellInfo(idx_type cell) const +Tabular::CellData const & Tabular::cellInfo(idx_type cell) const +{ + return cell_info[cellRow(cell)][cellColumn(cell)]; +} + + +Tabular::CellData & Tabular::cellInfo(idx_type cell) { return cell_info[cellRow(cell)][cellColumn(cell)]; } @@ -2606,7 +2612,7 @@ void Tabular::TeXRow(otexstream & os, row_type row, if (getAlignment(cell) == LYX_ALIGN_DECIMAL) { // copy cell and split in 2 InsetTableCell head = InsetTableCell(*cellInset(cell)); - head.setBuffer(buffer()); + head.setBuffer(const_cast(buffer())); DocIterator dit = cellInset(cell)->getText(0)->macrocontextPosition(); dit.pop_back(); dit.push_back(CursorSlice(head)); diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index ee5cffcd5e..d26b1aa4f3 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -24,7 +24,6 @@ #ifndef INSET_TABULAR_H #define INSET_TABULAR_H -#include "Inset.h" #include "InsetText.h" #include "Length.h" @@ -677,7 +676,10 @@ public: /// shared_ptr inset; }; - CellData & cellInfo(idx_type cell) const; + /// + CellData const & cellInfo(idx_type cell) const; + /// + CellData & cellInfo(idx_type cell); /// typedef std::vector cell_vector; /// @@ -832,7 +834,9 @@ public: /// change associated Buffer void setBuffer(Buffer & buffer); /// retrieve associated Buffer - Buffer & buffer() const { return *buffer_; } + Buffer const & buffer() const { return *buffer_; } + /// retrieve associated Buffer + Buffer & buffer() { return *buffer_; } private: Buffer * buffer_; -- 2.39.2