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 200268 : 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 1 : OUString SAL_CALL getImplementationName()
59 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
60 1 : { return OUString("com.sun.star.form.OButtonModel"); }
61 :
62 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
63 :
64 : // ::com::sun::star::io::XPersistObject
65 : virtual OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
66 : 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;
67 : 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;
68 :
69 : // XReset
70 : virtual void SAL_CALL reset( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
71 : 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;
72 : 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;
73 :
74 : // OControlModel's property handling
75 : virtual void describeFixedProperties(
76 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
77 : ) const SAL_OVERRIDE;
78 :
79 : // XPropertySet and friends
80 : virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE;
81 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
82 : throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
83 : virtual sal_Bool SAL_CALL convertFastPropertyValue(
84 : ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue )
85 : throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
86 : virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const SAL_OVERRIDE;
87 :
88 : // OComponentHelper
89 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
90 :
91 : protected:
92 : virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 :
94 : private:
95 : void impl_resetNoBroadcast_nothrow();
96 :
97 : using ::cppu::OPropertySetHelper::getFastPropertyValue;
98 :
99 : private:
100 : ResetHelper m_aResetHelper;
101 :
102 : // <properties>
103 : ToggleState m_eDefaultState; // the default check state
104 : // </properties>
105 : protected:
106 : using OClickableImageBaseModel::disposing;
107 : };
108 :
109 :
110 : // OButtonControl
111 :
112 : typedef ::cppu::ImplHelper3 < ::com::sun::star::awt::XButton
113 : , ::com::sun::star::awt::XActionListener
114 : , ::com::sun::star::beans::XPropertyChangeListener
115 : > OButtonControl_BASE;
116 :
117 : class OButtonControl :public OButtonControl_BASE
118 : ,public OClickableImageBaseControl
119 : ,public OFormNavigationHelper
120 : {
121 : private:
122 : ImplSVEvent * m_nClickEvent;
123 : sal_Int16 m_nTargetUrlFeatureId;
124 : /// caches the value of the "Enabled" property of our model
125 : bool m_bEnabledByPropertyValue;
126 :
127 : protected:
128 :
129 : // UNO binding
130 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
131 :
132 : public:
133 : OButtonControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory);
134 : virtual ~OButtonControl();
135 :
136 : // XServiceInfo
137 1 : OUString SAL_CALL getImplementationName()
138 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
139 1 : { return OUString("com.sun.star.form.OButtonControl"); }
140 :
141 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
142 :
143 : // UNO binding
144 99179 : DECLARE_UNO3_AGG_DEFAULTS(OButtonControl, OClickableImageBaseControl)
145 : 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;
146 :
147 : // XActionListener
148 : virtual void SAL_CALL actionPerformed(const ::com::sun::star::awt::ActionEvent& rEvent) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
149 :
150 : // XButton
151 : 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;
152 : 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;
153 : virtual void SAL_CALL setLabel(const OUString& Label) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
154 : virtual void SAL_CALL setActionCommand(const OUString& _rCommand) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 :
156 : // OComponentHelper
157 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
158 :
159 : // XPropertyChangeListener
160 : virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
161 :
162 : // XEventListener
163 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
164 :
165 : // XControl
166 : 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;
167 : void SAL_CALL setDesignMode(sal_Bool bOn) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
168 :
169 : protected:
170 : // OFormNavigationHelper overriables
171 : virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ) SAL_OVERRIDE;
172 : virtual void featureStateChanged( sal_Int16 _nFeatureId, bool _bEnabled ) SAL_OVERRIDE;
173 : virtual void allFeatureStatesChanged( ) SAL_OVERRIDE;
174 : virtual bool isEnabled( sal_Int16 _nFeatureId ) const SAL_OVERRIDE;
175 :
176 : // XDispatchProviderInterception disambiguaiton
177 : 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;
178 : 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;
179 :
180 : // OImageControl overridables
181 : virtual void actionPerformed_Impl( bool bNotifyListener, const ::com::sun::star::awt::MouseEvent& _rEvt ) SAL_OVERRIDE;
182 :
183 : private:
184 : DECL_LINK( OnClick, void* );
185 :
186 : /// to be called whenever the feature URL represented by our model has potentially changed
187 : void modelFeatureUrlPotentiallyChanged( );
188 :
189 : /// retrieves the feature id (see OFormNavigationHelper) of the TargetURL of the model.
190 : sal_Int16 getModelUrlFeatureId( ) const;
191 :
192 : /// starts or stops listening for changes in model properties we're interested in
193 : void startOrStopModelPropertyListening( bool _bStart );
194 : };
195 :
196 :
197 : } // namespace frm
198 :
199 :
200 : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_BUTTON_HXX
201 :
202 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|