commit c4ab6210883a5e4a973b5ad2d887aebdf98f131a
Author: Georg Baum <b...@lyx.org>
Date:   Tue Jun 21 21:09:50 2016 +0200

    more const correctness
    
    The const_cast shows the place where const correctness is violated, this is
    no longer hidden by lying member functions.

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 54b4158..7728a1a 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 &>(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 ee5cffc..d26b1aa 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<InsetTableCell> inset;
        };
-       CellData & cellInfo(idx_type cell) const;
+       ///
+       CellData const & cellInfo(idx_type cell) const;
+       ///
+       CellData & cellInfo(idx_type cell);
        ///
        typedef std::vector<CellData> 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_;

Reply via email to