]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettabular.C
hopefully fix tex2lyx linking.
[lyx.git] / src / insets / insettabular.C
index 6fbbb1c706b631031a8de3de6dd518d306214285..bc7888fe3e1a9801aeb05553a33273186d51274c 100644 (file)
@@ -40,7 +40,6 @@
 #include "frontends/Clipboard.h"
 #include "frontends/Painter.h"
 #include "frontends/Selection.h"
-#include "frontends/nullpainter.h"
 
 #include <sstream>
 #include <iostream>
@@ -312,9 +311,6 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
        //lyxerr << "InsetTabular::draw: " << x << " " << y << endl;
        BufferView * bv = pi.base.bv;
 
-       static frontend::NullPainter nop;
-       static PainterInfo nullpi(bv, nop);
-
        resetPos(bv->cursor());
 
        x += scx_;
@@ -338,8 +334,10 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
                            || nx > bv->workWidth()
                            || y + d < 0
                            || y - a > bv->workHeight()) {
-                               cell(idx)->draw(nullpi, cx, y);
-                               drawCellLines(nop, nx, y, i, idx, pi.erased_);
+                               pi.pain.setDrawingEnabled(false);
+                               cell(idx)->draw(pi, cx, y);
+                               drawCellLines(pi.pain, nx, y, i, idx, pi.erased_);
+                               pi.pain.setDrawingEnabled(true);
                        } else {
                                cell(idx)->draw(pi, cx, y);
                                drawCellLines(pi.pain, nx, y, i, idx, pi.erased_);
@@ -575,7 +573,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
                                cur.idx() = tabular.getCellBelow(cur.idx());
                                cur.pit() = 0;
                                cur.pos() = cell(cur.idx())->getText(0)->x2pos(
-                                       cur.pit(), 0, cur.targetX());
+                                       cur.bv(), cur.pit(), 0, cur.targetX());
                        }
                if (sl == cur.top()) {
                        // we trick it to go to the RIGHT after leaving the
@@ -598,6 +596,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
                                cur.pit() = cur.lastpit();
                                LyXText const * text = cell(cur.idx())->getText(0);
                                cur.pos() = text->x2pos(
+                                       cur.bv(),
                                        cur.pit(),
                                        text->paragraphs().back().rows().size()-1,
                                        cur.targetX());
@@ -1914,6 +1913,20 @@ void InsetTabular::setChange(Change const & change)
 }
 
 
+void InsetTabular::acceptChanges()
+{
+       for (idx_type idx = 0; idx < nargs(); ++idx)
+               cell(idx)->acceptChanges();
+}
+
+
+void InsetTabular::rejectChanges()
+{
+       for (idx_type idx = 0; idx < nargs(); ++idx)
+               cell(idx)->rejectChanges();
+}
+
+
 bool InsetTabular::forceDefaultParagraphs(idx_type cell) const
 {
        return tabular.getPWidth(cell).zero();
@@ -1926,6 +1939,8 @@ bool InsetTabular::insertAsciiString(BufferView & bv, docstring const & buf,
        if (buf.length() <= 0)
                return true;
 
+       Buffer const & buffer = *bv.buffer();
+
        col_type cols = 1;
        row_type rows = 1;
        col_type maxCols = 1;
@@ -1954,7 +1969,7 @@ bool InsetTabular::insertAsciiString(BufferView & bv, docstring const & buf,
        row_type row = 0;
        if (usePaste) {
                paste_tabular.reset(
-                       new LyXTabular(bv.buffer()->params(), rows, maxCols));
+                       new LyXTabular(buffer.params(), rows, maxCols));
                loctab = paste_tabular.get();
                cols = 0;
                dirtyTabularStack(true);
@@ -1982,11 +1997,10 @@ bool InsetTabular::insertAsciiString(BufferView & bv, docstring const & buf,
                        // we can only set this if we are not too far right
                        if (cols < columns) {
                                shared_ptr<InsetText> inset = loctab->getCellInset(cell);
-                               inset->setViewCache(&bv);
                                Paragraph & par = inset->text_.getPar(0);
-                               LyXFont const font = inset->text_.getFont(par, 0);
+                               LyXFont const font = inset->text_.getFont(buffer, par, 0);
                                inset->setText(buf.substr(op, p - op), font,
-                                              bv.buffer()->params().trackChanges);
+                                              buffer.params().trackChanges);
                                ++cols;
                                ++cell;
                        }
@@ -1995,11 +2009,10 @@ bool InsetTabular::insertAsciiString(BufferView & bv, docstring const & buf,
                        // we can only set this if we are not too far right
                        if (cols < columns) {
                                shared_ptr<InsetText> inset = tabular.getCellInset(cell);
-                               inset->setViewCache(&bv);
                                Paragraph & par = inset->text_.getPar(0);
-                               LyXFont const font = inset->text_.getFont(par, 0);
+                               LyXFont const font = inset->text_.getFont(buffer, par, 0);
                                inset->setText(buf.substr(op, p - op), font,
-                                              bv.buffer()->params().trackChanges);
+                                              buffer.params().trackChanges);
                        }
                        cols = ocol;
                        ++row;
@@ -2013,11 +2026,10 @@ bool InsetTabular::insertAsciiString(BufferView & bv, docstring const & buf,
        // check for the last cell if there is no trailing '\n'
        if (cell < cells && op < len) {
                shared_ptr<InsetText> inset = loctab->getCellInset(cell);
-               inset->setViewCache(&bv);
                Paragraph & par = inset->text_.getPar(0);
-               LyXFont const font = inset->text_.getFont(par, 0);
+               LyXFont const font = inset->text_.getFont(buffer, par, 0);
                inset->setText(buf.substr(op, len - op), font,
-                              bv.buffer()->params().trackChanges);
+                       buffer.params().trackChanges);
        }
        return true;
 }