Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_FORMS_SOURCE_COMPONENT_IMAGECONTROL_HXX
21 : #define INCLUDED_FORMS_SOURCE_COMPONENT_IMAGECONTROL_HXX
22 :
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>
31 :
32 : using namespace comphelper;
33 :
34 :
35 : namespace frm
36 : {
37 :
38 :
39 :
40 : // OImageControlModel
41 :
42 : typedef ::cppu::ImplHelper2 < ::com::sun::star::form::XImageProducerSupplier
43 : , ::com::sun::star::awt::XImageProducer
44 : > OImageControlModel_Base;
45 :
46 : class OImageControlModel
47 : :public OImageControlModel_Base
48 : ,public OBoundControlModel
49 : {
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;
58 :
59 : protected:
60 : // UNO Anbindung
61 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
62 :
63 12 : inline ImageProducer* GetImageProducer() { return m_pImageProducer; }
64 :
65 : public:
66 : DECLARE_DEFAULT_LEAF_XTOR( OImageControlModel );
67 :
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;
70 :
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;
73 :
74 : // UNO Anbindung
75 21808 : 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;
77 :
78 : // XServiceInfo
79 8 : OUString SAL_CALL getImplementationName()
80 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
81 8 : { return OUString("com.sun.star.form.OImageControlModel"); }
82 :
83 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
84 :
85 : // OComponentHelper
86 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
87 :
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;
92 :
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;
95 :
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;
100 :
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;
108 :
109 : // prevent method hiding
110 : using OBoundControlModel::disposing;
111 : using OBoundControlModel::getFastPropertyValue;
112 :
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;
120 :
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;
124 :
125 : virtual bool approveDbColumnType(sal_Int32 _nColumnType) SAL_OVERRIDE;
126 :
127 : virtual void resetNoBroadcast() SAL_OVERRIDE;
128 :
129 : protected:
130 : virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 :
132 : void implConstruct();
133 :
134 : /** displays the image described by the given URL
135 : @precond
136 : our own mutex is locked
137 : */
138 : bool impl_handleNewImageURL_lck( ValueChangeInstigator _eInstigator );
139 :
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
142 : */
143 : bool impl_updateStreamForURL_lck( const OUString& _rURL, ValueChangeInstigator _eInstigator );
144 :
145 : DECL_LINK( OnImageImportDone, ::Graphic* );
146 : };
147 :
148 : typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::XMouseListener
149 : , ::com::sun::star::util::XModifyBroadcaster
150 : > OImageControlControl_Base;
151 4 : class OImageControlControl : public OBoundControl
152 : , public OImageControlControl_Base
153 : {
154 : private:
155 : ::cppu::OInterfaceContainerHelper m_aModifyListeners;
156 :
157 : // XTypeProvider
158 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
159 :
160 : public:
161 : OImageControlControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory);
162 :
163 : // UNO
164 1285 : 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;
166 :
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;
169 :
170 : // XServiceInfo
171 1 : OUString SAL_CALL getImplementationName()
172 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
173 1 : { return OUString("com.sun.star.form.OImageControlControl"); }
174 :
175 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
176 :
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;
182 :
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;
186 :
187 : // OComponentHelper
188 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
189 :
190 : private:
191 : void implClearGraphics( bool _bForce );
192 : bool implInsertGraphics();
193 :
194 : /** determines whether the control does currently have an empty grahic set
195 : */
196 : bool impl_isEmptyGraphics_nothrow() const;
197 : };
198 :
199 :
200 : } // namespace frm
201 :
202 :
203 : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_IMAGECONTROL_HXX
204 :
205 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|