diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-06-02 18:29:27 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-13 18:07:14 -0400 |
commit | 5c6ee09126631342939ae8766fe36083d8c011e3 (patch) | |
tree | 48081d36ae5000542adb49cc037267992f59ec66 /sc/source/ui/undo | |
parent | b5bb15013617c6b9f1cdd089acae0bfb7104fa3a (diff) |
fdo#81309: Adjust references during sort.
Change-Id: I2b98610f6b774400ecfaffe2905201c27fcab33f
Diffstat (limited to 'sc/source/ui/undo')
-rw-r--r-- | sc/source/ui/undo/undobase.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/undo/undodat.cxx | 18 | ||||
-rw-r--r-- | sc/source/ui/undo/undosort.cxx | 55 |
3 files changed, 58 insertions, 16 deletions
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index 8740c6b31077..dc7efd49756e 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -33,6 +33,7 @@ #include "globstr.hrc" #include <rowheightcontext.hxx> #include <column.hxx> +#include <sortparam.hxx> TYPEINIT1(ScSimpleUndo, SfxUndoAction); TYPEINIT1(ScBlockUndo, ScSimpleUndo); diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx index b6bc5d614a33..d0a7c809faa8 100644 --- a/sc/source/ui/undo/undodat.cxx +++ b/sc/source/ui/undo/undodat.cxx @@ -739,21 +739,14 @@ bool ScUndoSubTotals::CanRepeat(SfxRepeatTarget& /* rTarget */) const ScUndoSort::ScUndoSort( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScSortParam& rParam, - ScDocument* pNewUndoDoc, ScDBCollection* pNewUndoDB, - const ScRange* pDest ) : + ScDocument* pNewUndoDoc, ScDBCollection* pNewUndoDB ) : ScDBFuncUndo( pNewDocShell, ScRange( rParam.nCol1, rParam.nRow1, nNewTab, rParam.nCol2, rParam.nRow2, nNewTab ) ), nTab( nNewTab ), aSortParam( rParam ), pUndoDoc( pNewUndoDoc ), - pUndoDB( pNewUndoDB ), - bDestArea( false ) + pUndoDB( pNewUndoDB ) { - if ( pDest ) - { - bDestArea = true; - aDestRange = *pDest; - } } ScUndoSort::~ScUndoSort() @@ -796,13 +789,6 @@ void ScUndoSort::Undo() pUndoDoc->CopyToDocument( nStartCol, nStartRow, nSortTab, nEndCol, nEndRow, nSortTab, IDF_ALL|IDF_NOCAPTIONS, false, &rDoc ); - if (bDestArea) - { - // do not delete/copy note captions, they are handled in drawing undo (ScDBFuncUndo::mpDrawUndo) - rDoc.DeleteAreaTab( aDestRange, IDF_ALL|IDF_NOCAPTIONS ); - pUndoDoc->CopyToDocument( aDestRange, IDF_ALL|IDF_NOCAPTIONS, false, &rDoc ); - } - // Row heights always (due to automatic adjustment) // TODO change to use ScBlockUndo pUndoDoc->CopyToDocument( 0, nStartRow, nSortTab, MAXCOL, nEndRow, nSortTab, diff --git a/sc/source/ui/undo/undosort.cxx b/sc/source/ui/undo/undosort.cxx new file mode 100644 index 000000000000..d138491c3abb --- /dev/null +++ b/sc/source/ui/undo/undosort.cxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <undosort.hxx> +#include <globstr.hrc> +#include <global.hxx> +#include <undoutil.hxx> + +namespace sc { + +UndoSort::UndoSort( ScDocShell* pDocSh, const ReorderParam& rParam ) : + ScSimpleUndo(pDocSh), maParam(rParam) {} + +OUString UndoSort::GetComment() const +{ + return ScGlobal::GetRscString(STR_UNDO_SORT); +} + +void UndoSort::Undo() +{ + BeginUndo(); + Execute(true); + EndUndo(); +} + +void UndoSort::Redo() +{ + BeginRedo(); + Execute(false); + EndRedo(); +} + +void UndoSort::Execute( bool bUndo ) +{ + ScDocument& rDoc = pDocShell->GetDocument(); + sc::ReorderParam aParam = maParam; + if (bUndo) + aParam.reverse(); + rDoc.Reorder(aParam, NULL); + + ScUndoUtil::MarkSimpleBlock(pDocShell, maParam.maSortRange); + + pDocShell->PostPaint(maParam.maSortRange, PAINT_GRID); + pDocShell->PostDataChanged(); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |