]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettabular.C
Implement copying of rows and columns in tables
[lyx.git] / src / insets / insettabular.C
index b5af539eb96d2ea80c3df8f6900c304b2066c233..0774f66c3fd38245f1c2ff6437992557ffc5e80d 100644 (file)
@@ -37,9 +37,8 @@
 #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"
@@ -59,7 +58,6 @@ using lyx::graphics::PreviewLoader;
 using lyx::support::ltrim;
 
 using lyx::frontend::Painter;
-using lyx::frontend::Gui;
 using lyx::frontend::Clipboard;
 
 using boost::shared_ptr;
@@ -97,6 +95,8 @@ TabularFeature tabularFeature[] =
        { 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" },
@@ -700,8 +700,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
        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
@@ -828,6 +828,8 @@ bool InsetTabular::getStatus(LCursor & cur, FuncRequest const & 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:
@@ -1463,6 +1465,15 @@ void InsetTabular::tabularFeatures(LCursor & cur,
                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: {
@@ -1780,7 +1791,7 @@ bool InsetTabular::copySelection(LCursor & cur)
        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.