Line data Source code
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 : #ifndef INCLUDED_SVX_FMGRIDIF_HXX
20 : #define INCLUDED_SVX_FMGRIDIF_HXX
21 :
22 : #include <svx/svxdllapi.h>
23 :
24 : #include <com/sun/star/view/XSelectionSupplier.hpp>
25 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 : #include <com/sun/star/container/XEnumerationAccess.hpp>
27 : #include <com/sun/star/container/XContainer.hpp>
28 : #include <com/sun/star/container/XContainerListener.hpp>
29 : #include <com/sun/star/sdbc/XRowSetListener.hpp>
30 : #include <com/sun/star/sdb/XRowSetSupplier.hpp>
31 : #include <com/sun/star/form/XReset.hpp>
32 : #include <com/sun/star/form/XBoundComponent.hpp>
33 : #include <com/sun/star/form/XLoadListener.hpp>
34 : #include <com/sun/star/form/XGridControl.hpp>
35 : #include <com/sun/star/form/XGridPeer.hpp>
36 : #include <com/sun/star/frame/XDispatchProvider.hpp>
37 : #include <com/sun/star/frame/XStatusListener.hpp>
38 : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
39 : #include <com/sun/star/view/XSelectionChangeListener.hpp>
40 : #include <com/sun/star/uno/XComponentContext.hpp>
41 : #include <com/sun/star/util/XModeSelector.hpp>
42 : #include <com/sun/star/util/XModifyListener.hpp>
43 : #include <com/sun/star/util/XModifyBroadcaster.hpp>
44 :
45 : #include <tools/wintypes.hxx>
46 : #include <toolkit/controls/unocontrol.hxx>
47 : #include <toolkit/awt/vclxwindow.hxx>
48 : #include <comphelper/uno3.hxx>
49 : #include <cppuhelper/implbase.hxx>
50 : #include <cppuhelper/implbase10.hxx>
51 :
52 : class DbGridColumn;
53 :
54 60 : class SAL_WARN_UNUSED OWeakSubObject : public ::cppu::OWeakObject
55 : {
56 : protected:
57 : ::cppu::OWeakObject& m_rParent;
58 :
59 : public:
60 60 : OWeakSubObject(::cppu::OWeakObject& rParent) : m_rParent(rParent) { }
61 :
62 4 : virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { m_rParent.acquire(); }
63 4 : virtual void SAL_CALL release() throw() SAL_OVERRIDE { m_rParent.release(); }
64 : };
65 :
66 :
67 : // FmXModifyMultiplexer
68 :
69 12 : class SAL_WARN_UNUSED FmXModifyMultiplexer :public OWeakSubObject
70 : ,public ::cppu::OInterfaceContainerHelper
71 : ,public ::com::sun::star::util::XModifyListener
72 : {
73 : public:
74 : FmXModifyMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex );
75 8 : DECLARE_UNO3_DEFAULTS(FmXModifyMultiplexer,OWeakSubObject)
76 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
77 :
78 : // ::com::sun::star::lang::XEventListener
79 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 :
81 : // ::com::sun::star::util::XModifyListener
82 : virtual void SAL_CALL modified(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 :
84 : // resolve ambiguity : both OWeakObject and OInterfaceContainerHelper have these memory operators
85 : void * SAL_CALL operator new( size_t size ) throw() { return OWeakSubObject::operator new(size); }
86 0 : void SAL_CALL operator delete( void * p ) throw() { OWeakSubObject::operator delete(p); }
87 : };
88 :
89 :
90 : // FmXUpdateMultiplexer
91 :
92 12 : class SAL_WARN_UNUSED FmXUpdateMultiplexer : public OWeakSubObject,
93 : public ::cppu::OInterfaceContainerHelper,
94 : public ::com::sun::star::form::XUpdateListener
95 : {
96 : public:
97 : FmXUpdateMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex );
98 0 : DECLARE_UNO3_DEFAULTS(FmXUpdateMultiplexer,OWeakSubObject)
99 :
100 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 :
102 : // ::com::sun::star::lang::XEventListener
103 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 :
105 : // ::com::sun::star::form::XUpdateListener
106 : virtual sal_Bool SAL_CALL approveUpdate(const ::com::sun::star::lang::EventObject &) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 : virtual void SAL_CALL updated(const ::com::sun::star::lang::EventObject &) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 :
109 : // resolve ambiguity : both OWeakObject and OInterfaceContainerHelper have these memory operators
110 : void * SAL_CALL operator new( size_t size ) throw() { return OWeakSubObject::operator new(size); }
111 0 : void SAL_CALL operator delete( void * p ) throw() { OWeakSubObject::operator delete(p); }
112 : };
113 :
114 :
115 : // FmXSelectionMultiplexer
116 :
117 12 : class SAL_WARN_UNUSED FmXSelectionMultiplexer :public OWeakSubObject
118 : ,public ::cppu::OInterfaceContainerHelper
119 : ,public ::com::sun::star::view::XSelectionChangeListener
120 : {
121 : public:
122 : FmXSelectionMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex );
123 0 : DECLARE_UNO3_DEFAULTS(FmXSelectionMultiplexer, OWeakSubObject)
124 :
125 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 :
127 : // ::com::sun::star::lang::XEventListener
128 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 :
130 : // ::com::sun::star::view::XSelectionChangeListener
131 : virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 :
133 : // resolve ambiguity : both OWeakObject and OInterfaceContainerHelper have these memory operators
134 : void * SAL_CALL operator new( size_t size ) throw() { return OWeakSubObject::operator new(size); }
135 0 : void SAL_CALL operator delete( void * p ) throw() { OWeakSubObject::operator delete(p); }
136 : };
137 :
138 :
139 : // FmXGridControlMultiplexer
140 :
141 12 : class SAL_WARN_UNUSED FmXGridControlMultiplexer :public OWeakSubObject
142 : ,public ::cppu::OInterfaceContainerHelper
143 : ,public ::com::sun::star::form::XGridControlListener
144 : {
145 : public:
146 : FmXGridControlMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex );
147 0 : DECLARE_UNO3_DEFAULTS( FmXGridControlMultiplexer, OWeakSubObject )
148 :
149 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
150 :
151 : // ::com::sun::star::lang::XEventListener
152 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
153 :
154 : // ::com::sun::star::view::XSelectionChangeListener
155 : virtual void SAL_CALL columnChanged( const ::com::sun::star::lang::EventObject& _event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
156 :
157 : // resolve ambiguity : both OWeakObject and OInterfaceContainerHelper have these memory operators
158 : void * SAL_CALL operator new( size_t size ) throw() { return OWeakSubObject::operator new(size); }
159 0 : void SAL_CALL operator delete( void * p ) throw() { OWeakSubObject::operator delete(p); }
160 : };
161 :
162 :
163 : // FmXContainerMultiplexer
164 :
165 12 : class SAL_WARN_UNUSED FmXContainerMultiplexer : public OWeakSubObject,
166 : public ::cppu::OInterfaceContainerHelper,
167 : public ::com::sun::star::container::XContainerListener
168 : {
169 : public:
170 : FmXContainerMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex);
171 0 : DECLARE_UNO3_DEFAULTS(FmXContainerMultiplexer,OWeakSubObject)
172 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 :
174 : // ::com::sun::star::lang::XEventListener
175 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 :
177 : // ::com::sun::star::container::XContainerListener
178 : virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 : virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 : virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 :
182 : // resolve ambiguity : both OWeakObject and OInterfaceContainerHelper have these memory operators
183 : void * SAL_CALL operator new( size_t size ) throw() { return OWeakSubObject::operator new(size); }
184 0 : void SAL_CALL operator delete( void * p ) throw() { OWeakSubObject::operator delete(p); }
185 : };
186 :
187 :
188 : // FmXGridControl
189 :
190 : typedef ::cppu::ImplHelper10< ::com::sun::star::form::XBoundComponent,
191 : ::com::sun::star::form::XGridControl,
192 : ::com::sun::star::util::XModifyBroadcaster,
193 : ::com::sun::star::container::XIndexAccess,
194 : ::com::sun::star::container::XEnumerationAccess,
195 : ::com::sun::star::util::XModeSelector,
196 : ::com::sun::star::container::XContainer,
197 : ::com::sun::star::frame::XDispatchProvider,
198 : ::com::sun::star::frame::XDispatchProviderInterception,
199 : ::com::sun::star::view::XSelectionSupplier
200 : > FmXGridControl_BASE;
201 :
202 : class FmXGridPeer;
203 : class SVX_DLLPUBLIC SAL_WARN_UNUSED FmXGridControl :public UnoControl
204 : ,public FmXGridControl_BASE
205 : {
206 : FmXModifyMultiplexer m_aModifyListeners;
207 : FmXUpdateMultiplexer m_aUpdateListeners;
208 : FmXContainerMultiplexer m_aContainerListeners;
209 : FmXSelectionMultiplexer m_aSelectionListeners;
210 : FmXGridControlMultiplexer m_aGridControlListeners;
211 :
212 : protected:
213 : sal_uInt16 m_nPeerCreationLevel;
214 : bool m_bInDraw;
215 :
216 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
217 :
218 : public:
219 : FmXGridControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
220 : virtual ~FmXGridControl();
221 :
222 : // UNO connection
223 5252 : DECLARE_UNO3_AGG_DEFAULTS(FmXGridControl, UnoControl)
224 : virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
225 :
226 : // XTypeProvider
227 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
228 : virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
229 :
230 : // ::com::sun::star::lang::XComponent
231 : virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
232 :
233 : // ::com::sun::star::lang::XServiceInfo
234 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(std::exception) SAL_OVERRIDE;
235 : virtual OUString SAL_CALL getImplementationName() throw(std::exception) SAL_OVERRIDE;
236 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
237 :
238 : // ::com::sun::star::awt::XControl
239 : virtual void SAL_CALL createPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& _rToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
240 : virtual sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
241 : virtual void SAL_CALL setDesignMode(sal_Bool bOn) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
242 :
243 : // ::com::sun::star::awt::XView
244 : virtual void SAL_CALL draw( sal_Int32 x, sal_Int32 y ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
245 :
246 : // ::com::sun::star::form::XBoundComponent
247 : virtual void SAL_CALL addUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
248 : virtual void SAL_CALL removeUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
249 : virtual sal_Bool SAL_CALL commit() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
250 :
251 : // ::com::sun::star::container::XElementAccess
252 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
253 : virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
254 :
255 : // ::com::sun::star::container::XEnumerationAccess
256 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
257 :
258 : // ::com::sun::star::container::XIndexAccess
259 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
260 : virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 _rIndex) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
261 :
262 : // ::com::sun::star::form::XGridControl
263 : virtual void SAL_CALL addGridControlListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XGridControlListener >& _listener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
264 : virtual void SAL_CALL removeGridControlListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XGridControlListener >& _listener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
265 :
266 : // ::com::sun::star::form::XGrid (base of XGridControl)
267 : virtual sal_Int16 SAL_CALL getCurrentColumnPosition() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
268 : virtual void SAL_CALL setCurrentColumnPosition(sal_Int16 nPos) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
269 :
270 : // ::com::sun::star::form::XGridFieldDataSupplier (base of XGridControl)
271 : virtual ::com::sun::star::uno::Sequence< sal_Bool > SAL_CALL queryFieldDataType( const ::com::sun::star::uno::Type& xType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
272 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL queryFieldData( sal_Int32 nRow, const ::com::sun::star::uno::Type& xType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
273 :
274 : // UnoControl
275 : virtual OUString GetComponentServiceName() SAL_OVERRIDE;
276 :
277 : // ::com::sun::star::util::XModifyBroadcaster
278 : virtual void SAL_CALL addModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
279 : virtual void SAL_CALL removeModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
280 :
281 : // ::com::sun::star::util::XModeSelector
282 : virtual void SAL_CALL setMode(const OUString& Mode) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
283 : virtual OUString SAL_CALL getMode() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
284 : virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL getSupportedModes() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
285 : virtual sal_Bool SAL_CALL supportsMode(const OUString& Mode) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
286 :
287 : // ::com::sun::star::container::XContainer
288 : virtual void SAL_CALL addContainerListener(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
289 : virtual void SAL_CALL removeContainerListener(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
290 :
291 : // ::com::sun::star::frame::XDispatchProvider
292 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch(const ::com::sun::star::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
293 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches(const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
294 :
295 : // ::com::sun::star::frame::XDispatchProviderInterception
296 : virtual void SAL_CALL registerDispatchProviderInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& xInterceptor) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
297 : virtual void SAL_CALL releaseDispatchProviderInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& xInterceptor) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
298 :
299 : // ::com::sun::star::view::XSelectionSupplier
300 : virtual sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& aSelection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
301 : virtual ::com::sun::star::uno::Any SAL_CALL getSelection( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
302 : virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
303 : virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
304 :
305 : protected:
306 : virtual FmXGridPeer* imp_CreatePeer(vcl::Window* pParent);
307 : // ImplCreatePeer would be better, but doesn't work because it's not exported
308 :
309 : };
310 :
311 :
312 : // FmXGridPeer -> Peer for the Gridcontrol
313 :
314 : class FmGridControl;
315 : class SVX_DLLPUBLIC SAL_WARN_UNUSED FmXGridPeer:
316 : public cppu::ImplInheritanceHelper<
317 : VCLXWindow,
318 : css::form::XGridPeer,
319 : css::form::XBoundComponent,
320 : css::form::XGridControl,
321 : css::sdb::XRowSetSupplier,
322 : css::util::XModifyBroadcaster,
323 : css::beans::XPropertyChangeListener,
324 : css::container::XContainerListener,
325 : css::sdbc::XRowSetListener,
326 : css::form::XLoadListener,
327 : css::view::XSelectionChangeListener,
328 : css::container::XIndexAccess,
329 : css::container::XEnumerationAccess,
330 : css::util::XModeSelector,
331 : css::container::XContainer,
332 : css::frame::XStatusListener,
333 : css::frame::XDispatchProvider,
334 : css::frame::XDispatchProviderInterception,
335 : css::form::XResetListener,
336 : css::view::XSelectionSupplier>
337 : {
338 : css::uno::Reference< css::container::XIndexContainer > m_xColumns;
339 : css::uno::Reference< css::sdbc::XRowSet > m_xCursor;
340 : ::cppu::OInterfaceContainerHelper m_aModifyListeners,
341 : m_aUpdateListeners,
342 : m_aContainerListeners,
343 : m_aSelectionListeners,
344 : m_aGridControlListeners;
345 :
346 : OUString m_aMode;
347 : sal_Int32 m_nCursorListening;
348 :
349 : css::uno::Reference< css::frame::XDispatchProviderInterceptor > m_xFirstDispatchInterceptor;
350 :
351 : bool m_bInterceptingDispatch;
352 :
353 : bool* m_pStateCache;
354 : // one bool for each supported url
355 : css::uno::Reference< css::frame::XDispatch > * m_pDispatchers;
356 : // one dispatcher for each supported url
357 : // (I would like to have a vector here but including the stl in an exported file seems
358 : // very risky to me ....)
359 :
360 : class GridListenerDelegator;
361 : friend class GridListenerDelegator;
362 : GridListenerDelegator* m_pGridListener;
363 :
364 : protected:
365 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
366 : ::osl::Mutex m_aMutex;
367 :
368 : public:
369 : FmXGridPeer(const css::uno::Reference< css::uno::XComponentContext >&);
370 : virtual ~FmXGridPeer();
371 :
372 : // spaeter Constructor, immer nach dem realen Constructor zu rufen !
373 : void Create(vcl::Window* pParent, WinBits nStyle);
374 :
375 : // ::com::sun::star::lang::XUnoTunnel
376 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelImplementationId() throw();
377 : static FmXGridPeer* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIFace ) throw();
378 : sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& _rIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
379 :
380 : // ::com::sun::star::form::XGridPeer
381 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
382 : virtual void SAL_CALL setColumns( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& aColumns ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
383 :
384 : // ::com::sun::star::lang::XComponent
385 : virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
386 :
387 : // ::com::sun::star::lang::XEventListener
388 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
389 :
390 : // ::com::sun::star::form::XBoundComponent
391 : virtual void SAL_CALL addUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
392 : virtual void SAL_CALL removeUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
393 : virtual sal_Bool SAL_CALL commit() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
394 :
395 : // ::com::sun::star::container::XElementAccess
396 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
397 : virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
398 :
399 : // ::com::sun::star::container::XEnumerationAccess
400 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
401 :
402 : // ::com::sun::star::container::XIndexAccess
403 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
404 : virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 _rIndex) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
405 :
406 : // ::com::sun::star::beans::XPropertyChangeListener
407 : virtual void SAL_CALL SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
408 :
409 : // ::com::sun::star::form::XLoadListener
410 : virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
411 : virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
412 : virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
413 : virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
414 : virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
415 :
416 : // ::com::sun::star::sdbc::XRowSetListener
417 : virtual void SAL_CALL cursorMoved(const ::com::sun::star::lang::EventObject& event) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
418 : virtual void SAL_CALL rowChanged(const ::com::sun::star::lang::EventObject& event) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
419 : virtual void SAL_CALL rowSetChanged(const ::com::sun::star::lang::EventObject& event) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
420 :
421 : // ::com::sun::star::container::XContainerListener
422 : virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
423 : virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
424 : virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
425 :
426 : // VCLXWindow
427 : virtual void SAL_CALL setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
428 : virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
429 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
430 : CreateAccessibleContext() SAL_OVERRIDE;
431 :
432 : // ::com::sun::star::form::XGridControl
433 : virtual void SAL_CALL addGridControlListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XGridControlListener >& _listener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
434 : virtual void SAL_CALL removeGridControlListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XGridControlListener >& _listener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
435 :
436 : // ::com::sun::star::form::XGrid (base of XGridControl)
437 : virtual sal_Int16 SAL_CALL getCurrentColumnPosition() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
438 : virtual void SAL_CALL setCurrentColumnPosition(sal_Int16 nPos) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
439 :
440 : // ::com::sun::star::form::XGridFieldDataSupplier (base of XGridControl)
441 : virtual ::com::sun::star::uno::Sequence< sal_Bool > SAL_CALL queryFieldDataType( const ::com::sun::star::uno::Type& xType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
442 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL queryFieldData( sal_Int32 nRow, const ::com::sun::star::uno::Type& xType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
443 :
444 : // ::com::sun::star::sdb::XRowSetSupplier
445 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > SAL_CALL getRowSet() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
446 : virtual void SAL_CALL setRowSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xDataSource) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
447 :
448 : // ::com::sun::star::util::XModifyBroadcaster
449 : virtual void SAL_CALL addModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
450 : virtual void SAL_CALL removeModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
451 :
452 : // UnoControl
453 : virtual void SAL_CALL SAL_CALL setDesignMode(sal_Bool bOn) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
454 : virtual sal_Bool SAL_CALL isDesignMode() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
455 :
456 : // ::com::sun::star::view::XSelectionChangeListener
457 : virtual void SAL_CALL selectionChanged(const ::com::sun::star::lang::EventObject& aEvent) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
458 :
459 : void CellModified();
460 :
461 : // PropertyListening
462 : void updateGrid(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rDatabaseCursor);
463 : void startCursorListening();
464 : void stopCursorListening();
465 :
466 : // ::com::sun::star::util::XModeSelector
467 : virtual void SAL_CALL setMode(const OUString& Mode) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
468 : virtual OUString SAL_CALL getMode() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
469 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedModes() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
470 : virtual sal_Bool SAL_CALL supportsMode(const OUString& Mode) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
471 :
472 : // ::com::sun::star::container::XContainer
473 : virtual void SAL_CALL addContainerListener(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
474 : virtual void SAL_CALL removeContainerListener(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& l) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
475 :
476 : void columnVisible(DbGridColumn* pColumn);
477 : void columnHidden(DbGridColumn* pColumn);
478 :
479 : // ::com::sun::star::awt::XView
480 : virtual void SAL_CALL draw( sal_Int32 x, sal_Int32 y ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
481 :
482 : // ::com::sun::star::frame::XDispatchProvider
483 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch(const ::com::sun::star::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
484 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches(const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
485 :
486 : // ::com::sun::star::frame::XDispatchProviderInterception
487 : virtual void SAL_CALL registerDispatchProviderInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& xInterceptor) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
488 : virtual void SAL_CALL releaseDispatchProviderInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& xInterceptor) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
489 :
490 : // ::com::sun::star::frame::XStatusListener
491 : virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
492 :
493 : // ::com::sun::star::form::XResetListener
494 : virtual sal_Bool SAL_CALL approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
495 : virtual void SAL_CALL resetted(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
496 :
497 : // ::com::sun::star::view::XSelectionSupplier
498 : virtual sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& aSelection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
499 : virtual ::com::sun::star::uno::Any SAL_CALL getSelection( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
500 : virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
501 : virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
502 :
503 : protected:
504 : virtual VclPtr<FmGridControl> imp_CreateControl(vcl::Window* pParent, WinBits nStyle);
505 :
506 : static ::com::sun::star::uno::Sequence< ::com::sun::star::util::URL>& getSupportedURLs();
507 : static ::com::sun::star::uno::Sequence<sal_uInt16>& getSupportedGridSlots();
508 : void ConnectToDispatcher();
509 : void DisConnectFromDispatcher();
510 : void UpdateDispatches(); // will connect if not already connected and just update else
511 :
512 : /** If a derived class wants to listen at some column properties, it doesn't have
513 : to override all methods affecting columns (setColumns, elementInserted, elementRemoved ...)
514 : Instead it may use addColumnListeners and removeColumnListeners which are called in all
515 : the cases.
516 : */
517 : void addColumnListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xCol);
518 : void removeColumnListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xCol);
519 :
520 : void selectionChanged();
521 : void columnChanged();
522 :
523 : DECL_LINK(OnQueryGridSlotState, void*);
524 : DECL_LINK(OnExecuteGridSlot, void*);
525 : };
526 :
527 :
528 :
529 : #endif // _SVX_FMGRID_HXX
530 :
531 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|