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 SC_UNDOBASE_HXX
21 : #define SC_UNDOBASE_HXX
22 :
23 : #include <svl/undo.hxx>
24 : #include "global.hxx"
25 : #include "address.hxx"
26 : #include "docsh.hxx"
27 :
28 : class ScDocument;
29 : class ScDocShell;
30 : class SdrUndoAction;
31 : class ScRefUndoData;
32 : class ScDBData;
33 :
34 : class ScSimpleUndo: public SfxUndoAction
35 : {
36 : ScSimpleUndo(const ScSimpleUndo&); // disabled
37 :
38 : public:
39 : TYPEINFO_OVERRIDE();
40 : ScSimpleUndo( ScDocShell* pDocSh );
41 : virtual ~ScSimpleUndo();
42 :
43 : virtual bool Merge( SfxUndoAction *pNextAction ) SAL_OVERRIDE;
44 :
45 : protected:
46 : ScDocShell* pDocShell;
47 : SfxUndoAction* pDetectiveUndo;
48 :
49 0 : bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
50 :
51 : bool SetViewMarkData( const ScMarkData& rMarkData );
52 :
53 : void BeginUndo();
54 : void EndUndo();
55 : void BeginRedo();
56 : void EndRedo();
57 :
58 : void BroadcastChanges( const ScRange& rRange );
59 :
60 : static void ShowTable( SCTAB nTab );
61 : static void ShowTable( const ScRange& rRange );
62 : };
63 :
64 : enum ScBlockUndoMode { SC_UNDO_SIMPLE, SC_UNDO_MANUALHEIGHT, SC_UNDO_AUTOHEIGHT };
65 :
66 : class ScBlockUndo: public ScSimpleUndo
67 : {
68 : public:
69 : TYPEINFO_OVERRIDE();
70 : ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
71 : ScBlockUndoMode eBlockMode );
72 : virtual ~ScBlockUndo();
73 :
74 : protected:
75 : ScRange aBlockRange;
76 : SdrUndoAction* pDrawUndo;
77 : ScBlockUndoMode eMode;
78 :
79 : void BeginUndo();
80 : void EndUndo();
81 : // void BeginRedo();
82 : void EndRedo();
83 :
84 : bool AdjustHeight();
85 : void ShowBlock();
86 : };
87 :
88 : class ScMultiBlockUndo: public ScSimpleUndo
89 : {
90 : public:
91 : TYPEINFO_OVERRIDE();
92 : ScMultiBlockUndo(ScDocShell* pDocSh, const ScRangeList& rRanges,
93 : ScBlockUndoMode eBlockMode);
94 : virtual ~ScMultiBlockUndo();
95 :
96 : protected:
97 : ScRangeList maBlockRanges;
98 : SdrUndoAction* mpDrawUndo;
99 : ScBlockUndoMode meMode;
100 :
101 : void BeginUndo();
102 : void EndUndo();
103 : void EndRedo();
104 :
105 : void AdjustHeight();
106 : void ShowBlock();
107 : };
108 :
109 : // for functions that act on a database range - takes care of the unnamed database range
110 : // (collected separately, before the undo action, for showing dialogs etc.)
111 :
112 : class ScDBFuncUndo: public ScSimpleUndo
113 : {
114 : protected:
115 : ScDBData* pAutoDBRange;
116 : ScRange aOriginalRange;
117 : SdrUndoAction* mpDrawUndo;
118 :
119 : public:
120 : TYPEINFO_OVERRIDE();
121 : ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal, SdrUndoAction* pDrawUndo = 0 );
122 : virtual ~ScDBFuncUndo();
123 :
124 : void SetDrawUndoAction( SdrUndoAction* pDrawUndo );
125 :
126 : void BeginUndo();
127 : void EndUndo();
128 : void BeginRedo();
129 : void EndRedo();
130 : };
131 :
132 : enum ScMoveUndoMode { SC_UNDO_REFFIRST, SC_UNDO_REFLAST };
133 :
134 : class ScMoveUndo: public ScSimpleUndo // mit Referenzen
135 : {
136 : public:
137 : TYPEINFO_OVERRIDE();
138 : ScMoveUndo( ScDocShell* pDocSh,
139 : ScDocument* pRefDoc, ScRefUndoData* pRefData,
140 : ScMoveUndoMode eRefMode );
141 : virtual ~ScMoveUndo();
142 :
143 : protected:
144 : SdrUndoAction* pDrawUndo;
145 : ScDocument* pRefUndoDoc;
146 : ScRefUndoData* pRefUndoData;
147 : ScMoveUndoMode eMode;
148 :
149 : void BeginUndo();
150 : void EndUndo();
151 : // void BeginRedo();
152 : // void EndRedo();
153 :
154 : private:
155 : void UndoRef();
156 : };
157 :
158 : class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
159 : {
160 : SfxUndoAction* pWrappedUndo;
161 :
162 : public:
163 : TYPEINFO_OVERRIDE();
164 : ScUndoWrapper( SfxUndoAction* pUndo );
165 : virtual ~ScUndoWrapper();
166 :
167 0 : SfxUndoAction* GetWrappedUndo() { return pWrappedUndo; }
168 : void ForgetWrappedUndo();
169 :
170 : virtual void SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction) SAL_OVERRIDE;
171 :
172 : virtual void Undo() SAL_OVERRIDE;
173 : virtual void Redo() SAL_OVERRIDE;
174 : virtual void Repeat(SfxRepeatTarget& rTarget) SAL_OVERRIDE;
175 : virtual bool CanRepeat(SfxRepeatTarget& rTarget) const SAL_OVERRIDE;
176 : virtual bool Merge( SfxUndoAction *pNextAction ) SAL_OVERRIDE;
177 : virtual OUString GetComment() const SAL_OVERRIDE;
178 : virtual OUString GetRepeatComment(SfxRepeatTarget&) const SAL_OVERRIDE;
179 : virtual sal_uInt16 GetId() const SAL_OVERRIDE;
180 : };
181 :
182 :
183 : #endif
184 :
185 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|