From: Jürgen Spitzmüller Date: Tue, 6 Sep 2005 17:39:39 +0000 (+0000) Subject: fix bug 1919 (table cells won't accept normal text pastes) X-Git-Tag: 1.6.10~13945 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4110aa3b1e2828e7df3ca964ccb7e79cc010ae03;p=features.git fix bug 1919 (table cells won't accept normal text pastes) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10416 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index ac32700ded..fe7cba16f3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,8 +1,16 @@ +2005-09-06 Jürgen Spitzmüller + + * 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 * text2.C (cursorEnd): check for empty text (fixes bug 1998) -2005-08-19 Lars Gullik Bjønnes +2005-08-19 Lars Gullik Bjønnes * CutAndPaste.C (eraseSelectionHelper): fix bug 1920 use old deleteion algorithm when changetracking is on. diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 8483d004d0..25193a4a07 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -68,6 +68,11 @@ typedef limited_stack > 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 { 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 diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h index cb384b868b..4acfbd8341 100644 --- a/src/CutAndPaste.h +++ b/src/CutAndPaste.h @@ -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 diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 774e90364f..2b99c1c14b 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2005-09-06 Jürgen Spitzmüller + + * insettabular.C: mark tabular_stack_ (of CutAndPaste) dirty + after copying several cells (works around bug 1919). + 2005-09-05 Michael Gerz * insetcharstyle.C (metrics,draw): consider inset label for diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index b98f1a32d7..93d063c772 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -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 #include +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; }