xref: /aoo41x/main/sd/source/core/undo/undomanager.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 #include <tools/debug.hxx>
27 #include "undo/undomanager.hxx"
28 
29 using namespace sd;
30 
31 UndoManager::UndoManager( sal_uInt16 nMaxUndoActionCount /* = 20 */ )
32 : SfxUndoManager( nMaxUndoActionCount )
33 , mpLinkedUndoManager(NULL)
34 {
35 }
36 
37 void UndoManager::EnterListAction(const UniString &rComment, const UniString& rRepeatComment, sal_uInt16 nId /* =0 */)
38 {
39 	if( !IsDoing() )
40 	{
41         ClearLinkedRedoActions();
42 		SfxUndoManager::EnterListAction( rComment, rRepeatComment, nId );
43 	}
44 }
45 
46 void UndoManager::AddUndoAction( SfxUndoAction *pAction, sal_Bool bTryMerg /* = sal_False */ )
47 {
48 	if( !IsDoing() )
49 	{
50         ClearLinkedRedoActions();
51 		SfxUndoManager::AddUndoAction( pAction, bTryMerg );
52 	}
53 	else
54 	{
55 		delete pAction;
56 	}
57 }
58 
59 
60 void UndoManager::SetLinkedUndoManager (::svl::IUndoManager* pLinkedUndoManager)
61 {
62     mpLinkedUndoManager = pLinkedUndoManager;
63 }
64 
65 
66 
67 
68 void UndoManager::ClearLinkedRedoActions (void)
69 {
70     if (mpLinkedUndoManager != NULL)
71         mpLinkedUndoManager->ClearRedo();
72 }
73