bump product version to 4.1.6.2
[LibreOffice.git] / forms / source / component / ImageControl.hxx
blob56f8952b2de4d8ab7f1d7e4bf0d901bcc3b52ca5
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 _FRM_IMAGE_CONTROL_HXX_
21 #define _FRM_IMAGE_CONTROL_HXX_
23 #include "FormComponent.hxx"
24 #include "imgprod.hxx"
25 #include <com/sun/star/form/XImageProducerSupplier.hpp>
26 #include <com/sun/star/awt/XMouseListener.hpp>
27 #include <com/sun/star/util/XModifyBroadcaster.hpp>
28 #include <com/sun/star/graphic/XGraphicObject.hpp>
29 #include <comphelper/propmultiplex.hxx>
30 #include <comphelper/implementationreference.hxx>
31 #include <cppuhelper/implbase2.hxx>
33 using namespace comphelper;
35 //.........................................................................
36 namespace frm
38 //.........................................................................
40 //==================================================================
41 // OImageControlModel
42 //==================================================================
43 typedef ::cppu::ImplHelper2 < ::com::sun::star::form::XImageProducerSupplier
44 , ::com::sun::star::awt::XImageProducer
45 > OImageControlModel_Base;
47 class OImageControlModel
48 :public OImageControlModel_Base
49 ,public OBoundControlModel
51 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> m_xImageProducer;
52 ImageProducer* m_pImageProducer;
53 bool m_bExternalGraphic;
54 sal_Bool m_bReadOnly;
55 OUString m_sImageURL;
56 ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject >
57 m_xGraphicObject;
58 OUString m_sDocumentURL;
60 protected:
61 // UNO Anbindung
62 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
64 inline ImageProducer* GetImageProducer() { return m_pImageProducer; }
66 public:
67 DECLARE_DEFAULT_LEAF_XTOR( OImageControlModel );
69 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
70 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception);
72 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 )
73 throw(::com::sun::star::lang::IllegalArgumentException);
75 // UNO Anbindung
76 DECLARE_UNO3_AGG_DEFAULTS(OImageControlModel, OBoundControlModel);
77 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException);
79 // XServiceInfo
80 IMPLEMENTATION_NAME(OImageControlModel);
81 virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
83 // OComponentHelper
84 virtual void SAL_CALL disposing();
86 // XPersistObject
87 virtual OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
88 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);
89 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);
91 // XImageProducerSupplier
92 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> SAL_CALL getImageProducer() throw ( ::com::sun::star::uno::RuntimeException);
94 // XImageProducer
95 virtual void SAL_CALL addConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException);
96 virtual void SAL_CALL removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException);
97 virtual void SAL_CALL startProduction( ) throw (::com::sun::star::uno::RuntimeException);
99 // OControlModel's property handling
100 virtual void describeAggregateProperties(
101 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
102 ) const;
103 virtual void describeFixedProperties(
104 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
105 ) const;
107 // prevent method hiding
108 using OBoundControlModel::disposing;
109 using OBoundControlModel::getFastPropertyValue;
111 protected:
112 // OBoundControlModel overridables
113 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm );
114 virtual void onDisconnectedDbColumn();
115 virtual ::com::sun::star::uno::Any
116 translateDbColumnToControlValue( );
117 virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset );
119 virtual ::com::sun::star::uno::Any
120 getControlValue( ) const;
121 virtual void doSetControlValue( const ::com::sun::star::uno::Any& _rValue );
123 virtual sal_Bool approveDbColumnType(sal_Int32 _nColumnType);
125 virtual void resetNoBroadcast();
127 protected:
128 DECLARE_XCLONEABLE();
130 void implConstruct();
132 /** displays the image described by the given URL
133 @precond
134 our own mutex is locked
136 sal_Bool impl_handleNewImageURL_lck( ValueChangeInstigator _eInstigator );
138 /** updates the binary stream, created from loading the file which the given URL points to, into our
139 bound field, or the control itself if there is no bound field
141 sal_Bool impl_updateStreamForURL_lck( const OUString& _rURL, ValueChangeInstigator _eInstigator );
143 DECL_LINK( OnImageImportDone, ::Graphic* );
146 //==================================================================
147 //= OImageControlControl
148 //==================================================================
149 typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::XMouseListener
150 , ::com::sun::star::util::XModifyBroadcaster
151 > OImageControlControl_Base;
152 class OImageControlControl : public OBoundControl
153 , public OImageControlControl_Base
155 private:
156 ::cppu::OInterfaceContainerHelper m_aModifyListeners;
158 // XTypeProvider
159 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
161 public:
162 OImageControlControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
164 // UNO
165 DECLARE_UNO3_AGG_DEFAULTS( OImageControlControl, OBoundControl );
166 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
168 // XEventListener
169 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
171 // XServiceInfo
172 IMPLEMENTATION_NAME(OImageControlControl);
173 virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
175 // XMouseListener
176 virtual void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
177 virtual void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
178 virtual void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
179 virtual void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
181 // XModifyBroadcaster
182 virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
183 virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
185 // OComponentHelper
186 virtual void SAL_CALL disposing();
188 private:
189 void implClearGraphics( sal_Bool _bForce );
190 bool implInsertGraphics();
192 /** determines whether the control does currently have an empty grahic set
194 bool impl_isEmptyGraphics_nothrow() const;
197 //.........................................................................
198 } // namespace frm
199 //.........................................................................
201 #endif // _FRM_IMAGE_CONTROL_HXX_
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */