merge the formfield patch from ooo-build
[ooovba.git] / sd / source / core / undo / undomanager.cxx
blobf98982db070c655ea04e98c3166c44a5c9e9f08d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: undomanager.cxx,v $
10 * $Revision: 1.6 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <tools/debug.hxx>
34 #include "undo/undomanager.hxx"
36 using namespace sd;
38 UndoManager::UndoManager( USHORT nMaxUndoActionCount /* = 20 */ )
39 : SfxUndoManager( nMaxUndoActionCount )
40 , mnListLevel( 0 )
41 , mpLinkedUndoManager(NULL)
45 void UndoManager::EnterListAction(const UniString &rComment, const UniString& rRepeatComment, USHORT nId /* =0 */)
47 if( !isInUndo() )
49 ClearLinkedRedoActions();
50 mnListLevel++;
51 SfxUndoManager::EnterListAction( rComment, rRepeatComment, nId );
55 void UndoManager::LeaveListAction()
57 if( !isInUndo() )
59 SfxUndoManager::LeaveListAction();
60 if( mnListLevel )
62 mnListLevel--;
64 else
66 DBG_ERROR("sd::UndoManager::LeaveListAction(), no open list action!" );
71 void UndoManager::AddUndoAction( SfxUndoAction *pAction, BOOL bTryMerg /* = FALSE */ )
73 if( !isInUndo() )
75 ClearLinkedRedoActions();
76 SfxUndoManager::AddUndoAction( pAction, bTryMerg );
78 else
80 delete pAction;
85 BOOL UndoManager::Undo( USHORT nCount )
87 ScopeLockGuard aGuard( maIsInUndoLock );
88 return SfxUndoManager::Undo( nCount );
91 BOOL UndoManager::Redo( USHORT nCount )
93 ScopeLockGuard aGuard( maIsInUndoLock );
94 return SfxUndoManager::Redo( nCount );
100 void UndoManager::SetLinkedUndoManager (SfxUndoManager* pLinkedUndoManager)
102 mpLinkedUndoManager = pLinkedUndoManager;
108 void UndoManager::ClearLinkedRedoActions (void)
110 if (mpLinkedUndoManager != NULL)
111 mpLinkedUndoManager->ClearRedo();