1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef DBA_CONTAINERLISTENER_HXX 24 #define DBA_CONTAINERLISTENER_HXX 25 26 #ifndef _CPPUHELPER_IMPLBASE2_HXX_ 27 #include <cppuhelper/implbase2.hxx> 28 #endif 29 #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_ 30 #include <com/sun/star/container/XContainerListener.hpp> 31 #endif 32 #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVELISTENER_HPP_ 33 #include <com/sun/star/container/XContainerApproveListener.hpp> 34 #endif 35 36 #ifndef _CPPUHELPER_WEAK_HXX_ 37 #include <cppuhelper/weak.hxx> 38 #endif 39 40 //........................................................................ 41 namespace dbaccess 42 { 43 //........................................................................ 44 45 //========================================================================== 46 //= OContainerListener 47 //========================================================================== 48 typedef ::cppu::WeakImplHelper2 < ::com::sun::star::container::XContainerListener 49 , ::com::sun::star::container::XContainerApproveListener 50 > OContainerListener_BASE; 51 52 /** is helper class to avoid a cycle in refcount 53 */ 54 class OContainerListener : public OContainerListener_BASE 55 { 56 ::osl::Mutex& m_rMutex; 57 OWeakObject& m_rDestination; 58 bool m_bDisposed; 59 60 public: OContainerListener(OWeakObject & _rDestination,::osl::Mutex & _rMutex)61 OContainerListener( OWeakObject& _rDestination, ::osl::Mutex& _rMutex ) 62 :m_rMutex( _rMutex ) 63 ,m_rDestination( _rDestination ) 64 ,m_bDisposed( false ) 65 { 66 } 67 68 // XContainerApproveListener 69 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveInsertElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 70 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveReplaceElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 71 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveRemoveElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 72 73 // XContainerListener 74 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); 75 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); 76 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); 77 78 // XEventListener 79 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); 80 dispose()81 void SAL_CALL dispose() 82 { 83 m_bDisposed = true; 84 } 85 86 protected: 87 virtual ~OContainerListener(); 88 }; 89 //........................................................................ 90 } // namespace dbaccess 91 //........................................................................ 92 #endif // DBA_CONTAINERLISTENER_HXX 93 94