tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / dbaccess / source / ui / inc / sbamultiplex.hxx
blob47fd753d4af6de0510463c3f98e6d2e808cbb395
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 #pragma once
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>
34 #include <comphelper/interfacecontainer3.hxx>
35 #include <comphelper/multiinterfacecontainer3.hxx>
36 #include <cppuhelper/weak.hxx>
38 namespace dbaui
40 // TODO : replace this class if MM provides a WeakSubObject in cppu
41 class OSbaWeakSubObject : public ::cppu::OWeakObject
43 protected:
44 ::cppu::OWeakObject& m_rParent;
46 public:
47 OSbaWeakSubObject(::cppu::OWeakObject& rParent) : m_rParent(rParent) { }
49 virtual void SAL_CALL acquire() noexcept override { m_rParent.acquire(); }
50 virtual void SAL_CALL release() noexcept override { m_rParent.release(); }
53 // some listener multiplexers
54 // css::frame::XStatusListener
55 class SbaXStatusMultiplexer
56 :public OSbaWeakSubObject
57 ,public css::frame::XStatusListener
58 ,public ::comphelper::OInterfaceContainerHelper3<css::frame::XStatusListener>
60 public:
61 SbaXStatusMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
62 DECLARE_UNO3_DEFAULTS(SbaXStatusMultiplexer, OSbaWeakSubObject)
63 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
65 /* css::lang::XEventListener */
66 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
68 virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& e) override;
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;
79 // css::form::XLoadListener
80 class SbaXLoadMultiplexer
81 :public OSbaWeakSubObject
82 ,public css::form::XLoadListener
83 ,public ::comphelper::OInterfaceContainerHelper3<css::form::XLoadListener>
85 public:
86 SbaXLoadMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
87 DECLARE_UNO3_DEFAULTS(SbaXLoadMultiplexer, OSbaWeakSubObject)
88 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
90 /* css::lang::XEventListener */
91 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
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;
103 // css::form::XDatabaseParameterListener
104 class SbaXParameterMultiplexer
105 :public OSbaWeakSubObject
106 ,public css::form::XDatabaseParameterListener
107 ,public ::comphelper::OInterfaceContainerHelper3<css::form::XDatabaseParameterListener>
109 public:
110 SbaXParameterMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
111 DECLARE_UNO3_DEFAULTS(SbaXParameterMultiplexer, OSbaWeakSubObject)
112 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
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;
122 // css::form::XSubmitListener
123 class SbaXSubmitMultiplexer
124 :public OSbaWeakSubObject
125 ,public css::form::XSubmitListener
126 ,public ::comphelper::OInterfaceContainerHelper3<css::form::XSubmitListener>
128 public:
129 SbaXSubmitMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
130 DECLARE_UNO3_DEFAULTS(SbaXSubmitMultiplexer, OSbaWeakSubObject)
131 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
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;
141 // css::form::XResetListener
142 class SbaXResetMultiplexer
143 :public OSbaWeakSubObject
144 ,public css::form::XResetListener
145 ,public ::comphelper::OInterfaceContainerHelper3<css::form::XResetListener>
147 public:
148 SbaXResetMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
149 DECLARE_UNO3_DEFAULTS(SbaXResetMultiplexer, OSbaWeakSubObject)
150 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
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;
161 // css::sdbc::XRowSetListener
162 class SbaXRowSetMultiplexer
163 :public OSbaWeakSubObject
164 ,public css::sdbc::XRowSetListener
165 ,public ::comphelper::OInterfaceContainerHelper3<css::sdbc::XRowSetListener>
167 public:
168 SbaXRowSetMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
169 DECLARE_UNO3_DEFAULTS(SbaXRowSetMultiplexer, OSbaWeakSubObject)
170 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
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;
182 // css::sdb::XRowSetApproveListener
183 class SbaXRowSetApproveMultiplexer
184 :public OSbaWeakSubObject
185 ,public css::sdb::XRowSetApproveListener
186 ,public ::comphelper::OInterfaceContainerHelper3<css::sdb::XRowSetApproveListener>
188 public:
189 SbaXRowSetApproveMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
190 DECLARE_UNO3_DEFAULTS(SbaXRowSetApproveMultiplexer, OSbaWeakSubObject)
191 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
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;
203 // css::sdb::XSQLErrorListener
204 class SbaXSQLErrorMultiplexer
205 :public OSbaWeakSubObject
206 ,public css::sdb::XSQLErrorListener
207 ,public ::comphelper::OInterfaceContainerHelper3<css::sdb::XSQLErrorListener>
209 public:
210 SbaXSQLErrorMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
211 DECLARE_UNO3_DEFAULTS(SbaXSQLErrorMultiplexer, OSbaWeakSubObject)
212 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
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;
222 // css::beans::XPropertyChangeListener
223 class SbaXPropertyChangeMultiplexer final
224 :public OSbaWeakSubObject
225 ,public css::beans::XPropertyChangeListener
227 typedef ::comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XPropertyChangeListener, OUString> ListenerContainerMap;
228 ListenerContainerMap m_aListeners;
230 public:
231 SbaXPropertyChangeMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex );
232 DECLARE_UNO3_DEFAULTS(SbaXPropertyChangeMultiplexer, OSbaWeakSubObject)
233 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
235 /* css::lang::XEventListener */
236 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
238 virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& e) override;
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);
243 void disposeAndClear();
245 sal_Int32 getOverallLen() const;
247 ::comphelper::OInterfaceContainerHelper3<css::beans::XPropertyChangeListener>* getContainer(const OUString& rName)
248 { return m_aListeners.getContainer(rName); }
250 private:
251 void Notify(::comphelper::OInterfaceContainerHelper3<css::beans::XPropertyChangeListener>& rListeners, const css::beans::PropertyChangeEvent& e);
254 // css::beans::XVetoableChangeListener
255 class SbaXVetoableChangeMultiplexer final
256 :public OSbaWeakSubObject
257 ,public css::beans::XVetoableChangeListener
259 typedef ::comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XVetoableChangeListener, OUString > ListenerContainerMap;
260 ListenerContainerMap m_aListeners;
262 public:
263 SbaXVetoableChangeMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex );
264 DECLARE_UNO3_DEFAULTS(SbaXVetoableChangeMultiplexer, OSbaWeakSubObject)
265 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
267 /* css::lang::XEventListener */
268 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
270 virtual void SAL_CALL vetoableChange(const css::beans::PropertyChangeEvent& e) override;
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);
275 void disposeAndClear();
277 sal_Int32 getOverallLen() const;
279 private:
280 void Notify(::comphelper::OInterfaceContainerHelper3<css::beans::XVetoableChangeListener>& rListeners, const css::beans::PropertyChangeEvent& e);
283 // css::beans::XPropertiesChangeListener
284 class SbaXPropertiesChangeMultiplexer
285 :public OSbaWeakSubObject
286 ,public css::beans::XPropertiesChangeListener
287 ,public ::comphelper::OInterfaceContainerHelper3<css::beans::XPropertiesChangeListener>
289 public:
290 SbaXPropertiesChangeMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
291 DECLARE_UNO3_DEFAULTS(SbaXPropertiesChangeMultiplexer, OSbaWeakSubObject)
292 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
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;
301 // the SbaXPropertiesChangeMultiplexer doesn't care about the property names a listener logs on for, it simply
302 // forwards _all_ changes to _all_ listeners
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */