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#pragma once
21
22#include <mutex>
23#include <osl/conditn.hxx>
24#include <cppuhelper/weak.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>
31
32#include <memory>
33
36 : public cppu::OWeakObject
37 , public css::ucb::XDynamicResultSet
38 , public css::ucb::XSourceInitialization
39{
40private:
41 //management of listeners
46protected:
49
50 css::uno::Reference< css::uno::XComponentContext >
52
53 std::mutex m_aMutex;
56
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 >
64
65 css::uno::Reference< css::sdbc::XResultSet >
67 css::uno::Reference< css::sdbc::XResultSet >
69
70 css::uno::Reference< css::ucb::XDynamicResultSetListener >
72
73 osl::Condition m_aSourceSet;
74 osl::Condition m_aListenerSet;
75
76protected:
77 void impl_init();
78 void impl_deinit();
81 void
83
84 virtual void
85 impl_InitResultSetOne( const css::uno::Reference<
86 css::sdbc::XResultSet >& xResultSet );
87 virtual void
88 impl_InitResultSetTwo( const css::uno::Reference<
89 css::sdbc::XResultSet >& xResultSet );
90
91public:
92
94 css::uno::Reference< css::ucb::XDynamicResultSet > const & xOrigin
95 , const css::uno::Reference< css::uno::XComponentContext > & rxContext );
96
97 virtual ~DynamicResultSetWrapper() override;
98
99
100 // XInterface
101 virtual css::uno::Any SAL_CALL
102 queryInterface( const css::uno::Type & rType ) override;
103
104
105 // XDynamicResultSet
106 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL
107 getStaticResultSet() override;
108
109 virtual void SAL_CALL
110 setListener( const css::uno::Reference< css::ucb::XDynamicResultSetListener > & Listener ) override;
111
112 virtual void SAL_CALL
113 connectToCache( const css::uno::Reference< css::ucb::XDynamicResultSet > & xCache ) override;
114
115 virtual sal_Int16 SAL_CALL
116 getCapabilities() override;
117
118
119 // XComponent ( base of XDynamicResultSet )
120 virtual void SAL_CALL
121 dispose() override;
122
123 virtual void SAL_CALL
124 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
125
126 virtual void SAL_CALL
127 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
128
129
130 // XSourceInitialization
131
132 virtual void SAL_CALL
133 setSource( const css::uno::Reference< css::uno::XInterface > & Source ) override;
134
135
136 // own methods:
138 virtual void
139 impl_disposing( const css::lang::EventObject& Source );
140
142 void
143 impl_notify( const css::ucb::ListEvent& Changes );
144};
145
146
148 : public cppu::OWeakObject
149 , public css::ucb::XDynamicResultSetListener
150{
152 std::mutex m_aMutex;
153
154public:
156
157 virtual ~DynamicResultSetWrapperListener() override;
158
159
160 // XInterface
161 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
162 virtual void SAL_CALL acquire()
163 noexcept override;
164 virtual void SAL_CALL release()
165 noexcept override;
166
167 // XEventListener ( base of XDynamicResultSetListener )
168
169 virtual void SAL_CALL
170 disposing( const css::lang::EventObject& Source ) override;
171
172 // XDynamicResultSetListener
173 virtual void SAL_CALL
174 notify( const css::ucb::ListEvent& Changes ) override;
175
176
177 // own methods:
178 void impl_OwnerDies();
179};
180
181
182/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL release() noexcept override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL notify(const css::ucb::ListEvent &Changes) override
DynamicResultSetWrapperListener(DynamicResultSetWrapper *pOwner)
rtl::Reference< DynamicResultSetWrapperListener > m_xMyListenerImpl
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Reference< css::ucb::XDynamicResultSet > m_xSource
virtual ~DynamicResultSetWrapper() 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
css::uno::Reference< css::ucb::XDynamicResultSetListener > m_xListener
virtual void SAL_CALL dispose() override
virtual void impl_disposing(const css::lang::EventObject &Source)
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aDisposeEventListeners
In dispose call.
virtual void SAL_CALL setSource(const css::uno::Reference< css::uno::XInterface > &Source) override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getStaticResultSet() override
virtual void SAL_CALL setListener(const css::uno::Reference< css::ucb::XDynamicResultSetListener > &Listener) override
DynamicResultSetWrapper(css::uno::Reference< css::ucb::XDynamicResultSet > const &xOrigin, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
void impl_notify(const css::ucb::ListEvent &Changes)
css::uno::Reference< css::sdbc::XResultSet > m_xMyResultOne
virtual void SAL_CALL connectToCache(const css::uno::Reference< css::ucb::XDynamicResultSet > &xCache) override
virtual sal_Int16 SAL_CALL getCapabilities() override
css::uno::Reference< css::sdbc::XResultSet > m_xSourceResultTwo
css::uno::Reference< css::sdbc::XResultSet > m_xSourceResultOne
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
css::uno::Reference< css::sdbc::XResultSet > m_xMyResultTwo
bool m_bInDispose
Dispose call ready.
virtual void impl_InitResultSetOne(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet)