xref: /aoo41x/main/sfx2/source/inc/docundomanager.hxx (revision cdf0e10c)
1 /*************************************************************************
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * Copyright 2000, 2010 Oracle and/or its affiliates.
5  *
6  * OpenOffice.org - a multi-platform office productivity suite
7  *
8  * This file is part of OpenOffice.org.
9  *
10  * OpenOffice.org is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License version 3
12  * only, as published by the Free Software Foundation.
13  *
14  * OpenOffice.org is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License version 3 for more details
18  * (a copy is included in the LICENSE file that accompanied this code).
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with OpenOffice.org.  If not, see
22  * <http://www.openoffice.org/license.html>
23  * for a copy of the LGPLv3 License.
24  *
25  ************************************************************************/
26 
27 #ifndef DOCUMENT_UNDO_MANAGER_HXX
28 #define DOCUMENT_UNDO_MANAGER_HXX
29 
30 #include "sfx2/sfxbasemodel.hxx"
31 
32 /** === begin UNO includes === **/
33 #include <com/sun/star/document/XUndoManager.hpp>
34 /** === end UNO includes === **/
35 
36 #include <cppuhelper/implbase1.hxx>
37 
38 #include <boost/scoped_ptr.hpp>
39 #include <boost/noncopyable.hpp>
40 
41 namespace svl
42 {
43     class IUndoManager;
44 }
45 
46 //......................................................................................................................
47 namespace sfx2
48 {
49 //......................................................................................................................
50 
51 	//==================================================================================================================
52 	//= DocumentUndoManager
53 	//==================================================================================================================
54     typedef ::cppu::ImplHelper1 <   ::com::sun::star::document::XUndoManager
55                                 >   DocumentUndoManager_Base;
56     struct DocumentUndoManager_Impl;
57     class DocumentUndoManager   :public DocumentUndoManager_Base
58                                 ,public SfxModelSubComponent
59                                 ,public ::boost::noncopyable
60 	{
61         friend struct DocumentUndoManager_Impl;
62 
63     public:
64         DocumentUndoManager( SfxBaseModel& i_document );
65         virtual ~DocumentUndoManager();
66 
67         // SfxModelSubComponent overridables
68         virtual void    disposing();
69 
70         // non-UNO API for our owner
71         /** determines whether we have an open Undo context. No mutex locking within this method, no disposal check - this
72             is the responsibility of the owner.
73         */
74         bool    isInContext() const;
75 
76         // XInterface
77         virtual void SAL_CALL acquire(  ) throw ();
78         virtual void SAL_CALL release(  ) throw ();
79 
80         // XUndoManager
81         virtual void SAL_CALL enterUndoContext( const ::rtl::OUString& i_title ) throw (::com::sun::star::uno::RuntimeException);
82         virtual void SAL_CALL enterHiddenUndoContext(  ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException);
83         virtual void SAL_CALL leaveUndoContext(  ) throw (::com::sun::star::util::InvalidStateException, ::com::sun::star::uno::RuntimeException);
84         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);
85         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);
86         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);
87         virtual ::sal_Bool SAL_CALL isUndoPossible(  ) throw (::com::sun::star::uno::RuntimeException);
88         virtual ::sal_Bool SAL_CALL isRedoPossible(  ) throw (::com::sun::star::uno::RuntimeException);
89         virtual ::rtl::OUString SAL_CALL getCurrentUndoActionTitle(  ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException);
90         virtual ::rtl::OUString SAL_CALL getCurrentRedoActionTitle(  ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException);
91         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoActionTitles(  ) throw (::com::sun::star::uno::RuntimeException);
92         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoActionTitles(  ) throw (::com::sun::star::uno::RuntimeException);
93         virtual void SAL_CALL clear(  ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException);
94         virtual void SAL_CALL clearRedo(  ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException);
95         virtual void SAL_CALL reset(  ) throw (::com::sun::star::uno::RuntimeException);
96         virtual void SAL_CALL addUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException);
97         virtual void SAL_CALL removeUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException);
98 
99         // XLockable, base of XUndoManager
100         virtual void SAL_CALL lock(  ) throw (::com::sun::star::uno::RuntimeException);
101         virtual void SAL_CALL unlock(  ) throw (::com::sun::star::util::NotLockedException, ::com::sun::star::uno::RuntimeException);
102         virtual ::sal_Bool SAL_CALL isLocked(  ) throw (::com::sun::star::uno::RuntimeException);
103 
104         // XChild, base of XUndoManager
105         virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
106         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);
107 
108     private:
109         ::boost::scoped_ptr< DocumentUndoManager_Impl > m_pImpl;
110 	};
111 
112 //......................................................................................................................
113 } // namespace sfx2
114 //......................................................................................................................
115 
116 #endif // DOCUMENT_UNDO_MANAGER_HXX
117