25#include <com/sun/star/awt/XVclWindowPeer.hpp>
26#include <com/sun/star/beans/PropertyAttribute.hpp>
27#include <com/sun/star/form/FormComponentType.hpp>
38#include <osl/mutex.hxx>
54using ::com::sun::star::frame::XDispatchProviderInterceptor;
66 m_nClassId = FormComponentType::COMMANDBUTTON;
70Any SAL_CALL OButtonModel::queryAggregation(
const Type& _type )
72 Any aReturn = OClickableImageBaseModel::queryAggregation( _type );
73 if ( !aReturn.hasValue() )
74 aReturn = OButtonModel_Base::queryInterface( _type );
79Sequence< Type > OButtonModel::_getTypes()
81 return ::comphelper::concatSequences(
82 OClickableImageBaseModel::_getTypes(),
83 OButtonModel_Base::getTypes()
88OButtonModel::OButtonModel(
const OButtonModel* _pOriginal,
const Reference<XComponentContext>& _rxFactory )
91 ,m_eDefaultState( _pOriginal->m_eDefaultState )
107 sal_Int32 nOldCount = _rProps.getLength();
108 _rProps.realloc( nOldCount + 6);
109 css::beans::Property* pProperties = _rProps.getArray() + nOldCount;
116 DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(),
"<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?");
123 pClone->clonedFrom(
this);
133 aSupported.realloc( aSupported.getLength() + 2 );
135 OUString* pArray = aSupported.getArray();
153 _rxOutStream->writeShort(0x0003);
156 OStreamSection aSection( _rxOutStream );
159 _rxOutStream->writeShort(
static_cast<sal_uInt16
>(
m_eButtonType) );
162 _rxOutStream << sTmp;
174 sal_uInt16
nVersion = _rxInStream->readShort();
179 m_eButtonType =
static_cast<FormButtonType
>(_rxInStream->readShort());
188 m_eButtonType =
static_cast<FormButtonType
>(_rxInStream->readShort());
198 OStreamSection aSection( _rxInStream );
202 m_eButtonType =
static_cast<FormButtonType
>(_rxInStream->readShort());
215 _rxInStream >> bDispatch;
221 OSL_FAIL(
"OButtonModel::read : unknown version !");
282 OSL_VERIFY( _rValue >>= nDefaultState );
297 bool bModified =
false;
347 return ::comphelper::concatSequences(
358 aSupported.realloc(aSupported.getLength() + 2);
360 OUString*pArray = aSupported.getArray();
370 ,m_nClickEvent( nullptr )
371 ,m_nTargetUrlFeatureId( -1 )
372 ,m_bEnabledByPropertyValue( false )
377 Reference<XButton> xButton;
380 xButton->addActionListener(
this);
402 if ( !aReturn.hasValue() )
405 if ( !aReturn.hasValue() )
434 ::osl::MutexGuard aGuard(
m_aMutex );
442 ::osl::ClearableMutexGuard aGuard(
m_aMutex );
443 m_nClickEvent =
nullptr;
445 if (m_aApproveActionListeners.getLength())
449 getImageProducerThread()->addEvent();
458 Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
462 if (FormButtonType_PUSH == *o3tl::doAccess<FormButtonType>(xSet->getPropertyValue(
PROPERTY_BUTTONTYPE)))
466 ActionEvent aEvt(
static_cast<XWeak*
>(
this), m_aActionCommand);
474 aIter.
next()->actionPerformed(aEvt);
477 catch(
const RuntimeException& )
484 TOOLS_WARN_EXCEPTION(
"forms.component",
"OButtonControl::OnClick: caught an exception other than RuntimeException!" );
489 actionPerformed_Impl(
false, css::awt::MouseEvent() );
497 sal_Int16 nFeatureId = -1;
499 ::osl::MutexGuard aGuard(
m_aMutex );
503 if ( nFeatureId != -1 )
521 Reference<XButton> xButton;
524 xButton->setLabel(
Label);
531 ::osl::MutexGuard aGuard(
m_aMutex );
535 Reference<XButton> xButton;
538 xButton->setActionCommand(_rCommand);
555class DoPropertyListening
564 const Reference< XInterface >& _rxComponent,
565 const Reference< XPropertyChangeListener >& _rxListener,
569 void handleListening(
const OUString& _rPropertyName );
574DoPropertyListening::DoPropertyListening(
575 const Reference< XInterface >& _rxComponent,
const Reference< XPropertyChangeListener >& _rxListener,
577 :
m_xProps( _rxComponent, UNO_QUERY )
581 DBG_ASSERT(
m_xProps.is() || !_rxComponent.is(),
"DoPropertyListening::DoPropertyListening: valid component, but no property set!" );
586void DoPropertyListening::handleListening(
const OUString& _rPropertyName )
598void OButtonControl::startOrStopModelPropertyListening(
bool _bStart )
600 DoPropertyListening aListeningHandler( getModel(),
this, _bStart );
607sal_Bool SAL_CALL OButtonControl::setModel(
const Reference< XControlModel >& _rxModel )
609 startOrStopModelPropertyListening(
false );
610 bool bResult = OClickableImageBaseControl::setModel( _rxModel );
611 startOrStopModelPropertyListening(
true );
613 m_bEnabledByPropertyValue =
true;
614 Reference< XPropertySet > xModelProps( _rxModel, UNO_QUERY );
615 if ( xModelProps.is() )
616 xModelProps->getPropertyValue(
PROPERTY_ENABLED ) >>= m_bEnabledByPropertyValue;
618 modelFeatureUrlPotentiallyChanged( );
624void OButtonControl::modelFeatureUrlPotentiallyChanged( )
626 sal_Int16 nOldUrlFeatureId = m_nTargetUrlFeatureId;
629 m_nTargetUrlFeatureId = getModelUrlFeatureId( );
630 if ( nOldUrlFeatureId != m_nTargetUrlFeatureId )
632 invalidateSupportedFeaturesSet();
633 if ( !isDesignMode() )
639void SAL_CALL OButtonControl::propertyChange(
const PropertyChangeEvent& _rEvent )
645 modelFeatureUrlPotentiallyChanged( );
649 _rEvent.NewValue >>= m_bEnabledByPropertyValue;
656 bool isFormControllerURL( std::u16string_view _rURL )
658 static constexpr std::u16string_view PREFIX =
u".uno:FormController/";
659 return ( _rURL.size() > PREFIX.size() )
665sal_Int16 OButtonControl::getModelUrlFeatureId( )
const
667 sal_Int16 nFeatureId = -1;
671 FormButtonType eButtonType = FormButtonType_PUSH;
673 Reference< XPropertySet > xModelProps(
const_cast< OButtonControl*
>(
this )->getModel(), UNO_QUERY );
674 if ( xModelProps.is() )
681 if ( eButtonType == FormButtonType_URL )
684 if ( isFormControllerURL( sUrl ) )
686 nFeatureId = OFormNavigationMapper::getFeatureId( sUrl );
694void SAL_CALL OButtonControl::setDesignMode(
sal_Bool _bOn )
696 OClickableImageBaseControl::setDesignMode( _bOn );
699 disconnectDispatchers();
701 connectDispatchers();
706void OButtonControl::getSupportedFeatures( ::std::vector< sal_Int16 >& _rFeatureIds )
708 if ( -1 != m_nTargetUrlFeatureId )
709 _rFeatureIds.push_back( m_nTargetUrlFeatureId );
713void OButtonControl::featureStateChanged( sal_Int16 _nFeatureId,
bool _bEnabled )
715 if ( _nFeatureId == m_nTargetUrlFeatureId )
718 Reference< XVclWindowPeer > xPeer( getPeer(), UNO_QUERY );
728 OFormNavigationHelper::featureStateChanged( _nFeatureId, _bEnabled );
732void OButtonControl::allFeatureStatesChanged( )
734 if ( -1 != m_nTargetUrlFeatureId )
736 featureStateChanged( m_nTargetUrlFeatureId, isEnabled( m_nTargetUrlFeatureId ) );
739 OFormNavigationHelper::allFeatureStatesChanged( );
743bool OButtonControl::isEnabled( sal_Int16 _nFeatureId )
const
749 return OFormNavigationHelper::isEnabled( _nFeatureId );
753void SAL_CALL OButtonControl::registerDispatchProviderInterceptor(
const Reference< XDispatchProviderInterceptor >& _rxInterceptor )
755 OClickableImageBaseControl::registerDispatchProviderInterceptor( _rxInterceptor );
756 OFormNavigationHelper::registerDispatchProviderInterceptor( _rxInterceptor );
760void SAL_CALL OButtonControl::releaseDispatchProviderInterceptor(
const Reference< XDispatchProviderInterceptor >& _rxInterceptor )
762 OClickableImageBaseControl::releaseDispatchProviderInterceptor( _rxInterceptor );
763 OFormNavigationHelper::releaseDispatchProviderInterceptor( _rxInterceptor );
768extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
770 css::uno::Sequence<css::uno::Any>
const &)
775extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
777 css::uno::Sequence<css::uno::Any>
const &)
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
sal_Int32 addInterface(const css::uno::Reference< ListenerT > &rxIFace)
sal_Int32 removeInterface(const css::uno::Reference< ListenerT > &rxIFace)
bool hasMoreElements() const
css::uno::Reference< ListenerT > const & next()
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
oslInterlockedCount m_refCount
OUString m_aActionCommand
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
bool approveAction()
approves the action by calling the approve listeners
virtual void actionPerformed_Impl(bool bNotifyListener, const css::awt::MouseEvent &rEvt)
::comphelper::OInterfaceContainerHelper3< css::awt::XActionListener > m_aActionListeners
css::uno::Sequence< css::uno::Type > _getTypes() override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual css::uno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
css::form::FormButtonType m_eButtonType
virtual void SAL_CALL disposing() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void implInitializeImageURL()
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
bool isDispatchUrlInternal() const
void setDispatchUrlInternal(bool _bDispatch)
virtual void describeFixedProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
describes the properties provided by this class, or its respective derived class
virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream) override
const css::uno::Reference< css::uno::XComponentContext > & getContext() const
void writeHelpTextCompatibly(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream)
virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream) override
void readHelpTextCompatibly(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream)
css::uno::Reference< css::uno::XAggregation > m_xAggregate
virtual void SAL_CALL disposing() override
void addResetListener(const css::uno::Reference< css::form::XResetListener > &_listener)
void removeResetListener(const css::uno::Reference< css::form::XResetListener > &_listener)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr OUStringLiteral PROPERTY_TABINDEX
constexpr OUStringLiteral PROPERTY_TARGET_URL
constexpr OUStringLiteral PROPERTY_DISPATCHURLINTERNAL
constexpr OUStringLiteral PROPERTY_STATE
constexpr OUStringLiteral PROPERTY_TARGET_FRAME
constexpr OUStringLiteral PROPERTY_DEFAULT_STATE
constexpr OUStringLiteral PROPERTY_BUTTONTYPE
constexpr OUStringLiteral PROPERTY_ENABLED
#define LINK(Instance, Class, Member)
bool query_aggregation(const css::uno::Reference< css::uno::XAggregation > &_rxAggregate, css::uno::Reference< iface > &_rxOut)
bool tryPropertyValue(Any &_rConvertedValue, Any &_rOldValue, const Any &_rValueToSet, const Any &_rCurrentValue, const Type &_rExpectedType)
ListBox is a bit confusing / different from other form components, so here are a few notes:
IMPL_LINK_NOARG(OButtonControl, OnClick, void *, void)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
#define PROPERTY_ID_DEFAULT_STATE
#define PROPERTY_ID_DISPATCHURLINTERNAL
#define PROPERTY_ID_TARGET_FRAME
#define PROPERTY_ID_TARGET_URL
#define PROPERTY_ID_BUTTONTYPE
#define PROPERTY_ID_TABINDEX
constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_COMMANDBUTTON
constexpr OUStringLiteral FRM_SUN_COMPONENT_COMMANDBUTTON
constexpr OUStringLiteral FRM_SUN_CONTROL_COMMANDBUTTON
constexpr OUStringLiteral FRM_COMPONENT_COMMANDBUTTON
constexpr OUStringLiteral VCL_CONTROLMODEL_COMMANDBUTTON
constexpr OUStringLiteral VCL_CONTROL_COMMANDBUTTON