diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2017-04-05 21:09:59 -0400 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2017-04-13 04:39:50 +0200 |
commit | 6d588e65021ad3d00a91a2732b2a6cf4c59b3534 (patch) | |
tree | a89812f2ba41ebdb8626f253b36f005015a52cb9 | |
parent | b9573789b5f47d67e4cb881aaa0fbdb3cb25fb31 (diff) |
tdf#92650: handle overwritten references correctly in undo.
Change-Id: Idc3fbd78f8163c97a9cd80a3ff474b6da0349353
Reviewed-on: https://gerrit.libreoffice.org/36496
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Tested-by: Kohei Yoshida <libreoffice@kohei.us>
-rw-r--r-- | sc/source/core/tool/token.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk.cxx | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 26075a4278f5..75ef12c08299 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -3167,6 +3167,11 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove( aAbs = aErrorPos; aRes.mbReferenceModified = true; } + else if (rCxt.maRange.In(aAbs)) + { + // Referenced cell has been overwritten. + aRes.mbValueChanged = true; + } rRef.SetAddress(aAbs, rNewPos); rRef.SetFlag3D(aAbs.Tab() != rNewPos.Tab() || !rRef.IsTabRel()); @@ -3183,6 +3188,11 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove( aAbs = aErrorRange; aRes.mbReferenceModified = true; } + else if (rCxt.maRange.In(aAbs)) + { + // Referenced range has been entirely overwritten. + aRes.mbValueChanged = true; + } rRef.SetRange(aAbs, rNewPos); // Absolute sheet reference => set 3D flag. diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 1619865cf7e9..76ac2a1aa902 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2839,8 +2839,10 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, function ScDocument::UpdateReference() is called which calls ScDrawLayer::MoveCells() which may move away inserted objects to wrong positions (e.g. if source and destination range overlaps).*/ - rDoc.CopyFromClip( aPasteDest, aDestMark, InsertDeleteFlags::ALL & ~(InsertDeleteFlags::OBJECTS), - nullptr, pClipDoc.get(), true, false, bIncludeFiltered ); + + rDoc.CopyFromClip( + aPasteDest, aDestMark, InsertDeleteFlags::ALL & ~(InsertDeleteFlags::OBJECTS), + pUndoDoc, pClipDoc.get(), true, false, bIncludeFiltered); // skipped rows and merged cells don't mix if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() ) diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index dccc583e1317..1141e75655b7 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -1101,7 +1101,7 @@ bool ScUndoPaste::CanRepeat(SfxRepeatTarget& rTarget) const ScUndoDragDrop::ScUndoDragDrop( ScDocShell* pNewDocShell, const ScRange& rRange, ScAddress aNewDestPos, bool bNewCut, ScDocument* pUndoDocument, bool bScenario ) : - ScMoveUndo( pNewDocShell, pUndoDocument, nullptr, SC_UNDO_REFFIRST ), + ScMoveUndo( pNewDocShell, pUndoDocument, nullptr, SC_UNDO_REFLAST ), mnPaintExtFlags( 0 ), aSrcRange( rRange ), bCut( bNewCut ), |