update dev300-m58
[ooovba.git] / forms / source / component / ImageControl.hxx
blob32a5ca548ed70e2700bc1f4942ecc6a891ef2e49
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ImageControl.hxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _FRM_IMAGE_CONTROL_HXX_
32 #define _FRM_IMAGE_CONTROL_HXX_
34 #include "FormComponent.hxx"
35 #include "imgprod.hxx"
36 #include <com/sun/star/form/XImageProducerSupplier.hpp>
37 #include <com/sun/star/awt/XMouseListener.hpp>
38 #include <com/sun/star/util/XModifyBroadcaster.hpp>
39 #include <comphelper/propmultiplex.hxx>
40 #include <comphelper/implementationreference.hxx>
41 #include <cppuhelper/implbase2.hxx>
43 using namespace comphelper;
45 //.........................................................................
46 namespace frm
48 //.........................................................................
50 //==================================================================
51 // OImageControlModel
52 //==================================================================
53 typedef ::cppu::ImplHelper2 < ::com::sun::star::form::XImageProducerSupplier
54 , ::com::sun::star::awt::XImageProducer
55 > OImageControlModel_Base;
57 class OImageControlModel
58 :public OImageControlModel_Base
59 ,public OBoundControlModel
61 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> m_xImageProducer;
62 ImageProducer* m_pImageProducer;
63 sal_Bool m_bReadOnly;
64 ::rtl::OUString m_sDocumentURL;
66 protected:
67 // UNO Anbindung
68 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
70 inline ImageProducer* GetImageProducer() { return m_pImageProducer; }
72 public:
73 DECLARE_DEFAULT_LEAF_XTOR( OImageControlModel );
75 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
76 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception);
78 virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue, sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
79 throw(::com::sun::star::lang::IllegalArgumentException);
81 // UNO Anbindung
82 DECLARE_UNO3_AGG_DEFAULTS(OImageControlModel, OBoundControlModel);
83 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException);
85 // XServiceInfo
86 IMPLEMENTATION_NAME(OImageControlModel);
87 virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
89 // OComponentHelper
90 virtual void SAL_CALL disposing();
92 // OPropertyChangeListener
93 virtual void _propertyChanged( const ::com::sun::star::beans::PropertyChangeEvent& ) throw(::com::sun::star::uno::RuntimeException);
95 // XPersistObject
96 virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
97 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);
98 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);
100 // XImageProducerSupplier
101 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> SAL_CALL getImageProducer() throw ( ::com::sun::star::uno::RuntimeException);
103 // XImageProducer
104 virtual void SAL_CALL addConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException);
105 virtual void SAL_CALL removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException);
106 virtual void SAL_CALL startProduction( ) throw (::com::sun::star::uno::RuntimeException);
108 // OControlModel's property handling
109 virtual void describeFixedProperties(
110 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
111 ) const;
113 // prevent method hiding
114 using OBoundControlModel::disposing;
115 using OBoundControlModel::getFastPropertyValue;
117 protected:
118 // OBoundControlModel overridables
119 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm );
120 virtual void onDisconnectedDbColumn();
121 virtual ::com::sun::star::uno::Any
122 translateDbColumnToControlValue( );
123 virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset );
125 virtual void doSetControlValue( const ::com::sun::star::uno::Any& _rValue );
127 virtual sal_Bool approveDbColumnType(sal_Int32 _nColumnType);
129 virtual void resetNoBroadcast();
131 protected:
132 DECLARE_XCLONEABLE();
134 void implConstruct();
136 /** displays the image described by the given URL
137 @precond
138 our own mutex is locked
140 sal_Bool impl_handleNewImageURL_lck( const ::rtl::OUString& _rURL, ValueChangeInstigator _eInstigator );
142 /** updates the binary stream, created from loading the file which the given URL points to, into our
143 bound field, or the control itself if there is no bound field
145 sal_Bool impl_updateStreamForURL_lck( const ::rtl::OUString& _rURL, ValueChangeInstigator _eInstigator );
148 //==================================================================
149 //= OImageControlControl
150 //==================================================================
151 typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::XMouseListener
152 , ::com::sun::star::util::XModifyBroadcaster
153 > OImageControlControl_Base;
154 class OImageControlControl : public OBoundControl
155 , public OImageControlControl_Base
157 private:
158 ::cppu::OInterfaceContainerHelper m_aModifyListeners;
160 // XTypeProvider
161 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
163 public:
164 OImageControlControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
166 // UNO
167 DECLARE_UNO3_AGG_DEFAULTS( OImageControlControl, OBoundControl );
168 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
170 // XEventListener
171 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
173 // XServiceInfo
174 IMPLEMENTATION_NAME(OImageControlControl);
175 virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
177 // XMouseListener
178 virtual void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
179 virtual void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
180 virtual void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
181 virtual void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
183 // XModifyBroadcaster
184 virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
185 virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
187 // OComponentHelper
188 virtual void SAL_CALL disposing();
190 private:
191 void implClearGraphics( sal_Bool _bForce );
192 bool implInsertGraphics();
194 /** determines whether the control does currently have an empty grahic set
196 bool impl_isEmptyGraphics_nothrow() const;
199 //.........................................................................
200 } // namespace frm
201 //.........................................................................
203 #endif // _FRM_IMAGE_CONTROL_HXX_