]> git.lyx.org Git - features.git/commitdiff
more const correctness
authorGeorg Baum <baum@lyx.org>
Tue, 21 Jun 2016 19:09:50 +0000 (21:09 +0200)
committerGeorg Baum <baum@lyx.org>
Tue, 21 Jun 2016 19:10:52 +0000 (21:10 +0200)
The const_cast shows the place where const correctness is violated, this is
no longer hidden by lying member functions.

src/insets/InsetTabular.cpp
src/insets/InsetTabular.h

index 54b4158b417431f511629e1994a26e3190e591a9..7728a1abd46cd502a645fc830c484fda263394cc 100644 (file)
@@ -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));
index ee5cffcd5ed8db8e7eb707cf5aff1e5c14bffc31..d26b1aa4f399efb657718ff75951848831c19867 100644 (file)
@@ -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_;