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 
16 namespace sc {
17 
18 UndoSort::UndoSort( ScDocShell* pDocSh, const ReorderParam& rParam ) :
19  ScSimpleUndo(pDocSh), maParam(rParam) {}
20 
21 OUString UndoSort::GetComment() const
22 {
23  return ScResId(STR_UNDO_SORT);
24 }
25 
27 {
28  BeginUndo();
29  Execute(true);
30  EndUndo();
31 }
32 
34 {
35  BeginRedo();
36  Execute(false);
37  EndRedo();
38 }
39 
40 void UndoSort::Execute( bool bUndo )
41 {
42  ScDocument& rDoc = pDocShell->GetDocument();
43  sc::ReorderParam aParam = maParam;
44  if (bUndo)
45  aParam.reverse();
46  rDoc.Reorder(aParam);
47 
49  {
50  ScRange aMarkRange( maParam.maSortRange);
51  if (maParam.mbByRow)
52  {
53  if (aMarkRange.aStart.Row() > 0)
54  aMarkRange.aStart.IncRow(-1);
55  }
56  else
57  {
58  if (aMarkRange.aStart.Col() > 0)
59  aMarkRange.aStart.IncCol(-1);
60  }
62  }
63  else
64  {
66  }
67 
68  rDoc.SetDirty(maParam.maSortRange, true);
69  if (!aParam.mbUpdateRefs)
70  rDoc.BroadcastCells(aParam.maSortRange, SfxHintId::ScDataChanged);
71 
74 }
75 
76 }
77 
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScAddress aStart
Definition: address.hxx:500
virtual void Redo() override
Definition: undosort.cxx:33
SCROW Row() const
Definition: address.hxx:262
UndoSort(ScDocShell *pDocSh, const ReorderParam &rParam)
Definition: undosort.cxx:18
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:30
void EndUndo()
Definition: undobase.cxx:122
ScRange maSortRange
This sort range already takes into account the presence or absence of header row / column i...
Definition: sortparam.hxx:91
void BeginRedo()
Definition: undobase.cxx:142
void Reorder(const sc::ReorderParam &rParam)
Definition: documen3.cxx:1415
virtual void Undo() override
Definition: undosort.cxx:26
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:304
ReorderParam maParam
Definition: undosort.hxx:20
ScDocShell * pDocShell
Definition: undobase.hxx:48
void IncRow(SCROW nDelta=1)
Definition: address.hxx:300
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:99
void PostDataChanged()
Definition: docsh3.cxx:91
void BroadcastCells(const ScRange &rRange, SfxHintId nHint, bool bBroadcastSingleBroadcasters=true)
Definition: documen7.cxx:143
SCCOL Col() const
Definition: address.hxx:267
void SetDirty(const ScRange &, bool bIncludeEmptyCells)
Definition: document.cxx:3860
void reverse()
Reorder the position indices such that it can be used to undo the original reordering.
Definition: sortparam.cxx:272
virtual OUString GetComment() const override
Definition: undosort.cxx:21
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
void EndRedo()
Definition: undobase.cxx:151
void BeginUndo()
Definition: undobase.cxx:87
void Execute(bool bUndo)
Definition: undosort.cxx:40