lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / ucb / source / cacher / dynamicresultsetwrapper.hxx
blob1278d927adfb652863213e4cfe0c9827efa3386a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
38 #include <memory>
40 class DynamicResultSetWrapperListener;
41 class DynamicResultSetWrapper
42 : public cppu::OWeakObject
43 , public css::ucb::XDynamicResultSet
44 , public css::ucb::XSourceInitialization
46 private:
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;
53 protected:
54 rtl::Reference<DynamicResultSetWrapperListener>
55 m_xMyListenerImpl;
57 css::uno::Reference< css::uno::XComponentContext >
58 m_xContext;
60 osl::Mutex m_aMutex;
61 bool m_bStatic;
62 bool m_bGotWelcome;
64 //different Interfaces from Origin:
65 css::uno::Reference< css::ucb::XDynamicResultSet >
66 m_xSource;
67 css::uno::Reference< css::sdbc::XResultSet >
68 m_xSourceResultOne;
69 css::uno::Reference< css::sdbc::XResultSet >
70 m_xSourceResultTwo;
72 css::uno::Reference< css::sdbc::XResultSet >
73 m_xMyResultOne;
74 css::uno::Reference< css::sdbc::XResultSet >
75 m_xMyResultTwo;
77 css::uno::Reference< css::ucb::XDynamicResultSetListener >
78 m_xListener;
80 osl::Condition m_aSourceSet;
81 osl::Condition m_aListenerSet;
83 protected:
84 void impl_init();
85 void impl_deinit();
86 /// @throws css::lang::DisposedException
87 /// @throws css::uno::RuntimeException
88 void
89 impl_EnsureNotDisposed();
91 virtual void
92 impl_InitResultSetOne( const css::uno::Reference<
93 css::sdbc::XResultSet >& xResultSet );
94 virtual void
95 impl_InitResultSetTwo( const css::uno::Reference<
96 css::sdbc::XResultSet >& xResultSet );
98 public:
100 DynamicResultSetWrapper(
101 css::uno::Reference< css::ucb::XDynamicResultSet > const & xOrigin
102 , const css::uno::Reference< css::uno::XComponentContext > & rxContext );
104 virtual ~DynamicResultSetWrapper() override;
107 // XInterface
108 virtual css::uno::Any SAL_CALL
109 queryInterface( const css::uno::Type & rType ) override;
112 // XDynamicResultSet
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
128 dispose() override;
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;
143 // own methods:
144 /// @throws css::uno::RuntimeException
145 virtual void
146 impl_disposing( const css::lang::EventObject& Source );
148 /// @throws css::uno::RuntimeException
149 void
150 impl_notify( const css::ucb::ListEvent& Changes );
154 class DynamicResultSetWrapperListener
155 : public cppu::OWeakObject
156 , public css::ucb::XDynamicResultSetListener
158 protected:
159 DynamicResultSetWrapper* m_pOwner;
160 osl::Mutex m_aMutex;
162 public:
163 DynamicResultSetWrapperListener( DynamicResultSetWrapper* pOwner );
165 virtual ~DynamicResultSetWrapperListener() override;
168 // XInterface
169 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
170 virtual void SAL_CALL acquire()
171 throw() override;
172 virtual void SAL_CALL release()
173 throw() override;
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;
185 // own methods:
186 void impl_OwnerDies();
190 #endif
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */