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