Update ooo320-m1
[ooovba.git] / ucb / source / cacher / dynamicresultsetwrapper.hxx
blob97eac446f333bbb47de986c5eabf2ff5f2ad4a8a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dynamicresultsetwrapper.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DYNAMIC_RESULTSET_WRAPPER_HXX
32 #define _DYNAMIC_RESULTSET_WRAPPER_HXX
34 #include <osl/mutex.hxx>
35 #include <osl/conditn.hxx>
36 #include <ucbhelper/macros.hxx>
37 #include <cppuhelper/weak.hxx>
38 #include <com/sun/star/lang/XTypeProvider.hpp>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <cppuhelper/interfacecontainer.hxx>
41 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
42 #include <com/sun/star/ucb/XSourceInitialization.hpp>
44 #ifndef __com_sun_star_lang_DisposedException_idl__
45 #include <com/sun/star/lang/DisposedException.hpp>
46 #endif
47 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
48 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 //#define CACHED_CRS_STUB_SERVICE_NAME "com.sun.star.ucb.CachedContentResultSetStub"
51 //#define CACHED_CRS_STUB_FACTORY_NAME "com.sun.star.ucb.CachedContentResultSetStubFactory"
53 //=========================================================================
55 class DynamicResultSetWrapperListener;
56 class DynamicResultSetWrapper
57 : public cppu::OWeakObject
58 , public com::sun::star::ucb::XDynamicResultSet
59 , public com::sun::star::ucb::XSourceInitialization
61 private:
62 //management of listeners
63 sal_Bool m_bDisposed; ///Dispose call ready.
64 sal_Bool m_bInDispose;///In dispose call
65 osl::Mutex m_aContainerMutex;
66 cppu::OInterfaceContainerHelper*
67 m_pDisposeEventListeners;
68 protected:
69 com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSetListener >
70 m_xMyListenerImpl;
71 DynamicResultSetWrapperListener*
72 m_pMyListenerImpl;
74 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
75 m_xSMgr;
77 osl::Mutex m_aMutex;
78 sal_Bool m_bStatic;
79 sal_Bool m_bGotWelcome;
81 //different Interfaces from Origin:
82 com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSet >
83 m_xSource;
84 com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
85 m_xSourceResultOne;
86 com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
87 m_xSourceResultTwo;
88 //com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
89 // m_xSourceResultCurrent;
90 //sal_Bool m_bUseOne;
92 com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
93 m_xMyResultOne;
94 com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
95 m_xMyResultTwo;
97 com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSetListener >
98 m_xListener;
100 osl::Condition m_aSourceSet;
101 osl::Condition m_aListenerSet;
103 protected:
104 void SAL_CALL impl_init();
105 void SAL_CALL impl_deinit();
106 void SAL_CALL
107 impl_EnsureNotDisposed()
108 throw( com::sun::star::lang::DisposedException,
109 com::sun::star::uno::RuntimeException );
111 virtual void SAL_CALL
112 impl_InitResultSetOne( const com::sun::star::uno::Reference<
113 com::sun::star::sdbc::XResultSet >& xResultSet );
114 virtual void SAL_CALL
115 impl_InitResultSetTwo( const com::sun::star::uno::Reference<
116 com::sun::star::sdbc::XResultSet >& xResultSet );
118 public:
120 DynamicResultSetWrapper(
121 com::sun::star::uno::Reference<
122 com::sun::star::ucb::XDynamicResultSet > xOrigin
123 , const com::sun::star::uno::Reference<
124 com::sun::star::lang::XMultiServiceFactory > & xSMgr );
126 virtual ~DynamicResultSetWrapper();
128 //-----------------------------------------------------------------
129 // XInterface
130 virtual com::sun::star::uno::Any SAL_CALL
131 queryInterface( const com::sun::star::uno::Type & rType )
132 throw( com::sun::star::uno::RuntimeException );
134 //-----------------------------------------------------------------
135 // XDynamicResultSet
136 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > SAL_CALL
137 getStaticResultSet()
138 throw( com::sun::star::ucb::ListenerAlreadySetException
139 , com::sun::star::uno::RuntimeException );
141 virtual void SAL_CALL
142 setListener( const com::sun::star::uno::Reference<
143 com::sun::star::ucb::XDynamicResultSetListener > & Listener )
144 throw( com::sun::star::ucb::ListenerAlreadySetException
145 , com::sun::star::uno::RuntimeException );
147 virtual void SAL_CALL
148 connectToCache( const com::sun::star::uno::Reference<
149 com::sun::star::ucb::XDynamicResultSet > & xCache )
150 throw( com::sun::star::ucb::ListenerAlreadySetException
151 , com::sun::star::ucb::AlreadyInitializedException
152 , com::sun::star::ucb::ServiceNotFoundException
153 , com::sun::star::uno::RuntimeException );
155 virtual sal_Int16 SAL_CALL
156 getCapabilities() throw( com::sun::star::uno::RuntimeException );
158 //-----------------------------------------------------------------
159 // XComponent ( base of XDynamicResultSet )
160 virtual void SAL_CALL
161 dispose() throw( com::sun::star::uno::RuntimeException );
163 virtual void SAL_CALL
164 addEventListener( const com::sun::star::uno::Reference<
165 com::sun::star::lang::XEventListener >& Listener )
166 throw( com::sun::star::uno::RuntimeException );
168 virtual void SAL_CALL
169 removeEventListener( const com::sun::star::uno::Reference<
170 com::sun::star::lang::XEventListener >& Listener )
171 throw( com::sun::star::uno::RuntimeException );
173 //-----------------------------------------------------------------
174 // XSourceInitialization
176 virtual void SAL_CALL
177 setSource( const com::sun::star::uno::Reference<
178 com::sun::star::uno::XInterface > & Source )
179 throw( com::sun::star::ucb::AlreadyInitializedException
180 , com::sun::star::uno::RuntimeException );
182 //-----------------------------------------------------------------
183 // own methods:
184 virtual void SAL_CALL
185 impl_disposing( const com::sun::star::lang::EventObject& Source )
186 throw( com::sun::star::uno::RuntimeException );
188 virtual void SAL_CALL
189 impl_notify( const ::com::sun::star::ucb::ListEvent& Changes )
190 throw( com::sun::star::uno::RuntimeException );
193 //=========================================================================
195 class DynamicResultSetWrapperListener
196 : public cppu::OWeakObject
197 , public com::sun::star::ucb::XDynamicResultSetListener
199 protected:
200 DynamicResultSetWrapper* m_pOwner;
201 osl::Mutex m_aMutex;
203 public:
204 DynamicResultSetWrapperListener( DynamicResultSetWrapper* pOwner );
206 virtual ~DynamicResultSetWrapperListener();
208 //-----------------------------------------------------------------
209 // XInterface
210 //-----------------------------------------------------------------
211 XINTERFACE_DECL()
213 //-----------------------------------------------------------------
214 // XEventListener ( base of XDynamicResultSetListener )
215 //-----------------------------------------------------------------
216 virtual void SAL_CALL
217 disposing( const com::sun::star::lang::EventObject& Source )
218 throw( com::sun::star::uno::RuntimeException );
219 //-----------------------------------------------------------------
220 // XDynamicResultSetListener
221 virtual void SAL_CALL
222 notify( const ::com::sun::star::ucb::ListEvent& Changes )
223 throw( com::sun::star::uno::RuntimeException );
225 //-----------------------------------------------------------------
226 // own methods:
227 void SAL_CALL impl_OwnerDies();
231 #endif