1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _FORMS_FORMCOMPONENT_HXX_
21 #define _FORMS_FORMCOMPONENT_HXX_
23 #include "cloneable.hxx"
25 #include "property.hrc"
26 #include "property.hxx"
27 #include "propertybaghelper.hxx"
28 #include "resettable.hxx"
29 #include "services.hxx"
30 #include "windowstateguard.hxx"
32 #include <com/sun/star/awt/XControl.hpp>
33 #include <com/sun/star/beans/XPropertyAccess.hpp>
34 #include <com/sun/star/beans/XPropertyContainer.hpp>
35 #include <com/sun/star/container/XChild.hpp>
36 #include <com/sun/star/container/XNamed.hpp>
37 #include <com/sun/star/form/binding/XBindableValue.hpp>
38 #include <com/sun/star/form/FormComponentType.hpp>
39 #include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
40 #include <com/sun/star/form/validation/XValidityConstraintListener.hpp>
41 #include <com/sun/star/form/XBoundComponent.hpp>
42 #include <com/sun/star/form/XBoundControl.hpp>
43 #include <com/sun/star/form/XFormComponent.hpp>
44 #include <com/sun/star/form/XLoadListener.hpp>
45 #include <com/sun/star/form/XReset.hpp>
46 #include <com/sun/star/io/XMarkableStream.hpp>
47 #include <com/sun/star/io/XPersistObject.hpp>
48 #include <com/sun/star/lang/DisposedException.hpp>
49 #include <com/sun/star/lang/XEventListener.hpp>
50 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 #include <com/sun/star/lang/XServiceInfo.hpp>
52 #include <com/sun/star/sdb/XColumn.hpp>
53 #include <com/sun/star/sdb/XColumnUpdate.hpp>
54 #include <com/sun/star/sdb/XRowSetChangeListener.hpp>
55 #include <com/sun/star/sdbc/XRowSet.hpp>
56 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
57 #include <com/sun/star/uno/XAggregation.hpp>
58 #include <com/sun/star/util/XCloneable.hpp>
59 #include <com/sun/star/util/XModifyListener.hpp>
60 #include <com/sun/star/form/XLoadable.hpp>
62 #include <comphelper/componentcontext.hxx>
63 #include <comphelper/propagg.hxx>
64 #include <comphelper/propertybag.hxx>
65 #include <comphelper/propmultiplex.hxx>
66 #include <comphelper/sequence.hxx>
67 #include <comphelper/uno3.hxx>
68 #include <cppuhelper/component.hxx>
69 #include <cppuhelper/implbase1.hxx>
70 #include <cppuhelper/implbase2.hxx>
71 #include <cppuhelper/implbase3.hxx>
72 #include <cppuhelper/implbase4.hxx>
73 #include <cppuhelper/implbase7.hxx>
74 #include <osl/mutex.hxx>
75 #include <rtl/ustring.hxx>
79 //.........................................................................
82 //.........................................................................
84 // default tab index for components
85 const sal_Int16 FRM_DEFAULT_TABINDEX
= 0;
87 // macros for quickly declaring/implementing XServiceInfo
88 #define DECLARE_XPERSISTOBJECT() \
89 virtual OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); \
90 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); \
91 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); \
93 // old macro for quickly implementing XServiceInfo::getImplementationName
94 #define IMPLEMENTATION_NAME(ImplName) \
95 virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) \
96 { return OUString("com.sun.star.comp.forms.") + OUString(#ImplName); }
100 //=========================================================================
102 //=========================================================================
103 /** class whose instances lock a OControlModel
105 Locking here merely means locking the OControlModel's mutex.
107 In addition to the locking facility, the class is also able to fire property
108 change notifications. This happens when the last ControlModelLock instance on a stack
111 class ControlModelLock
114 ControlModelLock( OControlModel
& _rModel
)
126 inline void acquire();
127 inline void release();
129 inline OControlModel
& getModel() const { return m_rModel
; };
131 /** adds a property change notification, which is to be fired when the last lock on the model
132 (in the current thread) is released.
134 void addPropertyNotification(
135 const sal_Int32 _nHandle
,
136 const ::com::sun::star::uno::Any
& _rOldValue
,
137 const ::com::sun::star::uno::Any
& _rNewValue
141 void impl_notifyAll_nothrow();
144 OControlModel
& m_rModel
;
146 ::com::sun::star::uno::Sequence
< sal_Int32
> m_aHandles
;
147 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> m_aOldValues
;
148 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> m_aNewValues
;
151 ControlModelLock(); // never implemented
152 ControlModelLock( const ControlModelLock
& ); // never implemented
153 ControlModelLock
& operator=( const ControlModelLock
& ); // never implemented
156 //=========================================================================
158 //= base class for form layer controls
159 //=========================================================================
160 typedef ::cppu::ImplHelper3
< ::com::sun::star::awt::XControl
161 , ::com::sun::star::lang::XEventListener
162 , ::com::sun::star::lang::XServiceInfo
165 class OControl
:public ::cppu::OComponentHelper
166 ,public OControl_BASE
169 ::osl::Mutex m_aMutex
;
170 OImplementationIdsRef m_aHoldIdHelper
;
171 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>
173 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAggregation
>
176 ::comphelper::ComponentContext m_aContext
;
177 WindowStateGuard m_aWindowStateGuard
;
180 /** constructs a control
183 the service factory for this control
184 @param _rAggregateService
185 the service name of the component to aggregate
186 @param _bSetDelegator
187 set this to <FALSE/> if you don't want the constructor to set the delegator at
188 the aggregate. In this case, you <em>have</em> to call doSetDelegator within your
191 This is helpful, if your derived class wants to cache an interface of the aggregate.
192 In this case, the aggregate needs to be queried for this interface <b>before</b> the
193 <member scope="com::sun::star::uno">XAggregation::setDelegator</member> call.
195 In such a case, pass <FALSE/> to this parameter. Then, cache the aggregate's interface(s)
196 as needed. Afterwards, call <member>doSetDelegator</member>.
198 In your destructor, you need to call <member>doResetDelegator</member> before
199 resetting the cached interfaces. This will reset the aggregates delegator to <NULL/>,
200 which will ensure that the <member scope="com::sun::star::uno">XInterface::release</member>
201 calls on the cached interfaces are really applied to the aggregate, instead of
202 the <type>OControl</type> itself.
205 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rFactory
,
206 const OUString
& _rAggregateService
,
207 const sal_Bool _bSetDelegator
= sal_True
210 /** initializes the given peer with various settings necessary for form controls
212 static void initFormControlPeer(
213 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>& _rxPeer
);
218 /** sets the control as delegator at the aggregate
220 This has to be called from within your derived class' constructor, if and only
221 if you passed <FALSE/> to the <arg>_bSetDelegator</arg> parameter of the
222 <type>OControl</type> constructor.
224 void doSetDelegator();
225 void doResetDelegator();
228 DECLARE_UNO3_AGG_DEFAULTS(OControl
, OComponentHelper
);
229 virtual ::com::sun::star::uno::Any SAL_CALL
queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw(::com::sun::star::uno::RuntimeException
);
232 virtual ::com::sun::star::uno::Sequence
<sal_Int8
> SAL_CALL
getImplementationId() throw(::com::sun::star::uno::RuntimeException
);
233 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes() throw(::com::sun::star::uno::RuntimeException
);
236 virtual void SAL_CALL
disposing();
238 // XComponent (as base of XControl)
239 virtual void SAL_CALL
dispose( ) throw(::com::sun::star::uno::RuntimeException
)
240 { OComponentHelper::dispose(); }
241 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& _rxListener
) throw(::com::sun::star::uno::RuntimeException
)
242 { OComponentHelper::addEventListener(_rxListener
); }
243 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& _rxListener
) throw(::com::sun::star::uno::RuntimeException
)
244 { OComponentHelper::removeEventListener(_rxListener
); }
247 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
250 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
);
251 virtual StringSequence SAL_CALL
getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
);
252 virtual OUString SAL_CALL
getImplementationName() throw(::com::sun::star::uno::RuntimeException
) = 0;
254 // XServiceInfo - static version
255 static StringSequence SAL_CALL
getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException
);
258 virtual void SAL_CALL
setContext(const InterfaceRef
& Context
) throw (::com::sun::star::uno::RuntimeException
);
259 virtual InterfaceRef SAL_CALL
getContext() throw (::com::sun::star::uno::RuntimeException
);
260 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
);
261 virtual ::com::sun::star::uno::Reference
<starawt::XWindowPeer
> SAL_CALL
getPeer() throw (::com::sun::star::uno::RuntimeException
);
262 virtual sal_Bool SAL_CALL
setModel(const ::com::sun::star::uno::Reference
<starawt::XControlModel
>& Model
) throw (::com::sun::star::uno::RuntimeException
);
263 virtual ::com::sun::star::uno::Reference
<starawt::XControlModel
> SAL_CALL
getModel() throw (::com::sun::star::uno::RuntimeException
);
264 virtual ::com::sun::star::uno::Reference
<starawt::XView
> SAL_CALL
getView() throw (::com::sun::star::uno::RuntimeException
);
265 virtual void SAL_CALL
setDesignMode(sal_Bool bOn
) throw (::com::sun::star::uno::RuntimeException
);
266 virtual sal_Bool SAL_CALL
isDesignMode() throw (::com::sun::star::uno::RuntimeException
);
267 virtual sal_Bool SAL_CALL
isTransparent() throw (::com::sun::star::uno::RuntimeException
);
270 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> _getTypes();
271 // overwrite this and call the base class if you have additional types
273 ::com::sun::star::uno::Sequence
< OUString
> getAggregateServiceNames();
276 void impl_resetStateGuard_nothrow();
279 //==================================================================
281 //= a form control implementing the XBoundControl interface
282 //==================================================================
283 typedef ::cppu::ImplHelper1
< ::com::sun::star::form::XBoundControl
284 > OBoundControl_BASE
;
285 class OBoundControl
:public OControl
286 ,public OBoundControl_BASE
289 sal_Bool m_bLocked
: 1;
291 OUString m_sOriginalHelpText
; // as long as the text/value is invalid, we change the help text of our peer
292 ::com::sun::star::awt::FontDescriptor
293 m_aOriginalFont
; // as long as the text/value is invalid, we also change the font
294 sal_Int32 m_nOriginalTextLineColor
; // (we add red underlining)
298 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxFactory
,
299 const OUString
& _rAggregateService
,
300 const sal_Bool _bSetDelegator
= sal_True
303 virtual ~OBoundControl();
305 DECLARE_UNO3_AGG_DEFAULTS(OBoundControl
, OControl
);
306 virtual ::com::sun::star::uno::Any SAL_CALL
queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw(::com::sun::star::uno::RuntimeException
);
309 virtual sal_Bool SAL_CALL
getLock() throw(::com::sun::star::uno::RuntimeException
);
310 virtual void SAL_CALL
setLock(sal_Bool _bLock
) throw(::com::sun::star::uno::RuntimeException
);
311 // default implementation just disables the controls, overwrite _setLock to change this behaviour
314 virtual sal_Bool SAL_CALL
setModel(const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>& Model
) throw (::com::sun::star::uno::RuntimeException
);
317 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
320 virtual void SAL_CALL
disposing();
323 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> _getTypes();
324 // implement the lock setting
325 virtual void _setLock(sal_Bool _bLock
);
328 //==================================================================
330 //= model of a form layer control
331 //==================================================================
333 typedef ::cppu::ImplHelper7
< ::com::sun::star::form::XFormComponent
334 , ::com::sun::star::io::XPersistObject
335 , ::com::sun::star::container::XNamed
336 , ::com::sun::star::lang::XServiceInfo
337 , ::com::sun::star::util::XCloneable
338 , ::com::sun::star::beans::XPropertyContainer
339 , ::com::sun::star::beans::XPropertyAccess
340 > OControlModel_BASE
;
342 class OControlModel
:public ::cppu::OComponentHelper
343 ,public OPropertySetAggregationHelper
344 ,public OControlModel_BASE
345 ,public OCloneableAggregation
346 ,public IPropertyBagHelperContext
350 ::comphelper::ComponentContext m_aContext
;
352 ::osl::Mutex m_aMutex
;
353 oslInterlockedCount m_lockCount
;
355 InterfaceRef m_xParent
; // ParentComponent
356 OImplementationIdsRef m_aHoldIdHelper
;
357 PropertyBagHelper m_aPropertyBagHelper
;
359 const ::comphelper::ComponentContext
&
360 getContext() const { return m_aContext
; }
363 OUString m_aName
; // name of the control
364 OUString m_aTag
; // tag for additional data
365 sal_Int16 m_nTabIndex
; // index within the taborder
366 sal_Int16 m_nClassId
; // type of the control
367 sal_Bool m_bNativeLook
; // should the control use the native platform look?
368 sal_Bool m_bGenerateVbEvents
; // should the control generate fake vba events
374 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rFactory
, // factory to create the aggregate with
375 const OUString
& _rUnoControlModelTypeName
, // service name of te model to aggregate
376 const OUString
& rDefault
= OUString(), // service name of the default control
377 const sal_Bool _bSetDelegator
= sal_True
// set to sal_False if you want to call setDelegator later (after returning from this ctor)
380 const OControlModel
* _pOriginal
, // the original object to clone
381 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rFactory
, // factory to create the aggregate with
382 const sal_Bool _bCloneAggregate
= sal_True
, // should the aggregate of the original be cloned, too?
383 const sal_Bool _bSetDelegator
= sal_True
// set to sal_False if you want to call setDelegator later (after returning from this ctor)
385 virtual ~OControlModel();
387 /** to be called after a OBoundControlModel (a derivee, respectively) has been cloned
389 <p>This method contains late initializations which cannot be done in the
390 constructor of this base class, since the virtual method of derived classes do
391 not yet work there.</p>
393 virtual void clonedFrom( const OControlModel
* _pOriginal
);
395 using OComponentHelper::rBHelper
;
397 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> _getTypes();
399 void readHelpTextCompatibly(const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectInputStream
>& _rxInStream
);
400 void writeHelpTextCompatibly(const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectOutputStream
>& _rxOutStream
);
402 void doSetDelegator();
403 void doResetDelegator();
405 ::com::sun::star::uno::Sequence
< OUString
> getAggregateServiceNames();
408 DECLARE_UNO3_AGG_DEFAULTS(OControl
, OComponentHelper
);
409 virtual ::com::sun::star::uno::Any SAL_CALL
queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw (::com::sun::star::uno::RuntimeException
);
412 virtual ::com::sun::star::uno::Sequence
<sal_Int8
> SAL_CALL
getImplementationId() throw(::com::sun::star::uno::RuntimeException
);
413 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes() throw(::com::sun::star::uno::RuntimeException
);
416 virtual void SAL_CALL
disposing();
419 virtual OUString SAL_CALL
getName() throw(::com::sun::star::uno::RuntimeException
);
420 virtual void SAL_CALL
setName(const OUString
& aName
) throw(::com::sun::star::uno::RuntimeException
);
423 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
);
424 virtual StringSequence SAL_CALL
getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
);
425 virtual OUString SAL_CALL
getImplementationName() throw(::com::sun::star::uno::RuntimeException
) = 0;
427 // XSericeInfo - static version(s)
428 static StringSequence SAL_CALL
getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException
);
431 virtual OUString SAL_CALL
getServiceName() throw(::com::sun::star::uno::RuntimeException
) = 0;
432 virtual void SAL_CALL
433 write(const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectOutputStream
>& _rxOutStream
) throw(::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
434 virtual void SAL_CALL
435 read(const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectInputStream
>& _rxInStream
) throw(::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
437 // XChild (base of XFormComponent)
438 virtual InterfaceRef SAL_CALL
getParent() throw(::com::sun::star::uno::RuntimeException
);
439 virtual void SAL_CALL
setParent(const InterfaceRef
& Parent
) throw(::com::sun::star::lang::NoSupportException
, ::com::sun::star::uno::RuntimeException
);
442 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
445 virtual void SAL_CALL
getFastPropertyValue(::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const;
446 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
447 ::com::sun::star::uno::Any
& _rConvertedValue
, ::com::sun::star::uno::Any
& _rOldValue
, sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
)
448 throw (::com::sun::star::lang::IllegalArgumentException
);
449 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
)
450 throw (::com::sun::star::uno::Exception
);
451 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
453 // ::com::sun::star::beans::XPropertyState
454 virtual ::com::sun::star::beans::PropertyState
getPropertyStateByHandle(sal_Int32 nHandle
);
455 virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle
);
456 virtual ::com::sun::star::uno::Any
getPropertyDefaultByHandle( sal_Int32 nHandle
) const;
459 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
> SAL_CALL
createClone( ) throw (::com::sun::star::uno::RuntimeException
) = 0;
461 // XPropertyContainer
462 virtual void SAL_CALL
addProperty( const 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
);
463 virtual void SAL_CALL
removeProperty( const OUString
& Name
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::NotRemoveableException
, ::com::sun::star::uno::RuntimeException
);
466 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
getPropertyValues( ) throw (::com::sun::star::uno::RuntimeException
);
467 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
);
470 using OPropertySetAggregationHelper::setPropertyValues
;
471 using OPropertySetAggregationHelper::getPropertyValues
;
474 virtual void writeAggregate( const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectOutputStream
>& _rxOutStream
) const;
475 virtual void readAggregate( const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectInputStream
>& _rxInStream
);
479 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException
);
480 // OPropertySetHelper
481 virtual cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
483 /** describes the properties provided by this class, or its respective
486 Derived classes usually call the base class first, and then append own properties.
488 virtual void describeFixedProperties(
489 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& /* [out] */ _rProps
492 // IPropertyBagHelperContext
493 virtual ::osl::Mutex
& getMutex();
494 virtual void describeFixedAndAggregateProperties(
495 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& _out_rFixedProperties
,
496 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& _out_rAggregateProperties
498 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XMultiPropertySet
>
499 getPropertiesInterface();
501 /** describes the properties of our aggregate
503 The default implementation simply asks m_xAggregateSet for its properties.
505 You usually only need to overload this method if you want to filter the aggregate
508 virtual void describeAggregateProperties(
509 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& /* [out] */ _rAggregateProps
513 struct LockAccess
{ friend class ControlModelLock
; private: LockAccess() { } };
515 void lockInstance( LockAccess
);
516 oslInterlockedCount
unlockInstance( LockAccess
);
518 void firePropertyChanges(
519 const ::com::sun::star::uno::Sequence
< sal_Int32
>& _rHandles
,
520 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& _rOldValues
,
521 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& _rNewValues
,
526 getInstanceMutex() { return m_aMutex
; }
529 //==================================================================
531 #define DECLARE_DEFAULT_DTOR( classname ) \
534 // constructor for cloning a class
535 #define DECLARE_DEFAULT_CLONE_CTOR( classname ) \
537 const classname* _pOriginal, \
538 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory \
541 // all xtors for an inner class of the object hierarchy
542 #define DECLARE_DEFAULT_XTOR( classname ) \
544 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, \
545 const OUString& _rUnoControlModelTypeName, \
546 const OUString& _rDefault \
548 DECLARE_DEFAULT_CLONE_CTOR( classname ) \
549 DECLARE_DEFAULT_DTOR( classname ) \
551 // all xtors for an inner class of the object hierarchy which is *bound*
552 #define DECLARE_DEFAULT_BOUND_XTOR( classname ) \
554 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, \
555 const OUString& _rUnoControlModelTypeName, \
556 const OUString& _rDefault, \
557 const sal_Bool _bSupportExternalBinding, \
558 const sal_Bool _bSupportsValidation \
560 DECLARE_DEFAULT_CLONE_CTOR( classname ) \
561 DECLARE_DEFAULT_DTOR( classname ) \
563 // all xtors for a leas class of the object hierarchy
564 #define DECLARE_DEFAULT_LEAF_XTOR( classname ) \
566 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory \
569 const classname* _pOriginal, \
570 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory \
572 DECLARE_DEFAULT_DTOR( classname ) \
574 //==================================================================
576 #define DECLARE_XCLONEABLE( ) \
577 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException)
579 #define IMPLEMENT_DEFAULT_CLONING( classname ) \
580 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL classname::createClone( ) throw (::com::sun::star::uno::RuntimeException) \
582 classname* pClone = new classname( this, getContext().getLegacyServiceFactory() ); \
583 pClone->clonedFrom( this ); \
587 //==================================================================
588 //= OBoundControlModel
589 //= model of a form layer control which is bound to a data source field
590 //==================================================================
591 typedef ::cppu::ImplHelper4
< ::com::sun::star::form::XLoadListener
592 , ::com::sun::star::form::XReset
593 , ::com::sun::star::beans::XPropertyChangeListener
594 , ::com::sun::star::sdb::XRowSetChangeListener
595 > OBoundControlModel_BASE1
;
597 // separated into an own base class since derivees can disable the support for this
598 // interface, thus we want to easily exclude it in the queryInterface and getTypes
599 typedef ::cppu::ImplHelper1
< ::com::sun::star::form::XBoundComponent
600 > OBoundControlModel_COMMITTING
;
603 typedef ::cppu::ImplHelper2
< ::com::sun::star::form::binding::XBindableValue
604 , ::com::sun::star::util::XModifyListener
605 > OBoundControlModel_BINDING
;
608 typedef ::cppu::ImplHelper2
< ::com::sun::star::form::validation::XValidityConstraintListener
609 , ::com::sun::star::form::validation::XValidatableFormComponent
610 > OBoundControlModel_VALIDATION
;
612 class OBoundControlModel
:public OControlModel
613 ,public OBoundControlModel_BASE1
614 ,public OBoundControlModel_COMMITTING
615 ,public OBoundControlModel_BINDING
616 ,public OBoundControlModel_VALIDATION
617 ,public ::comphelper::OPropertyChangeListener
620 enum ValueChangeInstigator
628 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
630 // the form which controls supplies the field we bind to.
631 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XLoadable
>
634 OUString m_sValuePropertyName
;
635 sal_Int32 m_nValuePropertyAggregateHandle
;
636 sal_Int32 m_nFieldType
;
637 ::com::sun::star::uno::Type m_aValuePropertyType
;
638 bool m_bValuePropertyMayBeVoid
;
640 ResetHelper m_aResetHelper
;
641 ::cppu::OInterfaceContainerHelper m_aUpdateListeners
;
642 ::cppu::OInterfaceContainerHelper m_aFormComponentListeners
;
644 ::com::sun::star::uno::Reference
< ::com::sun::star::form::binding::XValueBinding
>
646 ::com::sun::star::uno::Reference
< ::com::sun::star::form::validation::XValidator
>
648 ::com::sun::star::uno::Type m_aExternalValueType
;
651 OUString m_aControlSource
; // Datenquelle, Name des Feldes
652 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
653 m_xLabelControl
; // reference to a sibling control (model) which is our label
654 sal_Bool m_bInputRequired
;
657 ::comphelper::OPropertyChangeMultiplexer
*
658 m_pAggPropMultiplexer
;
660 bool m_bFormListening
: 1; // are we currently a XLoadListener at our ambient form?
661 sal_Bool m_bLoaded
: 1;
662 sal_Bool m_bRequired
: 1;
663 const sal_Bool m_bCommitable
: 1; // do we support XBoundComponent?
664 const sal_Bool m_bSupportsExternalBinding
: 1; // do we support XBindableValue?
665 const sal_Bool m_bSupportsValidation
: 1; // do we support XValidatable?
666 sal_Bool m_bForwardValueChanges
: 1; // do we currently handle changes in the bound database field?
667 sal_Bool m_bTransferingValue
: 1; // true if we're currently transfering our value to an external binding
668 sal_Bool m_bIsCurrentValueValid
: 1; // flag specifying whether our current value is valid, relative to our external validator
669 sal_Bool m_bBindingControlsRO
: 1; // is our ReadOnly property currently controlled by our external binding?
670 sal_Bool m_bBindingControlsEnable
: 1; // is our Enabled property currently controlled by our external binding?
672 ValueChangeInstigator m_eControlValueChangeInstigator
;
675 OUString m_aLabelServiceName
;
676 // when setting the label for our control (property FM_PROP_CONTROLLABEL, member m_xLabelControl),
677 // we accept only objects supporting an XControlModel interface, an XServiceInfo interface and
678 // support for a service (XServiceInfo::supportsService) determined by this string.
679 // Any other arguments will throw an IllegalArgumentException.
680 // The default value is FM_COMPONENT_FIXEDTEXT.
682 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>
684 ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XColumnUpdate
>
686 ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XColumn
>
690 inline const OUString
& getValuePropertyName( ) const { return m_sValuePropertyName
; }
691 inline sal_Int32
getValuePropertyAggHandle( ) const { return m_nValuePropertyAggregateHandle
; }
692 inline const OUString
& getControlSource( ) const { return m_aControlSource
; }
693 inline sal_Bool
isRequired() const { return m_bRequired
; }
694 inline sal_Bool
isLoaded() const { return m_bLoaded
; }
699 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rFactory
,
700 // factory to create the aggregate with
701 const OUString
& _rUnoControlModelTypeName
, // service name of te model to aggregate
702 const OUString
& _rDefault
, // service name of the default control
703 const sal_Bool _bCommitable
, // is the control (model) commitable ?
704 const sal_Bool _bSupportExternalBinding
, // set to sal_True if you want to support XBindableValue
705 const sal_Bool _bSupportsValidation
// set to sal_True if you want to support XValidatable
708 const OBoundControlModel
* _pOriginal
, // the original object to clone
709 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rFactory
710 // factory to create the aggregate with
712 virtual ~OBoundControlModel();
714 /// late ctor after cloning
715 virtual void clonedFrom( const OControlModel
* _pOriginal
);
717 /** initializes the part of the class which is related to the control value.
719 <p>Kind of late ctor, to be called for derivees which have a dedicated value property.<br/>
720 The value property is the property which's value is synced with either the database
721 column the object is bound to, or with the external value binding, if present.<br/>
722 E.g. for a text control model, this property will most probably be "Text".</p>
724 <p>Derived classes are stronly recommend to call this method - at least the
725 "DataFieldProperty" (exposed in getFastPropertyValue) relies on the information
726 given herein, and needs to be supplied otherwise else.</p>
728 <p>If this method has been called properly, then <member>setControlValue</member>
729 does not need to be overridden - it will simply set the property value at the
733 The method has not be called before during the life time of the object.
735 @param _rValuePropertyName
736 the name of the value property
737 @param _nValuePropertyExternalHandle
738 the handle of the property, as exposed to external components.<br/>
739 Normally, this information can be obtained dynamically (e.g. from describeFixedProperties),
740 but since this method is to be called from within the constructor of derived classes,
741 we prefer to be on the *really* safe side here ....
744 @see suspendValueListening
745 @see resumeValueListening
746 @see describeFixedProperties
748 void initValueProperty(
749 const OUString
& _rValuePropertyName
,
750 sal_Int32 _nValuePropertyExternalHandle
753 /** initializes the part of the class which is related to the control value.
755 <p>In opposite to ->initValueProperty, this method is to be used for value properties which are <em>not</em>
756 implemented by our aggregate, but by ourselves.</p>
758 <p>Certain functionality is not available when using own value properties. This includes binding to an external
759 value and external validation. (This is not a conceptual limit, but simply missing implementation.)</p>
761 void initOwnValueProperty(
762 const OUString
& i_rValuePropertyName
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>
781 listening at the value property is currently suspended
783 @see initValueProperty
784 @see resumeValueListening
786 void resumeValueListening( );
788 /** (to be) called when the value property changed
790 Normally, this is done automatically, since the value property is a property of our aggregate, and we're
791 a listener at this property.
792 However, in some cases the value property might not be an aggregate property, but a property of the
793 delegator instance. In this case, you'll need to call <code>onValuePropertyChange</code> whenever this
796 void onValuePropertyChange( ControlModelLock
& i_rControLock
);
798 /** starts listening at the aggregate, for changes in the given property
800 <p>The OBoundControlModel automatically registers a multiplexer which listens for
801 changes in the aggregate property values. By default, only the control value property
802 is observed. You may add additional properties to be observed with this method.</p>
804 @see initValueProperty
805 @see _propertyChanged
807 void startAggregatePropertyListening( const OUString
& _rPropertyName
);
809 /** returns the default which should be used when resetting the control
811 <p>The default implementation returns an empty Any.</p>
813 @see resetNoBroadcast
815 virtual ::com::sun::star::uno::Any
816 getDefaultForReset() const;
818 /** translates a db column value into a control value.
820 <p>Must transform the very current value of the database column we're bound to
821 (<member>m_xColumn</member>) into a value which can be used as current value
827 virtual ::com::sun::star::uno::Any
828 translateDbColumnToControlValue( ) = 0;
830 /** returns the data types which the control could use to exchange data with
831 an external value binding
833 The types returned here are completely independent from the concrete value binding,
834 they're just candidates which depend on the control type, and possible the concrete state
835 of the control (i.e. some property value).
837 If a control implementation supports multiple types, the ordering in the returned
838 sequence indicates preference: Preferred types are mentioned first.
840 The default implementation returns the type of our value property.
842 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
>
843 getSupportedBindingTypes();
845 /** translates the given value, which was obtained from the current external value binding,
846 to a value which can be used in setControlValue
848 <p>The default implementation returns the value itself, exception when it is VOID, and
849 our value property is not allowed to be void - in this case, the returned value is a
850 default-constructed value of the type required by our value property.
852 @see hasExternalValueBinding
853 @see getExternalValueType
855 virtual ::com::sun::star::uno::Any
856 translateExternalValueToControlValue( const ::com::sun::star::uno::Any
& _rExternalValue
) const;
858 /** commits the current control value to our external value binding
860 <p>The default implementation simply calls getControlValue.</p>
862 @see hasExternalValueBinding
863 @see initValueProperty
865 virtual ::com::sun::star::uno::Any
866 translateControlValueToExternalValue( ) const;
868 /** commits the current control value to the database column we're bound to
870 we're properly bound to a database column, especially <member>m_xColumnUpdate</member>
873 <TRUE/> if and only if the current control value results from a reset (<member>getDefaultForReset</member>)
876 virtual sal_Bool
commitControlValueToDbColumn(
880 /** sets the given value as new current value for the control
882 Besides some administrative work (such as caring for <member>m_eControlValueChangeInstigator</member>),
883 this method simply calls <member>doSetControlValue</member>.
886 Our own mutex is locked.
888 The value to set. This value is guaranteed to be created by
889 <member>translateDbColumnToControlValue</member> or
890 <member>translateExternalValueToControlValue</member>
892 the instigator of the value change
894 void setControlValue(
895 const ::com::sun::star::uno::Any
& _rValue
,
896 ValueChangeInstigator _eInstigator
899 <p>The default implementation will forward the given value to the aggregate, using
900 m_nValuePropertyAggregateHandle and/or m_sValuePropertyName.</p>
903 Our own mutex is locked.
905 The value to set. This value is guaranteed to be created by
906 <member>translateDbColumnToControlValue</member> or
907 <member>translateExternalValueToControlValue</member>
909 virtual void doSetControlValue(
910 const ::com::sun::star::uno::Any
& _rValue
913 /** retrieves the current value of the control
915 <p>The default implementation will ask the aggregate for the property value
916 determined by either m_nValuePropertyAggregateHandle and/or m_sValuePropertyName.</p>
919 Our own mutex is locked.
921 virtual ::com::sun::star::uno::Any
922 getControlValue( ) const;
924 /** called whenever a connection to a database column has been established
926 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxForm
);
927 /** called whenever a connection to a database column has been suspended
929 virtual void onDisconnectedDbColumn();
931 /** called whenever a connection to an external supplier of values (XValueBinding) has been established
932 @see m_xExternalBinding
934 virtual void onConnectedExternalValue( );
935 /** called whenever a connection to an external supplier of values (XValueBinding) has been suspended
937 virtual void onDisconnectedExternalValue();
939 /** called whenever an external validator has been registered
941 virtual void onConnectedValidator( );
942 /** called whenever an external validator has been revoked
944 virtual void onDisconnectedValidator( );
946 /** nFieldType ist der Typ des Feldes, an das das Model gebunden werden soll.
947 Das Binden erfolgt genau dann, wenn Rueckgabewert sal_True.
948 Die Standard-Implementation erlaubt alles ausser den drei binary-Typen und
951 virtual sal_Bool
approveDbColumnType(sal_Int32 _nColumnType
);
953 /** retrieves the current value of the control, in a shape which can be used with our
956 The default implementation simply calls <member>>translateControlValueToExternalValue</member>.
959 Our own mutex is locked.
961 virtual ::com::sun::star::uno::Any
962 translateControlValueToValidatableValue( ) const;
964 /** retrieves the current value of the form component
966 This is the implementation method for XValidatableFormComponent::getCurrentValue. The default implementation
967 calls translateControlValueToValidatableValue if a validator is present, otherwise getControlValue.
970 our mutex is locked when this method is called
972 virtual ::com::sun::star::uno::Any
973 getCurrentFormComponentValue() const;
975 /** We can't write (new) common properties in this base class, as the file format doesn't allow this
976 (unfortunally). So derived classes may use the following two methods. They secure the written
977 data with marks, so any new common properties in newer versions will be skipped by older ones.
979 void writeCommonProperties(const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectOutputStream
>& _rxOutStream
);
980 void readCommonProperties(const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectInputStream
>& _rxInStream
);
981 // the next method may be used in derived classes's read when an unknown version is encountered
982 void defaultCommonProperties();
984 /** called to reset the control to some kind of default.
986 <p>The semantics of "default" is finally defined by the derived class (in particular,
987 by <member>getDefaultForReset</member>).</p>
989 <p>No listener notification needs to be done in the derived class.</p>
991 <p>Normally, you won't override this method, but <member>getDefaultForReset</member> instead.</p>
993 @see getDefaultForReset
995 virtual void resetNoBroadcast();
997 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> _getTypes();
999 /// sets m_xField to the given new value, without notifying our listeners
1000 void impl_setField_noNotify(
1001 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxField
1003 inline bool hasField() const
1005 return m_xField
.is();
1007 inline sal_Int32
getFieldType() const
1009 return m_nFieldType
;
1012 // OControlModel's property handling
1013 virtual void describeFixedProperties(
1014 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& /* [out] */ _rProps
1018 inline const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& getField() const
1025 DECLARE_UNO3_AGG_DEFAULTS(OBoundControlModel
, OControlModel
);
1026 virtual ::com::sun::star::uno::Any SAL_CALL
queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw (::com::sun::star::uno::RuntimeException
);
1029 virtual void SAL_CALL
disposing();
1032 virtual void SAL_CALL
reset( ) throw(::com::sun::star::uno::RuntimeException
);
1033 virtual void SAL_CALL
addResetListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XResetListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
);
1034 virtual void SAL_CALL
removeResetListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XResetListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
);
1037 virtual StringSequence SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
1039 // XServiceInfo - static version
1040 static StringSequence SAL_CALL
getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException
);
1043 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
);
1046 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
);
1047 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
);
1050 virtual sal_Bool SAL_CALL
commit() throw(::com::sun::star::uno::RuntimeException
);
1052 // XUpdateBroadcaster (base of XBoundComponent)
1053 virtual void SAL_CALL
addUpdateListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XUpdateListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
);
1054 virtual void SAL_CALL
removeUpdateListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XUpdateListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
);
1057 virtual void SAL_CALL
getFastPropertyValue(::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const;
1058 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
1059 ::com::sun::star::uno::Any
& _rConvertedValue
, ::com::sun::star::uno::Any
& _rOldValue
, sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
)
1060 throw (::com::sun::star::lang::IllegalArgumentException
);
1061 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
)
1062 throw (::com::sun::star::uno::Exception
);
1063 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
1065 // ::com::sun::star::beans::XPropertyState
1066 virtual ::com::sun::star::uno::Any
getPropertyDefaultByHandle( sal_Int32 nHandle
) const;
1069 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
1071 // XPropertyChangeListener
1072 virtual void SAL_CALL
propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw(::com::sun::star::uno::RuntimeException
);
1074 // XRowSetChangeListener
1075 virtual void SAL_CALL
onRowSetChanged( const ::com::sun::star::lang::EventObject
& i_Event
) throw (::com::sun::star::uno::RuntimeException
);
1078 virtual void SAL_CALL
loaded( const ::com::sun::star::lang::EventObject
& aEvent
) throw(::com::sun::star::uno::RuntimeException
);
1079 virtual void SAL_CALL
unloading( const ::com::sun::star::lang::EventObject
& aEvent
) throw(::com::sun::star::uno::RuntimeException
);
1080 virtual void SAL_CALL
unloaded( const ::com::sun::star::lang::EventObject
& aEvent
) throw(::com::sun::star::uno::RuntimeException
);
1081 virtual void SAL_CALL
reloading( const ::com::sun::star::lang::EventObject
& aEvent
) throw(::com::sun::star::uno::RuntimeException
);
1082 virtual void SAL_CALL
reloaded( const ::com::sun::star::lang::EventObject
& aEvent
) throw(::com::sun::star::uno::RuntimeException
);
1086 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
);
1087 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::form::binding::XValueBinding
> SAL_CALL
getValueBinding( ) throw (::com::sun::star::uno::RuntimeException
);
1090 virtual void SAL_CALL
modified( const ::com::sun::star::lang::EventObject
& _rEvent
) throw (::com::sun::star::uno::RuntimeException
);
1093 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
);
1094 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::form::validation::XValidator
> SAL_CALL
getValidator( ) throw (::com::sun::star::uno::RuntimeException
);
1096 // XValidityConstraintListener
1097 virtual void SAL_CALL
validityConstraintChanged( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
1099 // XValidatableFormComponent
1100 virtual sal_Bool SAL_CALL
isValid( ) throw (::com::sun::star::uno::RuntimeException
);
1101 virtual ::com::sun::star::uno::Any SAL_CALL
getCurrentValue( ) throw (::com::sun::star::uno::RuntimeException
);
1102 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
);
1103 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
);
1106 // OPropertyChangeListener
1108 _propertyChanged( const ::com::sun::star::beans::PropertyChangeEvent
& _rEvt
) throw ( ::com::sun::star::uno::RuntimeException
);
1110 /// checks whether we currently have an external value binding in place
1111 inline bool hasExternalValueBinding() const { return m_xExternalBinding
.is(); }
1113 // checks whether we currently have an external validator
1114 inline bool hasValidator() const { return m_xValidator
.is(); }
1116 /** transfers the very current value of the db column we're bound to the control
1118 our own mutex is locked
1120 we don't have an external binding in place
1122 void transferDbValueToControl( );
1124 /** transfers the current value of the active external binding to the control
1126 we do have an active external binding in place
1128 void transferExternalValueToControl( ControlModelLock
& _rInstanceLock
);
1130 /** transfers the control value to the external binding
1132 our own mutex is locked, and _rInstanceLock is the guard locking it
1134 we do have an active external binding in place
1136 void transferControlValueToExternal( ControlModelLock
& _rInstanceLock
);
1138 /** calculates the type which is to be used to communicate with the current external binding,
1139 and stores it in m_aExternalValueType
1141 The method checks the possible type candidates as returned by getSupportedBindingTypes,
1142 and the types supported by the current external binding, if any.
1144 void calculateExternalValueType();
1146 /** returns the type which should be used to exchange data with our external value binding
1148 @see initValueProperty
1150 const ::com::sun::star::uno::Type
&
1151 getExternalValueType() const { return m_aExternalValueType
; }
1153 /** initializes the control from m_xField
1155 Basically, this method calls transferDbValueToControl - but only if our cursor is positioned
1156 on a valid row. Otherwise, the control is reset.
1159 m_xField is not <NULL/>
1161 void initFromField( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>& _rxForm
);
1164 sal_Bool
connectToField( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>& _rxForm
);
1167 /** does a new validation of the control value
1169 If necessary, our <member>m_bIsCurrentValueValid</member> member will be adjusted,
1170 and changes will be notified.
1172 Note that it's not necessary that we're connected to a validator. If we are not,
1173 it's assumed that our value is valid, and this is handled appropriately.
1175 Use this method if there is a potential that <b>only</b> the validity flag changed. If
1176 any of the other aspects (our current value, or our current text) changed, then
1177 pass <TRUE/> for <member>_bForceNotification</member>.
1179 @param _bForceNotification
1180 if <TRUE/>, then the validity listeners will be notified, not matter whether the validity
1183 void recheckValidity( bool _bForceNotification
);
1185 /// initializes m_pAggPropMultiplexer
1186 void implInitAggMultiplexer( );
1188 /// initializes listening at the value property
1189 void implInitValuePropertyListening( ) const;
1191 /** adds or removes the component as load listener to/from our form, and (if necessary) as RowSetChange listener at
1194 @precond there must no external value binding be in place
1196 void doFormListening( const bool _bStart
);
1198 inline bool isFormListening() const { return m_bFormListening
; }
1200 /** determines the new value of m_xAmbientForm
1202 void impl_determineAmbientForm_nothrow();
1204 /** connects to a value supplier which is an database column.
1206 The column is take from our parent, which must be a database form respectively row set.
1208 @precond The control does not have an external value supplier
1211 Determines whether the connection is made after the row set has been loaded (<FALSE/>)
1212 or reloaded (<TRUE/>)
1214 @see impl_disconnectDatabaseColumn_noNotify
1216 void impl_connectDatabaseColumn_noNotify(
1220 /** disconnects from a value supplier which is an database column
1222 @precond The control does not have an external value supplier
1223 @see impl_connectDatabaseColumn_noNotify
1225 void impl_disconnectDatabaseColumn_noNotify();
1227 /** connects to an external value binding
1229 <p>Note that by definition, external data bindings superseede the SQL data binding which
1230 is defined by our RowSet-column-related properties. This means that in case we're currently
1231 connected to a database column when this is called, this connection is suspended.</p>
1234 the new external binding has already been approved (see <member>impl_approveValueBinding_nolock</member>)
1236 there currently is no external binding in place
1238 void connectExternalValueBinding(
1239 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::binding::XValueBinding
>& _rxBinding
,
1240 ControlModelLock
& _rInstanceLock
1243 /** disconnects from an external value binding
1246 there currently is an external binding in place
1248 void disconnectExternalValueBinding( );
1250 /** connects the component to an external validator
1253 there currently is no active validator
1255 our mutex is currently locked exactly once
1257 void connectValidator(
1258 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::validation::XValidator
>& _rxValidator
1261 /** disconnects the component from it's current an external validator
1264 there currently is an active validator
1266 our mutex is currently locked exactly once
1268 void disconnectValidator( );
1270 /** called from within <member scope="com::sun::star:::form::binding">XBindableValue::setValueBinding</member>
1271 to approve the new binding
1273 The default implementation approves the binding if and only if it is not <NULL/>, and supports
1274 the type returned by getExternalValueType.
1277 the binding which applies for being responsible for our value, Must not be
1280 <TRUE/> if and only if the given binding can supply values in the proper type
1282 @seealso getExternalValueType
1284 sal_Bool
impl_approveValueBinding_nolock(
1285 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::binding::XValueBinding
>& _rxBinding
1289 //=========================================================================
1291 //=========================================================================
1292 inline void ControlModelLock::acquire()
1294 m_rModel
.lockInstance( OControlModel::LockAccess() );
1297 inline void ControlModelLock::release()
1299 OSL_ENSURE( m_bLocked
, "ControlModelLock::release: not locked!" );
1302 if ( 0 == m_rModel
.unlockInstance( OControlModel::LockAccess() ) )
1303 impl_notifyAll_nothrow();
1306 //.........................................................................
1308 //.........................................................................
1310 #endif // _FORMS_FORMCOMPONENT_HXX_
1312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */