1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 _FRM_BUTTON_HXX_
21 #define _FRM_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 //.........................................................................
41 //.........................................................................
43 //==================================================================
45 //==================================================================
46 typedef ::cppu::ImplHelper1
< ::com::sun::star::form::XReset
48 class OButtonModel
:public OClickableImageBaseModel
49 ,public OButtonModel_Base
52 DECLARE_DEFAULT_LEAF_XTOR( OButtonModel
);
55 DECLARE_UNO3_AGG_DEFAULTS( OButtonModel
, OClickableImageBaseModel
);
56 virtual ::com::sun::star::uno::Any SAL_CALL
queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw(::com::sun::star::uno::RuntimeException
);
58 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> _getTypes();
60 // ::com::sun::star::lang::XServiceInfo
61 IMPLEMENTATION_NAME(OButtonModel
);
62 virtual StringSequence SAL_CALL
getSupportedServiceNames() throw();
64 // ::com::sun::star::io::XPersistObject
65 virtual OUString SAL_CALL
getServiceName() throw ( ::com::sun::star::uno::RuntimeException
);
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
);
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
);
70 virtual void SAL_CALL
reset( ) throw (::com::sun::star::uno::RuntimeException
);
71 virtual void SAL_CALL
addResetListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XResetListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
72 virtual void SAL_CALL
removeResetListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XResetListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
74 // OControlModel's property handling
75 virtual void describeFixedProperties(
76 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& /* [out] */ _rProps
79 // XPropertySet and friends
80 virtual void SAL_CALL
getFastPropertyValue(::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const;
81 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
)
82 throw (::com::sun::star::uno::Exception
);
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
);
86 virtual ::com::sun::star::uno::Any
getPropertyDefaultByHandle( sal_Int32 nHandle
) const;
89 virtual void SAL_CALL
disposing();
95 void impl_resetNoBroadcast_nothrow();
97 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
100 ResetHelper m_aResetHelper
;
103 ToggleState m_eDefaultState
; // the default check state
106 using OClickableImageBaseModel::disposing
;
109 //==================================================================
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
;
117 class OButtonControl
:public OButtonControl_BASE
118 ,public OClickableImageBaseControl
119 ,public OFormNavigationHelper
122 sal_uLong m_nClickEvent
;
123 sal_Int16 m_nTargetUrlFeatureId
;
124 /// caches the value of the "Enabled" property of our model
125 sal_Bool m_bEnabledByPropertyValue
;
130 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> _getTypes();
133 OButtonControl(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxFactory
);
134 virtual ~OButtonControl();
137 IMPLEMENTATION_NAME(OButtonControl
);
138 virtual StringSequence SAL_CALL
getSupportedServiceNames() throw();
141 DECLARE_UNO3_AGG_DEFAULTS(OButtonControl
, OClickableImageBaseControl
);
142 virtual ::com::sun::star::uno::Any SAL_CALL
queryAggregation(const ::com::sun::star::uno::Type
& _rType
) throw(::com::sun::star::uno::RuntimeException
);
145 virtual void SAL_CALL
actionPerformed(const ::com::sun::star::awt::ActionEvent
& rEvent
) throw ( ::com::sun::star::uno::RuntimeException
);
148 virtual void SAL_CALL
addActionListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
>& _rxListener
) throw(::com::sun::star::uno::RuntimeException
);
149 virtual void SAL_CALL
removeActionListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
>& _rxListener
) throw(::com::sun::star::uno::RuntimeException
);
150 virtual void SAL_CALL
setLabel(const OUString
& Label
) throw(::com::sun::star::uno::RuntimeException
);
151 virtual void SAL_CALL
setActionCommand(const OUString
& _rCommand
) throw(::com::sun::star::uno::RuntimeException
);
154 virtual void SAL_CALL
disposing();
156 // XPropertyChangeListener
157 virtual void SAL_CALL
propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw(::com::sun::star::uno::RuntimeException
);
160 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& _rSource
) throw(::com::sun::star::uno::RuntimeException
);
163 virtual sal_Bool SAL_CALL
setModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>& _rxModel
) throw ( ::com::sun::star::uno::RuntimeException
);
164 void SAL_CALL
setDesignMode(sal_Bool bOn
) throw (::com::sun::star::uno::RuntimeException
);
167 // OFormNavigationHelper overriables
168 virtual void getSupportedFeatures( ::std::vector
< sal_Int16
>& /* [out] */ _rFeatureIds
);
169 virtual void featureStateChanged( sal_Int16 _nFeatureId
, sal_Bool _bEnabled
);
170 virtual void allFeatureStatesChanged( );
171 virtual bool isEnabled( sal_Int16 _nFeatureId
) const;
173 // XDispatchProviderInterception disambiguaiton
174 virtual void SAL_CALL
registerDispatchProviderInterceptor( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProviderInterceptor
>& Interceptor
) throw (::com::sun::star::uno::RuntimeException
);
175 virtual void SAL_CALL
releaseDispatchProviderInterceptor( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProviderInterceptor
>& Interceptor
) throw (::com::sun::star::uno::RuntimeException
);
177 // OImageControl overridables
178 virtual void actionPerformed_Impl( sal_Bool bNotifyListener
, const ::com::sun::star::awt::MouseEvent
& _rEvt
);
181 DECL_LINK( OnClick
, void* );
183 /** to be called whenever the feature URL represented by our model has potentially changed
185 void modelFeatureUrlPotentiallyChanged( );
187 /** retrieves the feature id (see OFormNavigationHelper) of the TargetURL of
190 sal_Int16
getModelUrlFeatureId( ) const;
192 /** starts or stops listening for changes in model properties we're interested in
194 void startOrStopModelPropertyListening( bool _bStart
);
197 //.........................................................................
199 //.........................................................................
201 #endif // _FRM_BUTTON_HXX_
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */