]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
* src/paragraph_funcs.cpp (breakParagraph): change parameter 'flag' to
[lyx.git] / src / insets / InsetTabular.cpp
index 47c50de74f72e328714187e9b4f3e760640b3b44..682b82514cbf926983ad7af1377e64a45243481e 100644 (file)
 
 #include "InsetTabular.h"
 
-#include "Buffer.h"
 #include "buffer_funcs.h"
+#include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
+#include "Color.h"
+#include "CoordCache.h"
 #include "Counters.h"
 #include "Cursor.h"
 #include "CutAndPaste.h"
-#include "CoordCache.h"
 #include "debug.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "gettext.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "Color.h"
-#include "callback.h"
 #include "Lexer.h"
 #include "MetricsInfo.h"
 #include "OutputParams.h"
-#include "Paragraph.h"
 #include "paragraph_funcs.h"
+#include "Paragraph.h"
 #include "ParagraphParameters.h"
 #include "ParIterator.h"
 #include "Undo.h"
@@ -430,7 +429,7 @@ bool getTokenValue(string const & str, char const * token, bool & flag)
 
 bool getTokenValue(string const & str, char const * token, Length & len)
 {
-       // set the lenght to be zero() as default as this it should be if not
+       // set the length to be zero() as default as this it should be if not
        // in the file format.
        len = Length();
        string tmp;
@@ -577,6 +576,12 @@ Tabular::ltType::ltType()
 {}
 
 
+Tabular::Tabular()
+{
+       // unusable now!
+}
+
+
 Tabular::Tabular(BufferParams const & bp, row_type rows_arg,
                       col_type columns_arg)
 {
@@ -2932,7 +2937,7 @@ void InsetTabular::read(Buffer const & buf, Lexer & lex)
 }
 
 
-bool InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        //lyxerr << "InsetTabular::metrics: " << mi.base.bv << " width: " <<
        //      mi.base.textwidth << "\n";
@@ -2986,16 +2991,11 @@ bool InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
        dim.asc = tabular.rowAscent(0);
        dim.des = tabular.height() - dim.asc;
        dim.wid = tabular.width() + 2 * ADD_TO_TABULAR_WIDTH;
-       bool const changed = dim_ != dim;
-       dim_ = dim;
-       return changed;
 }
 
 
 void InsetTabular::draw(PainterInfo & pi, int x, int y) const
 {
-       setPosCache(pi, x, y);
-
        //lyxerr << "InsetTabular::draw: " << x << " " << y << endl;
        BufferView * bv = pi.base.bv;
 
@@ -3022,6 +3022,8 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
                                first_visible_cell = idx;
 
                        int const cx = nx + tabular.getBeginningOfTextInCell(idx);
+                       // Cache the Inset position.
+                       bv->coordCache().insets().add(cell(idx).get(), cx, y);
                        if (nx + tabular.columnWidth(idx) < 0
                            || nx > bv->workWidth()
                            || y + d < 0
@@ -3047,8 +3049,6 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
 
 void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
 {
-       setPosCache(pi, x, y);
-
        Cursor & cur = pi.base.bv->cursor();
 
        x += scx_ + ADD_TO_TABULAR_WIDTH;
@@ -3374,7 +3374,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_FILE_INSERT_PLAINTEXT_PARA:
        case LFUN_FILE_INSERT_PLAINTEXT: {
                // FIXME UNICODE
-               docstring const tmpstr = getContentsOfPlaintextFile(&cur.bv(), to_utf8(cmd.argument()), false);
+               docstring const tmpstr = cur.bv().contentsOfPlaintextFile(to_utf8(cmd.argument()), false);
                if (!tmpstr.empty() && !insertPlaintextString(cur.bv(), tmpstr, false))
                        cur.undispatched();
                break;
@@ -3449,7 +3449,7 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_FONT_NOUN:
        case LFUN_FONT_ITAL:
        case LFUN_FONT_FRAK:
-       case LFUN_FONT_CODE:
+       case LFUN_FONT_TYPEWRITER:
        case LFUN_FONT_SANS:
        case LFUN_FONT_FREE_APPLY:
        case LFUN_FONT_FREE_UPDATE:
@@ -3736,7 +3736,6 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
        // disable in non-fixed-width cells
        case LFUN_BREAK_LINE:
        case LFUN_BREAK_PARAGRAPH:
-       case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
        case LFUN_BREAK_PARAGRAPH_SKIP: {
                if (tabular.getPWidth(cur.idx()).zero()) {
                        status.enabled(false);