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 INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DOCUMENTEVENTNOTIFIER_HXX
22 : #define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_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 : // DocumentEventNotifier
39 : class DocumentEventNotifier
40 : {
41 : public:
42 : DocumentEventNotifier( ::cppu::OWeakObject& _rBroadcasterDocument, ::osl::Mutex& _rMutex );
43 : ~DocumentEventNotifier();
44 :
45 : void addLegacyEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& _Listener );
46 : void removeLegacyEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& _Listener );
47 : void addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener );
48 : void removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener );
49 :
50 : /** disposes the instance
51 : @precond
52 : the mutex is not locked
53 : */
54 : void disposing();
55 :
56 : /** tells the instance that its document is completely initialized now.
57 :
58 : Before you call this method, no notification will actually happen
59 :
60 : @precond
61 : the mutex is locked
62 : */
63 : void onDocumentInitialized();
64 :
65 : /** notifies a document event described by the given parameters
66 :
67 : @precond
68 : the mutex is not locked
69 : @precond
70 : ->onDocumentInitialized has been called
71 : */
72 : void notifyDocumentEvent(
73 : const OUString& _EventName,
74 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
75 : const ::com::sun::star::uno::Any& _Supplement = ::com::sun::star::uno::Any()
76 : );
77 :
78 : /** notifies a document event, described by the given parameters, asynchronously
79 :
80 : Note that no event is actually notified before you called ->onDocumentInitialized.
81 :
82 : @precond
83 : the mutex is locked
84 : */
85 : void notifyDocumentEventAsync(
86 : const OUString& _EventName,
87 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController = NULL,
88 : const ::com::sun::star::uno::Any& _Supplement = ::com::sun::star::uno::Any()
89 : );
90 :
91 : /** notifies a document event to all registered listeners
92 :
93 : @precond
94 : the mutex is not locked
95 : @precond
96 : ->onDocumentInitialized has been called
97 : */
98 327 : void notifyDocumentEvent(
99 : const sal_Char* _pAsciiEventName,
100 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
101 : const ::com::sun::star::uno::Any& _rSupplement = ::com::sun::star::uno::Any()
102 : )
103 : {
104 327 : notifyDocumentEvent( OUString::createFromAscii( _pAsciiEventName ), _rxViewController, _rSupplement );
105 327 : }
106 :
107 : /** notifies a document event to all registered listeners, asynchronously
108 :
109 : Note that no event is actually notified before you called ->onDocumentInitialized.
110 :
111 : @precond
112 : the mutex is locked
113 : */
114 214 : void notifyDocumentEventAsync(
115 : const sal_Char* _pAsciiEventName,
116 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL,
117 : const ::com::sun::star::uno::Any& _rSupplement = ::com::sun::star::uno::Any()
118 : )
119 : {
120 214 : notifyDocumentEventAsync( OUString::createFromAscii( _pAsciiEventName ), _rxViewController, _rSupplement );
121 214 : }
122 :
123 : private:
124 : ::rtl::Reference< DocumentEventNotifier_Impl > m_pImpl;
125 : };
126 :
127 : } // namespace dbaccess
128 :
129 : #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DOCUMENTEVENTNOTIFIER_HXX
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|