bump product version to 5.0.4.1
[LibreOffice.git] / forms / source / component / ImageControl.hxx
blob1317c754932f55daef9ea4faa27f263eb5e68940
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_IMAGECONTROL_HXX
21 #define INCLUDED_FORMS_SOURCE_COMPONENT_IMAGECONTROL_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 <cppuhelper/implbase2.hxx>
32 using namespace comphelper;
35 namespace frm
40 // OImageControlModel
42 typedef ::cppu::ImplHelper2 < ::com::sun::star::form::XImageProducerSupplier
43 , ::com::sun::star::awt::XImageProducer
44 > OImageControlModel_Base;
46 class OImageControlModel
47 :public OImageControlModel_Base
48 ,public OBoundControlModel
50 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> m_xImageProducer;
51 ImageProducer* m_pImageProducer;
52 bool m_bExternalGraphic;
53 bool m_bReadOnly;
54 OUString m_sImageURL;
55 ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject >
56 m_xGraphicObject;
57 OUString m_sDocumentURL;
59 protected:
60 // UNO Anbindung
61 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
63 inline ImageProducer* GetImageProducer() { return m_pImageProducer; }
65 public:
66 DECLARE_DEFAULT_LEAF_XTOR( OImageControlModel );
68 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const SAL_OVERRIDE;
69 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
71 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 )
72 throw(::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
74 // UNO Anbindung
75 DECLARE_UNO3_AGG_DEFAULTS(OImageControlModel, OBoundControlModel)
76 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;
78 // XServiceInfo
79 OUString SAL_CALL getImplementationName()
80 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
81 { return OUString("com.sun.star.form.OImageControlModel"); }
83 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
85 // OComponentHelper
86 virtual void SAL_CALL disposing() SAL_OVERRIDE;
88 // XPersistObject
89 virtual OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 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;
91 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;
93 // XImageProducerSupplier
94 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> SAL_CALL getImageProducer() throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 // XImageProducer
97 virtual void SAL_CALL addConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 virtual void SAL_CALL removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 virtual void SAL_CALL startProduction( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 // OControlModel's property handling
102 virtual void describeAggregateProperties(
103 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
104 ) const SAL_OVERRIDE;
105 virtual void describeFixedProperties(
106 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
107 ) const SAL_OVERRIDE;
109 // prevent method hiding
110 using OBoundControlModel::disposing;
111 using OBoundControlModel::getFastPropertyValue;
113 protected:
114 // OBoundControlModel overridables
115 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ) SAL_OVERRIDE;
116 virtual void onDisconnectedDbColumn() SAL_OVERRIDE;
117 virtual ::com::sun::star::uno::Any
118 translateDbColumnToControlValue( ) SAL_OVERRIDE;
119 virtual bool commitControlValueToDbColumn( bool _bPostReset ) SAL_OVERRIDE;
121 virtual ::com::sun::star::uno::Any
122 getControlValue( ) const SAL_OVERRIDE;
123 virtual void doSetControlValue( const ::com::sun::star::uno::Any& _rValue ) SAL_OVERRIDE;
125 virtual bool approveDbColumnType(sal_Int32 _nColumnType) SAL_OVERRIDE;
127 virtual void resetNoBroadcast() SAL_OVERRIDE;
129 protected:
130 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 void implConstruct();
134 /** displays the image described by the given URL
135 @precond
136 our own mutex is locked
138 bool impl_handleNewImageURL_lck( ValueChangeInstigator _eInstigator );
140 /** updates the binary stream, created from loading the file which the given URL points to, into our
141 bound field, or the control itself if there is no bound field
143 bool impl_updateStreamForURL_lck( const OUString& _rURL, ValueChangeInstigator _eInstigator );
145 DECL_LINK( OnImageImportDone, ::Graphic* );
148 typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::XMouseListener
149 , ::com::sun::star::util::XModifyBroadcaster
150 > OImageControlControl_Base;
151 class OImageControlControl : public OBoundControl
152 , public OImageControlControl_Base
154 private:
155 ::cppu::OInterfaceContainerHelper m_aModifyListeners;
157 // XTypeProvider
158 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
160 public:
161 OImageControlControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory);
163 // UNO
164 DECLARE_UNO3_AGG_DEFAULTS( OImageControlControl, OBoundControl )
165 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;
167 // XEventListener
168 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
170 // XServiceInfo
171 OUString SAL_CALL getImplementationName()
172 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
173 { return OUString("com.sun.star.form.OImageControlControl"); }
175 virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
177 // XMouseListener
178 virtual void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 virtual void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 virtual void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 virtual void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
185 virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 // OComponentHelper
188 virtual void SAL_CALL disposing() SAL_OVERRIDE;
190 private:
191 void implClearGraphics( bool _bForce );
192 bool implInsertGraphics();
194 /** determines whether the control does currently have an empty grahic set
196 bool impl_isEmptyGraphics_nothrow() const;
200 } // namespace frm
203 #endif // INCLUDED_FORMS_SOURCE_COMPONENT_IMAGECONTROL_HXX
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */