From 9374e68bfd5b1bf03ce74fe9438956fddf3c6403 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 8 Aug 2008 17:28:25 +0000 Subject: [PATCH] Fix bug 5146. The problem arose when attempting to paste normal text into a multicell selection. But the more I thought about this, the more it seemed that pasting into multicell selections shouldn't be allowed. What exactly ought to happen if the user selects a 2x3 grid of cells and then tries to paste a 5x5 group of cells? LyX, anyway, just ignores the selection in this case, which is not what the user will expect. So let's just not go there. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26099 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/doc/UserGuide.lyx | 19 +++++++++++++++++++ src/Text3.cpp | 1 + src/insets/InsetTabular.cpp | 9 +++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/doc/UserGuide.lyx b/lib/doc/UserGuide.lyx index 9c2b429752..fd15620493 100644 --- a/lib/doc/UserGuide.lyx +++ b/lib/doc/UserGuide.lyx @@ -19164,6 +19164,25 @@ This is a multiline entry in a table. \begin_layout Standard Cutting and pasting between tables and table cells works reasonably well. You can cut and paste even more than one row. +\begin_inset Foot +status open + +\begin_layout Plain Layout +Note, however, that you cannot paste into a multicell selection. + The reason is that it is simply not clear what LyX should do in this case. + If you select a 2x3 group of cells but paste just the word +\begin_inset Quotes eld +\end_inset + +the +\begin_inset Quotes erd +\end_inset + + (or a 3x5 group of cells) what should happen? +\end_layout + +\end_inset + Selection with the mouse or with \family sans Shift diff --git a/src/Text3.cpp b/src/Text3.cpp index be8e80feb4..ff971cb0b5 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -931,6 +931,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_PASTE: { cur.message(_("Paste")); + LASSERT(cur.selBegin().idx() == cur.selEnd().idx(), /**/); cap::replaceSelection(cur); // without argument? diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index e30af38382..22237df636 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -3754,11 +3754,16 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd, } case LFUN_PASTE: + if (cur.selBegin().idx() != cur.selEnd().idx()) { + status.setEnabled(false); + status.message(_("You cannot paste into a multicell selection.")); + return true; + } if (tabularStackDirty() && theClipboard().isInternal()) { status.setEnabled(true); return true; - } else - return cell(cur.idx())->getStatus(cur, cmd, status); + } + return cell(cur.idx())->getStatus(cur, cmd, status); case LFUN_INSET_MODIFY: if (insetCode(cmd.getArg(0)) == TABULAR_CODE) {