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