1 
2 /*************************************************************************
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26 ************************************************************************/
27 
28 #ifndef DBACCESS_DOCUMENTEVENTNOTIFIER_HXX
29 #define DBACCESS_DOCUMENTEVENTNOTIFIER_HXX
30 
31 /** === begin UNO includes === **/
32 #include <com/sun/star/document/XEventListener.hpp>
33 #include <com/sun/star/document/XDocumentEventListener.hpp>
34 /** === end UNO includes === **/
35 
36 #include <rtl/ref.hxx>
37 
38 namespace cppu
39 {
40     class OWeakObject;
41 }
42 
43 //........................................................................
44 namespace dbaccess
45 {
46 //........................................................................
47 
48     class DocumentEventNotifier_Impl;
49 	//====================================================================
50 	//= DocumentEventNotifier
51 	//====================================================================
52 	class DocumentEventNotifier
53 	{
54     public:
55         DocumentEventNotifier( ::cppu::OWeakObject& _rBroadcasterDocument, ::osl::Mutex& _rMutex );
56         ~DocumentEventNotifier();
57 
58         void addLegacyEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& _Listener );
59         void removeLegacyEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& _Listener );
60         void addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener );
61         void removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener );
62 
63         /** disposes the instance
64             @precond
65                 the mutex is not locked
66         */
67         void    disposing();
68 
69         /** tells the instance that its document is completely initialized now.
70 
71             Before you call this method, no notification will actually happen
72 
73             @precond
74                 the mutex is locked
75         */
76         void    onDocumentInitialized();
77 
78         /** notifies a document event described by the given parameters
79 
80             @precond
81                 the mutex is not locked
82             @precond
83                 ->onDocumentInitialized has been called
84         */
85         void    notifyDocumentEvent(
86                     const ::rtl::OUString& _EventName,
87                     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
88                     const ::com::sun::star::uno::Any& _Supplement = ::com::sun::star::uno::Any()
89                 );
90 
91         /** notifies a document event, described by the given parameters, asynchronously
92 
93             Note that no event is actually notified before you called ->onDocumentInitialized.
94 
95             @precond
96                 the mutex is locked
97         */
98         void    notifyDocumentEventAsync(
99                     const ::rtl::OUString& _EventName,
100                     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController = NULL,
101                     const ::com::sun::star::uno::Any& _Supplement = ::com::sun::star::uno::Any()
102                 );
103 
104         /** notifies a document event to all registered listeners
105 
106             @precond
107                 the mutex is not locked
108             @precond
109                 ->onDocumentInitialized has been called
110         */
111         void    notifyDocumentEvent(
112                     const sal_Char* _pAsciiEventName,
113                     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
114                     const ::com::sun::star::uno::Any& _rSupplement = ::com::sun::star::uno::Any()
115                 )
116         {
117             notifyDocumentEvent( ::rtl::OUString::createFromAscii( _pAsciiEventName ), _rxViewController, _rSupplement );
118         }
119 
120         /** notifies a document event to all registered listeners, asynchronously
121 
122             Note that no event is actually notified before you called ->onDocumentInitialized.
123 
124             @precond
125                 the mutex is locked
126         */
127         void    notifyDocumentEventAsync(
128                     const sal_Char* _pAsciiEventName,
129                     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
130                     const ::com::sun::star::uno::Any& _rSupplement = ::com::sun::star::uno::Any()
131                 )
132         {
133             notifyDocumentEventAsync( ::rtl::OUString::createFromAscii( _pAsciiEventName ), _rxViewController, _rSupplement );
134         }
135 
136     private:
137         ::rtl::Reference< DocumentEventNotifier_Impl >   m_pImpl;
138 	};
139 
140 //........................................................................
141 } // namespace dbaccess
142 //........................................................................
143 
144 #endif // DBACCESS_DOCUMENTEVENTNOTIFIER_HXX
145