xref: /aoo42x/main/sd/source/ui/func/sdundogr.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 
28 #include "sdundogr.hxx"
29 
30 
31 TYPEINIT1(SdUndoGroup, SdUndoAction);
32 
33 /*************************************************************************
34 |*
35 |* Destruktor
36 |*
37 \************************************************************************/
38 
~SdUndoGroup()39 SdUndoGroup::~SdUndoGroup()
40 {
41 	sal_uLong nLast = aCtn.Count();
42 	for (sal_uLong nAction = 0; nAction < nLast; nAction++)
43 	{
44 		delete (SdUndoAction*) aCtn.GetObject(nAction);
45 	}
46 	aCtn.Clear();
47 }
48 
49 /*************************************************************************
50 |*
51 |* Merge
52 |*
53 \************************************************************************/
54 
Merge(SfxUndoAction * pNextAction)55 sal_Bool SdUndoGroup::Merge( SfxUndoAction* pNextAction )
56 {
57     sal_Bool bRet = sal_False;
58 
59     if( pNextAction && pNextAction->ISA( SdUndoAction ) )
60     {
61         SdUndoAction* pClone = static_cast< SdUndoAction* >( pNextAction )->Clone();
62 
63         if( pClone )
64         {
65             AddAction( pClone );
66             bRet = sal_True;
67         }
68     }
69 
70     return bRet;
71 }
72 
73 /*************************************************************************
74 |*
75 |* Undo, umgekehrte Reihenfolge der Ausfuehrung
76 |*
77 \************************************************************************/
78 
Undo()79 void SdUndoGroup::Undo()
80 {
81 	long nLast = aCtn.Count();
82 	for (long nAction = nLast - 1; nAction >= 0; nAction--)
83 	{
84 		((SdUndoAction*)aCtn.GetObject((sal_uLong)nAction))->Undo();
85 	}
86 
87 }
88 
89 /*************************************************************************
90 |*
91 |* Redo
92 |*
93 \************************************************************************/
94 
Redo()95 void SdUndoGroup::Redo()
96 {
97 	sal_uLong nLast = aCtn.Count();
98 	for (sal_uLong nAction = 0; nAction < nLast; nAction++)
99 	{
100 		((SdUndoAction*)aCtn.GetObject(nAction))->Redo();
101 	}
102 
103 }
104 
105 /*************************************************************************
106 |*
107 |* eine Aktion hinzufuegen
108 |*
109 \************************************************************************/
110 
AddAction(SdUndoAction * pAction)111 void SdUndoGroup::AddAction(SdUndoAction* pAction)
112 {
113 	aCtn.Insert(pAction, CONTAINER_APPEND);
114 }
115