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 .
23 #include <osl/conditn.hxx>
24 #include <cppuhelper/weak.hxx>
25 #include <comphelper/interfacecontainer4.hxx>
26 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
27 #include <com/sun/star/ucb/XSourceInitialization.hpp>
28 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <rtl/ref.hxx>
34 class DynamicResultSetWrapperListener
;
35 class DynamicResultSetWrapper
36 : public cppu::OWeakObject
37 , public css::ucb::XDynamicResultSet
38 , public css::ucb::XSourceInitialization
41 //management of listeners
42 bool m_bDisposed
; ///Dispose call ready.
43 bool m_bInDispose
;///In dispose call
44 comphelper::OInterfaceContainerHelper4
<css::lang::XEventListener
>
45 m_aDisposeEventListeners
;
47 rtl::Reference
<DynamicResultSetWrapperListener
>
50 css::uno::Reference
< css::uno::XComponentContext
>
57 //different Interfaces from Origin:
58 css::uno::Reference
< css::ucb::XDynamicResultSet
>
60 css::uno::Reference
< css::sdbc::XResultSet
>
62 css::uno::Reference
< css::sdbc::XResultSet
>
65 css::uno::Reference
< css::sdbc::XResultSet
>
67 css::uno::Reference
< css::sdbc::XResultSet
>
70 css::uno::Reference
< css::ucb::XDynamicResultSetListener
>
73 osl::Condition m_aSourceSet
;
74 osl::Condition m_aListenerSet
;
79 /// @throws css::lang::DisposedException
80 /// @throws css::uno::RuntimeException
82 impl_EnsureNotDisposed(std::unique_lock
<std::mutex
>& rGuard
);
85 impl_InitResultSetOne( std::unique_lock
<std::mutex
>& rGuard
, const css::uno::Reference
<
86 css::sdbc::XResultSet
>& xResultSet
);
88 impl_InitResultSetTwo( std::unique_lock
<std::mutex
>& rGuard
, const css::uno::Reference
<
89 css::sdbc::XResultSet
>& xResultSet
);
93 DynamicResultSetWrapper(
94 css::uno::Reference
< css::ucb::XDynamicResultSet
> const & xOrigin
95 , const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
);
97 virtual ~DynamicResultSetWrapper() override
;
101 virtual css::uno::Any SAL_CALL
102 queryInterface( const css::uno::Type
& rType
) override
;
106 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
107 getStaticResultSet() override
;
109 virtual void SAL_CALL
110 setListener( const css::uno::Reference
< css::ucb::XDynamicResultSetListener
> & Listener
) override
;
112 virtual void SAL_CALL
113 connectToCache( const css::uno::Reference
< css::ucb::XDynamicResultSet
> & xCache
) override
;
115 virtual sal_Int16 SAL_CALL
116 getCapabilities() override
;
119 // XComponent ( base of XDynamicResultSet )
120 virtual void SAL_CALL
123 virtual void SAL_CALL
124 addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
126 virtual void SAL_CALL
127 removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
130 // XSourceInitialization
132 virtual void SAL_CALL
133 setSource( const css::uno::Reference
< css::uno::XInterface
> & Source
) override
;
137 /// @throws css::uno::RuntimeException
139 impl_disposing( const css::lang::EventObject
& Source
);
141 /// @throws css::uno::RuntimeException
143 impl_notify( const css::ucb::ListEvent
& Changes
);
147 class DynamicResultSetWrapperListener
148 : public cppu::OWeakObject
149 , public css::ucb::XDynamicResultSetListener
151 DynamicResultSetWrapper
* m_pOwner
;
155 DynamicResultSetWrapperListener( DynamicResultSetWrapper
* pOwner
);
157 virtual ~DynamicResultSetWrapperListener() override
;
161 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
162 virtual void SAL_CALL
acquire()
164 virtual void SAL_CALL
release()
167 // XEventListener ( base of XDynamicResultSetListener )
169 virtual void SAL_CALL
170 disposing( const css::lang::EventObject
& Source
) override
;
172 // XDynamicResultSetListener
173 virtual void SAL_CALL
174 notify( const css::ucb::ListEvent
& Changes
) override
;
178 void impl_OwnerDies();
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */