1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _FRM_BUTTON_HXX_ 29*cdf0e10cSrcweir #define _FRM_BUTTON_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "clickableimage.hxx" 32*cdf0e10cSrcweir #include "togglestate.hxx" 33*cdf0e10cSrcweir #include "formnavigation.hxx" 34*cdf0e10cSrcweir #include "resettable.hxx" 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <com/sun/star/awt/MouseEvent.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/lang/EventObject.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/awt/ActionEvent.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/awt/XActionListener.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/awt/XButton.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/form/XReset.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyChangeEvent.hpp> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir //......................................................................... 47*cdf0e10cSrcweir namespace frm 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir //......................................................................... 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir //================================================================== 52*cdf0e10cSrcweir // OButtonModel 53*cdf0e10cSrcweir //================================================================== 54*cdf0e10cSrcweir typedef ::cppu::ImplHelper1 < ::com::sun::star::form::XReset 55*cdf0e10cSrcweir > OButtonModel_Base; 56*cdf0e10cSrcweir class OButtonModel :public OClickableImageBaseModel 57*cdf0e10cSrcweir ,public OButtonModel_Base 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir public: 60*cdf0e10cSrcweir DECLARE_DEFAULT_LEAF_XTOR( OButtonModel ); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir // UNO 63*cdf0e10cSrcweir DECLARE_UNO3_AGG_DEFAULTS( OButtonModel, OClickableImageBaseModel ); 64*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 69*cdf0e10cSrcweir IMPLEMENTATION_NAME(OButtonModel); 70*cdf0e10cSrcweir virtual StringSequence SAL_CALL getSupportedServiceNames() throw(); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir // ::com::sun::star::io::XPersistObject 73*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException); 74*cdf0e10cSrcweir virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 75*cdf0e10cSrcweir virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir // XReset 78*cdf0e10cSrcweir virtual void SAL_CALL reset( ) throw (::com::sun::star::uno::RuntimeException); 79*cdf0e10cSrcweir virtual void SAL_CALL addResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 80*cdf0e10cSrcweir virtual void SAL_CALL removeResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir // OControlModel's property handling 83*cdf0e10cSrcweir virtual void describeFixedProperties( 84*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps 85*cdf0e10cSrcweir ) const; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir // XPropertySet and friends 88*cdf0e10cSrcweir virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const; 89*cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) 90*cdf0e10cSrcweir throw (::com::sun::star::uno::Exception); 91*cdf0e10cSrcweir virtual sal_Bool SAL_CALL convertFastPropertyValue( 92*cdf0e10cSrcweir ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) 93*cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException); 94*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir // OComponentHelper 97*cdf0e10cSrcweir virtual void SAL_CALL disposing(); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir protected: 100*cdf0e10cSrcweir DECLARE_XCLONEABLE(); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir private: 103*cdf0e10cSrcweir void impl_resetNoBroadcast_nothrow(); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir using ::cppu::OPropertySetHelper::getFastPropertyValue; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir private: 108*cdf0e10cSrcweir ResetHelper m_aResetHelper; 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir // <properties> 111*cdf0e10cSrcweir ToggleState m_eDefaultState; // the default check state 112*cdf0e10cSrcweir // </properties> 113*cdf0e10cSrcweir protected: 114*cdf0e10cSrcweir using OClickableImageBaseModel::disposing; 115*cdf0e10cSrcweir }; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir //================================================================== 118*cdf0e10cSrcweir // OButtonControl 119*cdf0e10cSrcweir //================================================================== 120*cdf0e10cSrcweir typedef ::cppu::ImplHelper3 < ::com::sun::star::awt::XButton 121*cdf0e10cSrcweir , ::com::sun::star::awt::XActionListener 122*cdf0e10cSrcweir , ::com::sun::star::beans::XPropertyChangeListener 123*cdf0e10cSrcweir > OButtonControl_BASE; 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir class OButtonControl :public OButtonControl_BASE 126*cdf0e10cSrcweir ,public OClickableImageBaseControl 127*cdf0e10cSrcweir ,public OFormNavigationHelper 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir private: 130*cdf0e10cSrcweir sal_uLong m_nClickEvent; 131*cdf0e10cSrcweir sal_Int16 m_nTargetUrlFeatureId; 132*cdf0e10cSrcweir /// caches the value of the "Enabled" property of our model 133*cdf0e10cSrcweir sal_Bool m_bEnabledByPropertyValue; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir protected: 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir // UNO Anbindung 138*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir public: 141*cdf0e10cSrcweir OButtonControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); 142*cdf0e10cSrcweir virtual ~OButtonControl(); 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir // XServiceInfo 145*cdf0e10cSrcweir IMPLEMENTATION_NAME(OButtonControl); 146*cdf0e10cSrcweir virtual StringSequence SAL_CALL getSupportedServiceNames() throw(); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir // UNO Anbindung 149*cdf0e10cSrcweir DECLARE_UNO3_AGG_DEFAULTS(OButtonControl, OClickableImageBaseControl); 150*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir // XActionListener 153*cdf0e10cSrcweir virtual void SAL_CALL actionPerformed(const ::com::sun::star::awt::ActionEvent& rEvent) throw ( ::com::sun::star::uno::RuntimeException); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir // XButton 156*cdf0e10cSrcweir virtual void SAL_CALL addActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException); 157*cdf0e10cSrcweir virtual void SAL_CALL removeActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException); 158*cdf0e10cSrcweir virtual void SAL_CALL setLabel(const ::rtl::OUString& Label) throw(::com::sun::star::uno::RuntimeException); 159*cdf0e10cSrcweir virtual void SAL_CALL setActionCommand(const ::rtl::OUString& _rCommand) throw(::com::sun::star::uno::RuntimeException); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir // OComponentHelper 162*cdf0e10cSrcweir virtual void SAL_CALL disposing(); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir // XPropertyChangeListener 165*cdf0e10cSrcweir virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir // XEventListener 168*cdf0e10cSrcweir virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir // XControl 171*cdf0e10cSrcweir virtual sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ) throw ( ::com::sun::star::uno::RuntimeException ); 172*cdf0e10cSrcweir void SAL_CALL setDesignMode(sal_Bool bOn) throw (::com::sun::star::uno::RuntimeException); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir protected: 175*cdf0e10cSrcweir // OFormNavigationHelper overriables 176*cdf0e10cSrcweir virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ); 177*cdf0e10cSrcweir virtual void featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ); 178*cdf0e10cSrcweir virtual void allFeatureStatesChanged( ); 179*cdf0e10cSrcweir virtual bool isEnabled( sal_Int16 _nFeatureId ) const; 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir // XDispatchProviderInterception disambiguaiton 182*cdf0e10cSrcweir virtual void SAL_CALL registerDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException); 183*cdf0e10cSrcweir virtual void SAL_CALL releaseDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir // OImageControl overridables 186*cdf0e10cSrcweir virtual void actionPerformed_Impl( sal_Bool bNotifyListener, const ::com::sun::star::awt::MouseEvent& _rEvt ); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir private: 189*cdf0e10cSrcweir DECL_LINK( OnClick, void* ); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir /** to be called whenever the feature URL represented by our model has potentially changed 192*cdf0e10cSrcweir */ 193*cdf0e10cSrcweir void modelFeatureUrlPotentiallyChanged( ); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir /** retrieves the feature id (see OFormNavigationHelper) of the TargetURL of 196*cdf0e10cSrcweir the model. 197*cdf0e10cSrcweir */ 198*cdf0e10cSrcweir sal_Int16 getModelUrlFeatureId( ) const; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir /** starts or stops listening for changes in model properties we're interested in 201*cdf0e10cSrcweir */ 202*cdf0e10cSrcweir void startOrStopModelPropertyListening( bool _bStart ); 203*cdf0e10cSrcweir }; 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir //......................................................................... 206*cdf0e10cSrcweir } // namespace frm 207*cdf0e10cSrcweir //......................................................................... 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir #endif // _FRM_BUTTON_HXX_ 210*cdf0e10cSrcweir 211