bump product version to 4.1.6.2
[LibreOffice.git] / forms / source / component / Button.cxx
blobb7c759aeedb9ce3af6a452243b0a6010309e9350
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "Button.hxx"
23 #include <com/sun/star/awt/XVclWindowPeer.hpp>
25 #include <comphelper/streamsection.hxx>
26 #include <comphelper/basicio.hxx>
27 #include <tools/diagnose_ex.h>
28 #include <tools/debug.hxx>
29 #include <tools/urlobj.hxx>
30 #include <vcl/svapp.hxx>
31 #include <osl/mutex.hxx>
33 //.........................................................................
34 namespace frm
36 //.........................................................................
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::sdb;
40 using namespace ::com::sun::star::sdbc;
41 using namespace ::com::sun::star::sdbcx;
42 using namespace ::com::sun::star::beans;
43 using namespace ::com::sun::star::container;
44 using namespace ::com::sun::star::form;
45 using namespace ::com::sun::star::awt;
46 using namespace ::com::sun::star::io;
47 using namespace ::com::sun::star::lang;
48 using namespace ::com::sun::star::util;
49 using ::com::sun::star::frame::XDispatchProviderInterceptor;
51 //==================================================================
52 //= OButtonModel
53 //==================================================================
54 DBG_NAME(OButtonModel)
55 //------------------------------------------------------------------
56 InterfaceRef SAL_CALL OButtonModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
58 return *(new OButtonModel(_rxFactory));
61 //------------------------------------------------------------------
62 OButtonModel::OButtonModel(const Reference<XMultiServiceFactory>& _rxFactory)
63 :OClickableImageBaseModel( _rxFactory, VCL_CONTROLMODEL_COMMANDBUTTON, FRM_SUN_CONTROL_COMMANDBUTTON )
64 // use the old control name for compatibility reasons
65 ,m_aResetHelper( *this, m_aMutex )
66 ,m_eDefaultState( STATE_NOCHECK )
68 DBG_CTOR( OButtonModel, NULL );
69 m_nClassId = FormComponentType::COMMANDBUTTON;
72 //------------------------------------------------------------------
73 Any SAL_CALL OButtonModel::queryAggregation( const Type& _type ) throw(RuntimeException)
75 Any aReturn = OClickableImageBaseModel::queryAggregation( _type );
76 if ( !aReturn.hasValue() )
77 aReturn = OButtonModel_Base::queryInterface( _type );
78 return aReturn;
81 //------------------------------------------------------------------
82 Sequence< Type > OButtonModel::_getTypes()
84 return ::comphelper::concatSequences(
85 OClickableImageBaseModel::_getTypes(),
86 OButtonModel_Base::getTypes()
90 //------------------------------------------------------------------
91 OButtonModel::OButtonModel( const OButtonModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory )
92 :OClickableImageBaseModel( _pOriginal, _rxFactory )
93 ,m_aResetHelper( *this, m_aMutex )
94 ,m_eDefaultState( _pOriginal->m_eDefaultState )
96 DBG_CTOR( OButtonModel, NULL );
97 m_nClassId = FormComponentType::COMMANDBUTTON;
99 implInitializeImageURL();
102 //------------------------------------------------------------------------------
103 OButtonModel::~OButtonModel()
105 DBG_DTOR(OButtonModel, NULL);
108 //------------------------------------------------------------------------------
109 void OButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const
111 BEGIN_DESCRIBE_PROPERTIES( 6, OClickableImageBaseModel )
112 DECL_PROP1( BUTTONTYPE, FormButtonType, BOUND );
113 DECL_PROP1( DEFAULT_STATE, sal_Int16, BOUND );
114 DECL_PROP1( DISPATCHURLINTERNAL, sal_Bool, BOUND );
115 DECL_PROP1( TARGET_URL, OUString, BOUND );
116 DECL_PROP1( TARGET_FRAME, OUString, BOUND );
117 DECL_PROP1( TABINDEX, sal_Int16, BOUND );
118 END_DESCRIBE_PROPERTIES();
121 //------------------------------------------------------------------------------
122 IMPLEMENT_DEFAULT_CLONING( OButtonModel )
124 // XServiceInfo
125 //------------------------------------------------------------------------------
126 StringSequence OButtonModel::getSupportedServiceNames() throw()
128 StringSequence aSupported = OClickableImageBaseModel::getSupportedServiceNames();
129 aSupported.realloc( aSupported.getLength() + 1 );
131 OUString* pArray = aSupported.getArray();
132 pArray[ aSupported.getLength() - 1 ] = FRM_SUN_COMPONENT_COMMANDBUTTON;
134 return aSupported;
137 //------------------------------------------------------------------------------
138 OUString OButtonModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
140 return OUString(FRM_COMPONENT_COMMANDBUTTON); // old (non-sun) name for compatibility !
143 //------------------------------------------------------------------------------
144 void OButtonModel::write(const Reference<XObjectOutputStream>& _rxOutStream) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
146 OClickableImageBaseModel::write(_rxOutStream);
148 _rxOutStream->writeShort(0x0003); // Version
151 OStreamSection aSection( _rxOutStream.get() );
152 // this will allow readers to skip unknown bytes in their dtor
154 _rxOutStream->writeShort( (sal_uInt16)m_eButtonType );
156 OUString sTmp = INetURLObject::decode( m_sTargetURL, '%', INetURLObject::DECODE_UNAMBIGUOUS);
157 _rxOutStream << sTmp;
158 _rxOutStream << m_sTargetFrame;
159 writeHelpTextCompatibly(_rxOutStream);
160 _rxOutStream << isDispatchUrlInternal();
164 //------------------------------------------------------------------------------
165 void OButtonModel::read(const Reference<XObjectInputStream>& _rxInStream) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
167 OClickableImageBaseModel::read(_rxInStream);
169 sal_uInt16 nVersion = _rxInStream->readShort(); // Version
170 switch (nVersion)
172 case 0x0001:
174 m_eButtonType = (FormButtonType)_rxInStream->readShort();
176 _rxInStream >> m_sTargetURL;
177 _rxInStream >> m_sTargetFrame;
179 break;
181 case 0x0002:
183 m_eButtonType = (FormButtonType)_rxInStream->readShort();
185 _rxInStream >> m_sTargetURL;
186 _rxInStream >> m_sTargetFrame;
187 readHelpTextCompatibly(_rxInStream);
189 break;
191 case 0x0003:
193 OStreamSection aSection( _rxInStream.get() );
194 // this will skip any unknown bytes in it's dtor
196 // button type
197 m_eButtonType = (FormButtonType)_rxInStream->readShort();
199 // URL
200 _rxInStream >> m_sTargetURL;
202 // target frame
203 _rxInStream >> m_sTargetFrame;
205 // help text
206 readHelpTextCompatibly(_rxInStream);
208 // DispatchInternal
209 sal_Bool bDispath;
210 _rxInStream >> bDispath;
211 setDispatchUrlInternal(bDispath);
213 break;
215 default:
216 OSL_FAIL("OButtonModel::read : unknown version !");
217 m_eButtonType = FormButtonType_PUSH;
218 m_sTargetURL = OUString();
219 m_sTargetFrame = OUString();
220 break;
224 //--------------------------------------------------------------------
225 void SAL_CALL OButtonModel::disposing()
227 m_aResetHelper.disposing();
228 OClickableImageBaseModel::disposing();
231 //--------------------------------------------------------------------
232 void SAL_CALL OButtonModel::reset() throw (RuntimeException)
234 if ( !m_aResetHelper.approveReset() )
235 return;
237 impl_resetNoBroadcast_nothrow();
239 m_aResetHelper.notifyResetted();
242 //--------------------------------------------------------------------
243 void SAL_CALL OButtonModel::addResetListener( const Reference< XResetListener >& _listener ) throw (RuntimeException)
245 m_aResetHelper.addResetListener( _listener );
248 //--------------------------------------------------------------------
249 void SAL_CALL OButtonModel::removeResetListener( const Reference< XResetListener >& _listener ) throw (RuntimeException)
251 m_aResetHelper.removeResetListener( _listener );
254 //--------------------------------------------------------------------
255 void SAL_CALL OButtonModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
257 switch ( _nHandle )
259 case PROPERTY_ID_DEFAULT_STATE:
260 _rValue <<= (sal_Int16)m_eDefaultState;
261 break;
263 default:
264 OClickableImageBaseModel::getFastPropertyValue( _rValue, _nHandle );
265 break;
269 //--------------------------------------------------------------------
270 void SAL_CALL OButtonModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw (Exception)
272 switch ( _nHandle )
274 case PROPERTY_ID_DEFAULT_STATE:
276 sal_Int16 nDefaultState( (sal_Int16)STATE_NOCHECK );
277 OSL_VERIFY( _rValue >>= nDefaultState );
278 m_eDefaultState = (ToggleState)nDefaultState;
279 impl_resetNoBroadcast_nothrow();
281 break;
283 default:
284 OClickableImageBaseModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
285 break;
289 //--------------------------------------------------------------------
290 sal_Bool SAL_CALL OButtonModel::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue ) throw (IllegalArgumentException)
292 sal_Bool bModified = sal_False;
293 switch ( _nHandle )
295 case PROPERTY_ID_DEFAULT_STATE:
296 bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_eDefaultState );
297 break;
299 default:
300 bModified = OClickableImageBaseModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
301 break;
303 return bModified;
306 //--------------------------------------------------------------------
307 Any OButtonModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const
309 Any aDefault;
310 switch ( _nHandle )
312 case PROPERTY_ID_DEFAULT_STATE:
313 aDefault <<= (sal_Int16)STATE_NOCHECK;
314 break;
316 default:
317 aDefault = OClickableImageBaseModel::getPropertyDefaultByHandle( _nHandle );
318 break;
320 return aDefault;
323 //--------------------------------------------------------------------
324 void OButtonModel::impl_resetNoBroadcast_nothrow()
328 setPropertyValue( PROPERTY_STATE, getPropertyValue( PROPERTY_DEFAULT_STATE ) );
330 catch( const Exception& )
332 DBG_UNHANDLED_EXCEPTION();
336 //==================================================================
337 // OButtonControl
338 //==================================================================
339 //------------------------------------------------------------------
340 InterfaceRef SAL_CALL OButtonControl_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
342 return *(new OButtonControl(_rxFactory));
345 //------------------------------------------------------------------------------
346 Sequence<Type> OButtonControl::_getTypes()
348 return ::comphelper::concatSequences(
349 OButtonControl_BASE::getTypes(),
350 OClickableImageBaseControl::_getTypes(),
351 OFormNavigationHelper::getTypes()
355 //------------------------------------------------------------------------------
356 StringSequence OButtonControl::getSupportedServiceNames() throw()
358 StringSequence aSupported = OClickableImageBaseControl::getSupportedServiceNames();
359 aSupported.realloc(aSupported.getLength() + 1);
361 OUString*pArray = aSupported.getArray();
362 pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_COMMANDBUTTON;
363 return aSupported;
366 //------------------------------------------------------------------------------
367 OButtonControl::OButtonControl(const Reference<XMultiServiceFactory>& _rxFactory)
368 :OClickableImageBaseControl(_rxFactory, VCL_CONTROL_COMMANDBUTTON)
369 ,OFormNavigationHelper( _rxFactory )
370 ,m_nClickEvent( 0 )
371 ,m_nTargetUrlFeatureId( -1 )
372 ,m_bEnabledByPropertyValue( sal_False )
374 increment(m_refCount);
376 // Register as ActionListener
377 Reference<XButton> xButton;
378 query_aggregation( m_xAggregate, xButton);
379 if (xButton.is())
380 xButton->addActionListener(this);
382 // For Listener: refcount at one
383 decrement(m_refCount);
386 //------------------------------------------------------------------------------
387 OButtonControl::~OButtonControl()
389 if (m_nClickEvent)
390 Application::RemoveUserEvent(m_nClickEvent);
393 // UNO binding
394 //------------------------------------------------------------------------------
395 Any SAL_CALL OButtonControl::queryAggregation(const Type& _rType) throw (RuntimeException)
397 // if asked for the XTypeProvider, don't let OButtonControl_BASE do this
398 Any aReturn;
399 if ( !_rType.equals( ::getCppuType( static_cast< Reference< XTypeProvider >* >( NULL ) ) ) )
400 aReturn = OButtonControl_BASE::queryInterface( _rType );
402 if ( !aReturn.hasValue() )
403 aReturn = OClickableImageBaseControl::queryAggregation( _rType );
405 if ( !aReturn.hasValue() )
406 aReturn = OFormNavigationHelper::queryInterface( _rType );
408 return aReturn;
411 //------------------------------------------------------------------------------
412 void SAL_CALL OButtonControl::disposing()
414 startOrStopModelPropertyListening( false );
416 OClickableImageBaseControl::disposing();
417 OFormNavigationHelper::dispose();
420 //------------------------------------------------------------------------------
421 void SAL_CALL OButtonControl::disposing( const EventObject& _rSource ) throw( RuntimeException )
423 OControl::disposing( _rSource );
424 OFormNavigationHelper::disposing( _rSource );
427 // ActionListener
428 //------------------------------------------------------------------------------
429 void OButtonControl::actionPerformed(const ActionEvent& /*rEvent*/) throw ( ::com::sun::star::uno::RuntimeException)
431 // Asynchronous for starutil::URL-Button
432 sal_uLong n = Application::PostUserEvent( LINK(this, OButtonControl,OnClick) );
434 ::osl::MutexGuard aGuard( m_aMutex );
435 m_nClickEvent = n;
439 //------------------------------------------------------------------------------
440 IMPL_LINK_NOARG(OButtonControl, OnClick)
442 ::osl::ClearableMutexGuard aGuard( m_aMutex );
443 m_nClickEvent = 0;
445 if (m_aApproveActionListeners.getLength())
447 // if there are listeners, start the action in an own thread, to not allow
448 // them to block us here (we're in the application's main thread)
449 getImageProducerThread()->addEvent();
451 else
453 // Else, don't. We then must not notify the Listeners in any case,
454 // not even if added later on.
455 aGuard.clear();
457 // recognize the button type
458 Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
459 if (!xSet.is())
460 return 0L;
462 if (FormButtonType_PUSH == *(FormButtonType*)xSet->getPropertyValue(PROPERTY_BUTTONTYPE).getValue())
464 // notify the action listeners for a push button
465 ::cppu::OInterfaceIteratorHelper aIter(m_aActionListeners);
466 ActionEvent aEvt(static_cast<XWeak*>(this), m_aActionCommand);
467 while(aIter.hasMoreElements() )
469 // catch exceptions
470 // and catch them on a per-listener basis - if one listener fails, the others still need
471 // to get notified
474 static_cast< XActionListener* >( aIter.next() )->actionPerformed(aEvt);
476 #ifdef DBG_UTIL
477 catch( const RuntimeException& )
479 // silence this
481 #endif
482 catch( const Exception& )
484 OSL_FAIL( "OButtonControl::OnClick: caught a exception other than RuntimeException!" );
488 else
489 actionPerformed_Impl( sal_False, ::com::sun::star::awt::MouseEvent() );
491 return 0L;
494 //------------------------------------------------------------------------------
495 void OButtonControl::actionPerformed_Impl( sal_Bool _bNotifyListener, const ::com::sun::star::awt::MouseEvent& _rEvt )
498 sal_Int16 nFeatureId = -1;
500 ::osl::MutexGuard aGuard( m_aMutex );
501 nFeatureId = m_nTargetUrlFeatureId;
504 if ( nFeatureId != -1 )
506 if ( !approveAction() )
507 return;
509 SolarMutexGuard aGuard;
510 dispatch( nFeatureId );
511 return;
515 OClickableImageBaseControl::actionPerformed_Impl( _bNotifyListener, _rEvt );
518 // XButton
519 //------------------------------------------------------------------------------
520 void OButtonControl::setLabel(const OUString& Label) throw( RuntimeException )
522 Reference<XButton> xButton;
523 query_aggregation( m_xAggregate, xButton );
524 if (xButton.is())
525 xButton->setLabel(Label);
528 //------------------------------------------------------------------------------
529 void SAL_CALL OButtonControl::setActionCommand(const OUString& _rCommand) throw( RuntimeException )
532 ::osl::MutexGuard aGuard( m_aMutex );
533 m_aActionCommand = _rCommand;
536 Reference<XButton> xButton;
537 query_aggregation( m_xAggregate, xButton);
538 if (xButton.is())
539 xButton->setActionCommand(_rCommand);
542 //------------------------------------------------------------------------------
543 void SAL_CALL OButtonControl::addActionListener(const Reference<XActionListener>& _rxListener) throw( RuntimeException )
545 m_aActionListeners.addInterface(_rxListener);
548 //------------------------------------------------------------------------------
549 void SAL_CALL OButtonControl::removeActionListener(const Reference<XActionListener>& _rxListener) throw( RuntimeException )
551 m_aActionListeners.removeInterface(_rxListener);
554 //------------------------------------------------------------------------------
555 class DoPropertyListening
557 private:
558 Reference< XPropertySet > m_xProps;
559 Reference< XPropertyChangeListener > m_xListener;
560 bool m_bStartListening;
562 public:
563 DoPropertyListening(
564 const Reference< XInterface >& _rxComponent,
565 const Reference< XPropertyChangeListener >& _rxListener,
566 bool _bStart
569 void handleListening( const OUString& _rPropertyName );
572 //..............................................................................
573 DoPropertyListening::DoPropertyListening(
574 const Reference< XInterface >& _rxComponent, const Reference< XPropertyChangeListener >& _rxListener,
575 bool _bStart )
576 :m_xProps( _rxComponent, UNO_QUERY )
577 ,m_xListener( _rxListener )
578 ,m_bStartListening( _bStart )
580 DBG_ASSERT( m_xProps.is() || !_rxComponent.is(), "DoPropertyListening::DoPropertyListening: valid component, but no property set!" );
581 DBG_ASSERT( m_xListener.is(), "DoPropertyListening::DoPropertyListening: invalid listener!" );
584 //..............................................................................
585 void DoPropertyListening::handleListening( const OUString& _rPropertyName )
587 if ( m_xProps.is() )
589 if ( m_bStartListening )
590 m_xProps->addPropertyChangeListener( _rPropertyName, m_xListener );
591 else
592 m_xProps->removePropertyChangeListener( _rPropertyName, m_xListener );
596 //------------------------------------------------------------------------------
597 void OButtonControl::startOrStopModelPropertyListening( bool _bStart )
599 DoPropertyListening aListeningHandler( getModel(), this, _bStart );
600 aListeningHandler.handleListening( PROPERTY_TARGET_URL );
601 aListeningHandler.handleListening( PROPERTY_BUTTONTYPE );
602 aListeningHandler.handleListening( PROPERTY_ENABLED );
605 //------------------------------------------------------------------------------
606 sal_Bool SAL_CALL OButtonControl::setModel( const Reference< XControlModel >& _rxModel ) throw ( RuntimeException )
608 startOrStopModelPropertyListening( false );
609 sal_Bool bResult = OClickableImageBaseControl::setModel( _rxModel );
610 startOrStopModelPropertyListening( true );
612 m_bEnabledByPropertyValue = sal_True;
613 Reference< XPropertySet > xModelProps( _rxModel, UNO_QUERY );
614 if ( xModelProps.is() )
615 xModelProps->getPropertyValue( PROPERTY_ENABLED ) >>= m_bEnabledByPropertyValue;
617 modelFeatureUrlPotentiallyChanged( );
619 return bResult;
622 //------------------------------------------------------------------------------
623 void OButtonControl::modelFeatureUrlPotentiallyChanged( )
625 sal_Int16 nOldUrlFeatureId = m_nTargetUrlFeatureId;
627 // doe we have another TargetURL now? If so, we need to update our dispatches
628 m_nTargetUrlFeatureId = getModelUrlFeatureId( );
629 if ( nOldUrlFeatureId != m_nTargetUrlFeatureId )
631 invalidateSupportedFeaturesSet();
632 if ( !isDesignMode() )
633 updateDispatches( );
637 //------------------------------------------------------------------------------
638 void SAL_CALL OButtonControl::propertyChange( const PropertyChangeEvent& _rEvent ) throw ( RuntimeException )
640 if ( _rEvent.PropertyName.equals( PROPERTY_TARGET_URL )
641 || _rEvent.PropertyName.equals( PROPERTY_BUTTONTYPE )
644 modelFeatureUrlPotentiallyChanged( );
646 else if ( _rEvent.PropertyName.equals( PROPERTY_ENABLED ) )
648 _rEvent.NewValue >>= m_bEnabledByPropertyValue;
652 //------------------------------------------------------------------------------
653 namespace
655 bool isFormControllerURL( const OUString& _rURL )
657 return ( _rURL.getLength() > RTL_CONSTASCII_LENGTH( ".uno:FormController/" ) )
658 && ( _rURL.startsWith( ".uno:FormController/" ) );
662 //------------------------------------------------------------------------------
663 sal_Int16 OButtonControl::getModelUrlFeatureId( ) const
665 sal_Int16 nFeatureId = -1;
667 // some URL related properties of the model
668 OUString sUrl;
669 FormButtonType eButtonType = FormButtonType_PUSH;
671 Reference< XPropertySet > xModelProps( const_cast< OButtonControl* >( this )->getModel(), UNO_QUERY );
672 if ( xModelProps.is() )
674 xModelProps->getPropertyValue( PROPERTY_TARGET_URL ) >>= sUrl;
675 xModelProps->getPropertyValue( PROPERTY_BUTTONTYPE ) >>= eButtonType;
678 // are we a URL button?
679 if ( eButtonType == FormButtonType_URL )
681 // is it a feature URL?
682 if ( isFormControllerURL( sUrl ) )
684 OFormNavigationMapper aMapper( m_aContext.getLegacyServiceFactory() );
685 nFeatureId = aMapper.getFeatureId( sUrl );
689 return nFeatureId;
692 //------------------------------------------------------------------
693 void SAL_CALL OButtonControl::setDesignMode( sal_Bool _bOn ) throw( RuntimeException )
695 OClickableImageBaseControl::setDesignMode( _bOn );
697 if ( _bOn )
698 disconnectDispatchers();
699 else
700 connectDispatchers();
701 // this will connect if not already connected and just update else
704 //------------------------------------------------------------------------------
705 void OButtonControl::getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds )
707 if ( -1 != m_nTargetUrlFeatureId )
708 _rFeatureIds.push_back( m_nTargetUrlFeatureId );
711 //------------------------------------------------------------------
712 void OButtonControl::featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled )
714 if ( _nFeatureId == m_nTargetUrlFeatureId )
716 // enable or disable our peer, according to the new state
717 Reference< XVclWindowPeer > xPeer( getPeer(), UNO_QUERY );
718 if ( xPeer.is() )
719 xPeer->setProperty( PROPERTY_ENABLED, makeAny( m_bEnabledByPropertyValue ? _bEnabled : sal_False ) );
720 // if we're disabled according to our model's property, then
721 // we don't care for the feature state, but *are* disabled.
722 // If the model's property states that we're enabled, then we *do*
723 // care for the feature state
726 // base class
727 OFormNavigationHelper::featureStateChanged( _nFeatureId, _bEnabled );
730 //------------------------------------------------------------------
731 void OButtonControl::allFeatureStatesChanged( )
733 if ( -1 != m_nTargetUrlFeatureId )
734 // we have only one supported feature, so simulate it has changed ...
735 featureStateChanged( m_nTargetUrlFeatureId, isEnabled( m_nTargetUrlFeatureId ) );
737 // base class
738 OFormNavigationHelper::allFeatureStatesChanged( );
741 //------------------------------------------------------------------
742 bool OButtonControl::isEnabled( sal_Int16 _nFeatureId ) const
744 if ( const_cast< OButtonControl* >( this )->isDesignMode() )
745 // TODO: the model property?
746 return true;
748 return OFormNavigationHelper::isEnabled( _nFeatureId );
751 //--------------------------------------------------------------------
752 void SAL_CALL OButtonControl::registerDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) throw (RuntimeException)
754 OClickableImageBaseControl::registerDispatchProviderInterceptor( _rxInterceptor );
755 OFormNavigationHelper::registerDispatchProviderInterceptor( _rxInterceptor );
758 //--------------------------------------------------------------------
759 void SAL_CALL OButtonControl::releaseDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) throw (RuntimeException)
761 OClickableImageBaseControl::releaseDispatchProviderInterceptor( _rxInterceptor );
762 OFormNavigationHelper::releaseDispatchProviderInterceptor( _rxInterceptor );
765 //.........................................................................
766 } // namespace frm
767 //.........................................................................
769 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */