xref: /aoo41x/main/forms/source/component/Button.hxx (revision 2d785d7e)
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 _FRM_BUTTON_HXX_
25cdf0e10cSrcweir #define _FRM_BUTTON_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "clickableimage.hxx"
28cdf0e10cSrcweir #include "togglestate.hxx"
29cdf0e10cSrcweir #include "formnavigation.hxx"
30cdf0e10cSrcweir #include "resettable.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <com/sun/star/awt/MouseEvent.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/EventObject.hpp>
34cdf0e10cSrcweir #include <com/sun/star/awt/ActionEvent.hpp>
35cdf0e10cSrcweir #include <com/sun/star/awt/XActionListener.hpp>
36cdf0e10cSrcweir #include <com/sun/star/awt/XButton.hpp>
37cdf0e10cSrcweir #include <com/sun/star/form/XReset.hpp>
38cdf0e10cSrcweir #include <com/sun/star/beans/PropertyChangeEvent.hpp>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //.........................................................................
43cdf0e10cSrcweir namespace frm
44cdf0e10cSrcweir {
45cdf0e10cSrcweir //.........................................................................
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //==================================================================
48cdf0e10cSrcweir // OButtonModel
49cdf0e10cSrcweir //==================================================================
50cdf0e10cSrcweir typedef ::cppu::ImplHelper1 <   ::com::sun::star::form::XReset
51cdf0e10cSrcweir                             >   OButtonModel_Base;
52cdf0e10cSrcweir class OButtonModel  :public OClickableImageBaseModel
53cdf0e10cSrcweir                     ,public OButtonModel_Base
54cdf0e10cSrcweir {
55cdf0e10cSrcweir public:
56cdf0e10cSrcweir 	DECLARE_DEFAULT_LEAF_XTOR( OButtonModel );
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     // UNO
59cdf0e10cSrcweir 	DECLARE_UNO3_AGG_DEFAULTS( OButtonModel, OClickableImageBaseModel );
60cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
63cdf0e10cSrcweir 
64cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
65cdf0e10cSrcweir 	IMPLEMENTATION_NAME(OButtonModel);
66cdf0e10cSrcweir 	virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
67cdf0e10cSrcweir 
68cdf0e10cSrcweir // ::com::sun::star::io::XPersistObject
69cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
70cdf0e10cSrcweir 	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);
71cdf0e10cSrcweir 	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);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     // XReset
74cdf0e10cSrcweir     virtual void SAL_CALL reset(  ) throw (::com::sun::star::uno::RuntimeException);
75cdf0e10cSrcweir     virtual void SAL_CALL addResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
76cdf0e10cSrcweir     virtual void SAL_CALL removeResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     // OControlModel's property handling
79cdf0e10cSrcweir 	virtual void describeFixedProperties(
80cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
81cdf0e10cSrcweir     ) const;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     // XPropertySet and friends
84cdf0e10cSrcweir     virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const;
85cdf0e10cSrcweir     virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
86cdf0e10cSrcweir                 throw (::com::sun::star::uno::Exception);
87cdf0e10cSrcweir     virtual sal_Bool SAL_CALL convertFastPropertyValue(
88cdf0e10cSrcweir                 ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue )
89cdf0e10cSrcweir                 throw (::com::sun::star::lang::IllegalArgumentException);
90cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     // OComponentHelper
93cdf0e10cSrcweir     virtual void SAL_CALL disposing();
94cdf0e10cSrcweir 
95cdf0e10cSrcweir protected:
96cdf0e10cSrcweir 	DECLARE_XCLONEABLE();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir private:
99cdf0e10cSrcweir     void    impl_resetNoBroadcast_nothrow();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     using ::cppu::OPropertySetHelper::getFastPropertyValue;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir private:
104cdf0e10cSrcweir     ResetHelper m_aResetHelper;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     // <properties>
107cdf0e10cSrcweir     ToggleState m_eDefaultState;          // the default check state
108cdf0e10cSrcweir     // </properties>
109cdf0e10cSrcweir protected:
110cdf0e10cSrcweir     using OClickableImageBaseModel::disposing;
111cdf0e10cSrcweir };
112cdf0e10cSrcweir 
113cdf0e10cSrcweir //==================================================================
114cdf0e10cSrcweir // OButtonControl
115cdf0e10cSrcweir //==================================================================
116cdf0e10cSrcweir typedef ::cppu::ImplHelper3 <   ::com::sun::star::awt::XButton
117cdf0e10cSrcweir                             ,   ::com::sun::star::awt::XActionListener
118cdf0e10cSrcweir                             ,   ::com::sun::star::beans::XPropertyChangeListener
119cdf0e10cSrcweir                             >   OButtonControl_BASE;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir class OButtonControl	:public OButtonControl_BASE
122cdf0e10cSrcweir                         ,public OClickableImageBaseControl
123cdf0e10cSrcweir                         ,public OFormNavigationHelper
124cdf0e10cSrcweir {
125cdf0e10cSrcweir private:
126cdf0e10cSrcweir 	sal_uLong m_nClickEvent;
127cdf0e10cSrcweir     sal_Int16   m_nTargetUrlFeatureId;
128cdf0e10cSrcweir     /// caches the value of the "Enabled" property of our model
129cdf0e10cSrcweir     sal_Bool    m_bEnabledByPropertyValue;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir protected:
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	// UNO Anbindung
134cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
135cdf0e10cSrcweir 
136cdf0e10cSrcweir public:
137cdf0e10cSrcweir 	OButtonControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
138cdf0e10cSrcweir 	virtual ~OButtonControl();
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     // XServiceInfo
141cdf0e10cSrcweir 	IMPLEMENTATION_NAME(OButtonControl);
142cdf0e10cSrcweir 	virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     // UNO Anbindung
145cdf0e10cSrcweir 	DECLARE_UNO3_AGG_DEFAULTS(OButtonControl, OClickableImageBaseControl);
146cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     // XActionListener
149cdf0e10cSrcweir 	virtual void SAL_CALL actionPerformed(const ::com::sun::star::awt::ActionEvent& rEvent) throw ( ::com::sun::star::uno::RuntimeException);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     // XButton
152cdf0e10cSrcweir 	virtual void SAL_CALL addActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException);
153cdf0e10cSrcweir     virtual void SAL_CALL removeActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException);
154cdf0e10cSrcweir     virtual void SAL_CALL setLabel(const ::rtl::OUString& Label) throw(::com::sun::star::uno::RuntimeException);
155cdf0e10cSrcweir     virtual void SAL_CALL setActionCommand(const ::rtl::OUString& _rCommand) throw(::com::sun::star::uno::RuntimeException);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     // OComponentHelper
158cdf0e10cSrcweir 	virtual void SAL_CALL disposing();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     // XPropertyChangeListener
161cdf0e10cSrcweir     virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     // XEventListener
164cdf0e10cSrcweir     virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     // XControl
167cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ) throw ( ::com::sun::star::uno::RuntimeException );
168cdf0e10cSrcweir     void SAL_CALL setDesignMode(sal_Bool bOn) throw (::com::sun::star::uno::RuntimeException);
169cdf0e10cSrcweir 
170cdf0e10cSrcweir protected:
171cdf0e10cSrcweir     // OFormNavigationHelper overriables
172cdf0e10cSrcweir     virtual void    getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds );
173cdf0e10cSrcweir     virtual void    featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled );
174cdf0e10cSrcweir     virtual void    allFeatureStatesChanged( );
175cdf0e10cSrcweir     virtual bool    isEnabled( sal_Int16 _nFeatureId ) const;
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     // XDispatchProviderInterception disambiguaiton
178cdf0e10cSrcweir     virtual void SAL_CALL registerDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
179cdf0e10cSrcweir     virtual void SAL_CALL releaseDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     // OImageControl overridables
182cdf0e10cSrcweir 	virtual void    actionPerformed_Impl( sal_Bool bNotifyListener, const ::com::sun::star::awt::MouseEvent& _rEvt );
183cdf0e10cSrcweir 
184cdf0e10cSrcweir private:
185cdf0e10cSrcweir 	DECL_LINK( OnClick, void* );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     /** to be called whenever the feature URL represented by our model has potentially changed
188cdf0e10cSrcweir     */
189cdf0e10cSrcweir     void        modelFeatureUrlPotentiallyChanged( );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     /** retrieves the feature id (see OFormNavigationHelper) of the TargetURL of
192cdf0e10cSrcweir         the model.
193cdf0e10cSrcweir     */
194cdf0e10cSrcweir     sal_Int16   getModelUrlFeatureId( ) const;
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     /** starts or stops listening for changes in model properties we're interested in
197cdf0e10cSrcweir     */
198cdf0e10cSrcweir     void        startOrStopModelPropertyListening( bool _bStart );
199cdf0e10cSrcweir };
200cdf0e10cSrcweir 
201cdf0e10cSrcweir //.........................................................................
202cdf0e10cSrcweir }	// namespace frm
203cdf0e10cSrcweir //.........................................................................
204cdf0e10cSrcweir 
205cdf0e10cSrcweir #endif // _FRM_BUTTON_HXX_
206cdf0e10cSrcweir 
207