1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <undosort.hxx>
11 #include <globstr.hrc>
13 #include <undoutil.hxx>
17 UndoSort::UndoSort( ScDocShell
* pDocSh
, const ReorderParam
& rParam
) :
18 ScSimpleUndo(pDocSh
), maParam(rParam
) {}
20 OUString
UndoSort::GetComment() const
22 return ScGlobal::GetRscString(STR_UNDO_SORT
);
39 void UndoSort::Execute( bool bUndo
)
41 ScDocument
& rDoc
= pDocShell
->GetDocument();
42 sc::ReorderParam aParam
= maParam
;
45 rDoc
.Reorder(aParam
, NULL
);
47 if (maParam
.mbHasHeaders
)
49 ScRange
aMarkRange( maParam
.maSortRange
);
52 if (aMarkRange
.aStart
.Row() > 0)
53 aMarkRange
.aStart
.IncRow(-1);
57 if (aMarkRange
.aStart
.Col() > 0)
58 aMarkRange
.aStart
.IncCol(-1);
60 ScUndoUtil::MarkSimpleBlock(pDocShell
, aMarkRange
);
64 ScUndoUtil::MarkSimpleBlock(pDocShell
, maParam
.maSortRange
);
67 rDoc
.SetDirty(maParam
.maSortRange
, true);
68 if (!aParam
.mbUpdateRefs
)
69 rDoc
.BroadcastCells(aParam
.maSortRange
, SC_HINT_DATACHANGED
);
71 pDocShell
->PostPaint(maParam
.maSortRange
, PAINT_GRID
);
72 pDocShell
->PostDataChanged();
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */