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 INCLUDED_UCB_SOURCE_CACHER_DYNAMICRESULTSETWRAPPER_HXX
21 #define INCLUDED_UCB_SOURCE_CACHER_DYNAMICRESULTSETWRAPPER_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>
32 #include <com/sun/star/lang/DisposedException.hpp>
33 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 class DynamicResultSetWrapperListener
;
39 class DynamicResultSetWrapper
40 : public cppu::OWeakObject
41 , public com::sun::star::ucb::XDynamicResultSet
42 , public com::sun::star::ucb::XSourceInitialization
45 //management of listeners
46 bool m_bDisposed
; ///Dispose call ready.
47 bool m_bInDispose
;///In dispose call
48 osl::Mutex m_aContainerMutex
;
49 cppu::OInterfaceContainerHelper
*
50 m_pDisposeEventListeners
;
52 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSetListener
>
54 DynamicResultSetWrapperListener
*
57 com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>
64 //different Interfaces from Origin:
65 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSet
>
67 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
69 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
71 //com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
72 // m_xSourceResultCurrent;
75 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
77 com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
>
80 com::sun::star::uno::Reference
< com::sun::star::ucb::XDynamicResultSetListener
>
83 osl::Condition m_aSourceSet
;
84 osl::Condition m_aListenerSet
;
87 void SAL_CALL
impl_init();
88 void SAL_CALL
impl_deinit();
90 impl_EnsureNotDisposed()
91 throw( com::sun::star::lang::DisposedException
,
92 com::sun::star::uno::RuntimeException
);
95 impl_InitResultSetOne( const com::sun::star::uno::Reference
<
96 com::sun::star::sdbc::XResultSet
>& xResultSet
);
98 impl_InitResultSetTwo( const com::sun::star::uno::Reference
<
99 com::sun::star::sdbc::XResultSet
>& xResultSet
);
103 DynamicResultSetWrapper(
104 com::sun::star::uno::Reference
<
105 com::sun::star::ucb::XDynamicResultSet
> xOrigin
106 , const com::sun::star::uno::Reference
<
107 com::sun::star::uno::XComponentContext
> & rxContext
);
109 virtual ~DynamicResultSetWrapper();
113 virtual com::sun::star::uno::Any SAL_CALL
114 queryInterface( const com::sun::star::uno::Type
& rType
)
115 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
119 virtual com::sun::star::uno::Reference
< com::sun::star::sdbc::XResultSet
> SAL_CALL
121 throw( com::sun::star::ucb::ListenerAlreadySetException
122 , com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
124 virtual void SAL_CALL
125 setListener( const com::sun::star::uno::Reference
<
126 com::sun::star::ucb::XDynamicResultSetListener
> & Listener
)
127 throw( com::sun::star::ucb::ListenerAlreadySetException
128 , com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
130 virtual void SAL_CALL
131 connectToCache( const com::sun::star::uno::Reference
<
132 com::sun::star::ucb::XDynamicResultSet
> & xCache
)
133 throw( com::sun::star::ucb::ListenerAlreadySetException
134 , com::sun::star::ucb::AlreadyInitializedException
135 , com::sun::star::ucb::ServiceNotFoundException
136 , com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
138 virtual sal_Int16 SAL_CALL
139 getCapabilities() throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
142 // XComponent ( base of XDynamicResultSet )
143 virtual void SAL_CALL
144 dispose() throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
146 virtual void SAL_CALL
147 addEventListener( const com::sun::star::uno::Reference
<
148 com::sun::star::lang::XEventListener
>& Listener
)
149 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
151 virtual void SAL_CALL
152 removeEventListener( const com::sun::star::uno::Reference
<
153 com::sun::star::lang::XEventListener
>& Listener
)
154 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
157 // XSourceInitialization
159 virtual void SAL_CALL
160 setSource( const com::sun::star::uno::Reference
<
161 com::sun::star::uno::XInterface
> & Source
)
162 throw( com::sun::star::ucb::AlreadyInitializedException
163 , com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
167 virtual void SAL_CALL
168 impl_disposing( const com::sun::star::lang::EventObject
& Source
)
169 throw( com::sun::star::uno::RuntimeException
);
172 impl_notify( const ::com::sun::star::ucb::ListEvent
& Changes
)
173 throw( com::sun::star::uno::RuntimeException
);
178 class DynamicResultSetWrapperListener
179 : public cppu::OWeakObject
180 , public com::sun::star::ucb::XDynamicResultSetListener
183 DynamicResultSetWrapper
* m_pOwner
;
187 DynamicResultSetWrapperListener( DynamicResultSetWrapper
* pOwner
);
189 virtual ~DynamicResultSetWrapperListener();
193 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
)
194 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
195 virtual void SAL_CALL
acquire()
196 throw() SAL_OVERRIDE
;
197 virtual void SAL_CALL
release()
198 throw() SAL_OVERRIDE
;
200 // XEventListener ( base of XDynamicResultSetListener )
202 virtual void SAL_CALL
203 disposing( const com::sun::star::lang::EventObject
& Source
)
204 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
206 // XDynamicResultSetListener
207 virtual void SAL_CALL
208 notify( const ::com::sun::star::ucb::ListEvent
& Changes
)
209 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
213 void SAL_CALL
impl_OwnerDies();
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */