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