1*2e2212a7SAndrew Rist /************************************************************** 2*2e2212a7SAndrew Rist * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21cdf0e10cSrcweir 22*2e2212a7SAndrew Rist 23*2e2212a7SAndrew Rist 24cdf0e10cSrcweir 25cdf0e10cSrcweir #ifndef DBACCESS_DOCUMENTEVENTNOTIFIER_HXX 26cdf0e10cSrcweir #define DBACCESS_DOCUMENTEVENTNOTIFIER_HXX 27cdf0e10cSrcweir 28cdf0e10cSrcweir /** === begin UNO includes === **/ 29cdf0e10cSrcweir #include <com/sun/star/document/XEventListener.hpp> 30cdf0e10cSrcweir #include <com/sun/star/document/XDocumentEventListener.hpp> 31cdf0e10cSrcweir /** === end UNO includes === **/ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <rtl/ref.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace cppu 36cdf0e10cSrcweir { 37cdf0e10cSrcweir class OWeakObject; 38cdf0e10cSrcweir } 39cdf0e10cSrcweir 40cdf0e10cSrcweir //........................................................................ 41cdf0e10cSrcweir namespace dbaccess 42cdf0e10cSrcweir { 43cdf0e10cSrcweir //........................................................................ 44cdf0e10cSrcweir 45cdf0e10cSrcweir class DocumentEventNotifier_Impl; 46cdf0e10cSrcweir //==================================================================== 47cdf0e10cSrcweir //= DocumentEventNotifier 48cdf0e10cSrcweir //==================================================================== 49cdf0e10cSrcweir class DocumentEventNotifier 50cdf0e10cSrcweir { 51cdf0e10cSrcweir public: 52cdf0e10cSrcweir DocumentEventNotifier( ::cppu::OWeakObject& _rBroadcasterDocument, ::osl::Mutex& _rMutex ); 53cdf0e10cSrcweir ~DocumentEventNotifier(); 54cdf0e10cSrcweir 55cdf0e10cSrcweir void addLegacyEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& _Listener ); 56cdf0e10cSrcweir void removeLegacyEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& _Listener ); 57cdf0e10cSrcweir void addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ); 58cdf0e10cSrcweir void removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ); 59cdf0e10cSrcweir 60cdf0e10cSrcweir /** disposes the instance 61cdf0e10cSrcweir @precond 62cdf0e10cSrcweir the mutex is not locked 63cdf0e10cSrcweir */ 64cdf0e10cSrcweir void disposing(); 65cdf0e10cSrcweir 66cdf0e10cSrcweir /** tells the instance that its document is completely initialized now. 67cdf0e10cSrcweir 68cdf0e10cSrcweir Before you call this method, no notification will actually happen 69cdf0e10cSrcweir 70cdf0e10cSrcweir @precond 71cdf0e10cSrcweir the mutex is locked 72cdf0e10cSrcweir */ 73cdf0e10cSrcweir void onDocumentInitialized(); 74cdf0e10cSrcweir 75cdf0e10cSrcweir /** notifies a document event described by the given parameters 76cdf0e10cSrcweir 77cdf0e10cSrcweir @precond 78cdf0e10cSrcweir the mutex is not locked 79cdf0e10cSrcweir @precond 80cdf0e10cSrcweir ->onDocumentInitialized has been called 81cdf0e10cSrcweir */ 82cdf0e10cSrcweir void notifyDocumentEvent( 83cdf0e10cSrcweir const ::rtl::OUString& _EventName, 84cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL, 85cdf0e10cSrcweir const ::com::sun::star::uno::Any& _Supplement = ::com::sun::star::uno::Any() 86cdf0e10cSrcweir ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** notifies a document event, described by the given parameters, asynchronously 89cdf0e10cSrcweir 90cdf0e10cSrcweir Note that no event is actually notified before you called ->onDocumentInitialized. 91cdf0e10cSrcweir 92cdf0e10cSrcweir @precond 93cdf0e10cSrcweir the mutex is locked 94cdf0e10cSrcweir */ 95cdf0e10cSrcweir void notifyDocumentEventAsync( 96cdf0e10cSrcweir const ::rtl::OUString& _EventName, 97cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController = NULL, 98cdf0e10cSrcweir const ::com::sun::star::uno::Any& _Supplement = ::com::sun::star::uno::Any() 99cdf0e10cSrcweir ); 100cdf0e10cSrcweir 101cdf0e10cSrcweir /** notifies a document event to all registered listeners 102cdf0e10cSrcweir 103cdf0e10cSrcweir @precond 104cdf0e10cSrcweir the mutex is not locked 105cdf0e10cSrcweir @precond 106cdf0e10cSrcweir ->onDocumentInitialized has been called 107cdf0e10cSrcweir */ notifyDocumentEvent(const sal_Char * _pAsciiEventName,const::com::sun::star::uno::Reference<::com::sun::star::frame::XController2> & _rxViewController=NULL,const::com::sun::star::uno::Any & _rSupplement=::com::sun::star::uno::Any ())108cdf0e10cSrcweir void notifyDocumentEvent( 109cdf0e10cSrcweir const sal_Char* _pAsciiEventName, 110cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL, 111cdf0e10cSrcweir const ::com::sun::star::uno::Any& _rSupplement = ::com::sun::star::uno::Any() 112cdf0e10cSrcweir ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir notifyDocumentEvent( ::rtl::OUString::createFromAscii( _pAsciiEventName ), _rxViewController, _rSupplement ); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir /** notifies a document event to all registered listeners, asynchronously 118cdf0e10cSrcweir 119cdf0e10cSrcweir Note that no event is actually notified before you called ->onDocumentInitialized. 120cdf0e10cSrcweir 121cdf0e10cSrcweir @precond 122cdf0e10cSrcweir the mutex is locked 123cdf0e10cSrcweir */ notifyDocumentEventAsync(const sal_Char * _pAsciiEventName,const::com::sun::star::uno::Reference<::com::sun::star::frame::XController2> & _rxViewController=NULL,const::com::sun::star::uno::Any & _rSupplement=::com::sun::star::uno::Any ())124cdf0e10cSrcweir void notifyDocumentEventAsync( 125cdf0e10cSrcweir const sal_Char* _pAsciiEventName, 126cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _rxViewController = NULL, 127cdf0e10cSrcweir const ::com::sun::star::uno::Any& _rSupplement = ::com::sun::star::uno::Any() 128cdf0e10cSrcweir ) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir notifyDocumentEventAsync( ::rtl::OUString::createFromAscii( _pAsciiEventName ), _rxViewController, _rSupplement ); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir private: 134cdf0e10cSrcweir ::rtl::Reference< DocumentEventNotifier_Impl > m_pImpl; 135cdf0e10cSrcweir }; 136cdf0e10cSrcweir 137cdf0e10cSrcweir //........................................................................ 138cdf0e10cSrcweir } // namespace dbaccess 139cdf0e10cSrcweir //........................................................................ 140cdf0e10cSrcweir 141cdf0e10cSrcweir #endif // DBACCESS_DOCUMENTEVENTNOTIFIER_HXX 142