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 #ifndef DOCUMENT_UNDO_MANAGER_HXX 25 #define DOCUMENT_UNDO_MANAGER_HXX 26 27 #include "sfx2/sfxbasemodel.hxx" 28 29 /** === begin UNO includes === **/ 30 #include <com/sun/star/document/XUndoManager.hpp> 31 /** === end UNO includes === **/ 32 33 #include <cppuhelper/implbase1.hxx> 34 35 #include <boost/scoped_ptr.hpp> 36 #include <boost/noncopyable.hpp> 37 38 namespace svl 39 { 40 class IUndoManager; 41 } 42 43 //...................................................................................................................... 44 namespace sfx2 45 { 46 //...................................................................................................................... 47 48 //================================================================================================================== 49 //= DocumentUndoManager 50 //================================================================================================================== 51 typedef ::cppu::ImplHelper1 < ::com::sun::star::document::XUndoManager 52 > DocumentUndoManager_Base; 53 struct DocumentUndoManager_Impl; 54 class DocumentUndoManager :public DocumentUndoManager_Base 55 ,public SfxModelSubComponent 56 ,public ::boost::noncopyable 57 { 58 friend struct DocumentUndoManager_Impl; 59 60 public: 61 DocumentUndoManager( SfxBaseModel& i_document ); 62 virtual ~DocumentUndoManager(); 63 64 // SfxModelSubComponent overridables 65 virtual void disposing(); 66 67 // non-UNO API for our owner 68 /** determines whether we have an open Undo context. No mutex locking within this method, no disposal check - this 69 is the responsibility of the owner. 70 */ 71 bool isInContext() const; 72 73 // XInterface 74 virtual void SAL_CALL acquire( ) throw (); 75 virtual void SAL_CALL release( ) throw (); 76 77 // XUndoManager 78 virtual void SAL_CALL enterUndoContext( const ::rtl::OUString& i_title ) throw (::com::sun::star::uno::RuntimeException); 79 virtual void SAL_CALL enterHiddenUndoContext( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException); 80 virtual void SAL_CALL leaveUndoContext( ) throw (::com::sun::star::util::InvalidStateException, ::com::sun::star::uno::RuntimeException); 81 virtual void SAL_CALL addUndoAction( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoAction >& i_action ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 82 virtual void SAL_CALL undo( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); 83 virtual void SAL_CALL redo( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); 84 virtual ::sal_Bool SAL_CALL isUndoPossible( ) throw (::com::sun::star::uno::RuntimeException); 85 virtual ::sal_Bool SAL_CALL isRedoPossible( ) throw (::com::sun::star::uno::RuntimeException); 86 virtual ::rtl::OUString SAL_CALL getCurrentUndoActionTitle( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException); 87 virtual ::rtl::OUString SAL_CALL getCurrentRedoActionTitle( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException); 88 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoActionTitles( ) throw (::com::sun::star::uno::RuntimeException); 89 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoActionTitles( ) throw (::com::sun::star::uno::RuntimeException); 90 virtual void SAL_CALL clear( ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException); 91 virtual void SAL_CALL clearRedo( ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException); 92 virtual void SAL_CALL reset( ) throw (::com::sun::star::uno::RuntimeException); 93 virtual void SAL_CALL addUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException); 94 virtual void SAL_CALL removeUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException); 95 96 // XLockable, base of XUndoManager 97 virtual void SAL_CALL lock( ) throw (::com::sun::star::uno::RuntimeException); 98 virtual void SAL_CALL unlock( ) throw (::com::sun::star::util::NotLockedException, ::com::sun::star::uno::RuntimeException); 99 virtual ::sal_Bool SAL_CALL isLocked( ) throw (::com::sun::star::uno::RuntimeException); 100 101 // XChild, base of XUndoManager 102 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); 103 virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); 104 105 private: 106 ::boost::scoped_ptr< DocumentUndoManager_Impl > m_pImpl; 107 }; 108 109 //...................................................................................................................... 110 } // namespace sfx2 111 //...................................................................................................................... 112 113 #endif // DOCUMENT_UNDO_MANAGER_HXX 114