1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: undo.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #ifndef INCLUDED_SVTDLLAPI_H
34 #include "bf_svtools/svtdllapi.h"
38 #include <tools/rtti.hxx>
42 #include <tools/string.hxx>
46 #include <bf_svtools/svarray.hxx>
52 //====================================================================
58 virtual ~SfxRepeatTarget() = 0;
61 //====================================================================
69 virtual ~SfxUndoAction();
71 virtual BOOL
IsLinked();
72 virtual void SetLinked( BOOL bIsLinked
= TRUE
);
75 virtual void Repeat(SfxRepeatTarget
&);
76 virtual BOOL
CanRepeat(SfxRepeatTarget
&) const;
78 virtual BOOL
Merge( SfxUndoAction
*pNextAction
);
80 virtual UniString
GetComment() const;
81 virtual UniString
GetRepeatComment(SfxRepeatTarget
&) const;
82 virtual USHORT
GetId() const;
85 SfxUndoAction
& operator=( const SfxUndoAction
& ); // n.i.!!
88 //========================================================================
90 SV_DECL_PTRARR( SfxUndoActions
, SfxUndoAction
*, 20, 8 )
92 //====================================================================
94 /** do not make use of this implementation details, unless you
95 really really have to! */
98 SfxUndoActions aUndoActions
;
99 USHORT nMaxUndoActions
;
100 USHORT nCurUndoAction
;
101 SfxUndoArray
*pFatherUndoArray
;
102 SfxUndoArray(USHORT nMax
=0):
103 nMaxUndoActions(nMax
), nCurUndoAction(0),
104 pFatherUndoArray(0) {}
108 //=========================================================================
110 /** do not make use of this implementation details, unless you
111 really really have to! */
112 class SfxListUndoAction
: public SfxUndoAction
, public SfxUndoArray
116 UndoAction zur Klammerung mehrerer Undos in einer UndoAction.
117 Diese Actions werden vom SfxUndoManager verwendet. Dort
118 wird mit < SfxUndoManager::EnterListAction > eine Klammerebene
119 geoeffnet und mit <SfxUndoManager::LeaveListAction > wieder
120 geschlossen. Redo und Undo auf SfxListUndoActions wirken
128 SfxListUndoAction( const UniString
&rComment
,
129 const UniString rRepeatComment
, USHORT Id
, SfxUndoArray
*pFather
);
132 virtual void Repeat(SfxRepeatTarget
&);
133 virtual BOOL
CanRepeat(SfxRepeatTarget
&) const;
135 virtual BOOL
Merge( SfxUndoAction
*pNextAction
);
137 virtual UniString
GetComment() const;
138 virtual UniString
GetRepeatComment(SfxRepeatTarget
&) const;
139 virtual USHORT
GetId() const;
141 void SetComment( const UniString
& rComment
);
146 UniString aComment
, aRepeatComment
;
150 //=========================================================================
154 friend class SfxLinkUndoAction
;
156 SfxUndoArray
*pUndoArray
;
157 SfxUndoArray
*pActUndoArray
;
158 SfxUndoArray
*pFatherUndoArray
;
161 SfxUndoManager( USHORT nMaxUndoActionCount
= 20 );
162 virtual ~SfxUndoManager();
164 virtual void SetMaxUndoActionCount( USHORT nMaxUndoActionCount
);
165 virtual USHORT
GetMaxUndoActionCount() const;
166 virtual void Clear();
168 virtual void AddUndoAction( SfxUndoAction
*pAction
, BOOL bTryMerg
=FALSE
);
170 virtual USHORT
GetUndoActionCount() const;
171 virtual USHORT
GetUndoActionId(USHORT nNo
=0) const;
172 virtual UniString
GetUndoActionComment( USHORT nNo
=0 ) const;
174 virtual BOOL
Undo( USHORT nCount
=1 );
175 virtual void Undo( SfxUndoAction
&rAction
);
177 virtual USHORT
GetRedoActionCount() const;
178 virtual USHORT
GetRedoActionId(USHORT nNo
=0) const;
179 virtual UniString
GetRedoActionComment( USHORT nNo
=0 ) const;
181 virtual BOOL
Redo( USHORT nCount
=1 );
182 virtual void Redo( SfxUndoAction
&rAction
);
183 virtual void ClearRedo();
185 virtual USHORT
GetRepeatActionCount() const;
186 virtual UniString
GetRepeatActionComment( SfxRepeatTarget
&rTarget
, USHORT nNo
= 0) const;
187 virtual BOOL
Repeat( SfxRepeatTarget
&rTarget
, USHORT nFrom
=0, USHORT nCount
=1 );
188 virtual void Repeat( SfxRepeatTarget
&rTarget
, SfxUndoAction
&rAction
);
189 virtual BOOL
CanRepeat( SfxRepeatTarget
&rTarget
, USHORT nNo
= 0 ) const;
190 virtual BOOL
CanRepeat( SfxRepeatTarget
&rTarget
, SfxUndoAction
&rAction
) const;
192 virtual void EnterListAction(const UniString
&rComment
, const UniString
& rRepeatComment
, USHORT nId
=0);
193 virtual void LeaveListAction();
196 //=========================================================================
198 class SfxLinkUndoAction
: public SfxUndoAction
202 Die SfxLinkUndoAction dient zur Verbindung zweier SfxUndoManager. Die
203 im ersten SfxUndoManager eingefuegten SfxUndoAction leiten ihr Undo und Redo
204 an den zweiten weiter, so dass ein Undo und Redo am ersten
205 SfxUndoManager wie eine am zweiten wirkt.
207 Die SfxLinkUndoAction ist nach dem Einfuegen der SfxUndoAction am
208 zweiten SfxUndoManager einzufuegen. Waehrend der zweite SfxUndoManager
209 vom ersten ferngesteuert wird, duerfen an ihm weder Actions eingefuegt werden,
210 noch darf Undo/Redo aufgerufen werden.
217 ~SfxLinkUndoAction();
221 virtual BOOL
CanRepeat(SfxRepeatTarget
& r
) const;
223 virtual void Repeat(SfxRepeatTarget
&r
);
225 virtual UniString
GetComment() const;
226 virtual UniString
GetRepeatComment(SfxRepeatTarget
&r
) const;
227 virtual USHORT
GetId() const;
229 SfxUndoAction
* GetAction() const { return pAction
; }
232 SfxUndoManager
*pUndoManager
;
233 SfxUndoAction
*pAction
;