#include "support/convert.h"
#include "frontends/Alert.h"
+#include "frontends/Application.h"
#include "frontends/font_metrics.h"
-#include "frontends/Gui.h"
-#include "frontends/LyXView.h"
#include "frontends/Clipboard.h"
#include "frontends/Painter.h"
#include "frontends/Selection.h"
using lyx::support::ltrim;
using lyx::frontend::Painter;
-using lyx::frontend::Gui;
using lyx::frontend::Clipboard;
using boost::shared_ptr;
{ LyXTabular::APPEND_COLUMN, "append-column" },
{ LyXTabular::DELETE_ROW, "delete-row" },
{ LyXTabular::DELETE_COLUMN, "delete-column" },
+ { LyXTabular::COPY_ROW, "copy-row" },
+ { LyXTabular::COPY_COLUMN, "copy-column" },
{ LyXTabular::TOGGLE_LINE_TOP, "toggle-line-top" },
{ LyXTabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
{ LyXTabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
case LFUN_CLIPBOARD_PASTE:
case LFUN_PRIMARY_SELECTION_PASTE: {
docstring const clip = (cmd.action == LFUN_CLIPBOARD_PASTE) ?
- cur.bv().owner()->gui().clipboard().get() :
- cur.bv().owner()->gui().selection().get();
+ theApp->clipboard().get() :
+ theApp->selection().get();
if (clip.empty())
break;
// pass to InsertAsciiString, but
break;
}
cell(cur.idx())->dispatch(cur, cmd);
- // Reset pasted paragraphs:
- if (tabular.getPWidth(cur.idx()).zero())
- cell(cur.idx())->forceParagraphsToDefault(cur);
break;
case LFUN_FONT_EMPH:
row_type rs, re;
col_type cs, ce;
getSelection(cur, rs, re, cs, ce);
+ LCursor tmpcur = cur;
for (row_type i = rs; i <= re; ++i) {
for (col_type j = cs; j <= ce; ++j) {
// cursor follows cell:
- cur.idx() = tabular.getCellNumber(i, j);
+ tmpcur.idx() = tabular.getCellNumber(i, j);
// select this cell only:
- cur.pos() = 0;
- cur.resetAnchor();
- cur.pos() = cur.top().lastpos();
- cur.setCursor(cur);
- cur.setSelection();
- cell(cur.idx())->dispatch(cur, cmd);
+ tmpcur.pit() = 0;
+ tmpcur.pos() = 0;
+ tmpcur.resetAnchor();
+ tmpcur.pit() = tmpcur.lastpit();
+ tmpcur.pos() = tmpcur.top().lastpos();
+ tmpcur.setCursor(tmpcur);
+ tmpcur.setSelection();
+ cell(tmpcur.idx())->dispatch(tmpcur, cmd);
}
}
- // Restore original selection
- cur.idx() = tabular.getCellNumber(rs, cs);
- cur.pos() = 0;
- cur.resetAnchor();
- cur.idx() = tabular.getCellNumber(re, ce);
- cur.pos() = cur.top().lastpos();
- cur.setCursor(cur);
- cur.setSelection();
break;
} else {
cell(cur.idx())->dispatch(cur, cmd);
case LyXTabular::APPEND_COLUMN:
case LyXTabular::DELETE_ROW:
case LyXTabular::DELETE_COLUMN:
+ case LyXTabular::COPY_ROW:
+ case LyXTabular::COPY_COLUMN:
case LyXTabular::SET_ALL_LINES:
case LyXTabular::UNSET_ALL_LINES:
case LyXTabular::SET_TOP_SPACE:
cur.selection() = false;
break;
+ case LyXTabular::COPY_ROW:
+ tabular.copyRow(bv.buffer()->params(), row);
+ break;
+
+ case LyXTabular::COPY_COLUMN:
+ tabular.copyColumn(bv.buffer()->params(), column);
+ cur.idx() = tabular.getCellNumber(row, column);
+ break;
+
case LyXTabular::M_TOGGLE_LINE_TOP:
flag = false;
case LyXTabular::TOGGLE_LINE_TOP: {
ostringstream os;
OutputParams const runparams;
paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t');
- cur.bv().owner()->gui().clipboard().put(lyx::from_utf8(os.str()));
+ theApp->clipboard().put(lyx::from_utf8(os.str()));
// mark tabular stack dirty
// FIXME: this is a workaround for bug 1919. Should be removed for 1.5,
// when we (hopefully) have a one-for-all paste mechanism.
}
// cursor position might be invalid now
- cur.pos() = cur.lastpos();
+ if (cur.pit() > cur.lastpit())
+ cur.pit() = cur.lastpit();
+ if (cur.pos() > cur.lastpos())
+ cur.pos() = cur.lastpos();
cur.clearSelection();
}