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