Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : :
3 : : /*
4 : : * This file is part of the LibreOffice project.
5 : : *
6 : : * This Source Code Form is subject to the terms of the Mozilla Public
7 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
8 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 : : *
10 : : * This file incorporates work covered by the following license notice:
11 : : *
12 : : * Licensed to the Apache Software Foundation (ASF) under one or more
13 : : * contributor license agreements. See the NOTICE file distributed
14 : : * with this work for additional information regarding copyright
15 : : * ownership. The ASF licenses this file to you under the Apache
16 : : * License, Version 2.0 (the "License"); you may not use this file
17 : : * except in compliance with the License. You may obtain a copy of
18 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 : : */
20 : :
21 : : #ifndef DBACCESS_DOCUMENTEVENTNOTIFIER_HXX
22 : : #define DBACCESS_DOCUMENTEVENTNOTIFIER_HXX
23 : :
24 : : #include <com/sun/star/document/XEventListener.hpp>
25 : : #include <com/sun/star/document/XDocumentEventListener.hpp>
26 : :
27 : : #include <rtl/ref.hxx>
28 : :
29 : : namespace cppu
30 : : {
31 : : class OWeakObject;
32 : : }
33 : :
34 : : namespace dbaccess
35 : : {
36 : :
37 : : class DocumentEventNotifier_Impl;
38 : : //====================================================================
39 : : //= DocumentEventNotifier
40 : : //====================================================================
41 : : class DocumentEventNotifier
42 : : {
43 : : public:
44 : : DocumentEventNotifier( ::cppu::OWeakObject& _rBroadcasterDocument, ::osl::Mutex& _rMutex );
45 : : ~DocumentEventNotifier();
46 : :
47 : : void addLegacyEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& _Listener );
48 : : void removeLegacyEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& _Listener );
49 : : void addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener );
50 : : void removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener );
51 : :
52 : : /** disposes the instance
53 : : @precond
54 : : the mutex is not locked
55 : : */
56 : : void disposing();
57 : :
58 : : /** tells the instance that its document is completely initialized now.
59 : :
60 : : Before you call this method, no notification will actually happen
61 : :
62 : : @precond
63 : : the mutex is locked
64 : : */
65 : : void onDocumentInitialized();
66 : :
67 : : /** notifies a document event described by the given parameters
68 : :
69 : : @precond
70 : : the mutex is not locked
71 : : @precond
72 : : ->onDocumentInitialized has been called
73 : : */
74 : : void notifyDocumentEvent(
75 : : const ::rtl::OUString& _EventName,
76 : : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
77 : : const ::com::sun::star::uno::Any& _Supplement = ::com::sun::star::uno::Any()
78 : : );
79 : :
80 : : /** notifies a document event, described by the given parameters, asynchronously
81 : :
82 : : Note that no event is actually notified before you called ->onDocumentInitialized.
83 : :
84 : : @precond
85 : : the mutex is locked
86 : : */
87 : : void notifyDocumentEventAsync(
88 : : const ::rtl::OUString& _EventName,
89 : : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController = NULL,
90 : : const ::com::sun::star::uno::Any& _Supplement = ::com::sun::star::uno::Any()
91 : : );
92 : :
93 : : /** notifies a document event to all registered listeners
94 : :
95 : : @precond
96 : : the mutex is not locked
97 : : @precond
98 : : ->onDocumentInitialized has been called
99 : : */
100 : 560 : void notifyDocumentEvent(
101 : : const sal_Char* _pAsciiEventName,
102 : : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
103 : : const ::com::sun::star::uno::Any& _rSupplement = ::com::sun::star::uno::Any()
104 : : )
105 : : {
106 [ + - ]: 560 : notifyDocumentEvent( ::rtl::OUString::createFromAscii( _pAsciiEventName ), _rxViewController, _rSupplement );
107 : 560 : }
108 : :
109 : : /** notifies a document event to all registered listeners, asynchronously
110 : :
111 : : Note that no event is actually notified before you called ->onDocumentInitialized.
112 : :
113 : : @precond
114 : : the mutex is locked
115 : : */
116 : 376 : void notifyDocumentEventAsync(
117 : : const sal_Char* _pAsciiEventName,
118 : : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
119 : : const ::com::sun::star::uno::Any& _rSupplement = ::com::sun::star::uno::Any()
120 : : )
121 : : {
122 [ + - ]: 376 : notifyDocumentEventAsync( ::rtl::OUString::createFromAscii( _pAsciiEventName ), _rxViewController, _rSupplement );
123 : 376 : }
124 : :
125 : : private:
126 : : ::rtl::Reference< DocumentEventNotifier_Impl > m_pImpl;
127 : : };
128 : :
129 : : } // namespace dbaccess
130 : :
131 : : #endif // DBACCESS_DOCUMENTEVENTNOTIFIER_HXX
132 : :
133 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|