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 <comphelper/interfacecontainer2.hxx>
28 #include <com/sun/star/lang/XTypeProvider.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <cppuhelper/interfacecontainer.hxx>
31 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
32 #include <com/sun/star/ucb/XSourceInitialization.hpp>
33 #include <com/sun/star/lang/DisposedException.hpp>
34 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <rtl/ref.hxx>
40 class DynamicResultSetWrapperListener
;
41 class DynamicResultSetWrapper
42 : public cppu::OWeakObject
43 , public css::ucb::XDynamicResultSet
44 , public css::ucb::XSourceInitialization
47 //management of listeners
48 bool m_bDisposed
; ///Dispose call ready.
49 bool m_bInDispose
;///In dispose call
50 osl::Mutex m_aContainerMutex
;
51 std::unique_ptr
<comphelper::OInterfaceContainerHelper2
>
52 m_pDisposeEventListeners
;
54 rtl::Reference
<DynamicResultSetWrapperListener
>
57 css::uno::Reference
< css::uno::XComponentContext
>
64 //different Interfaces from Origin:
65 css::uno::Reference
< css::ucb::XDynamicResultSet
>
67 css::uno::Reference
< css::sdbc::XResultSet
>
69 css::uno::Reference
< css::sdbc::XResultSet
>
72 css::uno::Reference
< css::sdbc::XResultSet
>
74 css::uno::Reference
< css::sdbc::XResultSet
>
77 css::uno::Reference
< css::ucb::XDynamicResultSetListener
>
80 osl::Condition m_aSourceSet
;
81 osl::Condition m_aListenerSet
;
86 /// @throws css::lang::DisposedException
87 /// @throws css::uno::RuntimeException
89 impl_EnsureNotDisposed();
92 impl_InitResultSetOne( const css::uno::Reference
<
93 css::sdbc::XResultSet
>& xResultSet
);
95 impl_InitResultSetTwo( const css::uno::Reference
<
96 css::sdbc::XResultSet
>& xResultSet
);
100 DynamicResultSetWrapper(
101 css::uno::Reference
< css::ucb::XDynamicResultSet
> const & xOrigin
102 , const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
);
104 virtual ~DynamicResultSetWrapper() override
;
108 virtual css::uno::Any SAL_CALL
109 queryInterface( const css::uno::Type
& rType
) override
;
113 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
114 getStaticResultSet() override
;
116 virtual void SAL_CALL
117 setListener( const css::uno::Reference
< css::ucb::XDynamicResultSetListener
> & Listener
) override
;
119 virtual void SAL_CALL
120 connectToCache( const css::uno::Reference
< css::ucb::XDynamicResultSet
> & xCache
) override
;
122 virtual sal_Int16 SAL_CALL
123 getCapabilities() override
;
126 // XComponent ( base of XDynamicResultSet )
127 virtual void SAL_CALL
130 virtual void SAL_CALL
131 addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
133 virtual void SAL_CALL
134 removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
137 // XSourceInitialization
139 virtual void SAL_CALL
140 setSource( const css::uno::Reference
< css::uno::XInterface
> & Source
) override
;
144 /// @throws css::uno::RuntimeException
146 impl_disposing( const css::lang::EventObject
& Source
);
148 /// @throws css::uno::RuntimeException
150 impl_notify( const css::ucb::ListEvent
& Changes
);
154 class DynamicResultSetWrapperListener
155 : public cppu::OWeakObject
156 , public css::ucb::XDynamicResultSetListener
159 DynamicResultSetWrapper
* m_pOwner
;
163 DynamicResultSetWrapperListener( DynamicResultSetWrapper
* pOwner
);
165 virtual ~DynamicResultSetWrapperListener() override
;
169 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
170 virtual void SAL_CALL
acquire()
172 virtual void SAL_CALL
release()
175 // XEventListener ( base of XDynamicResultSetListener )
177 virtual void SAL_CALL
178 disposing( const css::lang::EventObject
& Source
) override
;
180 // XDynamicResultSetListener
181 virtual void SAL_CALL
182 notify( const css::ucb::ListEvent
& Changes
) override
;
186 void impl_OwnerDies();
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */