xref: /aoo41x/main/sd/source/ui/func/sdundogr.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 
32 #include "sdundogr.hxx"
33 
34 
35 TYPEINIT1(SdUndoGroup, SdUndoAction);
36 
37 /*************************************************************************
38 |*
39 |* Destruktor
40 |*
41 \************************************************************************/
42 
43 SdUndoGroup::~SdUndoGroup()
44 {
45 	sal_uLong nLast = aCtn.Count();
46 	for (sal_uLong nAction = 0; nAction < nLast; nAction++)
47 	{
48 		delete (SdUndoAction*) aCtn.GetObject(nAction);
49 	}
50 	aCtn.Clear();
51 }
52 
53 /*************************************************************************
54 |*
55 |* Merge
56 |*
57 \************************************************************************/
58 
59 sal_Bool SdUndoGroup::Merge( SfxUndoAction* pNextAction )
60 {
61     sal_Bool bRet = sal_False;
62 
63     if( pNextAction && pNextAction->ISA( SdUndoAction ) )
64     {
65         SdUndoAction* pClone = static_cast< SdUndoAction* >( pNextAction )->Clone();
66 
67         if( pClone )
68         {
69             AddAction( pClone );
70             bRet = sal_True;
71         }
72     }
73 
74     return bRet;
75 }
76 
77 /*************************************************************************
78 |*
79 |* Undo, umgekehrte Reihenfolge der Ausfuehrung
80 |*
81 \************************************************************************/
82 
83 void SdUndoGroup::Undo()
84 {
85 	long nLast = aCtn.Count();
86 	for (long nAction = nLast - 1; nAction >= 0; nAction--)
87 	{
88 		((SdUndoAction*)aCtn.GetObject((sal_uLong)nAction))->Undo();
89 	}
90 
91 }
92 
93 /*************************************************************************
94 |*
95 |* Redo
96 |*
97 \************************************************************************/
98 
99 void SdUndoGroup::Redo()
100 {
101 	sal_uLong nLast = aCtn.Count();
102 	for (sal_uLong nAction = 0; nAction < nLast; nAction++)
103 	{
104 		((SdUndoAction*)aCtn.GetObject(nAction))->Redo();
105 	}
106 
107 }
108 
109 /*************************************************************************
110 |*
111 |* eine Aktion hinzufuegen
112 |*
113 \************************************************************************/
114 
115 void SdUndoGroup::AddAction(SdUndoAction* pAction)
116 {
117 	aCtn.Insert(pAction, CONTAINER_APPEND);
118 }
119