Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_FORMS_SOURCE_COMPONENT_BUTTON_HXX
21 : #define INCLUDED_FORMS_SOURCE_COMPONENT_BUTTON_HXX
22 :
23 : #include "clickableimage.hxx"
24 : #include "togglestate.hxx"
25 : #include "formnavigation.hxx"
26 : #include "resettable.hxx"
27 :
28 : #include <com/sun/star/awt/MouseEvent.hpp>
29 : #include <com/sun/star/lang/EventObject.hpp>
30 : #include <com/sun/star/awt/ActionEvent.hpp>
31 : #include <com/sun/star/awt/XActionListener.hpp>
32 : #include <com/sun/star/awt/XButton.hpp>
33 : #include <com/sun/star/form/XReset.hpp>
34 : #include <com/sun/star/beans/PropertyChangeEvent.hpp>
35 :
36 : #include <cppuhelper/implbase1.hxx>
37 :
38 : struct ImplSVEvent;
39 :
40 : namespace frm
41 : {
42 :
43 : typedef ::cppu::ImplHelper1 < ::com::sun::star::form::XReset
44 : > OButtonModel_Base;
45 : class OButtonModel :public OClickableImageBaseModel
46 : ,public OButtonModel_Base
47 : {
48 : public:
49 : DECLARE_DEFAULT_LEAF_XTOR( OButtonModel );
50 :
51 : // UNO
52 362714 : DECLARE_UNO3_AGG_DEFAULTS( OButtonModel, OClickableImageBaseModel )
53 : virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
54 :
55 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
56 :
57 : // ::com::sun::star::lang::XServiceInfo
58 0 : IMPLEMENTATION_NAME(OButtonModel);
59 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
60 :
61 : // ::com::sun::star::io::XPersistObject
62 : virtual OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
63 : 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, std::exception) SAL_OVERRIDE;
64 : 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, std::exception) SAL_OVERRIDE;
65 :
66 : // XReset
67 : virtual void SAL_CALL reset( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
68 : virtual void SAL_CALL addResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
69 : virtual void SAL_CALL removeResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
70 :
71 : // OControlModel's property handling
72 : virtual void describeFixedProperties(
73 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
74 : ) const SAL_OVERRIDE;
75 :
76 : // XPropertySet and friends
77 : virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE;
78 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
79 : throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
80 : virtual sal_Bool SAL_CALL convertFastPropertyValue(
81 : ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue )
82 : throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
83 : virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const SAL_OVERRIDE;
84 :
85 : // OComponentHelper
86 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
87 :
88 : protected:
89 : virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 :
91 : private:
92 : void impl_resetNoBroadcast_nothrow();
93 :
94 : using ::cppu::OPropertySetHelper::getFastPropertyValue;
95 :
96 : private:
97 : ResetHelper m_aResetHelper;
98 :
99 : // <properties>
100 : ToggleState m_eDefaultState; // the default check state
101 : // </properties>
102 : protected:
103 : using OClickableImageBaseModel::disposing;
104 : };
105 :
106 :
107 : // OButtonControl
108 :
109 : typedef ::cppu::ImplHelper3 < ::com::sun::star::awt::XButton
110 : , ::com::sun::star::awt::XActionListener
111 : , ::com::sun::star::beans::XPropertyChangeListener
112 : > OButtonControl_BASE;
113 :
114 : class OButtonControl :public OButtonControl_BASE
115 : ,public OClickableImageBaseControl
116 : ,public OFormNavigationHelper
117 : {
118 : private:
119 : ImplSVEvent * m_nClickEvent;
120 : sal_Int16 m_nTargetUrlFeatureId;
121 : /// caches the value of the "Enabled" property of our model
122 : bool m_bEnabledByPropertyValue;
123 :
124 : protected:
125 :
126 : // UNO binding
127 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
128 :
129 : public:
130 : OButtonControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory);
131 : virtual ~OButtonControl();
132 :
133 : // XServiceInfo
134 0 : IMPLEMENTATION_NAME(OButtonControl);
135 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
136 :
137 : // UNO binding
138 183583 : DECLARE_UNO3_AGG_DEFAULTS(OButtonControl, OClickableImageBaseControl)
139 : virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 :
141 : // XActionListener
142 : virtual void SAL_CALL actionPerformed(const ::com::sun::star::awt::ActionEvent& rEvent) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
143 :
144 : // XButton
145 : virtual void SAL_CALL addActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 : virtual void SAL_CALL removeActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 : virtual void SAL_CALL setLabel(const OUString& Label) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
148 : virtual void SAL_CALL setActionCommand(const OUString& _rCommand) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
149 :
150 : // OComponentHelper
151 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
152 :
153 : // XPropertyChangeListener
154 : virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 :
156 : // XEventListener
157 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
158 :
159 : // XControl
160 : virtual sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
161 : void SAL_CALL setDesignMode(sal_Bool bOn) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
162 :
163 : protected:
164 : // OFormNavigationHelper overriables
165 : virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ) SAL_OVERRIDE;
166 : virtual void featureStateChanged( sal_Int16 _nFeatureId, bool _bEnabled ) SAL_OVERRIDE;
167 : virtual void allFeatureStatesChanged( ) SAL_OVERRIDE;
168 : virtual bool isEnabled( sal_Int16 _nFeatureId ) const SAL_OVERRIDE;
169 :
170 : // XDispatchProviderInterception disambiguaiton
171 : virtual void SAL_CALL registerDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
172 : virtual void SAL_CALL releaseDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 :
174 : // OImageControl overridables
175 : virtual void actionPerformed_Impl( bool bNotifyListener, const ::com::sun::star::awt::MouseEvent& _rEvt ) SAL_OVERRIDE;
176 :
177 : private:
178 : DECL_LINK( OnClick, void* );
179 :
180 : /// to be called whenever the feature URL represented by our model has potentially changed
181 : void modelFeatureUrlPotentiallyChanged( );
182 :
183 : /// retrieves the feature id (see OFormNavigationHelper) of the TargetURL of the model.
184 : sal_Int16 getModelUrlFeatureId( ) const;
185 :
186 : /// starts or stops listening for changes in model properties we're interested in
187 : void startOrStopModelPropertyListening( bool _bStart );
188 : };
189 :
190 :
191 : } // namespace frm
192 :
193 :
194 : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_BUTTON_HXX
195 :
196 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|