LibreOffice Module sc (master) 1
undosort.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 */
9
10#include <undosort.hxx>
11#include <globstr.hrc>
12#include <scresid.hxx>
13#include <global.hxx>
14#include <undoutil.hxx>
15#include <utility>
16
17namespace sc {
18
20 ScSimpleUndo(pDocSh), maParam(std::move(aParam)) {}
21
22OUString UndoSort::GetComment() const
23{
24 return ScResId(STR_UNDO_SORT);
25}
26
28{
29 BeginUndo();
30 Execute(true);
31 EndUndo();
32}
33
35{
36 BeginRedo();
37 Execute(false);
38 EndRedo();
39}
40
41void UndoSort::Execute( bool bUndo )
42{
45 if (bUndo)
46 aParam.reverse();
47 rDoc.Reorder(aParam);
48
49 ScRange aOverallRange( maParam.maSortRange);
51 {
56 }
57
59 {
60 ScRange aMarkRange( aOverallRange);
61 if (maParam.mbByRow)
62 {
63 if (aMarkRange.aStart.Row() > 0)
64 aMarkRange.aStart.IncRow(-1);
65 }
66 else
67 {
68 if (aMarkRange.aStart.Col() > 0)
69 aMarkRange.aStart.IncCol(-1);
70 }
72 }
73 else
74 {
76 }
77
78 rDoc.SetDirty(maParam.maSortRange, true);
79 if (!aParam.mbUpdateRefs)
80 rDoc.BroadcastCells(aParam.maSortRange, SfxHintId::ScDataChanged);
81
84}
85
86}
87
88/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetCol(SCCOL nColP)
Definition: address.hxx:291
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:316
SCROW Row() const
Definition: address.hxx:274
void SetRow(SCROW nRowP)
Definition: address.hxx:287
void IncRow(SCROW nDelta=1)
Definition: address.hxx:312
SCCOL Col() const
Definition: address.hxx:279
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
void PostDataChanged()
Definition: docsh3.cxx:93
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:101
void BroadcastCells(const ScRange &rRange, SfxHintId nHint, bool bBroadcastSingleBroadcasters=true)
Definition: documen7.cxx:158
void Reorder(const sc::ReorderParam &rParam)
Definition: documen3.cxx:1446
void SetDirty(const ScRange &, bool bIncludeEmptyCells)
Definition: document.cxx:3841
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
void BeginRedo()
Definition: undobase.cxx:145
void EndRedo()
Definition: undobase.cxx:154
void EndUndo()
Definition: undobase.cxx:125
ScDocShell * pDocShell
Definition: undobase.hxx:50
void BeginUndo()
Definition: undobase.cxx:90
static void MarkSimpleBlock(const ScDocShell *pDocShell, SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, SCCOL nEndX, SCROW nEndY, SCTAB nEndZ)
Mark Block (invisible - has to be repainted)
Definition: undoutil.cxx:31
virtual void Undo() override
Definition: undosort.cxx:27
UndoSort(ScDocShell *pDocSh, ReorderParam aParam)
Definition: undosort.cxx:19
void Execute(bool bUndo)
Definition: undosort.cxx:41
virtual void Redo() override
Definition: undosort.cxx:34
virtual OUString GetComment() const override
Definition: undosort.cxx:22
ReorderParam maParam
Definition: undosort.hxx:19
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
bool anyExtrasWanted() const
Definition: sortparam.hxx:65
void reverse()
Reorder the position indices such that it can be used to undo the original reordering.
Definition: sortparam.cxx:281
ScDataAreaExtras maDataAreaExtras
Definition: sortparam.hxx:161
ScRange maSortRange
This sort range already takes into account the presence or absence of header row / column i....
Definition: sortparam.hxx:160