]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettabular.C
prevent crash when inserting minipage in table cell,
[lyx.git] / src / insets / insettabular.C
index af8799e15f1a7a7c544759df9a6c8d691bec1276..1cbf00c932aadbfb672030041d1e326b9f9b9ba0 100644 (file)
@@ -224,7 +224,7 @@ void InsetTabular::buffer(Buffer * b)
 
 void InsetTabular::write(Buffer const * buf, ostream & os) const
 {
-       os << " Tabular" << endl;
+       os << "Tabular" << endl;
        tabular.write(buf, os);
 }
 
@@ -275,14 +275,12 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
 {
        //lyxerr << "InsetTabular::draw: " << x << " " << y << "\n";
        if (nodraw()) {
+               lyxerr << "InsetTabular::nodraw: " << x << " " << y << "\n";
                need_update = FULL;
                return;
        }
 
        BufferView * bv = pi.base.bv;
-       int i;
-       int j;
-       int nx;
 
 #if 0
        UpdatableInset::draw(pi, x, y);
@@ -296,25 +294,24 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
        x += ADD_TO_TABULAR_WIDTH;
 
        int cell = 0;
-       int cx;
        first_visible_cell = -1;
-       for (i = 0; i < tabular.rows(); ++i) {
-               nx = x;
+       for (int i = 0; i < tabular.rows(); ++i) {
+               int nx = x;
                cell = tabular.getCellNumber(i, 0);
-               if (!((y + tabular.getDescentOfRow(i)) > 0) &&
-                       (y - tabular.getAscentOfRow(i)) < pi.pain.paperHeight())
+               if (y + tabular.getDescentOfRow(i) <= 0 &&
+                         y - tabular.getAscentOfRow(i) < pi.pain.paperHeight())
                {
-               y += tabular.getDescentOfRow(i) +
-                               tabular.getAscentOfRow(i + 1) +
-                               tabular.getAdditionalHeight(i + 1);
+                       y += tabular.getDescentOfRow(i) +
+                                       tabular.getAscentOfRow(i + 1) +
+                                       tabular.getAdditionalHeight(i + 1);
                        continue;
                }
-               for (j = 0; j < tabular.columns(); ++j) {
+               for (int j = 0; j < tabular.columns(); ++j) {
                        if (nx > bv->workWidth())
                                break;
                        if (tabular.isPartOfMultiColumn(i, j))
                                continue;
-                       cx = nx + tabular.getBeginningOfTextInCell(cell);
+                       int cx = nx + tabular.getBeginningOfTextInCell(cell);
                        if (first_visible_cell < 0)
                                first_visible_cell = cell;
                        if (hasSelection()) {
@@ -1179,12 +1176,7 @@ int InsetTabular::ascii(Buffer const * buf, ostream & os, int ll) const
 
 int InsetTabular::linuxdoc(Buffer const * buf, ostream & os) const
 {
-       os << "<![CDATA[";
-       int const ret = tabular.ascii(buf,os,
-                                      (int)parOwner()->params().depth(),
-                                      false, 0);
-       os << "]]>";
-       return ret;
+       return tabular.linuxdoc(buf,os);
 }
 
 
@@ -2624,7 +2616,9 @@ bool InsetTabular::forceDefaultParagraphs(InsetOld const * in) const
        // well we didn't obviously find it so maybe our owner knows more
        if (owner())
                return owner()->forceDefaultParagraphs(in);
+
        // if we're here there is really something strange going on!!!
+       lyxerr << "if we're here there is really something strange going on!\n";
        return false;
 }
 
@@ -2693,7 +2687,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
                        if (cols < columns) {
                                InsetText & inset = loctab->getCellInset(cell);
                                LyXFont const font = inset.getLyXText(bv)->
-                                       getFont(bv->buffer(), inset.paragraphs.begin(), 0);
+                                       getFont(inset.paragraphs.begin(), 0);
                                inset.setText(buf.substr(op, p - op), font);
                                ++cols;
                                ++cell;
@@ -2704,7 +2698,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
                        if (cols < columns) {
                                InsetText & inset = tabular.getCellInset(cell);
                                LyXFont const font = inset.getLyXText(bv)->
-                                       getFont(bv->buffer(), inset.paragraphs.begin(), 0);
+                                       getFont(inset.paragraphs.begin(), 0);
                                inset.setText(buf.substr(op, p - op), font);
                        }
                        cols = ocol;
@@ -2720,7 +2714,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
        if (cell < cells && op < len) {
                InsetText & inset = loctab->getCellInset(cell);
                LyXFont const font = inset.getLyXText(bv)->
-                       getFont(bv->buffer(), inset.paragraphs.begin(), 0);
+                       getFont(inset.paragraphs.begin(), 0);
                inset.setText(buf.substr(op, len - op), font);
        }