]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
Fix bug 2485 and crash on middle mouse paste on math
[lyx.git] / src / tabular.C
index 055b390321bf66027dbd5366b0ba6e6a508921b1..7bb2cf78a7970acd7cf2c5985d9a276d0096bc6a 100644 (file)
@@ -313,8 +313,7 @@ void l_getline(istream & is, string & str)
 
 /// Define a few methods for the inner structs
 
-LyXTabular::cellstruct::cellstruct(BufferParams const & bp,
-               BufferView const * bv)
+LyXTabular::cellstruct::cellstruct(BufferParams const & bp)
        : cellno(0),
          width_of_cell(0),
          multicolumn(LyXTabular::CELL_NORMAL),
@@ -327,9 +326,7 @@ LyXTabular::cellstruct::cellstruct(BufferParams const & bp,
          usebox(BOX_NONE),
          rotate(false),
          inset(new InsetText(bp))
-{
-       inset->setViewCache(bv);
-}
+{}
 
 
 LyXTabular::cellstruct::cellstruct(cellstruct const & cs)
@@ -409,21 +406,21 @@ LyXTabular::ltType::ltType()
 
 
 LyXTabular::LyXTabular(BufferParams const & bp, row_type rows_arg,
-                       col_type columns_arg, BufferView const * bv)
+                      col_type columns_arg)
 {
-       init(bp, rows_arg, columns_arg, bv);
+       init(bp, rows_arg, columns_arg);
 }
 
 
 // activates all lines and sets all widths to 0
 void LyXTabular::init(BufferParams const & bp, row_type rows_arg,
-                      col_type columns_arg, BufferView const * bv)
+                     col_type columns_arg)
 {
        rows_    = rows_arg;
        columns_ = columns_arg;
        row_info = row_vector(rows_);
        column_info = column_vector(columns_);
-       cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp, bv)));
+       cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp)));
        row_info.reserve(10);
        column_info.reserve(10);
        cell_info.reserve(100);
@@ -457,7 +454,6 @@ void LyXTabular::fixCellNums()
 
 void LyXTabular::appendRow(BufferParams const & bp, idx_type const cell)
 {
-       BufferView const * const bv = getCellInset(0)->getText(0)->bv();
        ++rows_;
 
        row_type const row = row_of_cell(cell);
@@ -471,7 +467,7 @@ void LyXTabular::appendRow(BufferParams const & bp, idx_type const cell)
        for (row_type i = 0; i < rows_ - 1; ++i)
                swap(cell_info[i], old[i]);
 
-       cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp, bv)));
+       cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp)));
 
        for (row_type i = 0; i <= row; ++i)
                swap(cell_info[i], old[i]);
@@ -501,7 +497,6 @@ void LyXTabular::deleteRow(row_type const row)
 
 void LyXTabular::appendColumn(BufferParams const & bp, idx_type const cell)
 {
-       BufferView const * const bv = getCellInset(0)->getText(0)->bv();
        ++columns_;
 
        col_type const column = column_of_cell(cell);
@@ -511,7 +506,7 @@ void LyXTabular::appendColumn(BufferParams const & bp, idx_type const cell)
        column_info[column + 1] = column_info[column];
 
        for (row_type i = 0; i < rows_; ++i) {
-               cell_info[i].insert(cell_info[i].begin() + column + 1, cellstruct(bp, bv));
+               cell_info[i].insert(cell_info[i].begin() + column + 1, cellstruct(bp));
 
                // care about multicolumns
                if (cell_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN)
@@ -861,7 +856,7 @@ void LyXTabular::setWidthOfCell(idx_type cell, int new_width)
 
 
 void LyXTabular::setAlignment(idx_type cell, LyXAlignment align,
-                              bool onlycolumn)
+                             bool onlycolumn)
 {
        if (!isMultiColumn(cell) || onlycolumn)
                column_info[column_of_cell(cell)].alignment = align;
@@ -871,7 +866,7 @@ void LyXTabular::setAlignment(idx_type cell, LyXAlignment align,
 
 
 void LyXTabular::setVAlignment(idx_type cell, VAlignment align,
-                               bool onlycolumn)
+                              bool onlycolumn)
 {
        if (!isMultiColumn(cell) || onlycolumn)
                column_info[column_of_cell(cell)].valignment = align;
@@ -920,7 +915,7 @@ void LyXTabular::setColumnPWidth(LCursor & cur, idx_type cell,
                idx_type const cell = getCellNumber(i, j);
                // because of multicolumns
                toggleFixedWidth(cur, getCellInset(cell).get(),
-                                !getPWidth(cell).zero());
+                                !getPWidth(cell).zero());
        }
        // cur paragraph can become invalid after paragraphs were merged
        if (cur.pit() > cur.lastpit())
@@ -1278,7 +1273,7 @@ void LyXTabular::read(Buffer const & buf, LyXLex & lex)
        int columns_arg;
        if (!getTokenValue(line, "columns", columns_arg))
                return;
-       init(buf.params(), rows_arg, columns_arg, buf.text().bv());
+       init(buf.params(), rows_arg, columns_arg);
        l_getline(is, line);
        if (!prefixIs(line, "<features")) {
                lyxerr << "Wrong tabular format (expected <features ...> got"
@@ -1390,7 +1385,7 @@ LyXTabular::cellstruct & LyXTabular::cellinfo_of_cell(idx_type cell) const
 
 
 void LyXTabular::setMultiColumn(Buffer * buffer, idx_type cell,
-                                idx_type number)
+                               idx_type number)
 {
        cellstruct & cs = cellinfo_of_cell(cell);
        cs.multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
@@ -1541,10 +1536,10 @@ LyXTabular::idx_type LyXTabular::getLastCellBelow(idx_type cell) const
 
 
 LyXTabular::idx_type LyXTabular::getCellNumber(row_type row,
-                                               col_type column) const
+                                              col_type column) const
 {
        BOOST_ASSERT(column != npos && column < columns_ &&
-                    row    != npos && row    < rows_);
+                    row    != npos && row    < rows_);
        return cell_info[row][column].cellno;
 }
 
@@ -1570,7 +1565,7 @@ LyXTabular::BoxType LyXTabular::getUsebox(idx_type cell) const
 //  This are functions used for the longtable support
 ///
 void LyXTabular::setLTHead(row_type row, bool flag, ltType const & hd,
-                           bool first)
+                          bool first)
 {
        if (first) {
                endfirsthead = hd;
@@ -1601,7 +1596,7 @@ bool LyXTabular::getRowOfLTFirstHead(row_type row, ltType & hd) const
 
 
 void LyXTabular::setLTFoot(row_type row, bool flag, ltType const & fd,
-                           bool last)
+                          bool last)
 {
        if (last) {
                endlastfoot = fd;
@@ -2558,7 +2553,7 @@ shared_ptr<InsetText> LyXTabular::getCellInset(idx_type cell) const
 
 
 shared_ptr<InsetText> LyXTabular::getCellInset(row_type row,
-                                               col_type column) const
+                                              col_type column) const
 {
        return cell_info[row][column].inset;
 }