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
This commit is contained in:
Jürgen Spitzmüller 2005-09-06 17:39:39 +00:00
parent 878e743d6d
commit 4110aa3b1e
5 changed files with 56 additions and 2 deletions

View 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> 2005-08-26 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* text2.C (cursorEnd): check for empty text (fixes bug 1998) * 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 * CutAndPaste.C (eraseSelectionHelper): fix bug 1920
use old deleteion algorithm when changetracking is on. use old deleteion algorithm when changetracking is on.

View File

@ -68,6 +68,11 @@ typedef limited_stack<pair<ParagraphList, textclass_type> > CutStack;
CutStack theCuts(10); 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> { class resetOwnerAndChanges : public std::unary_function<Paragraph, void> {
public: public:
void operator()(Paragraph & p) const { void operator()(Paragraph & p) const {
@ -531,6 +536,9 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut)
// need a valid cursor. (Lgb) // need a valid cursor. (Lgb)
cur.clearSelection(); cur.clearSelection();
updateCounters(cur.buffer()); updateCounters(cur.buffer());
// tell tabular that a recent copy happened
dirtyTabularStack(false);
} }
if (cur.inMathed()) { if (cur.inMathed()) {
@ -581,6 +589,8 @@ void copySelection(LCursor & cur)
pars.back().insert(0, grabSelection(cur), LyXFont()); pars.back().insert(0, grabSelection(cur), LyXFont());
theCuts.push(make_pair(pars, bp.textclass)); 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 cap
} // namespace lyx } // namespace lyx

View File

@ -81,6 +81,17 @@ void selDel(LCursor & cur);
void selClearOrDel(LCursor & cur); void selClearOrDel(LCursor & cur);
/// pastes n-th element of cut buffer /// pastes n-th element of cut buffer
void selPaste(LCursor & cur, size_t n); 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 } // namespace cap
} // namespce lyx } // namespce lyx

View 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> 2005-09-05 Michael Gerz <michael.gerz@teststep.org>
* insetcharstyle.C (metrics,draw): consider inset label for * insetcharstyle.C (metrics,draw): consider inset label for

View File

@ -16,6 +16,7 @@
#include "bufferparams.h" #include "bufferparams.h"
#include "BufferView.h" #include "BufferView.h"
#include "cursor.h" #include "cursor.h"
#include "CutAndPaste.h"
#include "coordcache.h" #include "coordcache.h"
#include "debug.h" #include "debug.h"
#include "dispatchresult.h" #include "dispatchresult.h"
@ -45,6 +46,8 @@
#include <iostream> #include <iostream>
#include <limits> #include <limits>
using lyx::cap::tabularStackDirty;
using lyx::graphics::PreviewLoader; using lyx::graphics::PreviewLoader;
using lyx::support::ltrim; using lyx::support::ltrim;
@ -719,7 +722,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
} }
case LFUN_PASTE: case LFUN_PASTE:
if (hasPasteBuffer()) { if (hasPasteBuffer() && tabularStackDirty()) {
recordUndo(cur, Undo::INSERT); recordUndo(cur, Undo::INSERT);
pasteSelection(cur); pasteSelection(cur);
break; break;
@ -1719,6 +1722,11 @@ bool InsetTabular::copySelection(LCursor & cur)
OutputParams const runparams; OutputParams const runparams;
paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t'); paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t');
cur.bv().stuffClipboard(os.str()); 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; return true;
} }