Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / undobase.hxx
blob5c9df4bf9f62c92a4a406911ca427c0849423568
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SC_UNDOBASE_HXX
21 #define SC_UNDOBASE_HXX
23 #include <svl/undo.hxx>
24 #include "global.hxx"
25 #include "address.hxx"
26 #include "docsh.hxx"
28 class ScDocument;
29 class ScDocShell;
30 class SdrUndoAction;
31 class ScRefUndoData;
32 class ScDBData;
34 //----------------------------------------------------------------------------
36 class ScSimpleUndo: public SfxUndoAction
38 ScSimpleUndo(const ScSimpleUndo&); // disabled
40 public:
41 TYPEINFO();
42 ScSimpleUndo( ScDocShell* pDocSh );
43 virtual ~ScSimpleUndo();
45 virtual bool Merge( SfxUndoAction *pNextAction );
47 protected:
48 ScDocShell* pDocShell;
49 SfxUndoAction* pDetectiveUndo;
51 bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
53 bool SetViewMarkData( const ScMarkData& rMarkData );
55 void BeginUndo();
56 void EndUndo();
57 void BeginRedo();
58 void EndRedo();
60 void BroadcastChanges( const ScRange& rRange );
62 static void ShowTable( SCTAB nTab );
63 static void ShowTable( const ScRange& rRange );
66 //----------------------------------------------------------------------------
68 enum ScBlockUndoMode { SC_UNDO_SIMPLE, SC_UNDO_MANUALHEIGHT, SC_UNDO_AUTOHEIGHT };
70 class ScBlockUndo: public ScSimpleUndo
72 public:
73 TYPEINFO();
74 ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
75 ScBlockUndoMode eBlockMode );
76 virtual ~ScBlockUndo();
78 protected:
79 ScRange aBlockRange;
80 SdrUndoAction* pDrawUndo;
81 ScBlockUndoMode eMode;
83 void BeginUndo();
84 void EndUndo();
85 // void BeginRedo();
86 void EndRedo();
88 sal_Bool AdjustHeight();
89 void ShowBlock();
92 class ScMultiBlockUndo: public ScSimpleUndo
94 public:
95 TYPEINFO();
96 ScMultiBlockUndo(ScDocShell* pDocSh, const ScRangeList& rRanges,
97 ScBlockUndoMode eBlockMode);
98 virtual ~ScMultiBlockUndo();
100 protected:
101 ScRangeList maBlockRanges;
102 SdrUndoAction* mpDrawUndo;
103 ScBlockUndoMode meMode;
105 void BeginUndo();
106 void EndUndo();
107 void EndRedo();
109 void AdjustHeight();
110 void ShowBlock();
113 //----------------------------------------------------------------------------
115 // for functions that act on a database range - takes care of the unnamed database range
116 // (collected separately, before the undo action, for showing dialogs etc.)
118 class ScDBFuncUndo: public ScSimpleUndo
120 protected:
121 ScDBData* pAutoDBRange;
122 ScRange aOriginalRange;
123 SdrUndoAction* mpDrawUndo;
125 public:
126 TYPEINFO();
127 ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal, SdrUndoAction* pDrawUndo = 0 );
128 virtual ~ScDBFuncUndo();
130 void SetDrawUndoAction( SdrUndoAction* pDrawUndo );
132 void BeginUndo();
133 void EndUndo();
134 void BeginRedo();
135 void EndRedo();
138 //----------------------------------------------------------------------------
140 enum ScMoveUndoMode { SC_UNDO_REFFIRST, SC_UNDO_REFLAST };
142 class ScMoveUndo: public ScSimpleUndo // mit Referenzen
144 public:
145 TYPEINFO();
146 ScMoveUndo( ScDocShell* pDocSh,
147 ScDocument* pRefDoc, ScRefUndoData* pRefData,
148 ScMoveUndoMode eRefMode );
149 virtual ~ScMoveUndo();
151 protected:
152 SdrUndoAction* pDrawUndo;
153 ScDocument* pRefUndoDoc;
154 ScRefUndoData* pRefUndoData;
155 ScMoveUndoMode eMode;
157 void BeginUndo();
158 void EndUndo();
159 // void BeginRedo();
160 // void EndRedo();
162 private:
163 void UndoRef();
166 //----------------------------------------------------------------------------
168 class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
170 SfxUndoAction* pWrappedUndo;
172 public:
173 TYPEINFO();
174 ScUndoWrapper( SfxUndoAction* pUndo );
175 virtual ~ScUndoWrapper();
177 SfxUndoAction* GetWrappedUndo() { return pWrappedUndo; }
178 void ForgetWrappedUndo();
180 virtual void SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction);
182 virtual void Undo();
183 virtual void Redo();
184 virtual void Repeat(SfxRepeatTarget& rTarget);
185 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
186 virtual bool Merge( SfxUndoAction *pNextAction );
187 virtual OUString GetComment() const;
188 virtual OUString GetRepeatComment(SfxRepeatTarget&) const;
189 virtual sal_uInt16 GetId() const;
193 #endif
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */