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