diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-22 11:23:08 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-22 21:49:24 -0400 |
commit | bffe8b807ec2ac9e4749360151682591895778fd (patch) | |
tree | c3c161448d19f9ff94d921d941ed8fe30abd6a60 /sc/source/ui/undo | |
parent | 6dfdce83578ce44720e4cf1d84c6e4ef50686983 (diff) |
Get change tracking to work again with these new ScDocFunc methods.
Change-Id: Icdbf2af7bc552bc8f4914cc8bd036ed45934c461
Diffstat (limited to 'sc/source/ui/undo')
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index d78ac09eaff1..14296f16053d 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -419,10 +419,16 @@ sal_Bool ScUndoEnterValue::CanRepeat(SfxRepeatTarget& /* rTarget */) const } ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rNewVal ) : - ScSimpleUndo(pDocSh), maPos(rPos), maNewValue(rNewVal) {} + ScSimpleUndo(pDocSh), maPos(rPos), maNewValue(rNewVal), mnEndChangeAction(0) +{ + SetChangeTrack(); +} ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rOldVal, const ScCellValue& rNewVal ) : - ScSimpleUndo(pDocSh), maPos(rPos), maOldValue(rOldVal), maNewValue(rNewVal) {} + ScSimpleUndo(pDocSh), maPos(rPos), maOldValue(rOldVal), maNewValue(rNewVal), mnEndChangeAction(0) +{ + SetChangeTrack(); +} ScUndoSetCell::~ScUndoSetCell() {} @@ -431,6 +437,12 @@ void ScUndoSetCell::Undo() BeginUndo(); SetValue(maOldValue); pDocShell->PostPaintCell(maPos); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if (pChangeTrack) + pChangeTrack->Undo(mnEndChangeAction, mnEndChangeAction); + EndUndo(); } @@ -439,6 +451,7 @@ void ScUndoSetCell::Redo() BeginRedo(); SetValue(maNewValue); pDocShell->PostPaintCell(maPos); + SetChangeTrack(); EndRedo(); } @@ -457,6 +470,29 @@ OUString ScUndoSetCell::GetComment() const return ScGlobal::GetRscString(STR_UNDO_ENTERDATA); // "Input" } +void ScUndoSetCell::SetChangeTrack() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if (pChangeTrack) + { + mnEndChangeAction = pChangeTrack->GetActionMax() + 1; + + { + // TODO: Come back to this later. + ScBaseCell* pOldCell = getHackedBaseCell(pDoc, maOldValue); + pChangeTrack->AppendContent(maPos, pOldCell); + if (pOldCell) + pOldCell->Delete(); + } + + if (mnEndChangeAction > pChangeTrack->GetActionMax()) + mnEndChangeAction = 0; // Nothing is appended + } + else + mnEndChangeAction = 0; +} + void ScUndoSetCell::SetValue( const ScCellValue& rVal ) { ScDocument* pDoc = pDocShell->GetDocument(); |