Line data Source code
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 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SC_SOURCE_UI_INC_UNDOBASE_HXX
21 : #define INCLUDED_SC_SOURCE_UI_INC_UNDOBASE_HXX
22 :
23 : #include <svl/undo.hxx>
24 : #include "global.hxx"
25 : #include "address.hxx"
26 : #include "docsh.hxx"
27 : #include <columnspanset.hxx>
28 :
29 : #include <boost/ptr_container/ptr_map.hpp>
30 :
31 : class ScDocument;
32 : class ScDocShell;
33 : class SdrUndoAction;
34 : class ScRefUndoData;
35 : class ScDBData;
36 :
37 : class ScSimpleUndo: public SfxUndoAction
38 : {
39 : ScSimpleUndo(const ScSimpleUndo&); // disabled
40 :
41 : public:
42 : typedef boost::ptr_map<SCTAB,sc::ColumnSpanSet> DataSpansType;
43 :
44 : TYPEINFO_OVERRIDE();
45 : ScSimpleUndo( ScDocShell* pDocSh );
46 : virtual ~ScSimpleUndo();
47 :
48 : virtual bool Merge( SfxUndoAction *pNextAction ) SAL_OVERRIDE;
49 :
50 : protected:
51 : ScDocShell* pDocShell;
52 : SfxUndoAction* pDetectiveUndo;
53 :
54 40 : bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
55 :
56 : bool SetViewMarkData( const ScMarkData& rMarkData );
57 :
58 : void BeginUndo();
59 : void EndUndo();
60 : void BeginRedo();
61 : void EndRedo();
62 :
63 : void BroadcastChanges( const ScRange& rRange );
64 :
65 : /**
66 : * Broadcast changes on specified spans.
67 : *
68 : * @param rSpans container that specifies all spans whose changes need to
69 : * be broadcasted.
70 : */
71 : void BroadcastChanges( const DataSpansType& rSpans );
72 :
73 : static void ShowTable( SCTAB nTab );
74 : static void ShowTable( const ScRange& rRange );
75 : };
76 :
77 : enum ScBlockUndoMode { SC_UNDO_SIMPLE, SC_UNDO_MANUALHEIGHT, SC_UNDO_AUTOHEIGHT };
78 :
79 : class ScBlockUndo: public ScSimpleUndo
80 : {
81 : public:
82 : TYPEINFO_OVERRIDE();
83 : ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
84 : ScBlockUndoMode eBlockMode );
85 : virtual ~ScBlockUndo();
86 :
87 : protected:
88 : ScRange aBlockRange;
89 : SdrUndoAction* pDrawUndo;
90 : ScBlockUndoMode eMode;
91 :
92 : void BeginUndo();
93 : void EndUndo();
94 : // void BeginRedo();
95 : void EndRedo();
96 :
97 : bool AdjustHeight();
98 : void ShowBlock();
99 : };
100 :
101 : class ScMultiBlockUndo: public ScSimpleUndo
102 : {
103 : public:
104 : TYPEINFO_OVERRIDE();
105 : ScMultiBlockUndo(ScDocShell* pDocSh, const ScRangeList& rRanges,
106 : ScBlockUndoMode eBlockMode);
107 : virtual ~ScMultiBlockUndo();
108 :
109 : protected:
110 : ScRangeList maBlockRanges;
111 : SdrUndoAction* mpDrawUndo;
112 : ScBlockUndoMode meMode;
113 :
114 : void BeginUndo();
115 : void EndUndo();
116 : void EndRedo();
117 :
118 : void AdjustHeight();
119 : void ShowBlock();
120 : };
121 :
122 : // for functions that act on a database range - takes care of the unnamed database range
123 : // (collected separately, before the undo action, for showing dialogs etc.)
124 :
125 : class ScDBFuncUndo: public ScSimpleUndo
126 : {
127 : protected:
128 : ScDBData* pAutoDBRange;
129 : ScRange aOriginalRange;
130 : SdrUndoAction* mpDrawUndo;
131 :
132 : public:
133 : TYPEINFO_OVERRIDE();
134 : ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal, SdrUndoAction* pDrawUndo = 0 );
135 : virtual ~ScDBFuncUndo();
136 :
137 : void SetDrawUndoAction( SdrUndoAction* pDrawUndo );
138 :
139 : void BeginUndo();
140 : void EndUndo();
141 : void BeginRedo();
142 : void EndRedo();
143 : };
144 :
145 : enum ScMoveUndoMode { SC_UNDO_REFFIRST, SC_UNDO_REFLAST };
146 :
147 : class ScMoveUndo: public ScSimpleUndo // mit Referenzen
148 : {
149 : public:
150 : TYPEINFO_OVERRIDE();
151 : ScMoveUndo( ScDocShell* pDocSh,
152 : ScDocument* pRefDoc, ScRefUndoData* pRefData,
153 : ScMoveUndoMode eRefMode );
154 : virtual ~ScMoveUndo();
155 :
156 : protected:
157 : SdrUndoAction* pDrawUndo;
158 : ScDocument* pRefUndoDoc;
159 : ScRefUndoData* pRefUndoData;
160 : ScMoveUndoMode eMode;
161 :
162 : void BeginUndo();
163 : void EndUndo();
164 : // void BeginRedo();
165 : // void EndRedo();
166 :
167 : private:
168 : void UndoRef();
169 : };
170 :
171 : class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
172 : {
173 : SfxUndoAction* pWrappedUndo;
174 :
175 : public:
176 : TYPEINFO_OVERRIDE();
177 : ScUndoWrapper( SfxUndoAction* pUndo );
178 : virtual ~ScUndoWrapper();
179 :
180 0 : SfxUndoAction* GetWrappedUndo() { return pWrappedUndo; }
181 : void ForgetWrappedUndo();
182 :
183 : virtual void SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction) SAL_OVERRIDE;
184 :
185 : virtual void Undo() SAL_OVERRIDE;
186 : virtual void Redo() SAL_OVERRIDE;
187 : virtual void Repeat(SfxRepeatTarget& rTarget) SAL_OVERRIDE;
188 : virtual bool CanRepeat(SfxRepeatTarget& rTarget) const SAL_OVERRIDE;
189 : virtual bool Merge( SfxUndoAction *pNextAction ) SAL_OVERRIDE;
190 : virtual OUString GetComment() const SAL_OVERRIDE;
191 : virtual OUString GetRepeatComment(SfxRepeatTarget&) const SAL_OVERRIDE;
192 : virtual sal_uInt16 GetId() const SAL_OVERRIDE;
193 : };
194 :
195 : #endif
196 :
197 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|