LibreOffice Module dbaccess (master) 1
sbamultiplex.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 <com/sun/star/beans/XVetoableChangeListener.hpp>
23#include <com/sun/star/form/XDatabaseParameterListener.hpp>
24#include <com/sun/star/form/XLoadListener.hpp>
25#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
26#include <com/sun/star/beans/XPropertyChangeListener.hpp>
27#include <com/sun/star/form/XSubmitListener.hpp>
28#include <com/sun/star/form/XResetListener.hpp>
29#include <com/sun/star/sdb/XSQLErrorListener.hpp>
30#include <com/sun/star/sdb/XRowSetApproveListener.hpp>
31#include <com/sun/star/sdbc/XRowSetListener.hpp>
32#include <com/sun/star/frame/XStatusListener.hpp>
33#include <comphelper/uno3.hxx>
36#include <cppuhelper/weak.hxx>
37
38namespace dbaui
39{
40 // TODO : replace this class if MM provides a WeakSubObject in cppu
42 {
43 protected:
45
46 public:
48
49 virtual void SAL_CALL acquire() noexcept override { m_rParent.acquire(); }
50 virtual void SAL_CALL release() noexcept override { m_rParent.release(); }
51 };
52
53 // some listener multiplexers
54 // css::frame::XStatusListener
56 :public OSbaWeakSubObject
57 ,public css::frame::XStatusListener
58 ,public ::comphelper::OInterfaceContainerHelper3<css::frame::XStatusListener>
59 {
60 public:
61 SbaXStatusMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
63 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
64
65 /* css::lang::XEventListener */
66 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
67
68 virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& e) override;
69
70 private:
71 css::frame::FeatureStateEvent m_aLastKnownStatus;
72 public:
73 const css::frame::FeatureStateEvent& getLastEvent( ) const { return m_aLastKnownStatus; }
74 /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */
75 using OSbaWeakSubObject::operator new;
76 using OSbaWeakSubObject::operator delete;
77 };
78
79 // css::form::XLoadListener
81 :public OSbaWeakSubObject
82 ,public css::form::XLoadListener
83 ,public ::comphelper::OInterfaceContainerHelper3<css::form::XLoadListener>
84 {
85 public:
86 SbaXLoadMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
88 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
89
90 /* css::lang::XEventListener */
91 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
92
93 virtual void SAL_CALL loaded(const css::lang::EventObject& e) override;
94 virtual void SAL_CALL unloaded(const css::lang::EventObject& e) override;
95 virtual void SAL_CALL unloading(const css::lang::EventObject& e) override;
96 virtual void SAL_CALL reloading(const css::lang::EventObject& e) override;
97 virtual void SAL_CALL reloaded(const css::lang::EventObject& e) override;
98 /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */
99 using OSbaWeakSubObject::operator new;
100 using OSbaWeakSubObject::operator delete;
101 };
102
103 // css::form::XDatabaseParameterListener
105 :public OSbaWeakSubObject
106 ,public css::form::XDatabaseParameterListener
107 ,public ::comphelper::OInterfaceContainerHelper3<css::form::XDatabaseParameterListener>
108 {
109 public:
110 SbaXParameterMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
112 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
113
114 /* css::lang::XEventListener */
115 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
116 virtual sal_Bool SAL_CALL approveParameter(const css::form::DatabaseParameterEvent& e) override;
117 /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */
118 using OSbaWeakSubObject::operator new;
119 using OSbaWeakSubObject::operator delete;
120 };
121
122 // css::form::XSubmitListener
124 :public OSbaWeakSubObject
125 ,public css::form::XSubmitListener
126 ,public ::comphelper::OInterfaceContainerHelper3<css::form::XSubmitListener>
127 {
128 public:
129 SbaXSubmitMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
131 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
132
133 /* css::lang::XEventListener */
134 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
135 virtual sal_Bool SAL_CALL approveSubmit(const css::lang::EventObject& e) override;
136 /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */
137 using OSbaWeakSubObject::operator new;
138 using OSbaWeakSubObject::operator delete;
139 };
140
141 // css::form::XResetListener
143 :public OSbaWeakSubObject
144 ,public css::form::XResetListener
145 ,public ::comphelper::OInterfaceContainerHelper3<css::form::XResetListener>
146 {
147 public:
148 SbaXResetMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
150 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
151
152 /* css::lang::XEventListener */
153 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
154 virtual sal_Bool SAL_CALL approveReset(const css::lang::EventObject& e) override;
155 virtual void SAL_CALL resetted(const css::lang::EventObject& e) override;
156 /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */
157 using OSbaWeakSubObject::operator new;
158 using OSbaWeakSubObject::operator delete;
159 };
160
161 // css::sdbc::XRowSetListener
163 :public OSbaWeakSubObject
164 ,public css::sdbc::XRowSetListener
165 ,public ::comphelper::OInterfaceContainerHelper3<css::sdbc::XRowSetListener>
166 {
167 public:
168 SbaXRowSetMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
170 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
171
172 /* css::lang::XEventListener */
173 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
174 virtual void SAL_CALL cursorMoved(const css::lang::EventObject& e) override;
175 virtual void SAL_CALL rowChanged(const css::lang::EventObject& e) override;
176 virtual void SAL_CALL rowSetChanged(const css::lang::EventObject& e) override;
177 /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */
178 using OSbaWeakSubObject::operator new;
179 using OSbaWeakSubObject::operator delete;
180 };
181
182 // css::sdb::XRowSetApproveListener
184 :public OSbaWeakSubObject
185 ,public css::sdb::XRowSetApproveListener
186 ,public ::comphelper::OInterfaceContainerHelper3<css::sdb::XRowSetApproveListener>
187 {
188 public:
189 SbaXRowSetApproveMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
191 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
192
193 /* css::lang::XEventListener */
194 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
195 virtual sal_Bool SAL_CALL approveCursorMove(const css::lang::EventObject& e) override;
196 virtual sal_Bool SAL_CALL approveRowChange(const css::sdb::RowChangeEvent& e) override;
197 virtual sal_Bool SAL_CALL approveRowSetChange(const css::lang::EventObject& e) override;
198 /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */
199 using OSbaWeakSubObject::operator new;
200 using OSbaWeakSubObject::operator delete;
201 };
202
203 // css::sdb::XSQLErrorListener
205 :public OSbaWeakSubObject
206 ,public css::sdb::XSQLErrorListener
207 ,public ::comphelper::OInterfaceContainerHelper3<css::sdb::XSQLErrorListener>
208 {
209 public:
210 SbaXSQLErrorMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
212 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
213
214 /* css::lang::XEventListener */
215 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
216 virtual void SAL_CALL errorOccured(const css::sdb::SQLErrorEvent& e) override;
217 /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */
218 using OSbaWeakSubObject::operator new;
219 using OSbaWeakSubObject::operator delete;
220 };
221
222 // css::beans::XPropertyChangeListener
224 :public OSbaWeakSubObject
225 ,public css::beans::XPropertyChangeListener
226 {
227 typedef ::comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XPropertyChangeListener, OUString> ListenerContainerMap;
229
230 public:
231 SbaXPropertyChangeMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex );
233 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
234
235 /* css::lang::XEventListener */
236 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
237
238 virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& e) override;
239
240 void addInterface(const OUString& rName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rListener);
241 void removeInterface(const OUString& rName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rListener);
242
243 void disposeAndClear();
244
245 sal_Int32 getOverallLen() const;
246
248 { return m_aListeners.getContainer(rName); }
249
250 private:
251 void Notify(::comphelper::OInterfaceContainerHelper3<css::beans::XPropertyChangeListener>& rListeners, const css::beans::PropertyChangeEvent& e);
252 };
253
254 // css::beans::XVetoableChangeListener
256 :public OSbaWeakSubObject
257 ,public css::beans::XVetoableChangeListener
258 {
259 typedef ::comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XVetoableChangeListener, OUString > ListenerContainerMap;
261
262 public:
263 SbaXVetoableChangeMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex );
265 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
266
267 /* css::lang::XEventListener */
268 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
269
270 virtual void SAL_CALL vetoableChange(const css::beans::PropertyChangeEvent& e) override;
271
272 void addInterface(const OUString& rName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rListener);
273 void removeInterface(const OUString& rName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rListener);
274
275 void disposeAndClear();
276
277 sal_Int32 getOverallLen() const;
278
279 private:
280 void Notify(::comphelper::OInterfaceContainerHelper3<css::beans::XVetoableChangeListener>& rListeners, const css::beans::PropertyChangeEvent& e);
281 };
282
283 // css::beans::XPropertiesChangeListener
285 :public OSbaWeakSubObject
286 ,public css::beans::XPropertiesChangeListener
287 ,public ::comphelper::OInterfaceContainerHelper3<css::beans::XPropertiesChangeListener>
288 {
289 public:
290 SbaXPropertiesChangeMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
292 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
293
294 /* css::lang::XEventListener */
295 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
296 virtual void SAL_CALL propertiesChange(const css::uno::Sequence< css::beans::PropertyChangeEvent >& e) override;
297 /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */
298 using OSbaWeakSubObject::operator new;
299 using OSbaWeakSubObject::operator delete;
300 };
301 // the SbaXPropertiesChangeMultiplexer doesn't care about the property names a listener logs on for, it simply
302 // forwards _all_ changes to _all_ listeners
303}
304
305/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OInterfaceContainerHelper3< listener > * getContainer(const key &rKey) const
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
::cppu::OWeakObject & m_rParent
virtual void SAL_CALL acquire() noexcept override
OSbaWeakSubObject(::cppu::OWeakObject &rParent)
virtual void SAL_CALL release() noexcept override
virtual void SAL_CALL unloading(const css::lang::EventObject &e) override
virtual void SAL_CALL loaded(const css::lang::EventObject &e) override
virtual void SAL_CALL reloading(const css::lang::EventObject &e) override
SbaXLoadMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL reloaded(const css::lang::EventObject &e) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
virtual void SAL_CALL unloaded(const css::lang::EventObject &e) override
SbaXParameterMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual sal_Bool SAL_CALL approveParameter(const css::form::DatabaseParameterEvent &e) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
SbaXPropertiesChangeMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL propertiesChange(const css::uno::Sequence< css::beans::PropertyChangeEvent > &e) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
::comphelper::OInterfaceContainerHelper3< css::beans::XPropertyChangeListener > * getContainer(const OUString &rName)
void removeInterface(const OUString &rName, const css::uno::Reference< css::beans::XPropertyChangeListener > &rListener)
SbaXPropertyChangeMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
void Notify(::comphelper::OInterfaceContainerHelper3< css::beans::XPropertyChangeListener > &rListeners, const css::beans::PropertyChangeEvent &e)
void addInterface(const OUString &rName, const css::uno::Reference< css::beans::XPropertyChangeListener > &rListener)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &e) override
::comphelper::OMultiTypeInterfaceContainerHelperVar3< css::beans::XPropertyChangeListener, OUString > ListenerContainerMap
virtual sal_Bool SAL_CALL approveReset(const css::lang::EventObject &e) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
SbaXResetMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
virtual void SAL_CALL resetted(const css::lang::EventObject &e) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
SbaXRowSetApproveMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
virtual sal_Bool SAL_CALL approveCursorMove(const css::lang::EventObject &e) override
virtual sal_Bool SAL_CALL approveRowChange(const css::sdb::RowChangeEvent &e) override
virtual sal_Bool SAL_CALL approveRowSetChange(const css::lang::EventObject &e) override
virtual void SAL_CALL cursorMoved(const css::lang::EventObject &e) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
SbaXRowSetMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
virtual void SAL_CALL rowChanged(const css::lang::EventObject &e) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL rowSetChanged(const css::lang::EventObject &e) override
virtual void SAL_CALL errorOccured(const css::sdb::SQLErrorEvent &e) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
SbaXSQLErrorMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &e) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
const css::frame::FeatureStateEvent & getLastEvent() const
SbaXStatusMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
css::frame::FeatureStateEvent m_aLastKnownStatus
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
SbaXSubmitMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
virtual sal_Bool SAL_CALL approveSubmit(const css::lang::EventObject &e) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
void removeInterface(const OUString &rName, const css::uno::Reference< css::beans::XVetoableChangeListener > &rListener)
void addInterface(const OUString &rName, const css::uno::Reference< css::beans::XVetoableChangeListener > &rListener)
SbaXVetoableChangeMultiplexer(::cppu::OWeakObject &rSource, ::osl::Mutex &rMutex)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void Notify(::comphelper::OInterfaceContainerHelper3< css::beans::XVetoableChangeListener > &rListeners, const css::beans::PropertyChangeEvent &e)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
virtual void SAL_CALL vetoableChange(const css::beans::PropertyChangeEvent &e) override
::comphelper::OMultiTypeInterfaceContainerHelperVar3< css::beans::XVetoableChangeListener, OUString > ListenerContainerMap
unsigned char sal_Bool
#define DECLARE_UNO3_DEFAULTS(classname, baseclass)