update dev300-m58
[ooovba.git] / forms / source / inc / FormComponent.hxx
blob85f3c3e5f22abc7384edcfad981571addaeb7119
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FormComponent.hxx,v $
10 * $Revision: 1.23 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _FORMS_FORMCOMPONENT_HXX_
32 #define _FORMS_FORMCOMPONENT_HXX_
34 #include "cloneable.hxx"
35 #include "ids.hxx"
36 #include "property.hrc"
37 #include "property.hxx"
38 #include "propertybaghelper.hxx"
39 #include "resettable.hxx"
40 #include "services.hxx"
41 #include "windowstateguard.hxx"
43 /** === begin UNO includes === **/
44 #include <com/sun/star/awt/XControl.hpp>
45 #include <com/sun/star/beans/XPropertyAccess.hpp>
46 #include <com/sun/star/beans/XPropertyContainer.hpp>
47 #include <com/sun/star/container/XChild.hpp>
48 #include <com/sun/star/container/XNamed.hpp>
49 #include <com/sun/star/form/binding/XBindableValue.hpp>
50 #include <com/sun/star/form/FormComponentType.hpp>
51 #include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
52 #include <com/sun/star/form/validation/XValidityConstraintListener.hpp>
53 #include <com/sun/star/form/XBoundComponent.hpp>
54 #include <com/sun/star/form/XBoundControl.hpp>
55 #include <com/sun/star/form/XFormComponent.hpp>
56 #include <com/sun/star/form/XLoadListener.hpp>
57 #include <com/sun/star/form/XReset.hpp>
58 #include <com/sun/star/io/XMarkableStream.hpp>
59 #include <com/sun/star/io/XPersistObject.hpp>
60 #include <com/sun/star/lang/DisposedException.hpp>
61 #include <com/sun/star/lang/XEventListener.hpp>
62 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
63 #include <com/sun/star/lang/XServiceInfo.hpp>
64 #include <com/sun/star/sdb/XColumn.hpp>
65 #include <com/sun/star/sdb/XColumnUpdate.hpp>
66 #include <com/sun/star/sdb/XRowSetChangeListener.hpp>
67 #include <com/sun/star/sdbc/XRowSet.hpp>
68 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
69 #include <com/sun/star/uno/XAggregation.hpp>
70 #include <com/sun/star/util/XCloneable.hpp>
71 #include <com/sun/star/util/XModifyListener.hpp>
72 #include <com/sun/star/form/XLoadable.hpp>
73 /** === end UNO includes === **/
75 #include <comphelper/componentcontext.hxx>
76 #include <comphelper/propagg.hxx>
77 #include <comphelper/propertybag.hxx>
78 #include <comphelper/propmultiplex.hxx>
79 #include <comphelper/sequence.hxx>
80 #include <comphelper/uno3.hxx>
81 #include <cppuhelper/component.hxx>
82 #include <cppuhelper/implbase1.hxx>
83 #include <cppuhelper/implbase2.hxx>
84 #include <cppuhelper/implbase3.hxx>
85 #include <cppuhelper/implbase4.hxx>
86 #include <cppuhelper/implbase7.hxx>
87 #include <osl/mutex.hxx>
88 #include <rtl/ustring.hxx>
90 #include <memory>
92 //.........................................................................
93 namespace frm
95 //.........................................................................
97 // default tab index for components
98 const sal_Int16 FRM_DEFAULT_TABINDEX = 0;
100 // macros for quickly declaring/implementing XServiceInfo
101 #define DECLARE_XPERSISTOBJECT() \
102 virtual ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); \
103 virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); \
104 virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); \
106 // old macro for quickly implementing XServiceInfo::getImplementationName
107 #define IMPLEMENTATION_NAME(ImplName) \
108 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) \
109 { return ::rtl::OUString::createFromAscii("com.sun.star.comp.forms.") + ::rtl::OUString::createFromAscii(#ImplName); }
111 class OControlModel;
113 //=========================================================================
114 //= ControlModelLock
115 //=========================================================================
116 /** class whose instances lock a OControlModel
118 Locking here merely means locking the OControlModel's mutex.
120 In addition to the locking facility, the class is also able to fire property
121 change notifications. This happens when the last ControlModelLock instance on a stack
122 dies.
124 class ControlModelLock
126 public:
127 ControlModelLock( OControlModel& _rModel )
128 :m_rModel( _rModel )
129 ,m_bLocked( false )
131 acquire();
134 ~ControlModelLock()
136 if ( m_bLocked )
137 release();
139 inline void acquire();
140 inline void release();
142 inline OControlModel& getModel() const { return m_rModel; };
144 /** adds a property change notification, which is to be fired when the last lock on the model
145 (in the current thread) is released.
147 void addPropertyNotification(
148 const sal_Int32 _nHandle,
149 const ::com::sun::star::uno::Any& _rOldValue,
150 const ::com::sun::star::uno::Any& _rNewValue
153 private:
154 void impl_notifyAll_nothrow();
156 private:
157 OControlModel& m_rModel;
158 bool m_bLocked;
159 ::com::sun::star::uno::Sequence< sal_Int32 > m_aHandles;
160 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aOldValues;
161 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aNewValues;
163 private:
164 ControlModelLock(); // never implemented
165 ControlModelLock( const ControlModelLock& ); // never implemented
166 ControlModelLock& operator=( const ControlModelLock& ); // never implemented
169 //=========================================================================
170 //= OControl
171 //= base class for form layer controls
172 //=========================================================================
173 typedef ::cppu::ImplHelper3 < ::com::sun::star::awt::XControl
174 , ::com::sun::star::lang::XEventListener
175 , ::com::sun::star::lang::XServiceInfo
176 > OControl_BASE;
178 class OControl :public ::cppu::OComponentHelper
179 ,public OControl_BASE
181 protected:
182 ::osl::Mutex m_aMutex;
183 OImplementationIdsRef m_aHoldIdHelper;
184 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >
185 m_xControl;
186 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation>
187 m_xAggregate;
189 ::comphelper::ComponentContext m_aContext;
190 WindowStateGuard m_aWindowStateGuard;
192 public:
193 /** constructs a control
195 @param _rFactory
196 the service factory for this control
197 @param _rAggregateService
198 the service name of the component to aggregate
199 @param _bSetDelegator
200 set this to <FALSE/> if you don't want the constructor to set the delegator at
201 the aggregate. In this case, you <em>have</em> to call doSetDelegator within your
202 own constructor.
204 This is helpfull, if your derived class wants to cache an interface of the aggregate.
205 In this case, the aggregate needs to be queried for this interface <b>before</b> the
206 <member scope="com::sun::star::uno">XAggregation::setDelegator</member> call.
208 In such a case, pass <FALSE/> to this parameter. Then, cache the aggregate's interface(s)
209 as needed. Afterwards, call <member>doSetDelegator</member>.
211 In your destructor, you need to call <member>doResetDelegator</member> before
212 resetting the cached interfaces. This will reset the aggregates delegator to <NULL/>,
213 which will ensure that the <member scope="com::sun::star::uno">XInterface::release</member>
214 calls on the cached interfaces are really applied to the aggregate, instead of
215 the <type>OControl</type> itself.
217 OControl(
218 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rFactory,
219 const ::rtl::OUString& _rAggregateService,
220 const sal_Bool _bSetDelegator = sal_True
223 /** initializes the given peer with various settings necessary for form controls
225 static void initFormControlPeer(
226 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& _rxPeer );
228 protected:
229 virtual ~OControl();
231 /** sets the control as delegator at the aggregate
233 This has to be called from within your derived class' constructor, if and only
234 if you passed <FALSE/> to the <arg>_bSetDelegator</arg> parameter of the
235 <type>OControl</type> constructor.
237 void doSetDelegator();
238 void doResetDelegator();
240 // UNO
241 DECLARE_UNO3_AGG_DEFAULTS(OControl, OComponentHelper);
242 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
244 // XTypeProvider
245 virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
246 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
248 // OComponentHelper
249 virtual void SAL_CALL disposing();
251 // XComponent (as base of XControl)
252 virtual void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException)
253 { OComponentHelper::dispose(); }
254 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException)
255 { OComponentHelper::addEventListener(_rxListener); }
256 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException)
257 { OComponentHelper::removeEventListener(_rxListener); }
259 // XEventListener
260 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException);
262 // XServiceInfo
263 virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw (::com::sun::star::uno::RuntimeException);
264 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
265 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException) = 0;
267 // XServiceInfo - static version
268 static StringSequence SAL_CALL getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException);
270 // XControl
271 virtual void SAL_CALL setContext(const InterfaceRef& Context) throw (::com::sun::star::uno::RuntimeException);
272 virtual InterfaceRef SAL_CALL getContext() throw (::com::sun::star::uno::RuntimeException);
273 virtual void SAL_CALL createPeer(const ::com::sun::star::uno::Reference<starawt::XToolkit>& Toolkit, const ::com::sun::star::uno::Reference<starawt::XWindowPeer>& Parent) throw (::com::sun::star::uno::RuntimeException);
274 virtual ::com::sun::star::uno::Reference<starawt::XWindowPeer> SAL_CALL getPeer() throw (::com::sun::star::uno::RuntimeException);
275 virtual sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference<starawt::XControlModel>& Model) throw (::com::sun::star::uno::RuntimeException);
276 virtual ::com::sun::star::uno::Reference<starawt::XControlModel> SAL_CALL getModel() throw (::com::sun::star::uno::RuntimeException);
277 virtual ::com::sun::star::uno::Reference<starawt::XView> SAL_CALL getView() throw (::com::sun::star::uno::RuntimeException);
278 virtual void SAL_CALL setDesignMode(sal_Bool bOn) throw (::com::sun::star::uno::RuntimeException);
279 virtual sal_Bool SAL_CALL isDesignMode() throw (::com::sun::star::uno::RuntimeException);
280 virtual sal_Bool SAL_CALL isTransparent() throw (::com::sun::star::uno::RuntimeException);
282 protected:
283 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
284 // overwrite this and call the base class if you have additional types
286 ::com::sun::star::uno::Sequence< ::rtl::OUString > getAggregateServiceNames();
288 private:
289 void impl_resetStateGuard_nothrow();
292 //==================================================================
293 //= OBoundControl
294 //= a form control implementing the XBoundControl interface
295 //==================================================================
296 typedef ::cppu::ImplHelper1 < ::com::sun::star::form::XBoundControl
297 > OBoundControl_BASE;
298 class OBoundControl :public OControl
299 ,public OBoundControl_BASE
301 protected:
302 sal_Bool m_bLocked : 1;
304 ::rtl::OUString m_sOriginalHelpText; // as long as the text/value is invalid, we change the help text of our peer
305 ::com::sun::star::awt::FontDescriptor
306 m_aOriginalFont; // as long as the text/value is invalid, we also change the font
307 sal_Int32 m_nOriginalTextLineColor; // (we add red underlining)
309 public:
310 OBoundControl(
311 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,
312 const ::rtl::OUString& _rAggregateService,
313 const sal_Bool _bSetDelegator = sal_True
316 virtual ~OBoundControl();
318 DECLARE_UNO3_AGG_DEFAULTS(OBoundControl, OControl);
319 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
321 // XBoundControl
322 virtual sal_Bool SAL_CALL getLock() throw(::com::sun::star::uno::RuntimeException);
323 virtual void SAL_CALL setLock(sal_Bool _bLock) throw(::com::sun::star::uno::RuntimeException);
324 // default implementation just disables the controls, overwrite _setLock to change this behaviour
326 // XControl
327 virtual sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model) throw (::com::sun::star::uno::RuntimeException);
329 // XEventListener
330 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException);
332 // OComponentHelper
333 virtual void SAL_CALL disposing();
335 protected:
336 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
337 // implement the lock setting
338 virtual void _setLock(sal_Bool _bLock);
341 //==================================================================
342 //= OControlModel
343 //= model of a form layer control
344 //==================================================================
346 typedef ::cppu::ImplHelper7 < ::com::sun::star::form::XFormComponent
347 , ::com::sun::star::io::XPersistObject
348 , ::com::sun::star::container::XNamed
349 , ::com::sun::star::lang::XServiceInfo
350 , ::com::sun::star::util::XCloneable
351 , ::com::sun::star::beans::XPropertyContainer
352 , ::com::sun::star::beans::XPropertyAccess
353 > OControlModel_BASE;
355 class OControlModel :public ::cppu::OComponentHelper
356 ,public OPropertySetAggregationHelper
357 ,public OControlModel_BASE
358 ,public OCloneableAggregation
359 ,public IPropertyBagHelperContext
362 protected:
363 ::comphelper::ComponentContext m_aContext;
365 ::osl::Mutex m_aMutex;
366 oslInterlockedCount m_lockCount;
368 InterfaceRef m_xParent; // ParentComponent
369 OImplementationIdsRef m_aHoldIdHelper;
370 PropertyBagHelper m_aPropertyBagHelper;
372 const ::comphelper::ComponentContext&
373 getContext() const { return m_aContext; }
375 // <properties>
376 ::rtl::OUString m_aName; // name of the control
377 ::rtl::OUString m_aTag; // tag for additional data
378 sal_Int16 m_nTabIndex; // index within the taborder
379 sal_Int16 m_nClassId; // type of the control
380 sal_Bool m_bNativeLook; // should the control use the native platform look?
381 // </properties>
384 protected:
385 OControlModel(
386 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rFactory, // factory to create the aggregate with
387 const ::rtl::OUString& _rUnoControlModelTypeName, // service name of te model to aggregate
388 const ::rtl::OUString& rDefault = ::rtl::OUString(), // service name of the default control
389 const sal_Bool _bSetDelegator = sal_True // set to FALSE if you want to call setDelegator later (after returning from this ctor)
391 OControlModel(
392 const OControlModel* _pOriginal, // the original object to clone
393 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rFactory, // factory to create the aggregate with
394 const sal_Bool _bCloneAggregate = sal_True, // should the aggregate of the original be cloned, too?
395 const sal_Bool _bSetDelegator = sal_True // set to FALSE if you want to call setDelegator later (after returning from this ctor)
397 virtual ~OControlModel();
399 /** to be called after a OBoundControlModel (a derivee, respectively) has been cloned
401 <p>This method contains late initializations which cannot be done in the
402 constructor of this base class, since the virtual method of derived classes do
403 not yet work there.</p>
405 virtual void clonedFrom( const OControlModel* _pOriginal );
407 using OComponentHelper::rBHelper;
409 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
411 void readHelpTextCompatibly(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream);
412 void writeHelpTextCompatibly(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream);
414 void doSetDelegator();
415 void doResetDelegator();
417 ::com::sun::star::uno::Sequence< ::rtl::OUString > getAggregateServiceNames();
419 public:
420 DECLARE_UNO3_AGG_DEFAULTS(OControl, OComponentHelper);
421 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
423 // XTypeProvider
424 virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
425 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
427 // OComponentHelper
428 virtual void SAL_CALL disposing();
430 // XNamed
431 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
432 virtual void SAL_CALL setName(const ::rtl::OUString& aName) throw(::com::sun::star::uno::RuntimeException);
434 // XServiceInfo
435 virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw (::com::sun::star::uno::RuntimeException);
436 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
437 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException) = 0;
439 // XSericeInfo - static version(s)
440 static StringSequence SAL_CALL getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException);
442 // XPersistObject
443 virtual ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException) = 0;
444 virtual void SAL_CALL
445 write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
446 virtual void SAL_CALL
447 read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
449 // XChild (base of XFormComponent)
450 virtual InterfaceRef SAL_CALL getParent() throw(::com::sun::star::uno::RuntimeException);
451 virtual void SAL_CALL setParent(const InterfaceRef& Parent) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
453 // XEventListener
454 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException);
456 // XPropertySet
457 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const;
458 virtual sal_Bool SAL_CALL convertFastPropertyValue(
459 ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue )
460 throw (::com::sun::star::lang::IllegalArgumentException);
461 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
462 throw (::com::sun::star::uno::Exception);
463 using ::cppu::OPropertySetHelper::getFastPropertyValue;
465 // ::com::sun::star::beans::XPropertyState
466 virtual ::com::sun::star::beans::PropertyState getPropertyStateByHandle(sal_Int32 nHandle);
467 virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle);
468 virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
470 // XCloneable
471 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException) = 0;
473 // XPropertyContainer
474 virtual void SAL_CALL addProperty( const ::rtl::OUString& Name, ::sal_Int16 Attributes, const ::com::sun::star::uno::Any& DefaultValue ) throw (::com::sun::star::beans::PropertyExistException, ::com::sun::star::beans::IllegalTypeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
475 virtual void SAL_CALL removeProperty( const ::rtl::OUString& Name ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::NotRemoveableException, ::com::sun::star::uno::RuntimeException);
477 // XPropertyAccess
478 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues( ) throw (::com::sun::star::uno::RuntimeException);
479 virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
481 protected:
482 using OPropertySetAggregationHelper::setPropertyValues;
483 using OPropertySetAggregationHelper::getPropertyValues;
485 protected:
486 virtual void writeAggregate( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream ) const;
487 virtual void readAggregate( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream );
489 protected:
490 // XPropertySet
491 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException);
492 // OPropertySetHelper
493 virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
495 /** describes the properties provided by this class, or its respective
496 derived class
498 Derived classes usually call the base class first, and then append own properties.
500 virtual void describeFixedProperties(
501 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
502 ) const;
504 // IPropertyBagHelperContext
505 virtual ::osl::Mutex& getMutex();
506 virtual void describeFixedAndAggregateProperties(
507 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& _out_rFixedProperties,
508 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& _out_rAggregateProperties
509 ) const;
510 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet >
511 getPropertiesInterface();
513 /** describes the properties of our aggregate
515 The default implementation simply asks m_xAggregateSet for its properties.
517 You usually only need to overload this method if you want to filter the aggregate
518 properties.
520 virtual void describeAggregateProperties(
521 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
522 ) const;
524 public:
525 struct LockAccess { friend class ControlModelLock; private: LockAccess() { } };
527 void lockInstance( LockAccess );
528 oslInterlockedCount unlockInstance( LockAccess );
530 void firePropertyChanges(
531 const ::com::sun::star::uno::Sequence< sal_Int32 >& _rHandles,
532 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rOldValues,
533 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rNewValues,
534 LockAccess
537 inline ::osl::Mutex&
538 getInstanceMutex() { return m_aMutex; }
541 //==================================================================
542 // simple destructor
543 #define DECLARE_DEFAULT_DTOR( classname ) \
544 ~classname() \
546 // constructor for cloning a class
547 #define DECLARE_DEFAULT_CLONE_CTOR( classname ) \
548 classname( \
549 const classname* _pOriginal, \
550 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory \
551 ); \
553 // all xtors for an inner class of the object hierarchy
554 #define DECLARE_DEFAULT_XTOR( classname ) \
555 classname( \
556 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, \
557 const ::rtl::OUString& _rUnoControlModelTypeName, \
558 const ::rtl::OUString& _rDefault \
559 ); \
560 DECLARE_DEFAULT_CLONE_CTOR( classname ) \
561 DECLARE_DEFAULT_DTOR( classname ) \
563 // all xtors for an inner class of the object hierarchy which is *bound*
564 #define DECLARE_DEFAULT_BOUND_XTOR( classname ) \
565 classname( \
566 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, \
567 const ::rtl::OUString& _rUnoControlModelTypeName, \
568 const ::rtl::OUString& _rDefault, \
569 const sal_Bool _bSupportExternalBinding, \
570 const sal_Bool _bSupportsValidation \
571 ); \
572 DECLARE_DEFAULT_CLONE_CTOR( classname ) \
573 DECLARE_DEFAULT_DTOR( classname ) \
575 // all xtors for a leas class of the object hierarchy
576 #define DECLARE_DEFAULT_LEAF_XTOR( classname ) \
577 classname( \
578 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory \
579 ); \
580 classname( \
581 const classname* _pOriginal, \
582 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory \
583 ); \
584 DECLARE_DEFAULT_DTOR( classname ) \
586 //==================================================================
587 // XCloneable
588 #define DECLARE_XCLONEABLE( ) \
589 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException)
591 #define IMPLEMENT_DEFAULT_CLONING( classname ) \
592 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL classname::createClone( ) throw (::com::sun::star::uno::RuntimeException) \
594 classname* pClone = new classname( this, getContext().getLegacyServiceFactory() ); \
595 pClone->clonedFrom( this ); \
596 return pClone; \
599 //==================================================================
600 //= OBoundControlModel
601 //= model of a form layer control which is bound to a data source field
602 //==================================================================
603 typedef ::cppu::ImplHelper4 < ::com::sun::star::form::XLoadListener
604 , ::com::sun::star::form::XReset
605 , ::com::sun::star::beans::XPropertyChangeListener
606 , ::com::sun::star::sdb::XRowSetChangeListener
607 > OBoundControlModel_BASE1;
609 // separated into an own base class since derivees can disable the support for this
610 // interface, thus we want to easily exclude it in the queryInterface and getTypes
611 typedef ::cppu::ImplHelper1 < ::com::sun::star::form::XBoundComponent
612 > OBoundControlModel_COMMITTING;
614 // dito
615 typedef ::cppu::ImplHelper2 < ::com::sun::star::form::binding::XBindableValue
616 , ::com::sun::star::util::XModifyListener
617 > OBoundControlModel_BINDING;
619 // dito
620 typedef ::cppu::ImplHelper2 < ::com::sun::star::form::validation::XValidityConstraintListener
621 , ::com::sun::star::form::validation::XValidatableFormComponent
622 > OBoundControlModel_VALIDATION;
624 class OBoundControlModel :public OControlModel
625 ,public OBoundControlModel_BASE1
626 ,public OBoundControlModel_COMMITTING
627 ,public OBoundControlModel_BINDING
628 ,public OBoundControlModel_VALIDATION
629 ,public ::comphelper::OPropertyChangeListener
631 protected:
632 enum ValueChangeInstigator
634 eDbColumnBinding,
635 eExternalBinding,
636 eOther
639 private:
640 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
641 m_xField;
642 // the form which controls supplies the field we bind to.
643 ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable >
644 m_xAmbientForm;
646 ::rtl::OUString m_sValuePropertyName;
647 sal_Int32 m_nValuePropertyAggregateHandle;
648 sal_Int32 m_nFieldType;
649 ::com::sun::star::uno::Type m_aValuePropertyType;
650 bool m_bValuePropertyMayBeVoid;
652 ResetHelper m_aResetHelper;
653 ::cppu::OInterfaceContainerHelper m_aUpdateListeners;
654 ::cppu::OInterfaceContainerHelper m_aFormComponentListeners;
656 ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
657 m_xExternalBinding;
658 ::com::sun::star::uno::Reference< ::com::sun::star::form::validation::XValidator >
659 m_xValidator;
660 ::com::sun::star::uno::Type m_aExternalValueType;
662 // <properties>
663 ::rtl::OUString m_aControlSource; // Datenquelle, Name des Feldes
664 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
665 m_xLabelControl; // reference to a sibling control (model) which is our label
666 sal_Bool m_bInputRequired;
667 // </properties>
669 ::comphelper::OPropertyChangeMultiplexer*
670 m_pAggPropMultiplexer;
672 bool m_bFormListening : 1; // are we currently a XLoadListener at our ambient form?
673 sal_Bool m_bLoaded : 1;
674 sal_Bool m_bRequired : 1;
675 const sal_Bool m_bCommitable : 1; // do we support XBoundComponent?
676 const sal_Bool m_bSupportsExternalBinding : 1; // do we support XBindableValue?
677 const sal_Bool m_bSupportsValidation : 1; // do we support XValidatable?
678 sal_Bool m_bForwardValueChanges : 1; // do we currently handle changes in the bound database field?
679 sal_Bool m_bTransferingValue : 1; // true if we're currently transfering our value to an external binding
680 sal_Bool m_bIsCurrentValueValid : 1; // flag specifying whether our current value is valid, relative to our external validator
681 sal_Bool m_bBindingControlsRO : 1; // is our ReadOnly property currently controlled by our external binding?
682 sal_Bool m_bBindingControlsEnable : 1; // is our Enabled property currently controlled by our external binding?
684 ValueChangeInstigator m_eControlValueChangeInstigator;
686 protected:
687 ::rtl::OUString m_aLabelServiceName;
688 // when setting the label for our control (property FM_PROP_CONTROLLABEL, member m_xLabelControl),
689 // we accept only objects supporting an XControlModel interface, an XServiceInfo interface and
690 // support for a service (XServiceInfo::supportsService) determined by this string.
691 // Any other arguments will throw an IllegalArgumentException.
692 // The default value is FM_COMPONENT_FIXEDTEXT.
694 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >
695 m_xCursor;
696 ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumnUpdate >
697 m_xColumnUpdate;
698 ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >
699 m_xColumn;
701 protected:
702 inline const ::rtl::OUString& getValuePropertyName( ) const { return m_sValuePropertyName; }
703 inline sal_Int32 getValuePropertyAggHandle( ) const { return m_nValuePropertyAggregateHandle; }
704 inline const ::rtl::OUString& getControlSource( ) const { return m_aControlSource; }
705 inline sal_Bool isRequired() const { return m_bRequired; }
706 inline sal_Bool isLoaded() const { return m_bLoaded; }
708 protected:
710 OBoundControlModel(
711 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rFactory,
712 // factory to create the aggregate with
713 const ::rtl::OUString& _rUnoControlModelTypeName, // service name of te model to aggregate
714 const ::rtl::OUString& _rDefault, // service name of the default control
715 const sal_Bool _bCommitable, // is the control (model) commitable ?
716 const sal_Bool _bSupportExternalBinding, // set to TRUE if you want to support XBindableValue
717 const sal_Bool _bSupportsValidation // set to TRUE if you want to support XValidatable
719 OBoundControlModel(
720 const OBoundControlModel* _pOriginal, // the original object to clone
721 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rFactory
722 // factory to create the aggregate with
724 virtual ~OBoundControlModel();
726 /// late ctor after cloning
727 virtual void clonedFrom( const OControlModel* _pOriginal );
729 /** initializes the part of the class which is related to the control value.
731 <p>Kind of late ctor, to be called for derivees which have a dedicated value property.<br/>
732 The value property is the property which's value is synced with either the database
733 column the object is bound to, or with the external value binding, if present.<br/>
734 E.g. for a text control model, this property will most probably be "Text".</p>
736 <p>Derived classes are stronly recommend to call this method - at least the
737 "DataFieldProperty" (exposed in getFastPropertyValue) relies on the information
738 given herein, and needs to be supplied otherwise else.</p>
740 <p>If this method has been called properly, then <member>setControlValue</member>
741 does not need to be overridden - it will simply set the property value at the
742 aggregate then.</p>
744 @precond
745 The method has not be called before during the life time of the object.
747 @param _rValuePropertyName
748 the name of the value property
749 @param _nValuePropertyExternalHandle
750 the handle of the property, as exposed to external components.<br/>
751 Normally, this information can be obtained dynamically (e.g. from describeFixedProperties),
752 but since this method is to be called from within the constructor of derived classes,
753 we prefer to be on the *really* safe side here ....
755 @see setControlValue
756 @see suspendValueListening
757 @see resumeValueListening
758 @see describeFixedProperties
760 void initValueProperty(
761 const ::rtl::OUString& _rValuePropertyName,
762 sal_Int32 _nValuePropertyExternalHandle
765 /** suspends listening at the value property
767 <p>As long as this listening is suspended, changes in the value property will not be
768 recognized and not be handled.</p>
770 @see initValueProperty
771 @see resumeValueListening
773 void suspendValueListening( );
775 /** resumes listening at the value property
777 <p>As long as this listening is suspended, changes in the value property will not be
778 recognized and not be handled.</p>
780 @precond
781 listening at the value property is currently suspended
783 @see initValueProperty
784 @see resumeValueListening
786 void resumeValueListening( );
788 /** starts listening at the aggregate, for changes in the given property
790 <p>The OBoundControlModel automatically registers a multiplexer which listens for
791 changes in the aggregate property values. By default, only the control value property
792 is observed. You may add additional properties to be observed with this method.</p>
794 @see initValueProperty
795 @see _propertyChanged
797 void startAggregatePropertyListening( const ::rtl::OUString& _rPropertyName );
799 /** returns the default which should be used when resetting the control
801 <p>The default implementation returns an empty Any.</p>
803 @see resetNoBroadcast
805 virtual ::com::sun::star::uno::Any
806 getDefaultForReset() const;
808 /** translates a db column value into a control value.
810 <p>Must transform the very current value of the database column we're bound to
811 (<member>m_xColumn</member>) into a value which can be used as current value
812 for the control.</p>
814 @see setControlValue
815 @pure
817 virtual ::com::sun::star::uno::Any
818 translateDbColumnToControlValue( ) = 0;
820 /** returns the data types which the control could use to exchange data with
821 an external value binding
823 The types returned here are completely independent from the concrete value binding,
824 they're just candidates which depend on the control type, and possible the concrete state
825 of the control (i.e. some property value).
827 If a control implementation supports multiple types, the ordering in the returned
828 sequence indicates preference: Preferred types are mentioned first.
830 The default implementation returns the type of our value property.
832 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
833 getSupportedBindingTypes();
835 /** translates the given value, which was obtained from the current external value binding,
836 to a value which can be used in setControlValue
838 <p>The default implementation returns the value itself, exception when it is VOID, and
839 our value property is not allowed to be void - in this case, the returned value is a
840 default-constructed value of the type required by our value property.
842 @see hasExternalValueBinding
843 @see getExternalValueType
845 virtual ::com::sun::star::uno::Any
846 translateExternalValueToControlValue( const ::com::sun::star::uno::Any& _rExternalValue ) const;
848 /** commits the current control value to our external value binding
850 <p>The default implementation simply calls getControlValue.</p>
852 @see hasExternalValueBinding
853 @see initValueProperty
855 virtual ::com::sun::star::uno::Any
856 translateControlValueToExternalValue( ) const;
858 /** commits the current control value to the database column we're bound to
859 @precond
860 we're properly bound to a database column, especially <member>m_xColumnUpdate</member>
861 is not <NULL/>
862 @param _bPostReset
863 <TRUE/> if and only if the current control value results from a reset (<member>getDefaultForReset</member>)
864 @pure
866 virtual sal_Bool commitControlValueToDbColumn(
867 bool _bPostReset
868 ) = 0;
870 /** sets the given value as new current value for the control
872 Besides some administrative work (such as caring for <member>m_eControlValueChangeInstigator</member>),
873 this method simply calls <member>doSetControlValue</member>.
875 @precond
876 Our own mutex is locked.
877 @param _rValue
878 The value to set. This value is guaranteed to be created by
879 <member>translateDbColumnToControlValue</member> or
880 <member>translateExternalValueToControlValue</member>
881 @param _eInstigator
882 the instigator of the value change
884 void setControlValue(
885 const ::com::sun::star::uno::Any& _rValue,
886 ValueChangeInstigator _eInstigator
889 <p>The default implementation will forward the given value to the aggregate, using
890 m_nValuePropertyAggregateHandle and/or m_sValuePropertyName.</p>
892 @precond
893 Our own mutex is locked.
894 @param _rValue
895 The value to set. This value is guaranteed to be created by
896 <member>translateDbColumnToControlValue</member> or
897 <member>translateExternalValueToControlValue</member>
899 virtual void doSetControlValue(
900 const ::com::sun::star::uno::Any& _rValue
903 /** retrieves the current value of the control
905 <p>The default implementation will ask the aggregate for the property value
906 determined by either m_nValuePropertyAggregateHandle and/or m_sValuePropertyName.</p>
908 @precond
909 Our own mutex is locked.
911 virtual ::com::sun::star::uno::Any
912 getControlValue( ) const;
914 /** called whenever a connection to a database column has been established
916 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm );
917 /** called whenever a connection to a database column has been suspended
919 virtual void onDisconnectedDbColumn();
921 /** called whenever a connection to an external supplier of values (XValueBinding) has been established
922 @see m_xExternalBinding
924 virtual void onConnectedExternalValue( );
925 /** called whenever a connection to an external supplier of values (XValueBinding) has been suspended
927 virtual void onDisconnectedExternalValue();
929 /** called whenever an external validator has been registered
931 virtual void onConnectedValidator( );
932 /** called whenever an external validator has been revoked
934 virtual void onDisconnectedValidator( );
936 /** nFieldType ist der Typ des Feldes, an das das Model gebunden werden soll.
937 Das Binden erfolgt genau dann, wenn Rueckgabewert sal_True.
938 Die Standard-Implementation erlaubt alles ausser den drei binary-Typen und
939 FieldType_OTHER.
941 virtual sal_Bool approveDbColumnType(sal_Int32 _nColumnType);
943 /** retrieves the current value of the control, in a shape which can be used with our
944 external validator.
946 The default implementation simply calls <member>>translateControlValueToExternalValue</member>.
948 @precond
949 Our own mutex is locked.
951 virtual ::com::sun::star::uno::Any
952 translateControlValueToValidatableValue( ) const;
954 /** retrieves the current value of the form component
956 This is the implementation method for XValidatableFormComponent::getCurrentValue. The default implementation
957 calls translateControlValueToValidatableValue if a validator is present, otherwise getControlValue.
959 @precond
960 our mutex is locked when this method is called
962 virtual ::com::sun::star::uno::Any
963 getCurrentFormComponentValue() const;
965 /** We can't write (new) common properties in this base class, as the file format doesn't allow this
966 (unfortunally). So derived classes may use the following to methods. They secure the written
967 data with marks, so any new common properties in newer versions will be skipped by older ones.
969 void writeCommonProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream);
970 void readCommonProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream);
971 // the next method may be used in derived classes's read when an unknown version is encountered
972 void defaultCommonProperties();
974 /** called to reset the control to some kind of default.
976 <p>The semantics of "default" is finally defined by the derived class (in particular,
977 by <member>getDefaultForReset</member>).</p>
979 <p>No listener notification needs to be done in the derived class.</p>
981 <p>Normally, you won't override this method, but <member>getDefaultForReset</member> instead.</p>
983 @see getDefaultForReset
985 virtual void resetNoBroadcast();
987 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
989 /// sets m_xField to the given new value, without notifying our listeners
990 void impl_setField_noNotify(
991 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxField
993 inline bool hasField() const
995 return m_xField.is();
997 inline sal_Int32 getFieldType() const
999 return m_nFieldType;
1002 // OControlModel's property handling
1003 virtual void describeFixedProperties(
1004 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
1005 ) const;
1007 public:
1008 inline const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& getField() const
1010 return m_xField;
1013 public:
1014 // UNO Anbindung
1015 DECLARE_UNO3_AGG_DEFAULTS(OBoundControlModel, OControlModel);
1016 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
1018 // OComponentHelper
1019 virtual void SAL_CALL disposing();
1021 // XReset
1022 virtual void SAL_CALL reset( ) throw(::com::sun::star::uno::RuntimeException);
1023 virtual void SAL_CALL addResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
1024 virtual void SAL_CALL removeResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
1026 // XServiceInfo
1027 virtual StringSequence SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
1029 // XServiceInfo - static version
1030 static StringSequence SAL_CALL getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException);
1032 // XChild
1033 virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
1035 // XPersistObject
1036 virtual void SAL_CALL write( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& OutStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
1037 virtual void SAL_CALL read( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& InStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
1039 // XBoundComponent
1040 virtual sal_Bool SAL_CALL commit() throw(::com::sun::star::uno::RuntimeException);
1042 // XUpdateBroadcaster (base of XBoundComponent)
1043 virtual void SAL_CALL addUpdateListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
1044 virtual void SAL_CALL removeUpdateListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
1046 // XPropertySet
1047 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const;
1048 virtual sal_Bool SAL_CALL convertFastPropertyValue(
1049 ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue )
1050 throw (::com::sun::star::lang::IllegalArgumentException);
1051 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
1052 throw (::com::sun::star::uno::Exception);
1053 using ::cppu::OPropertySetHelper::getFastPropertyValue;
1055 // ::com::sun::star::beans::XPropertyState
1056 virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
1058 // XEventListener
1059 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException);
1061 // XPropertyChangeListener
1062 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
1064 // XRowSetChangeListener
1065 virtual void SAL_CALL onRowSetChanged( const ::com::sun::star::lang::EventObject& i_Event ) throw (::com::sun::star::uno::RuntimeException);
1067 // XLoadListener
1068 virtual void SAL_CALL loaded( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException);
1069 virtual void SAL_CALL unloading( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException);
1070 virtual void SAL_CALL unloaded( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException);
1071 virtual void SAL_CALL reloading( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException);
1072 virtual void SAL_CALL reloaded( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException);
1074 private:
1075 // XBindableValue
1076 virtual void SAL_CALL setValueBinding( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding ) throw (::com::sun::star::form::binding::IncompatibleTypesException, ::com::sun::star::uno::RuntimeException);
1077 virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding > SAL_CALL getValueBinding( ) throw (::com::sun::star::uno::RuntimeException);
1079 // XModifyListener
1080 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
1082 // XValidatable
1083 virtual void SAL_CALL setValidator( const ::com::sun::star::uno::Reference< ::com::sun::star::form::validation::XValidator >& Validator ) throw (::com::sun::star::util::VetoException, ::com::sun::star::uno::RuntimeException);
1084 virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::validation::XValidator > SAL_CALL getValidator( ) throw (::com::sun::star::uno::RuntimeException);
1086 // XValidityConstraintListener
1087 virtual void SAL_CALL validityConstraintChanged( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
1089 // XValidatableFormComponent
1090 virtual sal_Bool SAL_CALL isValid( ) throw (::com::sun::star::uno::RuntimeException);
1091 virtual ::com::sun::star::uno::Any SAL_CALL getCurrentValue( ) throw (::com::sun::star::uno::RuntimeException);
1092 virtual void SAL_CALL addFormComponentValidityListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::validation::XFormComponentValidityListener >& Listener ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
1093 virtual void SAL_CALL removeFormComponentValidityListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::validation::XFormComponentValidityListener >& Listener ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
1095 protected:
1096 // OPropertyChangeListener
1097 virtual void
1098 _propertyChanged( const ::com::sun::star::beans::PropertyChangeEvent& _rEvt ) throw ( ::com::sun::star::uno::RuntimeException );
1100 /// checks whether we currently have an external value binding in place
1101 inline bool hasExternalValueBinding() const { return m_xExternalBinding.is(); }
1103 // checks whether we currently have an external validator
1104 inline bool hasValidator() const { return m_xValidator.is(); }
1106 /** transfers the very current value of the db column we're bound to the control
1107 @precond
1108 our own mutex is locked
1109 @precond
1110 we don't have an external binding in place
1112 void transferDbValueToControl( );
1114 /** transfers the current value of the active external binding to the control
1115 @precond
1116 we do have an active external binding in place
1118 void transferExternalValueToControl( ControlModelLock& _rInstanceLock );
1120 /** transfers the control value to the external binding
1121 @precond
1122 our own mutex is locked, and _rInstanceLock is the guard locking it
1123 @precond
1124 we do have an active external binding in place
1126 void transferControlValueToExternal( ControlModelLock& _rInstanceLock );
1128 /** calculates the type which is to be used to communicate with the current external binding,
1129 and stores it in m_aExternalValueType
1131 The method checks the possible type candidates as returned by getSupportedBindingTypes,
1132 and the types supported by the current external binding, if any.
1134 void calculateExternalValueType();
1136 /** returns the type which should be used to exchange data with our external value binding
1138 @see initValueProperty
1140 const ::com::sun::star::uno::Type&
1141 getExternalValueType() const { return m_aExternalValueType; }
1143 /** initializes the control from m_xField
1145 Basically, this method calls transferDbValueToControl - but only if our cursor is positioned
1146 on a valid row. Otherwise, the control is reset.
1148 @precond
1149 m_xField is not <NULL/>
1151 void initFromField( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxForm );
1153 private:
1154 sal_Bool connectToField( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxForm );
1155 void resetField();
1157 /** does a new validation of the control value
1159 If necessary, our <member>m_bIsCurrentValueValid</member> member will be adjusted,
1160 and changes will be notified.
1162 Note that it's not necessary that we're connected to a validator. If we are not,
1163 it's assumed that our value is valid, and this is handled appropriately.
1165 Use this method if there is a potential that <b>only</b> the validity flag changed. If
1166 any of the other aspects (our current value, or our current text) changed, then
1167 pass <TRUE/> for <member>_bForceNotification</member>.
1169 @param _bForceNotification
1170 if <TRUE/>, then the validity listeners will be notified, not matter whether the validity
1171 changed.
1173 void recheckValidity( bool _bForceNotification );
1175 /// initializes m_pAggPropMultiplexer
1176 void implInitAggMultiplexer( );
1178 /// initializes listening at the value property
1179 void implInitValuePropertyListening( ) const;
1181 /** adds or removes the component as load listener to/from our form, and (if necessary) as RowSetChange listener at
1182 our parent.
1184 @precond there must no external value binding be in place
1186 void doFormListening( const bool _bStart );
1188 inline bool isFormListening() const { return m_bFormListening; }
1190 /** determines the new value of m_xAmbientForm
1192 void impl_determineAmbientForm_nothrow();
1194 /** connects to a value supplier which is an database column.
1196 The column is take from our parent, which must be a database form respectively row set.
1198 @precond The control does not have an external value supplier
1200 @param _bFromReload
1201 Determines whether the connection is made after the row set has been loaded (<FALSE/>)
1202 or reloaded (<TRUE/>)
1204 @see impl_disconnectDatabaseColumn_noNotify
1206 void impl_connectDatabaseColumn_noNotify(
1207 bool _bFromReload
1210 /** disconnects from a value supplier which is an database column
1212 @precond The control does not have an external value supplier
1213 @see impl_connectDatabaseColumn_noNotify
1215 void impl_disconnectDatabaseColumn_noNotify();
1217 /** connects to an external value binding
1219 <p>Note that by definition, external data bindings superseede the SQL data binding which
1220 is defined by our RowSet-column-related properties. This means that in case we're currently
1221 connected to a database column when this is called, this connection is suspended.</p>
1223 @precond
1224 the new external binding has already been approved (see <member>impl_approveValueBinding_nolock</member>)
1225 @precond
1226 there currently is no external binding in place
1228 void connectExternalValueBinding(
1229 const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding,
1230 ControlModelLock& _rInstanceLock
1233 /** disconnects from an external value binding
1235 @precond
1236 there currently is an external binding in place
1238 void disconnectExternalValueBinding( );
1240 /** connects the component to an external validator
1242 @precond
1243 there currently is no active validator
1244 @precond
1245 our mutex is currently locked exactly once
1247 void connectValidator(
1248 const ::com::sun::star::uno::Reference< ::com::sun::star::form::validation::XValidator >& _rxValidator
1251 /** disconnects the component from it's current an external validator
1253 @precond
1254 there currently is an active validator
1255 @precond
1256 our mutex is currently locked exactly once
1258 void disconnectValidator( );
1260 /** called from within <member scope="com::sun::star:::form::binding">XBindableValue::setValueBinding</member>
1261 to approve the new binding
1263 The default implementation approves the binding if and only if it is not <NULL/>, and supports
1264 the type returned by getExternalValueType.
1266 @param _rxBinding
1267 the binding which applies for being responsible for our value, Must not be
1268 <NULL/>
1269 @return
1270 <TRUE/> if and only if the given binding can supply values in the proper type
1272 @seealso getExternalValueType
1274 sal_Bool impl_approveValueBinding_nolock(
1275 const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
1279 //=========================================================================
1280 //= inlines
1281 //=========================================================================
1282 inline void ControlModelLock::acquire()
1284 m_rModel.lockInstance( OControlModel::LockAccess() );
1285 m_bLocked = true;
1287 inline void ControlModelLock::release()
1289 OSL_ENSURE( m_bLocked, "ControlModelLock::release: not locked!" );
1290 m_bLocked = false;
1292 if ( 0 == m_rModel.unlockInstance( OControlModel::LockAccess() ) )
1293 impl_notifyAll_nothrow();
1296 //.........................................................................
1298 //.........................................................................
1300 #endif // _FORMS_FORMCOMPONENT_HXX_