1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dynamicresultsetwrapper.hxx,v $
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>
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
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
;
69 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSetListener
>
71 DynamicResultSetWrapperListener
*
74 com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>
79 sal_Bool m_bGotWelcome
;
81 //different Interfaces from Origin:
82 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSet
>
84 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
86 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
88 //com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
89 // m_xSourceResultCurrent;
92 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
94 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
97 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSetListener
>
100 osl::Condition m_aSourceSet
;
101 osl::Condition m_aListenerSet
;
104 void SAL_CALL
impl_init();
105 void SAL_CALL
impl_deinit();
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
);
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 //-----------------------------------------------------------------
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 //-----------------------------------------------------------------
136 virtual com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
> SAL_CALL
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 //-----------------------------------------------------------------
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
200 DynamicResultSetWrapper
* m_pOwner
;
204 DynamicResultSetWrapperListener( DynamicResultSetWrapper
* pOwner
);
206 virtual ~DynamicResultSetWrapperListener();
208 //-----------------------------------------------------------------
210 //-----------------------------------------------------------------
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 //-----------------------------------------------------------------
227 void SAL_CALL
impl_OwnerDies();