LibreOffice Module ucb (master)  1
dynamicresultsetwrapper.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_UCB_SOURCE_CACHER_DYNAMICRESULTSETWRAPPER_HXX
21 #define INCLUDED_UCB_SOURCE_CACHER_DYNAMICRESULTSETWRAPPER_HXX
22 
23 #include <osl/mutex.hxx>
24 #include <osl/conditn.hxx>
25 #include <cppuhelper/weak.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>
32 
33 #include <memory>
34 
37  : public cppu::OWeakObject
38  , public css::ucb::XDynamicResultSet
39  , public css::ucb::XSourceInitialization
40 {
41 private:
42  //management of listeners
43  bool m_bDisposed;
45  osl::Mutex m_aContainerMutex;
46  std::unique_ptr<comphelper::OInterfaceContainerHelper2>
48 protected:
51 
52  css::uno::Reference< css::uno::XComponentContext >
54 
55  osl::Mutex m_aMutex;
56  bool m_bStatic;
58 
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 >
66 
67  css::uno::Reference< css::sdbc::XResultSet >
69  css::uno::Reference< css::sdbc::XResultSet >
71 
72  css::uno::Reference< css::ucb::XDynamicResultSetListener >
74 
75  osl::Condition m_aSourceSet;
76  osl::Condition m_aListenerSet;
77 
78 protected:
79  void impl_init();
80  void impl_deinit();
83  void
85 
86  virtual void
87  impl_InitResultSetOne( const css::uno::Reference<
88  css::sdbc::XResultSet >& xResultSet );
89  virtual void
90  impl_InitResultSetTwo( const css::uno::Reference<
91  css::sdbc::XResultSet >& xResultSet );
92 
93 public:
94 
96  css::uno::Reference< css::ucb::XDynamicResultSet > const & xOrigin
97  , const css::uno::Reference< css::uno::XComponentContext > & rxContext );
98 
99  virtual ~DynamicResultSetWrapper() override;
100 
101 
102  // XInterface
103  virtual css::uno::Any SAL_CALL
104  queryInterface( const css::uno::Type & rType ) override;
105 
106 
107  // XDynamicResultSet
108  virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL
109  getStaticResultSet() override;
110 
111  virtual void SAL_CALL
112  setListener( const css::uno::Reference< css::ucb::XDynamicResultSetListener > & Listener ) override;
113 
114  virtual void SAL_CALL
115  connectToCache( const css::uno::Reference< css::ucb::XDynamicResultSet > & xCache ) override;
116 
117  virtual sal_Int16 SAL_CALL
118  getCapabilities() override;
119 
120 
121  // XComponent ( base of XDynamicResultSet )
122  virtual void SAL_CALL
123  dispose() override;
124 
125  virtual void SAL_CALL
126  addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
127 
128  virtual void SAL_CALL
129  removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
130 
131 
132  // XSourceInitialization
133 
134  virtual void SAL_CALL
135  setSource( const css::uno::Reference< css::uno::XInterface > & Source ) override;
136 
137 
138  // own methods:
140  virtual void
141  impl_disposing( const css::lang::EventObject& Source );
142 
144  void
145  impl_notify( const css::ucb::ListEvent& Changes );
146 };
147 
148 
150  : public cppu::OWeakObject
151  , public css::ucb::XDynamicResultSetListener
152 {
153 protected:
155  osl::Mutex m_aMutex;
156 
157 public:
159 
160  virtual ~DynamicResultSetWrapperListener() override;
161 
162 
163  // XInterface
164  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
165  virtual void SAL_CALL acquire()
166  throw() override;
167  virtual void SAL_CALL release()
168  throw() override;
169 
170  // XEventListener ( base of XDynamicResultSetListener )
171 
172  virtual void SAL_CALL
173  disposing( const css::lang::EventObject& Source ) override;
174 
175  // XDynamicResultSetListener
176  virtual void SAL_CALL
177  notify( const css::ucb::ListEvent& Changes ) override;
178 
179 
180  // own methods:
181  void impl_OwnerDies();
182 };
183 
184 
185 #endif
186 
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL setListener(const css::uno::Reference< css::ucb::XDynamicResultSetListener > &Listener) override
virtual void impl_InitResultSetTwo(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL connectToCache(const css::uno::Reference< css::ucb::XDynamicResultSet > &xCache) override
css::uno::Reference< css::sdbc::XResultSet > m_xMyResultTwo
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
css::uno::Reference< css::ucb::XDynamicResultSetListener > m_xListener
virtual void impl_disposing(const css::lang::EventObject &Source)
virtual sal_Int16 SAL_CALL getCapabilities() override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
virtual void SAL_CALL acquire() override
virtual void impl_InitResultSetOne(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet)
virtual void SAL_CALL dispose() override
osl::Mutex m_aContainerMutex
In dispose call.
rtl::Reference< DynamicResultSetWrapperListener > m_xMyListenerImpl
DynamicResultSetWrapper(css::uno::Reference< css::ucb::XDynamicResultSet > const &xOrigin, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual ~DynamicResultSetWrapper() override
bool m_bInDispose
Dispose call ready.
css::uno::Reference< css::sdbc::XResultSet > m_xMyResultOne
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pDisposeEventListeners
css::uno::Reference< css::ucb::XDynamicResultSet > m_xSource
css::uno::Reference< css::sdbc::XResultSet > m_xSourceResultTwo
css::uno::Reference< css::uno::XComponentContext > m_xContext
void impl_notify(const css::ucb::ListEvent &Changes)
DynamicResultSetWrapperListener(DynamicResultSetWrapper *pOwner)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL notify(const css::ucb::ListEvent &Changes) override
css::uno::Reference< css::sdbc::XResultSet > m_xSourceResultOne
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getStaticResultSet() override
virtual void SAL_CALL setSource(const css::uno::Reference< css::uno::XInterface > &Source) override
virtual void SAL_CALL release() override