xref: /aoo42x/main/sfx2/source/doc/docundomanager.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3*cdf0e10cSrcweir  *
4*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
5*cdf0e10cSrcweir  *
6*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
7*cdf0e10cSrcweir  *
8*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
9*cdf0e10cSrcweir  *
10*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
11*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
12*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
13*cdf0e10cSrcweir  *
14*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
15*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
18*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
19*cdf0e10cSrcweir  *
20*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
21*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
22*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
23*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
24*cdf0e10cSrcweir  *
25*cdf0e10cSrcweir  ************************************************************************/
26*cdf0e10cSrcweir 
27*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
28*cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "docundomanager.hxx"
31*cdf0e10cSrcweir #include "sfx2/sfxbasemodel.hxx"
32*cdf0e10cSrcweir #include "sfx2/objsh.hxx"
33*cdf0e10cSrcweir #include "sfx2/viewfrm.hxx"
34*cdf0e10cSrcweir #include "sfx2/viewsh.hxx"
35*cdf0e10cSrcweir #include "sfx2/bindings.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir /** === begin UNO includes === **/
38*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
39*cdf0e10cSrcweir /** === end UNO includes === **/
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <comphelper/anytostring.hxx>
42*cdf0e10cSrcweir #include <comphelper/flagguard.hxx>
43*cdf0e10cSrcweir #include <svl/undo.hxx>
44*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
45*cdf0e10cSrcweir #include <framework/undomanagerhelper.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include <boost/noncopyable.hpp>
48*cdf0e10cSrcweir #include <stack>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir //......................................................................................................................
51*cdf0e10cSrcweir namespace sfx2
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir //......................................................................................................................
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir 	/** === begin UNO using === **/
56*cdf0e10cSrcweir 	using ::com::sun::star::uno::Reference;
57*cdf0e10cSrcweir 	using ::com::sun::star::uno::XInterface;
58*cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_QUERY;
59*cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_QUERY_THROW;
60*cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_SET_THROW;
61*cdf0e10cSrcweir 	using ::com::sun::star::uno::Exception;
62*cdf0e10cSrcweir 	using ::com::sun::star::uno::RuntimeException;
63*cdf0e10cSrcweir 	using ::com::sun::star::uno::Any;
64*cdf0e10cSrcweir 	using ::com::sun::star::uno::makeAny;
65*cdf0e10cSrcweir 	using ::com::sun::star::uno::Sequence;
66*cdf0e10cSrcweir 	using ::com::sun::star::uno::Type;
67*cdf0e10cSrcweir     using ::com::sun::star::util::InvalidStateException;
68*cdf0e10cSrcweir     using ::com::sun::star::document::EmptyUndoStackException;
69*cdf0e10cSrcweir     using ::com::sun::star::util::NotLockedException;
70*cdf0e10cSrcweir     using ::com::sun::star::document::UndoContextNotClosedException;
71*cdf0e10cSrcweir     using ::com::sun::star::document::XUndoAction;
72*cdf0e10cSrcweir     using ::com::sun::star::document::XUndoManagerSupplier;
73*cdf0e10cSrcweir     using ::com::sun::star::lang::XComponent;
74*cdf0e10cSrcweir     using ::com::sun::star::lang::IllegalArgumentException;
75*cdf0e10cSrcweir     using ::com::sun::star::lang::NotInitializedException;
76*cdf0e10cSrcweir     using ::com::sun::star::lang::EventObject;
77*cdf0e10cSrcweir     using ::com::sun::star::document::UndoManagerEvent;
78*cdf0e10cSrcweir     using ::com::sun::star::document::XUndoManagerListener;
79*cdf0e10cSrcweir     using ::com::sun::star::document::UndoFailedException;
80*cdf0e10cSrcweir     using ::com::sun::star::document::XUndoManager;
81*cdf0e10cSrcweir     using ::com::sun::star::lang::NoSupportException;
82*cdf0e10cSrcweir     using ::com::sun::star::frame::XModel;
83*cdf0e10cSrcweir 	/** === end UNO using === **/
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     using ::svl::IUndoManager;
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 	//==================================================================================================================
88*cdf0e10cSrcweir 	//= DocumentUndoManager_Impl
89*cdf0e10cSrcweir 	//==================================================================================================================
90*cdf0e10cSrcweir     struct DocumentUndoManager_Impl : public ::framework::IUndoManagerImplementation
91*cdf0e10cSrcweir     {
92*cdf0e10cSrcweir         DocumentUndoManager&                rAntiImpl;
93*cdf0e10cSrcweir         IUndoManager*                       pUndoManager;
94*cdf0e10cSrcweir         ::framework::UndoManagerHelper      aUndoHelper;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir         DocumentUndoManager_Impl( DocumentUndoManager& i_antiImpl )
97*cdf0e10cSrcweir             :rAntiImpl( i_antiImpl )
98*cdf0e10cSrcweir             ,pUndoManager( impl_retrieveUndoManager( i_antiImpl.getBaseModel() ) )
99*cdf0e10cSrcweir                 // do this *before* the construction of aUndoHelper (which actually means: put pUndoManager before
100*cdf0e10cSrcweir                 // aUndoHelper in the member list)!
101*cdf0e10cSrcweir             ,aUndoHelper( *this )
102*cdf0e10cSrcweir         {
103*cdf0e10cSrcweir         }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir         const SfxObjectShell* getObjectShell() const { return rAntiImpl.getBaseModel().GetObjectShell(); }
106*cdf0e10cSrcweir               SfxObjectShell* getObjectShell()       { return rAntiImpl.getBaseModel().GetObjectShell(); }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir         // IUndoManagerImplementation
109*cdf0e10cSrcweir         virtual ::svl::IUndoManager&        getImplUndoManager();
110*cdf0e10cSrcweir         virtual Reference< XUndoManager >   getThis();
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir         void disposing()
113*cdf0e10cSrcweir         {
114*cdf0e10cSrcweir             aUndoHelper.disposing();
115*cdf0e10cSrcweir             ENSURE_OR_RETURN_VOID( pUndoManager, "DocumentUndoManager_Impl::disposing: already disposed!" );
116*cdf0e10cSrcweir             pUndoManager = NULL;
117*cdf0e10cSrcweir         }
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir         void invalidateXDo_nolck();
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     private:
122*cdf0e10cSrcweir         static IUndoManager* impl_retrieveUndoManager( SfxBaseModel& i_baseModel )
123*cdf0e10cSrcweir         {
124*cdf0e10cSrcweir             IUndoManager* pUndoManager( NULL );
125*cdf0e10cSrcweir             SfxObjectShell* pObjectShell = i_baseModel.GetObjectShell();
126*cdf0e10cSrcweir             if ( pObjectShell != NULL )
127*cdf0e10cSrcweir                 pUndoManager = pObjectShell->GetUndoManager();
128*cdf0e10cSrcweir             if ( !pUndoManager )
129*cdf0e10cSrcweir                 throw NotInitializedException( ::rtl::OUString(), *&i_baseModel );
130*cdf0e10cSrcweir             return pUndoManager;
131*cdf0e10cSrcweir         }
132*cdf0e10cSrcweir     };
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
135*cdf0e10cSrcweir     ::svl::IUndoManager& DocumentUndoManager_Impl::getImplUndoManager()
136*cdf0e10cSrcweir     {
137*cdf0e10cSrcweir         ENSURE_OR_THROW( pUndoManager != NULL, "DocumentUndoManager_Impl::getImplUndoManager: no access to the doc's UndoManager implementation!" );
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
140*cdf0e10cSrcweir         // in a non-product build, assert if the current UndoManager at the shell is not the same we obtained
141*cdf0e10cSrcweir         // (and cached) at construction time
142*cdf0e10cSrcweir         SfxObjectShell* pObjectShell = rAntiImpl.getBaseModel().GetObjectShell();
143*cdf0e10cSrcweir         OSL_ENSURE( ( pObjectShell != NULL ) && ( pUndoManager == pObjectShell->GetUndoManager() ),
144*cdf0e10cSrcweir             "DocumentUndoManager_Impl::getImplUndoManager: the UndoManager changed meanwhile - what about our listener?" );
145*cdf0e10cSrcweir #endif
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir         return *pUndoManager;
148*cdf0e10cSrcweir     }
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
151*cdf0e10cSrcweir     Reference< XUndoManager > DocumentUndoManager_Impl::getThis()
152*cdf0e10cSrcweir     {
153*cdf0e10cSrcweir         return static_cast< XUndoManager* >( &rAntiImpl );
154*cdf0e10cSrcweir     }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
157*cdf0e10cSrcweir     void DocumentUndoManager_Impl::invalidateXDo_nolck()
158*cdf0e10cSrcweir     {
159*cdf0e10cSrcweir         SfxModelGuard aGuard( rAntiImpl );
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir         const SfxObjectShell* pDocShell = getObjectShell();
162*cdf0e10cSrcweir         ENSURE_OR_THROW( pDocShell != NULL, "lcl_invalidateUndo: no access to the doc shell!" );
163*cdf0e10cSrcweir         SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst( pDocShell );
164*cdf0e10cSrcweir         while ( pViewFrame )
165*cdf0e10cSrcweir         {
166*cdf0e10cSrcweir             pViewFrame->GetBindings().Invalidate( SID_UNDO );
167*cdf0e10cSrcweir             pViewFrame->GetBindings().Invalidate( SID_REDO );
168*cdf0e10cSrcweir             pViewFrame = SfxViewFrame::GetNext( *pViewFrame, pDocShell );
169*cdf0e10cSrcweir         }
170*cdf0e10cSrcweir     }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 	//==================================================================================================================
173*cdf0e10cSrcweir 	//= SolarMutexFacade
174*cdf0e10cSrcweir 	//==================================================================================================================
175*cdf0e10cSrcweir     /** a facade for the SolarMutex, implementing ::framework::IMutex (as opposed to ::vos::IMutex)
176*cdf0e10cSrcweir     */
177*cdf0e10cSrcweir     class SolarMutexFacade : public ::framework::IMutex
178*cdf0e10cSrcweir     {
179*cdf0e10cSrcweir     public:
180*cdf0e10cSrcweir         SolarMutexFacade()
181*cdf0e10cSrcweir         {
182*cdf0e10cSrcweir         }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir         virtual void acquire()
185*cdf0e10cSrcweir         {
186*cdf0e10cSrcweir             Application::GetSolarMutex().acquire();
187*cdf0e10cSrcweir         }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir         virtual void release()
190*cdf0e10cSrcweir         {
191*cdf0e10cSrcweir             Application::GetSolarMutex().release();
192*cdf0e10cSrcweir         }
193*cdf0e10cSrcweir     };
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 	//==================================================================================================================
196*cdf0e10cSrcweir 	//= UndoManagerGuard
197*cdf0e10cSrcweir 	//==================================================================================================================
198*cdf0e10cSrcweir     class UndoManagerGuard  :public ::framework::IMutexGuard
199*cdf0e10cSrcweir                             ,public ::boost::noncopyable
200*cdf0e10cSrcweir     {
201*cdf0e10cSrcweir     public:
202*cdf0e10cSrcweir         UndoManagerGuard( DocumentUndoManager& i_undoManager )
203*cdf0e10cSrcweir             :m_guard( i_undoManager )
204*cdf0e10cSrcweir             ,m_solarMutexFacade()
205*cdf0e10cSrcweir         {
206*cdf0e10cSrcweir         }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir         ~UndoManagerGuard()
209*cdf0e10cSrcweir         {
210*cdf0e10cSrcweir         }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir         virtual void reset()
213*cdf0e10cSrcweir         {
214*cdf0e10cSrcweir             m_guard.reset();
215*cdf0e10cSrcweir         }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir         virtual void clear()
218*cdf0e10cSrcweir         {
219*cdf0e10cSrcweir             m_guard.clear();
220*cdf0e10cSrcweir         }
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir         virtual ::framework::IMutex& getGuardedMutex()
223*cdf0e10cSrcweir         {
224*cdf0e10cSrcweir             // note that this means that we *know* that SfxModelGuard also locks the SolarMutex (nothing more, nothing less).
225*cdf0e10cSrcweir             // If this ever changes, we need to adjust this code here, too.
226*cdf0e10cSrcweir             return m_solarMutexFacade;
227*cdf0e10cSrcweir         }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     private:
230*cdf0e10cSrcweir         SfxModelGuard       m_guard;
231*cdf0e10cSrcweir         SolarMutexFacade    m_solarMutexFacade;
232*cdf0e10cSrcweir     };
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir 	//==================================================================================================================
235*cdf0e10cSrcweir 	//= DocumentUndoManager
236*cdf0e10cSrcweir 	//==================================================================================================================
237*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------------------------------------
238*cdf0e10cSrcweir     DocumentUndoManager::DocumentUndoManager( SfxBaseModel& i_document )
239*cdf0e10cSrcweir         :SfxModelSubComponent( i_document )
240*cdf0e10cSrcweir         ,m_pImpl( new DocumentUndoManager_Impl( *this ) )
241*cdf0e10cSrcweir     {
242*cdf0e10cSrcweir     }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------------------------------------
245*cdf0e10cSrcweir     DocumentUndoManager::~DocumentUndoManager()
246*cdf0e10cSrcweir     {
247*cdf0e10cSrcweir     }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------------------------------------
250*cdf0e10cSrcweir     void DocumentUndoManager::disposing()
251*cdf0e10cSrcweir     {
252*cdf0e10cSrcweir         m_pImpl->disposing();
253*cdf0e10cSrcweir     }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
256*cdf0e10cSrcweir     bool DocumentUndoManager::isInContext() const
257*cdf0e10cSrcweir     {
258*cdf0e10cSrcweir         // No mutex locking within this method, no disposal check - this is the responsibility of the owner.
259*cdf0e10cSrcweir         return m_pImpl->getImplUndoManager().IsInListAction();
260*cdf0e10cSrcweir     }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
263*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::acquire(  ) throw ()
264*cdf0e10cSrcweir     {
265*cdf0e10cSrcweir         SfxModelSubComponent::acquire();
266*cdf0e10cSrcweir     }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
269*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::release(  ) throw ()
270*cdf0e10cSrcweir     {
271*cdf0e10cSrcweir         SfxModelSubComponent::release();
272*cdf0e10cSrcweir     }
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
275*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::enterUndoContext( const ::rtl::OUString& i_title ) throw (RuntimeException)
276*cdf0e10cSrcweir     {
277*cdf0e10cSrcweir         // SYNCHRONIZED --->
278*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
279*cdf0e10cSrcweir         m_pImpl->aUndoHelper.enterUndoContext( i_title, aGuard );
280*cdf0e10cSrcweir         // <--- SYNCHRONIZED
281*cdf0e10cSrcweir         m_pImpl->invalidateXDo_nolck();
282*cdf0e10cSrcweir     }
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
285*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::enterHiddenUndoContext(  ) throw (EmptyUndoStackException, RuntimeException)
286*cdf0e10cSrcweir     {
287*cdf0e10cSrcweir         // SYNCHRONIZED --->
288*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
289*cdf0e10cSrcweir         m_pImpl->aUndoHelper.enterHiddenUndoContext( aGuard );
290*cdf0e10cSrcweir         // <--- SYNCHRONIZED
291*cdf0e10cSrcweir         m_pImpl->invalidateXDo_nolck();
292*cdf0e10cSrcweir     }
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
295*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::leaveUndoContext(  ) throw (InvalidStateException, RuntimeException)
296*cdf0e10cSrcweir     {
297*cdf0e10cSrcweir         // SYNCHRONIZED --->
298*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
299*cdf0e10cSrcweir         m_pImpl->aUndoHelper.leaveUndoContext( aGuard );
300*cdf0e10cSrcweir         // <--- SYNCHRONIZED
301*cdf0e10cSrcweir         m_pImpl->invalidateXDo_nolck();
302*cdf0e10cSrcweir     }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
305*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::addUndoAction( const Reference< XUndoAction >& i_action ) throw (RuntimeException, IllegalArgumentException)
306*cdf0e10cSrcweir     {
307*cdf0e10cSrcweir         // SYNCHRONIZED --->
308*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
309*cdf0e10cSrcweir         m_pImpl->aUndoHelper.addUndoAction( i_action, aGuard );
310*cdf0e10cSrcweir         // <--- SYNCHRONIZED
311*cdf0e10cSrcweir         m_pImpl->invalidateXDo_nolck();
312*cdf0e10cSrcweir     }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
315*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::undo(  ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException)
316*cdf0e10cSrcweir     {
317*cdf0e10cSrcweir         // SYNCHRONIZED --->
318*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
319*cdf0e10cSrcweir         m_pImpl->aUndoHelper.undo( aGuard );
320*cdf0e10cSrcweir         // <--- SYNCHRONIZED
321*cdf0e10cSrcweir         m_pImpl->invalidateXDo_nolck();
322*cdf0e10cSrcweir     }
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
325*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::redo(  ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException)
326*cdf0e10cSrcweir     {
327*cdf0e10cSrcweir         // SYNCHRONIZED --->
328*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
329*cdf0e10cSrcweir         m_pImpl->aUndoHelper.redo( aGuard );
330*cdf0e10cSrcweir         // <--- SYNCHRONIZED
331*cdf0e10cSrcweir         m_pImpl->invalidateXDo_nolck();
332*cdf0e10cSrcweir     }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
335*cdf0e10cSrcweir     ::sal_Bool SAL_CALL DocumentUndoManager::isUndoPossible(  ) throw (RuntimeException)
336*cdf0e10cSrcweir     {
337*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
338*cdf0e10cSrcweir         return m_pImpl->aUndoHelper.isUndoPossible();
339*cdf0e10cSrcweir     }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
342*cdf0e10cSrcweir     ::sal_Bool SAL_CALL DocumentUndoManager::isRedoPossible(  ) throw (RuntimeException)
343*cdf0e10cSrcweir     {
344*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
345*cdf0e10cSrcweir         return m_pImpl->aUndoHelper.isRedoPossible();
346*cdf0e10cSrcweir     }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
349*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL DocumentUndoManager::getCurrentUndoActionTitle(  ) throw (EmptyUndoStackException, RuntimeException)
350*cdf0e10cSrcweir     {
351*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
352*cdf0e10cSrcweir         return m_pImpl->aUndoHelper.getCurrentUndoActionTitle();
353*cdf0e10cSrcweir     }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
356*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL DocumentUndoManager::getCurrentRedoActionTitle(  ) throw (EmptyUndoStackException, RuntimeException)
357*cdf0e10cSrcweir     {
358*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
359*cdf0e10cSrcweir         return m_pImpl->aUndoHelper.getCurrentRedoActionTitle();
360*cdf0e10cSrcweir     }
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
363*cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL DocumentUndoManager::getAllUndoActionTitles(  ) throw (RuntimeException)
364*cdf0e10cSrcweir     {
365*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
366*cdf0e10cSrcweir         return m_pImpl->aUndoHelper.getAllUndoActionTitles();
367*cdf0e10cSrcweir     }
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
370*cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL DocumentUndoManager::getAllRedoActionTitles(  ) throw (RuntimeException)
371*cdf0e10cSrcweir     {
372*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
373*cdf0e10cSrcweir         return m_pImpl->aUndoHelper.getAllRedoActionTitles();
374*cdf0e10cSrcweir     }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
377*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::clear(  ) throw (UndoContextNotClosedException, RuntimeException)
378*cdf0e10cSrcweir     {
379*cdf0e10cSrcweir         // SYNCHRONIZED --->
380*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
381*cdf0e10cSrcweir         m_pImpl->aUndoHelper.clear( aGuard );
382*cdf0e10cSrcweir         // <--- SYNCHRONIZED
383*cdf0e10cSrcweir         m_pImpl->invalidateXDo_nolck();
384*cdf0e10cSrcweir     }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
387*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::clearRedo(  ) throw (UndoContextNotClosedException, RuntimeException)
388*cdf0e10cSrcweir     {
389*cdf0e10cSrcweir         // SYNCHRONIZED --->
390*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
391*cdf0e10cSrcweir         m_pImpl->aUndoHelper.clearRedo( aGuard );
392*cdf0e10cSrcweir         // <--- SYNCHRONIZED
393*cdf0e10cSrcweir         m_pImpl->invalidateXDo_nolck();
394*cdf0e10cSrcweir     }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
397*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::reset() throw (RuntimeException)
398*cdf0e10cSrcweir     {
399*cdf0e10cSrcweir         // SYNCHRONIZED --->
400*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
401*cdf0e10cSrcweir         m_pImpl->aUndoHelper.reset( aGuard );
402*cdf0e10cSrcweir         // <--- SYNCHRONIZED
403*cdf0e10cSrcweir         m_pImpl->invalidateXDo_nolck();
404*cdf0e10cSrcweir     }
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
407*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::lock(  ) throw (RuntimeException)
408*cdf0e10cSrcweir     {
409*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
410*cdf0e10cSrcweir         m_pImpl->aUndoHelper.lock();
411*cdf0e10cSrcweir     }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
414*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::unlock(  ) throw (RuntimeException, NotLockedException)
415*cdf0e10cSrcweir     {
416*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
417*cdf0e10cSrcweir         m_pImpl->aUndoHelper.unlock();
418*cdf0e10cSrcweir     }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
421*cdf0e10cSrcweir     ::sal_Bool SAL_CALL DocumentUndoManager::isLocked(  ) throw (RuntimeException)
422*cdf0e10cSrcweir     {
423*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
424*cdf0e10cSrcweir         return m_pImpl->aUndoHelper.isLocked();
425*cdf0e10cSrcweir     }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
428*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException)
429*cdf0e10cSrcweir     {
430*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
431*cdf0e10cSrcweir         return m_pImpl->aUndoHelper.addUndoManagerListener( i_listener );
432*cdf0e10cSrcweir     }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
435*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException)
436*cdf0e10cSrcweir     {
437*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
438*cdf0e10cSrcweir         return m_pImpl->aUndoHelper.removeUndoManagerListener( i_listener );
439*cdf0e10cSrcweir     }
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
442*cdf0e10cSrcweir     Reference< XInterface > SAL_CALL DocumentUndoManager::getParent(  ) throw (RuntimeException)
443*cdf0e10cSrcweir     {
444*cdf0e10cSrcweir         UndoManagerGuard aGuard( *this );
445*cdf0e10cSrcweir         return static_cast< XModel* >( &getBaseModel() );
446*cdf0e10cSrcweir     }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
449*cdf0e10cSrcweir     void SAL_CALL DocumentUndoManager::setParent( const Reference< XInterface >& i_parent ) throw (NoSupportException, RuntimeException)
450*cdf0e10cSrcweir     {
451*cdf0e10cSrcweir         (void)i_parent;
452*cdf0e10cSrcweir         throw NoSupportException( ::rtl::OUString(), m_pImpl->getThis() );
453*cdf0e10cSrcweir     }
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir //......................................................................................................................
456*cdf0e10cSrcweir } // namespace sfx2
457*cdf0e10cSrcweir //......................................................................................................................
458