1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #include <ImageControl.hxx>
20 #include <strings.hxx>
21 #include <strings.hrc>
22 #include <core_resource.hxx>
24 #include <tools/color.hxx>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <FormatCondition.hxx>
27 #include <com/sun/star/awt/ImageScaleMode.hpp>
28 #include <ReportHelperImpl.hxx>
30 namespace reportdesign
33 using namespace com::sun::star
;
34 static uno::Sequence
< OUString
> lcl_getImageOptionals()
38 ,PROPERTY_CHAREMPHASIS
39 ,PROPERTY_CHARFONTCHARSET
40 ,PROPERTY_CHARFONTFAMILY
41 ,PROPERTY_CHARFONTNAME
42 ,PROPERTY_CHARFONTPITCH
43 ,PROPERTY_CHARFONTSTYLENAME
47 ,PROPERTY_FONTDESCRIPTOR
48 ,PROPERTY_FONTDESCRIPTORASIAN
49 ,PROPERTY_FONTDESCRIPTORCOMPLEX
50 ,PROPERTY_CONTROLTEXTEMPHASISMARK
51 ,PROPERTY_CHARROTATION
52 ,PROPERTY_CHARSCALEWIDTH
53 ,PROPERTY_CHARSTRIKEOUT
54 ,PROPERTY_CHARUNDERLINECOLOR
55 ,PROPERTY_CHARUNDERLINE
57 ,PROPERTY_CHARWORDMODE
59 ,PROPERTY_CHARAUTOKERNING
60 ,PROPERTY_CHARESCAPEMENTHEIGHT
62 ,PROPERTY_CHARESCAPEMENT
64 ,PROPERTY_CHARCOMBINEISON
65 ,PROPERTY_CHARCOMBINEPREFIX
66 ,PROPERTY_CHARCOMBINESUFFIX
68 ,PROPERTY_CHARSHADOWED
69 ,PROPERTY_CHARCONTOURED
70 ,PROPERTY_VISITEDCHARSTYLENAME
71 ,PROPERTY_UNVISITEDCHARSTYLENAME
73 ,PROPERTY_MASTERFIELDS
74 ,PROPERTY_DETAILFIELDS
76 , PROPERTY_CHAREMPHASISASIAN
77 , PROPERTY_CHARFONTNAMEASIAN
78 , PROPERTY_CHARFONTSTYLENAMEASIAN
79 , PROPERTY_CHARFONTFAMILYASIAN
80 , PROPERTY_CHARFONTCHARSETASIAN
81 , PROPERTY_CHARFONTPITCHASIAN
82 , PROPERTY_CHARHEIGHTASIAN
83 , PROPERTY_CHARUNDERLINEASIAN
84 , PROPERTY_CHARWEIGHTASIAN
85 , PROPERTY_CHARPOSTUREASIAN
86 , PROPERTY_CHARWORDMODEASIAN
87 , PROPERTY_CHARROTATIONASIAN
88 , PROPERTY_CHARSCALEWIDTHASIAN
89 , PROPERTY_CHARLOCALEASIAN
90 , PROPERTY_CHAREMPHASISCOMPLEX
91 , PROPERTY_CHARFONTNAMECOMPLEX
92 , PROPERTY_CHARFONTSTYLENAMECOMPLEX
93 , PROPERTY_CHARFONTFAMILYCOMPLEX
94 , PROPERTY_CHARFONTCHARSETCOMPLEX
95 , PROPERTY_CHARFONTPITCHCOMPLEX
96 , PROPERTY_CHARHEIGHTCOMPLEX
97 , PROPERTY_CHARUNDERLINECOMPLEX
98 , PROPERTY_CHARWEIGHTCOMPLEX
99 , PROPERTY_CHARPOSTURECOMPLEX
100 , PROPERTY_CHARWORDMODECOMPLEX
101 , PROPERTY_CHARROTATIONCOMPLEX
102 , PROPERTY_CHARSCALEWIDTHCOMPLEX
103 , PROPERTY_CHARLOCALECOMPLEX
106 return uno::Sequence
< OUString
>(pProps
,SAL_N_ELEMENTS(pProps
));
110 OImageControl::OImageControl(uno::Reference
< uno::XComponentContext
> const & _xContext
)
111 :ImageControlBase(m_aMutex
)
112 ,ImageControlPropertySet(_xContext
,IMPLEMENTS_PROPERTY_SET
,lcl_getImageOptionals())
113 ,m_aProps(m_aMutex
,static_cast< container::XContainer
*>( this ),_xContext
)
114 ,m_nScaleMode(awt::ImageScaleMode::NONE
)
115 ,m_bPreserveIRI(true)
117 m_aProps
.aComponent
.m_sName
= RptResId(RID_STR_IMAGECONTROL
);
120 OImageControl::OImageControl(uno::Reference
< uno::XComponentContext
> const & _xContext
121 ,const uno::Reference
< lang::XMultiServiceFactory
>& _xFactory
122 ,uno::Reference
< drawing::XShape
>& _xShape
)
123 :ImageControlBase(m_aMutex
)
124 ,ImageControlPropertySet(_xContext
,IMPLEMENTS_PROPERTY_SET
,lcl_getImageOptionals())
125 ,m_aProps(m_aMutex
,static_cast< container::XContainer
*>( this ),_xContext
)
126 ,m_nScaleMode(awt::ImageScaleMode::NONE
)
127 ,m_bPreserveIRI(true)
129 m_aProps
.aComponent
.m_sName
= RptResId(RID_STR_IMAGECONTROL
);
130 m_aProps
.aComponent
.m_xFactory
= _xFactory
;
131 osl_atomic_increment( &m_refCount
);
133 m_aProps
.aComponent
.setShape(_xShape
,this,m_refCount
);
135 osl_atomic_decrement( &m_refCount
);
138 OImageControl::~OImageControl()
142 //IMPLEMENT_FORWARD_XINTERFACE2(OImageControl,ImageControlBase,ImageControlPropertySet)
143 IMPLEMENT_FORWARD_REFCOUNT( OImageControl
, ImageControlBase
)
145 uno::Any SAL_CALL
OImageControl::queryInterface( const uno::Type
& _rType
)
147 uno::Any aReturn
= ImageControlBase::queryInterface(_rType
);
148 if ( !aReturn
.hasValue() )
149 aReturn
= ImageControlPropertySet::queryInterface(_rType
);
151 if ( !aReturn
.hasValue() && OReportControlModel::isInterfaceForbidden(_rType
) )
154 return aReturn
.hasValue() ? aReturn
: (m_aProps
.aComponent
.m_xProxy
.is() ? m_aProps
.aComponent
.m_xProxy
->queryAggregation(_rType
) : aReturn
);
158 void SAL_CALL
OImageControl::dispose()
160 ImageControlPropertySet::dispose();
161 cppu::WeakComponentImplHelperBase::dispose();
164 OUString
OImageControl::getImplementationName_Static( )
166 return u
"com.sun.star.comp.report.OImageControl"_ustr
;
170 OUString SAL_CALL
OImageControl::getImplementationName( )
172 return getImplementationName_Static();
175 uno::Sequence
< OUString
> OImageControl::getSupportedServiceNames_Static( )
177 uno::Sequence
< OUString
> aServices
{ SERVICE_IMAGECONTROL
};
182 uno::Reference
< uno::XInterface
> OImageControl::create(uno::Reference
< uno::XComponentContext
> const & xContext
)
184 return *(new OImageControl(xContext
));
188 uno::Sequence
< OUString
> SAL_CALL
OImageControl::getSupportedServiceNames( )
190 return getSupportedServiceNames_Static();
193 sal_Bool SAL_CALL
OImageControl::supportsService(const OUString
& ServiceName
)
195 return cppu::supportsService(this, ServiceName
);
199 REPORTCOMPONENT_IMPL(OImageControl
,m_aProps
.aComponent
)
200 REPORTCOMPONENT_IMPL2(OImageControl
,m_aProps
.aComponent
)
201 REPORTCOMPONENT_NOMASTERDETAIL(OImageControl
)
202 NO_REPORTCONTROLFORMAT_IMPL(OImageControl
)
203 OUString SAL_CALL
OImageControl::getHyperLinkURL()
205 ::osl::MutexGuard
aGuard(m_aMutex
);
206 return m_aProps
.aFormatProperties
.sHyperLinkURL
;
208 void SAL_CALL
OImageControl::setHyperLinkURL(const OUString
& the_value
)
210 set(PROPERTY_HYPERLINKURL
,the_value
,m_aProps
.aFormatProperties
.sHyperLinkURL
);
212 OUString SAL_CALL
OImageControl::getHyperLinkTarget()
214 ::osl::MutexGuard
aGuard(m_aMutex
);
215 return m_aProps
.aFormatProperties
.sHyperLinkTarget
;
217 void SAL_CALL
OImageControl::setHyperLinkTarget(const OUString
& the_value
)
219 set(PROPERTY_HYPERLINKTARGET
,the_value
,m_aProps
.aFormatProperties
.sHyperLinkTarget
);
221 OUString SAL_CALL
OImageControl::getHyperLinkName()
223 ::osl::MutexGuard
aGuard(m_aMutex
);
224 return m_aProps
.aFormatProperties
.sHyperLinkName
;
226 void SAL_CALL
OImageControl::setHyperLinkName(const OUString
& the_value
)
228 set(PROPERTY_HYPERLINKNAME
,the_value
,m_aProps
.aFormatProperties
.sHyperLinkName
);
232 ::sal_Int32 SAL_CALL
OImageControl::getControlBackground()
234 ::osl::MutexGuard
aGuard(m_aMutex
);
235 return m_aProps
.aFormatProperties
.m_bBackgroundTransparent
? static_cast<sal_Int32
>(COL_TRANSPARENT
) : m_aProps
.aFormatProperties
.nBackgroundColor
;
238 void SAL_CALL
OImageControl::setControlBackground( ::sal_Int32 _backgroundcolor
)
240 bool bTransparent
= _backgroundcolor
== static_cast<sal_Int32
>(COL_TRANSPARENT
);
241 setControlBackgroundTransparent(bTransparent
);
243 set(PROPERTY_CONTROLBACKGROUND
,_backgroundcolor
,m_aProps
.aFormatProperties
.nBackgroundColor
);
246 sal_Bool SAL_CALL
OImageControl::getControlBackgroundTransparent()
248 ::osl::MutexGuard
aGuard(m_aMutex
);
249 return m_aProps
.aFormatProperties
.m_bBackgroundTransparent
;
252 void SAL_CALL
OImageControl::setControlBackgroundTransparent( sal_Bool _controlbackgroundtransparent
)
254 set(PROPERTY_CONTROLBACKGROUNDTRANSPARENT
,_controlbackgroundtransparent
,m_aProps
.aFormatProperties
.m_bBackgroundTransparent
);
255 if ( _controlbackgroundtransparent
)
256 set(PROPERTY_CONTROLBACKGROUND
,static_cast<sal_Int32
>(COL_TRANSPARENT
),m_aProps
.aFormatProperties
.nBackgroundColor
);
260 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OImageControl::getPropertySetInfo( )
262 return ImageControlPropertySet::getPropertySetInfo();
265 void SAL_CALL
OImageControl::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
267 ImageControlPropertySet::setPropertyValue( aPropertyName
, aValue
);
270 uno::Any SAL_CALL
OImageControl::getPropertyValue( const OUString
& PropertyName
)
272 return ImageControlPropertySet::getPropertyValue( PropertyName
);
275 void SAL_CALL
OImageControl::addPropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& xListener
)
277 ImageControlPropertySet::addPropertyChangeListener( aPropertyName
, xListener
);
280 void SAL_CALL
OImageControl::removePropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& aListener
)
282 ImageControlPropertySet::removePropertyChangeListener( aPropertyName
, aListener
);
285 void SAL_CALL
OImageControl::addVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
)
287 ImageControlPropertySet::addVetoableChangeListener( PropertyName
, aListener
);
290 void SAL_CALL
OImageControl::removeVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
)
292 ImageControlPropertySet::removeVetoableChangeListener( PropertyName
, aListener
);
295 // XReportControlModel
296 OUString SAL_CALL
OImageControl::getDataField()
298 ::osl::MutexGuard
aGuard(m_aMutex
);
299 return m_aProps
.aDataField
;
302 void SAL_CALL
OImageControl::setDataField( const OUString
& _datafield
)
304 set(PROPERTY_DATAFIELD
,_datafield
,m_aProps
.aDataField
);
308 sal_Bool SAL_CALL
OImageControl::getPrintWhenGroupChange()
310 ::osl::MutexGuard
aGuard(m_aMutex
);
311 return m_aProps
.bPrintWhenGroupChange
;
314 void SAL_CALL
OImageControl::setPrintWhenGroupChange( sal_Bool _printwhengroupchange
)
316 set(PROPERTY_PRINTWHENGROUPCHANGE
,_printwhengroupchange
,m_aProps
.bPrintWhenGroupChange
);
319 OUString SAL_CALL
OImageControl::getConditionalPrintExpression()
321 ::osl::MutexGuard
aGuard(m_aMutex
);
322 return m_aProps
.aConditionalPrintExpression
;
325 void SAL_CALL
OImageControl::setConditionalPrintExpression( const OUString
& _conditionalprintexpression
)
327 set(PROPERTY_CONDITIONALPRINTEXPRESSION
,_conditionalprintexpression
,m_aProps
.aConditionalPrintExpression
);
332 uno::Reference
< util::XCloneable
> SAL_CALL
OImageControl::createClone( )
334 uno::Reference
< report::XReportComponent
> xSource
= this;
335 uno::Reference
< report::XImageControl
> xSet(cloneObject(xSource
,m_aProps
.aComponent
.m_xFactory
,SERVICE_IMAGECONTROL
),uno::UNO_QUERY_THROW
);
342 OUString SAL_CALL
OImageControl::getImageURL()
344 ::osl::MutexGuard
aGuard(m_aMutex
);
348 void SAL_CALL
OImageControl::setImageURL( const OUString
& _imageurl
)
350 set(PROPERTY_IMAGEURL
,_imageurl
,m_aImageURL
);
353 uno::Reference
< awt::XImageProducer
> SAL_CALL
OImageControl::getImageProducer( )
355 return uno::Reference
< awt::XImageProducer
>();
359 uno::Reference
< uno::XInterface
> SAL_CALL
OImageControl::getParent( )
361 return OShapeHelper::getParent(this);
364 void SAL_CALL
OImageControl::setParent( const uno::Reference
< uno::XInterface
>& Parent
)
366 OShapeHelper::setParent(Parent
,this);
368 uno::Reference
< report::XFormatCondition
> SAL_CALL
OImageControl::createFormatCondition( )
370 return new OFormatCondition(m_aProps
.aComponent
.m_xContext
);
374 void SAL_CALL
OImageControl::addContainerListener( const uno::Reference
< container::XContainerListener
>& xListener
)
376 m_aProps
.addContainerListener(xListener
);
379 void SAL_CALL
OImageControl::removeContainerListener( const uno::Reference
< container::XContainerListener
>& xListener
)
381 m_aProps
.removeContainerListener(xListener
);
385 uno::Type SAL_CALL
OImageControl::getElementType( )
387 return cppu::UnoType
<report::XFormatCondition
>::get();
390 sal_Bool SAL_CALL
OImageControl::hasElements( )
392 return m_aProps
.hasElements();
396 void SAL_CALL
OImageControl::insertByIndex( ::sal_Int32 Index
, const uno::Any
& Element
)
398 m_aProps
.insertByIndex(Index
,Element
);
401 void SAL_CALL
OImageControl::removeByIndex( ::sal_Int32 Index
)
403 m_aProps
.removeByIndex(Index
);
407 void SAL_CALL
OImageControl::replaceByIndex( ::sal_Int32 Index
, const uno::Any
& Element
)
409 m_aProps
.replaceByIndex(Index
,Element
);
413 ::sal_Int32 SAL_CALL
OImageControl::getCount( )
415 return m_aProps
.getCount();
418 uno::Any SAL_CALL
OImageControl::getByIndex( ::sal_Int32 Index
)
420 return m_aProps
.getByIndex( Index
);
425 awt::Point SAL_CALL
OImageControl::getPosition( )
427 return OShapeHelper::getPosition(this);
430 void SAL_CALL
OImageControl::setPosition( const awt::Point
& aPosition
)
432 OShapeHelper::setPosition(aPosition
,this);
435 awt::Size SAL_CALL
OImageControl::getSize( )
437 return OShapeHelper::getSize(this);
440 void SAL_CALL
OImageControl::setSize( const awt::Size
& aSize
)
442 OShapeHelper::setSize(aSize
,this);
447 OUString SAL_CALL
OImageControl::getShapeType( )
449 ::osl::MutexGuard
aGuard(m_aMutex
);
450 if ( m_aProps
.aComponent
.m_xShape
.is() )
451 return m_aProps
.aComponent
.m_xShape
->getShapeType();
452 return u
"com.sun.star.drawing.ControlShape"_ustr
;
455 ::sal_Int16 SAL_CALL
OImageControl::getScaleMode()
457 ::osl::MutexGuard
aGuard(m_aMutex
);
461 void SAL_CALL
OImageControl::setScaleMode( ::sal_Int16 _scalemode
)
463 if ( _scalemode
< awt::ImageScaleMode::NONE
||_scalemode
> awt::ImageScaleMode::ANISOTROPIC
)
464 throw lang::IllegalArgumentException();
465 set(PROPERTY_SCALEMODE
,_scalemode
,m_nScaleMode
);
468 sal_Bool SAL_CALL
OImageControl::getPreserveIRI()
470 ::osl::MutexGuard
aGuard(m_aMutex
);
471 return m_bPreserveIRI
;
474 void SAL_CALL
OImageControl::setPreserveIRI( sal_Bool _preserveiri
)
476 set(PROPERTY_PRESERVEIRI
,_preserveiri
,m_bPreserveIRI
);
479 } // namespace reportdesign
482 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */