LibreOffice Module forms (master) 1
ImageControl.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <FormComponent.hxx>
23#include "imgprod.hxx"
24#include <com/sun/star/form/XImageProducerSupplier.hpp>
25#include <com/sun/star/awt/XMouseListener.hpp>
26#include <com/sun/star/util/XModifyBroadcaster.hpp>
27#include <com/sun/star/graphic/XGraphicObject.hpp>
30#include <rtl/ref.hxx>
31
32
33namespace frm
34{
35
36
37// OImageControlModel
38
39typedef ::cppu::ImplHelper2 < css::form::XImageProducerSupplier
40 , css::awt::XImageProducer
42
45 ,public OBoundControlModel
46{
50 OUString m_sImageURL;
51 css::uno::Reference< css::graphic::XGraphicObject >
54
55 // UNO binding
56 virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
57
59
60public:
62 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
63 );
65 const OImageControlModel* _pOriginal,
66 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
67 );
68 virtual ~OImageControlModel() override;
69
70 virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle ) const override;
71 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any& rValue) override;
72
73 virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any& rConvertedValue, css::uno::Any& rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue ) override;
74
75 // UNO binding
77 virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override;
78
79 // XServiceInfo
80 OUString SAL_CALL getImplementationName() override
81 { return "com.sun.star.form.OImageControlModel"; }
82
83 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
84
85 // XPersistObject
86 virtual OUString SAL_CALL getServiceName() override;
87 virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) override;
88 virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) override;
89
90 // XImageProducerSupplier
91 virtual css::uno::Reference< css::awt::XImageProducer> SAL_CALL getImageProducer() override;
92
93 // XImageProducer
94 virtual void SAL_CALL addConsumer( const css::uno::Reference< css::awt::XImageConsumer >& xConsumer ) override;
95 virtual void SAL_CALL removeConsumer( const css::uno::Reference< css::awt::XImageConsumer >& xConsumer ) override;
96 virtual void SAL_CALL startProduction( ) override;
97
98 // OControlModel's property handling
99 virtual void describeAggregateProperties(
100 css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps
101 ) const override;
102 virtual void describeFixedProperties(
103 css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps
104 ) const override;
105
106 // prevent method hiding
109
110private:
111 // OBoundControlModel overridables
112 virtual void onConnectedDbColumn( const css::uno::Reference< css::uno::XInterface >& _rxForm ) override;
113 virtual void onDisconnectedDbColumn() override;
114 virtual css::uno::Any translateDbColumnToControlValue( ) override;
115 virtual bool commitControlValueToDbColumn( bool _bPostReset ) override;
116
117 virtual css::uno::Any getControlValue( ) const override;
118 virtual void doSetControlValue( const css::uno::Any& _rValue ) override;
119
120 virtual bool approveDbColumnType(sal_Int32 _nColumnType) override;
121
122 virtual void resetNoBroadcast() override;
123
124 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
125
126 void implConstruct();
127
133
137 bool impl_updateStreamForURL_lck( const OUString& _rURL, ValueChangeInstigator _eInstigator );
138
139 DECL_LINK( OnImageImportDone, ::Graphic*, void );
140};
141
142typedef ::cppu::ImplHelper2 < css::awt::XMouseListener
143 , css::util::XModifyBroadcaster
147{
148private:
150
151 // XTypeProvider
152 virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
153
154public:
155 explicit OImageControlControl(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory);
156
157 // UNO
159 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override;
160
161 // XEventListener
162 virtual void SAL_CALL disposing(const css::lang::EventObject& _rSource) override;
163
164 // XServiceInfo
165 OUString SAL_CALL getImplementationName() override
166 { return "com.sun.star.form.OImageControlControl"; }
167
168 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
169
170 // XMouseListener
171 virtual void SAL_CALL mousePressed(const css::awt::MouseEvent& e) override;
172 virtual void SAL_CALL mouseReleased(const css::awt::MouseEvent& e) override;
173 virtual void SAL_CALL mouseEntered(const css::awt::MouseEvent& e) override;
174 virtual void SAL_CALL mouseExited(const css::awt::MouseEvent& e) override;
175
176 // XModifyBroadcaster
177 virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
178 virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
179
180 // OComponentHelper
181 virtual void SAL_CALL disposing() override;
182
183private:
184 void implClearGraphics( bool _bForce );
185 bool implInsertGraphics();
186
189 bool impl_isEmptyGraphics_nothrow() const;
190};
191
192
193} // namespace frm
194
195
196/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL disposing() override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
OImageControlControl(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
void implClearGraphics(bool _bForce)
::comphelper::OInterfaceContainerHelper3< css::util::XModifyListener > m_aModifyListeners
virtual void SAL_CALL disposing() override
virtual void SAL_CALL mouseEntered(const css::awt::MouseEvent &e) override
bool impl_isEmptyGraphics_nothrow() const
determines whether the control does currently have an empty graphic set
OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL disposing(const css::lang::EventObject &_rSource) override
virtual void SAL_CALL mouseExited(const css::awt::MouseEvent &e) override
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
virtual css::uno::Sequence< css::uno::Type > _getTypes() override
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL mousePressed(const css::awt::MouseEvent &e) override
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
virtual void SAL_CALL mouseReleased(const css::awt::MouseEvent &e) override
bool impl_updateStreamForURL_lck(const OUString &_rURL, ValueChangeInstigator _eInstigator)
updates the binary stream, created from loading the file which the given URL points to,...
virtual OUString SAL_CALL getServiceName() override
OUString SAL_CALL getImplementationName() override
virtual css::uno::Any translateDbColumnToControlValue() override
translates a db column value into a control value.
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
virtual css::uno::Sequence< css::uno::Type > _getTypes() override
ImageProducer * GetImageProducer()
virtual void SAL_CALL addConsumer(const css::uno::Reference< css::awt::XImageConsumer > &xConsumer) override
DECL_LINK(OnImageImportDone, ::Graphic *, void)
virtual ~OImageControlModel() override
virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream) override
virtual void resetNoBroadcast() override
called to reset the control to some kind of default.
virtual css::uno::Any getControlValue() const override
retrieves the current value of the control
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual void describeFixedProperties(css::uno::Sequence< css::beans::Property > &_rProps) const override
describes the properties provided by this class, or its respective derived class
virtual void doSetControlValue(const css::uno::Any &_rValue) override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
rtl::Reference< ImageProducer > m_xImageProducer
virtual void onDisconnectedDbColumn() override
called whenever a connection to a database column has been suspended
virtual bool commitControlValueToDbColumn(bool _bPostReset) override
commits the current control value to the database column we're bound to @precond we're properly bound...
virtual void describeAggregateProperties(css::uno::Sequence< css::beans::Property > &_rAggregateProps) const override
describes the properties of our aggregate
virtual bool approveDbColumnType(sal_Int32 _nColumnType) override
nFieldType is the type of the field, on which the model will be linked.
OImageControlModel(const OImageControlModel *_pOriginal, const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
virtual void onConnectedDbColumn(const css::uno::Reference< css::uno::XInterface > &_rxForm) override
called whenever a connection to a database column has been established
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
void impl_handleNewImageURL_lck(ValueChangeInstigator _eInstigator)
displays the image described by the given URL @precond our own mutex is locked
virtual css::uno::Reference< css::awt::XImageProducer > SAL_CALL getImageProducer() override
virtual void SAL_CALL removeConsumer(const css::uno::Reference< css::awt::XImageConsumer > &xConsumer) override
virtual void SAL_CALL startProduction() override
OImageControlModel(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
css::uno::Reference< css::graphic::XGraphicObject > m_xGraphicObject
virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream) override
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
::cppu::ImplHelper2< css::awt::XMouseListener, css::util::XModifyBroadcaster > OImageControlControl_Base
::cppu::ImplHelper2< css::form::XImageProducerSupplier, css::awt::XImageProducer > OImageControlModel_Base
unsigned char sal_Bool
#define DECLARE_UNO3_AGG_DEFAULTS(classname, baseclass)