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 #ifndef _CPPUHELPER_COMPBASE_EX_HXX_ 28 #define _CPPUHELPER_COMPBASE_EX_HXX_ 29 30 #include <osl/mutex.hxx> 31 #include <cppuhelper/implbase_ex.hxx> 32 #include <cppuhelper/interfacecontainer.hxx> 33 #include <com/sun/star/lang/XComponent.hpp> 34 35 36 namespace cppu 37 { 38 39 /** Implementation helper base class for components. Inherits from ::cppu::OWeakObject and 40 ::com::sun::star::lang::XComponent. 41 @internal 42 */ 43 class SAL_NO_VTABLE WeakComponentImplHelperBase 44 : public ::cppu::OWeakObject 45 , public ::com::sun::star::lang::XComponent 46 { 47 protected: 48 /** boradcast helper for disposing events 49 */ 50 ::cppu::OBroadcastHelper rBHelper; 51 52 /** this function is called upon disposing the component 53 */ 54 virtual void SAL_CALL disposing(); 55 56 /** This is the one and only constructor that is called from derived implementations. 57 58 @param rMutex mutex to sync upon disposing 59 */ 60 WeakComponentImplHelperBase( ::osl::Mutex & rMutex ) SAL_THROW( () ); 61 public: 62 /** Destructor 63 */ 64 virtual ~WeakComponentImplHelperBase() SAL_THROW( () ); 65 66 // these are here to force memory de/allocation to sal lib. 67 inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) 68 { return ::rtl_allocateMemory( nSize ); } 69 inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) 70 { ::rtl_freeMemory( pMem ); } 71 inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) 72 { return pMem; } 73 inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) 74 {} 75 76 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 77 ::com::sun::star::uno::Type const & rType ) 78 throw (::com::sun::star::uno::RuntimeException); 79 virtual void SAL_CALL acquire() 80 throw (); 81 virtual void SAL_CALL release() 82 throw (); 83 virtual void SAL_CALL dispose() 84 throw (::com::sun::star::uno::RuntimeException); 85 virtual void SAL_CALL addEventListener( 86 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) 87 throw (::com::sun::star::uno::RuntimeException); 88 virtual void SAL_CALL removeEventListener( 89 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) 90 throw (::com::sun::star::uno::RuntimeException); 91 }; 92 93 /** Implementation helper base class for components. Inherits from ::cppu::OWeakAggObject and 94 ::com::sun::star::lang::XComponent. 95 @internal 96 */ 97 class SAL_NO_VTABLE WeakAggComponentImplHelperBase 98 : public ::cppu::OWeakAggObject 99 , public ::com::sun::star::lang::XComponent 100 { 101 protected: 102 ::cppu::OBroadcastHelper rBHelper; 103 104 /** Is called upon disposing the component. 105 */ 106 virtual void SAL_CALL disposing(); 107 108 WeakAggComponentImplHelperBase( ::osl::Mutex & rMutex ) SAL_THROW( () ); 109 public: 110 virtual ~WeakAggComponentImplHelperBase() SAL_THROW( () ); 111 112 // these are here to force memory de/allocation to sal lib. 113 inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) 114 { return ::rtl_allocateMemory( nSize ); } 115 inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) 116 { ::rtl_freeMemory( pMem ); } 117 inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) 118 { return pMem; } 119 inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) 120 {} 121 122 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 123 ::com::sun::star::uno::Type const & rType ) 124 throw (::com::sun::star::uno::RuntimeException); 125 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( 126 ::com::sun::star::uno::Type const & rType ) 127 throw (::com::sun::star::uno::RuntimeException); 128 virtual void SAL_CALL acquire() 129 throw (); 130 virtual void SAL_CALL release() 131 throw (); 132 virtual void SAL_CALL dispose() 133 throw (::com::sun::star::uno::RuntimeException); 134 virtual void SAL_CALL addEventListener( 135 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) 136 throw (::com::sun::star::uno::RuntimeException); 137 virtual void SAL_CALL removeEventListener( 138 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) 139 throw (::com::sun::star::uno::RuntimeException); 140 }; 141 142 /** WeakComponentImplHelper 143 @internal 144 */ 145 ::com::sun::star::uno::Any SAL_CALL WeakComponentImplHelper_query( 146 ::com::sun::star::uno::Type const & rType, 147 class_data * cd, 148 void * that, 149 ::cppu::WeakComponentImplHelperBase * pBase ) 150 SAL_THROW( (::com::sun::star::uno::RuntimeException) ); 151 /** WeakComponentImplHelper 152 @internal 153 */ 154 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakComponentImplHelper_getTypes( 155 class_data * cd ) 156 SAL_THROW( (::com::sun::star::uno::RuntimeException) ); 157 158 /** WeakAggComponentImplHelper 159 @internal 160 */ 161 ::com::sun::star::uno::Any SAL_CALL WeakAggComponentImplHelper_queryAgg( 162 ::com::sun::star::uno::Type const & rType, 163 class_data * cd, 164 void * that, 165 ::cppu::WeakAggComponentImplHelperBase * pBase ) 166 SAL_THROW( (::com::sun::star::uno::RuntimeException) ); 167 /** WeakAggComponentImplHelper 168 @internal 169 */ 170 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakAggComponentImplHelper_getTypes( 171 class_data * cd ) 172 SAL_THROW( (::com::sun::star::uno::RuntimeException) ); 173 174 } 175 176 #endif 177