#include "frontends/Clipboard.h"
#include "frontends/Painter.h"
#include "frontends/Selection.h"
-#include "frontends/nullpainter.h"
#include <sstream>
#include <iostream>
}
-void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
+bool InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
{
//lyxerr << "InsetTabular::metrics: " << mi.base.bv << " width: " <<
// mi.base.textwidth << "\n";
dim.asc = tabular.getAscentOfRow(0);
dim.des = tabular.getHeightOfTabular() - dim.asc;
dim.wid = tabular.getWidthOfTabular() + 2 * ADD_TO_TABULAR_WIDTH;
+ bool const changed = dim_ != dim;
dim_ = dim;
+ return changed;
}
case LFUN_MOUSE_PRESS:
//lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
- if (cmd.button() == mouse_button::button1
- || cmd.button() == mouse_button::button3) {
+ if (cmd.button() == mouse_button::button1
+ || (cmd.button() == mouse_button::button3
+ && (&bvcur.selBegin().inset() != this || !tablemode(bvcur)))) {
cur.selection() = false;
setCursorFromCoordinates(cur, cmd.x, cmd.y);
- cur.resetAnchor();
- bvcur = cur;
+ cur.bv().mouseSetCursor(cur);
break;
}
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
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());
// insert file functions
case LFUN_FILE_INSERT_ASCII_PARA:
case LFUN_FILE_INSERT_ASCII: {
- // FIXME: We don't know the encoding of filenames
+ // FIXME UNICODE
string const tmpstr = getContentsOfAsciiFile(&cur.bv(), to_utf8(cmd.argument()), false);
// FIXME: We don't know the encoding of the file
if (!tmpstr.empty() && !insertAsciiString(cur.bv(), from_utf8(tmpstr), false))
if (buf.length() <= 0)
return true;
+ Buffer const & buffer = *bv.buffer();
+
col_type cols = 1;
row_type rows = 1;
col_type maxCols = 1;
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);
// 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;
}
// 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;
// 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;
}