1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _DYNAMIC_RESULTSET_WRAPPER_HXX
21 #define _DYNAMIC_RESULTSET_WRAPPER_HXX
23 #include <osl/mutex.hxx>
24 #include <osl/conditn.hxx>
25 #include <ucbhelper/macros.hxx>
26 #include <cppuhelper/weak.hxx>
27 #include <com/sun/star/lang/XTypeProvider.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <cppuhelper/interfacecontainer.hxx>
30 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
31 #include <com/sun/star/ucb/XSourceInitialization.hpp>
33 #ifndef __com_sun_star_lang_DisposedException_idl__
34 #include <com/sun/star/lang/DisposedException.hpp>
36 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39 //=========================================================================
41 class DynamicResultSetWrapperListener
;
42 class DynamicResultSetWrapper
43 : public cppu::OWeakObject
44 , public com::sun::star::ucb::XDynamicResultSet
45 , public com::sun::star::ucb::XSourceInitialization
48 //management of listeners
49 sal_Bool m_bDisposed
; ///Dispose call ready.
50 sal_Bool m_bInDispose
;///In dispose call
51 osl::Mutex m_aContainerMutex
;
52 cppu::OInterfaceContainerHelper
*
53 m_pDisposeEventListeners
;
55 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSetListener
>
57 DynamicResultSetWrapperListener
*
60 com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>
65 sal_Bool m_bGotWelcome
;
67 //different Interfaces from Origin:
68 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSet
>
70 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
72 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
74 //com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
75 // m_xSourceResultCurrent;
78 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
80 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
83 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSetListener
>
86 osl::Condition m_aSourceSet
;
87 osl::Condition m_aListenerSet
;
90 void SAL_CALL
impl_init();
91 void SAL_CALL
impl_deinit();
93 impl_EnsureNotDisposed()
94 throw( com::sun::star::lang::DisposedException
,
95 com::sun::star::uno::RuntimeException
);
98 impl_InitResultSetOne( const com::sun::star::uno::Reference
<
99 com::sun::star::sdbc::XResultSet
>& xResultSet
);
100 virtual void SAL_CALL
101 impl_InitResultSetTwo( const com::sun::star::uno::Reference
<
102 com::sun::star::sdbc::XResultSet
>& xResultSet
);
106 DynamicResultSetWrapper(
107 com::sun::star::uno::Reference
<
108 com::sun::star::ucb::XDynamicResultSet
> xOrigin
109 , const com::sun::star::uno::Reference
<
110 com::sun::star::uno::XComponentContext
> & rxContext
);
112 virtual ~DynamicResultSetWrapper();
114 //-----------------------------------------------------------------
116 virtual com::sun::star::uno::Any SAL_CALL
117 queryInterface( const com::sun::star::uno::Type
& rType
)
118 throw( com::sun::star::uno::RuntimeException
);
120 //-----------------------------------------------------------------
122 virtual com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
> SAL_CALL
124 throw( com::sun::star::ucb::ListenerAlreadySetException
125 , com::sun::star::uno::RuntimeException
);
127 virtual void SAL_CALL
128 setListener( const com::sun::star::uno::Reference
<
129 com::sun::star::ucb::XDynamicResultSetListener
> & Listener
)
130 throw( com::sun::star::ucb::ListenerAlreadySetException
131 , com::sun::star::uno::RuntimeException
);
133 virtual void SAL_CALL
134 connectToCache( const com::sun::star::uno::Reference
<
135 com::sun::star::ucb::XDynamicResultSet
> & xCache
)
136 throw( com::sun::star::ucb::ListenerAlreadySetException
137 , com::sun::star::ucb::AlreadyInitializedException
138 , com::sun::star::ucb::ServiceNotFoundException
139 , com::sun::star::uno::RuntimeException
);
141 virtual sal_Int16 SAL_CALL
142 getCapabilities() throw( com::sun::star::uno::RuntimeException
);
144 //-----------------------------------------------------------------
145 // XComponent ( base of XDynamicResultSet )
146 virtual void SAL_CALL
147 dispose() throw( com::sun::star::uno::RuntimeException
);
149 virtual void SAL_CALL
150 addEventListener( const com::sun::star::uno::Reference
<
151 com::sun::star::lang::XEventListener
>& Listener
)
152 throw( com::sun::star::uno::RuntimeException
);
154 virtual void SAL_CALL
155 removeEventListener( const com::sun::star::uno::Reference
<
156 com::sun::star::lang::XEventListener
>& Listener
)
157 throw( com::sun::star::uno::RuntimeException
);
159 //-----------------------------------------------------------------
160 // XSourceInitialization
162 virtual void SAL_CALL
163 setSource( const com::sun::star::uno::Reference
<
164 com::sun::star::uno::XInterface
> & Source
)
165 throw( com::sun::star::ucb::AlreadyInitializedException
166 , com::sun::star::uno::RuntimeException
);
168 //-----------------------------------------------------------------
170 virtual void SAL_CALL
171 impl_disposing( const com::sun::star::lang::EventObject
& Source
)
172 throw( com::sun::star::uno::RuntimeException
);
174 virtual void SAL_CALL
175 impl_notify( const ::com::sun::star::ucb::ListEvent
& Changes
)
176 throw( com::sun::star::uno::RuntimeException
);
179 //=========================================================================
181 class DynamicResultSetWrapperListener
182 : public cppu::OWeakObject
183 , public com::sun::star::ucb::XDynamicResultSetListener
186 DynamicResultSetWrapper
* m_pOwner
;
190 DynamicResultSetWrapperListener( DynamicResultSetWrapper
* pOwner
);
192 virtual ~DynamicResultSetWrapperListener();
194 //-----------------------------------------------------------------
196 //-----------------------------------------------------------------
199 //-----------------------------------------------------------------
200 // XEventListener ( base of XDynamicResultSetListener )
201 //-----------------------------------------------------------------
202 virtual void SAL_CALL
203 disposing( const com::sun::star::lang::EventObject
& Source
)
204 throw( com::sun::star::uno::RuntimeException
);
205 //-----------------------------------------------------------------
206 // XDynamicResultSetListener
207 virtual void SAL_CALL
208 notify( const ::com::sun::star::ucb::ListEvent
& Changes
)
209 throw( com::sun::star::uno::RuntimeException
);
211 //-----------------------------------------------------------------
213 void SAL_CALL
impl_OwnerDies();
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */