]> git.lyx.org Git - features.git/blobdiff - src/tabular.C
Hopefully fixed the redo problems with insets!
[features.git] / src / tabular.C
index 58b9dbcd0cc7061c29ad1e88d65046b0b7fef084..5213651290be0272b317d78b35e5836db4a69e27 100644 (file)
@@ -26,7 +26,7 @@
 #include "debug.h"
 #include "vspace.h"
 #include "layout.h"
-#include "lyx_gui_misc.h"
+#include "frontends/Alert.h"
 #include "buffer.h"
 #include "BufferView.h"
 #include "Painter.h"
@@ -110,11 +110,23 @@ LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg)
 }
 
 
-LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt)
+LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt,
+                       bool same_id)
 {
        owner_ = inset;
        cur_cell = -1;
        Init(lt.rows_, lt.columns_, &lt);
+       // we really should change again to have InsetText as a pointer
+       // and allocate it then we would not have to do this stuff all
+       // double!
+       if (same_id) {
+               for (int i = 0; i < rows_; ++i) {
+                       for (int j = 0; j < columns_; ++j) {
+                               cell_info[i][j].inset.id(lt.cell_info[i][j].inset.id());
+                               cell_info[i][j].inset.setParagraphData(lt.cell_info[i][j].inset.paragraph(),true);
+                       }
+               }
+       }
 #if 0
 #ifdef WITH_WARNINGS
 #warning Jürgen, can you make it the other way round. So that copy assignment depends on the copy constructor and not the other way. (Lgb)
@@ -164,9 +176,9 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
 }
 
 
-LyXTabular * LyXTabular::clone(InsetTabular * inset)
+LyXTabular * LyXTabular::clone(InsetTabular * inset, bool same_id)
 {
-       LyXTabular * result = new LyXTabular(inset, *this);
+       LyXTabular * result = new LyXTabular(inset, *this, same_id);
 #if 0
        // don't know if this is good but I need to Clone also
        // the text-insets here, this is for the Undo-facility!
@@ -266,9 +278,6 @@ void LyXTabular::AppendRow(int cell)
 
 void LyXTabular::DeleteRow(int row)
 {
-       // Why make it so hard? (Lgb)
-       //if (!(rows_ - 1))
-       //return;
        if (rows_ == 1) return; // Not allowed to delete last row
        
        row_info.erase(row_info.begin() + row); //&row_info[row]);
@@ -1442,7 +1451,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
                lyxerr << "Tabular format < 5 is not supported anymore\n"
                        "Get an older version of LyX (< 1.1.x) for conversion!"
                           << endl;
-               WriteAlert(_("Warning:"),
+               Alert::alert(_("Warning:"),
                                   _("Tabular format < 5 is not supported anymore\n"),
                                   _("Get an older version of LyX (< 1.1.x) for conversion!"));
                if (version > 2) {
@@ -2215,6 +2224,7 @@ int LyXTabular::Latex(Buffer const * buf,
                        ++cell;
                }
                os << "\\\\\n";
+               ++ret;
                ret += TeXBottomHLine(os, i);
                if (IsLongTabular()) {
                        if (i == (endhead.row - 1)) {
@@ -2651,16 +2661,9 @@ LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
 
        for (; par; par = par->next()) {
                for (int i = 0; i < par->size(); ++i) {
-                       if (par->getChar(i)     == Paragraph::META_NEWLINE)
+                       if (par->getChar(i) == Paragraph::META_NEWLINE)
                                return BOX_PARBOX;
                }
        }
        return BOX_NONE;
 }
-
-/* Emacs:
- * Local variables:
- * tab-width: 4
- * End:
- * vi:set tabstop=4:
- */