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