]> git.lyx.org Git - features.git/commitdiff
fix bug 1919 (table cells won't accept normal text pastes)
authorJürgen Spitzmüller <spitz@lyx.org>
Tue, 6 Sep 2005 17:39:39 +0000 (17:39 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Tue, 6 Sep 2005 17:39:39 +0000 (17:39 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10416 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/CutAndPaste.C
src/CutAndPaste.h
src/insets/ChangeLog
src/insets/insettabular.C

index ac32700ded36d0d197c63f63b3f5ef455a5dbb54..fe7cba16f39784d14792cb3bdaacdba39ccbc76a 100644 (file)
@@ -1,8 +1,16 @@
+2005-09-06  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * CutAndPaste.[Ch]: new methods dirtyTabularStack and 
+       tabularStackDirty to work around bug 1919 (tabular needs
+       to know whether its own cell paste buffer or the one of 
+       texted is newer.
+       * CutAndPaste.C: mark tabular_stack_ clean after copy.
+
 2005-08-26  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * text2.C (cursorEnd): check for empty text (fixes bug 1998)
 
-2005-08-19  Lars Gullik Bjønnes  <larsbj@gullik.net>
+2005-08-19  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * CutAndPaste.C (eraseSelectionHelper): fix bug 1920
        use old deleteion algorithm when changetracking is on.
index 8483d004d0b9f2077288947b15d77bf07a608356..25193a4a07cf335c0d43d47c853b38d2bc3c957a 100644 (file)
@@ -68,6 +68,11 @@ typedef limited_stack<pair<ParagraphList, textclass_type> > CutStack;
 
 CutStack theCuts(10);
 
+// store whether the tabular stack is newer than the normal copy stack
+// FIXME: this is a workaround for bug 1919. Should be removed for 1.5, 
+// when we (hopefully) have a one-for-all paste mechanism.
+bool dirty_tabular_stack_;
+
 class resetOwnerAndChanges : public std::unary_function<Paragraph, void> {
 public:
        void operator()(Paragraph & p) const {
@@ -531,6 +536,9 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut)
                // need a valid cursor. (Lgb)
                cur.clearSelection();
                updateCounters(cur.buffer());
+
+               // tell tabular that a recent copy happened
+               dirtyTabularStack(false);
        }
 
        if (cur.inMathed()) {
@@ -581,6 +589,8 @@ void copySelection(LCursor & cur)
                pars.back().insert(0, grabSelection(cur), LyXFont());
                theCuts.push(make_pair(pars, bp.textclass));
        }
+       // tell tabular that a recent copy happened
+       dirtyTabularStack(false);
 }
 
 
@@ -779,5 +789,17 @@ string grabSelection(LCursor & cur)
 }
 
 
+void dirtyTabularStack(bool b)
+{
+       dirty_tabular_stack_ = b;
+}
+
+
+bool tabularStackDirty()
+{
+       return dirty_tabular_stack_;
+}
+
+
 } // namespace cap
 } // namespace lyx
index cb384b868b5e27e96ea031e592c31e271b42e528..4acfbd8341fbe9cb461d4a7f5de9f02252696da1 100644 (file)
@@ -81,6 +81,17 @@ void selDel(LCursor & cur);
 void selClearOrDel(LCursor & cur);
 /// pastes n-th element of cut buffer
 void selPaste(LCursor & cur, size_t n);
+
+/** Tabular has its own paste stack for multiple cells
+ *  but it needs to know whether there is a more recent 
+ *  ordinary paste. Therefore which one is newer.
+ */
+//FIXME: this is a workaround for bug 1919. Replace this by
+//an all-for-one-paste mechanism in 1.5
+/// store whether tabular or ordinary paste stack is newer
+void dirtyTabularStack(bool b);
+/// is the tabular paste stack newer than the ordinary one?
+bool tabularStackDirty();
 } // namespace cap
 } // namespce lyx
 
index 774e90364f3ebb4ee369353d604da23d89aeada4..2b99c1c14b1fd23308f495c08710172a91f35f68 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-06  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * insettabular.C: mark tabular_stack_ (of CutAndPaste) dirty
+       after copying several cells (works around bug 1919).
+
 2005-09-05  Michael Gerz  <michael.gerz@teststep.org>
 
        * insetcharstyle.C (metrics,draw): consider inset label for
index b98f1a32d738ad61d2e0badfc276ef719b8101b7..93d063c772e34a55af7c95ad3d66bae903bd647b 100644 (file)
@@ -16,6 +16,7 @@
 #include "bufferparams.h"
 #include "BufferView.h"
 #include "cursor.h"
+#include "CutAndPaste.h"
 #include "coordcache.h"
 #include "debug.h"
 #include "dispatchresult.h"
@@ -45,6 +46,8 @@
 #include <iostream>
 #include <limits>
 
+using lyx::cap::tabularStackDirty;
+
 using lyx::graphics::PreviewLoader;
 
 using lyx::support::ltrim;
@@ -719,7 +722,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_PASTE:
-               if (hasPasteBuffer()) {
+               if (hasPasteBuffer() && tabularStackDirty()) {
                        recordUndo(cur, Undo::INSERT);
                        pasteSelection(cur);
                        break;
@@ -1719,6 +1722,11 @@ bool InsetTabular::copySelection(LCursor & cur)
        OutputParams const runparams;
        paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t');
        cur.bv().stuffClipboard(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.
+       lyx::cap::dirtyTabularStack(true);
+
        return true;
 }