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 <cppuhelper/weak.hxx>
26 #include <comphelper/interfacecontainer2.hxx>
27 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
28 #include <com/sun/star/ucb/XSourceInitialization.hpp>
29 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
30 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <rtl/ref.hxx>
35 class DynamicResultSetWrapperListener
;
36 class DynamicResultSetWrapper
37 : public cppu::OWeakObject
38 , public css::ucb::XDynamicResultSet
39 , public css::ucb::XSourceInitialization
42 //management of listeners
43 bool m_bDisposed
; ///Dispose call ready.
44 bool m_bInDispose
;///In dispose call
45 osl::Mutex m_aContainerMutex
;
46 std::unique_ptr
<comphelper::OInterfaceContainerHelper2
>
47 m_pDisposeEventListeners
;
49 rtl::Reference
<DynamicResultSetWrapperListener
>
52 css::uno::Reference
< css::uno::XComponentContext
>
59 //different Interfaces from Origin:
60 css::uno::Reference
< css::ucb::XDynamicResultSet
>
62 css::uno::Reference
< css::sdbc::XResultSet
>
64 css::uno::Reference
< css::sdbc::XResultSet
>
67 css::uno::Reference
< css::sdbc::XResultSet
>
69 css::uno::Reference
< css::sdbc::XResultSet
>
72 css::uno::Reference
< css::ucb::XDynamicResultSetListener
>
75 osl::Condition m_aSourceSet
;
76 osl::Condition m_aListenerSet
;
81 /// @throws css::lang::DisposedException
82 /// @throws css::uno::RuntimeException
84 impl_EnsureNotDisposed();
87 impl_InitResultSetOne( const css::uno::Reference
<
88 css::sdbc::XResultSet
>& xResultSet
);
90 impl_InitResultSetTwo( const css::uno::Reference
<
91 css::sdbc::XResultSet
>& xResultSet
);
95 DynamicResultSetWrapper(
96 css::uno::Reference
< css::ucb::XDynamicResultSet
> const & xOrigin
97 , const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
);
99 virtual ~DynamicResultSetWrapper() override
;
103 virtual css::uno::Any SAL_CALL
104 queryInterface( const css::uno::Type
& rType
) override
;
108 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
109 getStaticResultSet() override
;
111 virtual void SAL_CALL
112 setListener( const css::uno::Reference
< css::ucb::XDynamicResultSetListener
> & Listener
) override
;
114 virtual void SAL_CALL
115 connectToCache( const css::uno::Reference
< css::ucb::XDynamicResultSet
> & xCache
) override
;
117 virtual sal_Int16 SAL_CALL
118 getCapabilities() override
;
121 // XComponent ( base of XDynamicResultSet )
122 virtual void SAL_CALL
125 virtual void SAL_CALL
126 addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
128 virtual void SAL_CALL
129 removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
132 // XSourceInitialization
134 virtual void SAL_CALL
135 setSource( const css::uno::Reference
< css::uno::XInterface
> & Source
) override
;
139 /// @throws css::uno::RuntimeException
141 impl_disposing( const css::lang::EventObject
& Source
);
143 /// @throws css::uno::RuntimeException
145 impl_notify( const css::ucb::ListEvent
& Changes
);
149 class DynamicResultSetWrapperListener
150 : public cppu::OWeakObject
151 , public css::ucb::XDynamicResultSetListener
154 DynamicResultSetWrapper
* m_pOwner
;
158 DynamicResultSetWrapperListener( DynamicResultSetWrapper
* pOwner
);
160 virtual ~DynamicResultSetWrapperListener() override
;
164 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
165 virtual void SAL_CALL
acquire()
167 virtual void SAL_CALL
release()
170 // XEventListener ( base of XDynamicResultSetListener )
172 virtual void SAL_CALL
173 disposing( const css::lang::EventObject
& Source
) override
;
175 // XDynamicResultSetListener
176 virtual void SAL_CALL
177 notify( const css::ucb::ListEvent
& Changes
) override
;
181 void impl_OwnerDies();
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */