bump product version to 5.0.4.1
[LibreOffice.git] / forms / source / component / Button.hxx
blobcd28061b545f3a72561488a66c5c925c57f2d894
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_FORMS_SOURCE_COMPONENT_BUTTON_HXX
21 #define INCLUDED_FORMS_SOURCE_COMPONENT_BUTTON_HXX
23 #include "clickableimage.hxx"
24 #include "togglestate.hxx"
25 #include "formnavigation.hxx"
26 #include "resettable.hxx"
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>
36 #include <cppuhelper/implbase1.hxx>
38 struct ImplSVEvent;
40 namespace frm
43 typedef ::cppu::ImplHelper1 < ::com::sun::star::form::XReset
44 > OButtonModel_Base;
45 class OButtonModel :public OClickableImageBaseModel
46 ,public OButtonModel_Base
48 public:
49 DECLARE_DEFAULT_LEAF_XTOR( OButtonModel );
51 // UNO
52 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;
55 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
57 // ::com::sun::star::lang::XServiceInfo
58 OUString SAL_CALL getImplementationName()
59 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
60 { return OUString("com.sun.star.form.OButtonModel"); }
62 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
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;
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;
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;
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;
88 // OComponentHelper
89 virtual void SAL_CALL disposing() SAL_OVERRIDE;
91 protected:
92 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 private:
95 void impl_resetNoBroadcast_nothrow();
97 using ::cppu::OPropertySetHelper::getFastPropertyValue;
99 private:
100 ResetHelper m_aResetHelper;
102 // <properties>
103 ToggleState m_eDefaultState; // the default check state
104 // </properties>
105 protected:
106 using OClickableImageBaseModel::disposing;
110 // OButtonControl
112 typedef ::cppu::ImplHelper3 < ::com::sun::star::awt::XButton
113 , ::com::sun::star::awt::XActionListener
114 , ::com::sun::star::beans::XPropertyChangeListener
115 > OButtonControl_BASE;
117 class OButtonControl :public OButtonControl_BASE
118 ,public OClickableImageBaseControl
119 ,public OFormNavigationHelper
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;
127 protected:
129 // UNO binding
130 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
132 public:
133 OButtonControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory);
134 virtual ~OButtonControl();
136 // XServiceInfo
137 OUString SAL_CALL getImplementationName()
138 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
139 { return OUString("com.sun.star.form.OButtonControl"); }
141 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
143 // UNO binding
144 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;
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;
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;
156 // OComponentHelper
157 virtual void SAL_CALL disposing() SAL_OVERRIDE;
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;
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;
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;
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;
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;
180 // OImageControl overridables
181 virtual void actionPerformed_Impl( bool bNotifyListener, const ::com::sun::star::awt::MouseEvent& _rEvt ) SAL_OVERRIDE;
183 private:
184 DECL_LINK( OnClick, void* );
186 /// to be called whenever the feature URL represented by our model has potentially changed
187 void modelFeatureUrlPotentiallyChanged( );
189 /// retrieves the feature id (see OFormNavigationHelper) of the TargetURL of the model.
190 sal_Int16 getModelUrlFeatureId( ) const;
192 /// starts or stops listening for changes in model properties we're interested in
193 void startOrStopModelPropertyListening( bool _bStart );
197 } // namespace frm
200 #endif // INCLUDED_FORMS_SOURCE_COMPONENT_BUTTON_HXX
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */