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 #include <FixedText.hxx>
20 #include <com/sun/star/beans/PropertyAttribute.hpp>
21 #include <strings.hxx>
22 #include <com/sun/star/beans/XPropertyState.hpp>
23 #include <strings.hrc>
24 #include <core_resource.hxx>
25 #include <Tools.hxx>
26 #include <tools/color.hxx>
27 #include <cppuhelper/supportsservice.hxx>
28 #include <FormatCondition.hxx>
29 #include <com/sun/star/text/ParagraphVertAlign.hpp>
30 #include <ReportHelperImpl.hxx>
31
32 namespace reportdesign
33 {
34
35 using namespace com::sun::star;
36
lcl_getFixedTextOptionals()37 static uno::Sequence< OUString > lcl_getFixedTextOptionals()
38 {
39 OUString pProps[] = { OUString(PROPERTY_DATAFIELD),OUString(PROPERTY_MASTERFIELDS),OUString(PROPERTY_DETAILFIELDS) };
40 return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps));
41 }
42
OFixedText(uno::Reference<uno::XComponentContext> const & _xContext)43 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext)
44 :FixedTextBase(m_aMutex)
45 ,FixedTextPropertySet(_xContext,IMPLEMENTS_PROPERTY_SET,lcl_getFixedTextOptionals())
46 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
47 {
48 m_aProps.aComponent.m_sName = RptResId(RID_STR_FIXEDTEXT);
49 m_aProps.aComponent.m_nBorder = 0; // no border
50 }
51
OFixedText(uno::Reference<uno::XComponentContext> const & _xContext,const uno::Reference<lang::XMultiServiceFactory> & _xFactory,uno::Reference<drawing::XShape> & _xShape)52 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext
53 ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
54 ,uno::Reference< drawing::XShape >& _xShape)
55 :FixedTextBase(m_aMutex)
56 ,FixedTextPropertySet(_xContext,IMPLEMENTS_PROPERTY_SET,lcl_getFixedTextOptionals())
57 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
58 {
59 m_aProps.aComponent.m_sName = RptResId(RID_STR_FIXEDTEXT);
60 m_aProps.aComponent.m_nBorder = 0; // no border
61 m_aProps.aComponent.m_xFactory = _xFactory;
62 osl_atomic_increment( &m_refCount );
63 {
64 m_aProps.aComponent.setShape(_xShape,this,m_refCount);
65 }
66 osl_atomic_decrement( &m_refCount );
67 }
68
~OFixedText()69 OFixedText::~OFixedText()
70 {
71 }
72
IMPLEMENT_FORWARD_REFCOUNT(OFixedText,FixedTextBase)73 IMPLEMENT_FORWARD_REFCOUNT( OFixedText, FixedTextBase )
74
75 uno::Any SAL_CALL OFixedText::queryInterface( const uno::Type& _rType )
76 {
77 uno::Any aReturn = FixedTextBase::queryInterface(_rType);
78 if ( !aReturn.hasValue() )
79 aReturn = FixedTextPropertySet::queryInterface(_rType);
80 if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
81 return aReturn;
82
83 return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn);
84 }
85
86
dispose()87 void SAL_CALL OFixedText::dispose()
88 {
89 FixedTextPropertySet::dispose();
90 cppu::WeakComponentImplHelperBase::dispose();
91 uno::Reference< report::XFixedText> xHoldAlive = this;
92 }
93
getImplementationName_Static()94 OUString OFixedText::getImplementationName_Static( )
95 {
96 return "com.sun.star.comp.report.OFixedText";
97 }
98
99
getImplementationName()100 OUString SAL_CALL OFixedText::getImplementationName( )
101 {
102 return getImplementationName_Static();
103 }
104
getSupportedServiceNames_Static()105 uno::Sequence< OUString > OFixedText::getSupportedServiceNames_Static( )
106 {
107 uno::Sequence< OUString > aServices { SERVICE_FIXEDTEXT };
108
109 return aServices;
110 }
111
create(uno::Reference<uno::XComponentContext> const & xContext)112 uno::Reference< uno::XInterface > OFixedText::create(uno::Reference< uno::XComponentContext > const & xContext)
113 {
114 return *(new OFixedText(xContext));
115 }
116
117
getSupportedServiceNames()118 uno::Sequence< OUString > SAL_CALL OFixedText::getSupportedServiceNames( )
119 {
120 return getSupportedServiceNames_Static();
121 }
122
supportsService(const OUString & ServiceName)123 sal_Bool SAL_CALL OFixedText::supportsService(const OUString& ServiceName)
124 {
125 return cppu::supportsService(this, ServiceName);
126 }
127
128 // XReportComponent
129 REPORTCOMPONENT_IMPL(OFixedText,m_aProps.aComponent)
130 REPORTCOMPONENT_IMPL2(OFixedText,m_aProps.aComponent)
REPORTCOMPONENT_NOMASTERDETAIL(OFixedText)131 REPORTCOMPONENT_NOMASTERDETAIL(OFixedText)
132 REPORTCONTROLFORMAT_IMPL(OFixedText,m_aProps.aFormatProperties)
133
134 uno::Reference< beans::XPropertySetInfo > SAL_CALL OFixedText::getPropertySetInfo( )
135 {
136 return FixedTextPropertySet::getPropertySetInfo();
137 }
138
setPropertyValue(const OUString & aPropertyName,const uno::Any & aValue)139 void SAL_CALL OFixedText::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
140 {
141 FixedTextPropertySet::setPropertyValue( aPropertyName, aValue );
142 }
143
getPropertyValue(const OUString & PropertyName)144 uno::Any SAL_CALL OFixedText::getPropertyValue( const OUString& PropertyName )
145 {
146 return FixedTextPropertySet::getPropertyValue( PropertyName);
147 }
148
addPropertyChangeListener(const OUString & aPropertyName,const uno::Reference<beans::XPropertyChangeListener> & xListener)149 void SAL_CALL OFixedText::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
150 {
151 FixedTextPropertySet::addPropertyChangeListener( aPropertyName, xListener );
152 }
153
removePropertyChangeListener(const OUString & aPropertyName,const uno::Reference<beans::XPropertyChangeListener> & aListener)154 void SAL_CALL OFixedText::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener )
155 {
156 FixedTextPropertySet::removePropertyChangeListener( aPropertyName, aListener );
157 }
158
addVetoableChangeListener(const OUString & PropertyName,const uno::Reference<beans::XVetoableChangeListener> & aListener)159 void SAL_CALL OFixedText::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
160 {
161 FixedTextPropertySet::addVetoableChangeListener( PropertyName, aListener );
162 }
163
removeVetoableChangeListener(const OUString & PropertyName,const uno::Reference<beans::XVetoableChangeListener> & aListener)164 void SAL_CALL OFixedText::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
165 {
166 FixedTextPropertySet::removeVetoableChangeListener( PropertyName, aListener );
167 }
168
169 // XReportControlModel
getDataField()170 OUString SAL_CALL OFixedText::getDataField()
171 {
172 throw beans::UnknownPropertyException();
173 }
174
setDataField(const OUString &)175 void SAL_CALL OFixedText::setDataField( const OUString& /*_datafield*/ )
176 {
177 throw beans::UnknownPropertyException();
178 }
179
180
getPrintWhenGroupChange()181 sal_Bool SAL_CALL OFixedText::getPrintWhenGroupChange()
182 {
183 ::osl::MutexGuard aGuard(m_aMutex);
184 return m_aProps.bPrintWhenGroupChange;
185 }
186
setPrintWhenGroupChange(sal_Bool _printwhengroupchange)187 void SAL_CALL OFixedText::setPrintWhenGroupChange( sal_Bool _printwhengroupchange )
188 {
189 set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange);
190 }
191
getConditionalPrintExpression()192 OUString SAL_CALL OFixedText::getConditionalPrintExpression()
193 {
194 ::osl::MutexGuard aGuard(m_aMutex);
195 return m_aProps.aConditionalPrintExpression;
196 }
197
setConditionalPrintExpression(const OUString & _conditionalprintexpression)198 void SAL_CALL OFixedText::setConditionalPrintExpression( const OUString& _conditionalprintexpression )
199 {
200 set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression);
201 }
202
203
204 // XCloneable
createClone()205 uno::Reference< util::XCloneable > SAL_CALL OFixedText::createClone( )
206 {
207 uno::Reference< report::XReportComponent> xSource = this;
208 uno::Reference< report::XFixedText> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FIXEDTEXT),uno::UNO_QUERY_THROW);
209 return xSet.get();
210 }
211
212
213 // XFixedText
getLabel()214 OUString SAL_CALL OFixedText::getLabel()
215 {
216 ::osl::MutexGuard aGuard(m_aMutex);
217 return m_sLabel;
218 }
219
setLabel(const OUString & _label)220 void SAL_CALL OFixedText::setLabel( const OUString& _label )
221 {
222 set(PROPERTY_LABEL,_label,m_sLabel);
223 }
224
225 // XChild
getParent()226 uno::Reference< uno::XInterface > SAL_CALL OFixedText::getParent( )
227 {
228 return OShapeHelper::getParent(this);
229 }
230
setParent(const uno::Reference<uno::XInterface> & Parent)231 void SAL_CALL OFixedText::setParent( const uno::Reference< uno::XInterface >& Parent )
232 {
233 OShapeHelper::setParent(Parent,this);
234 }
235
createFormatCondition()236 uno::Reference< report::XFormatCondition > SAL_CALL OFixedText::createFormatCondition( )
237 {
238 return new OFormatCondition(m_aProps.aComponent.m_xContext);
239 }
240
241 // XContainer
addContainerListener(const uno::Reference<container::XContainerListener> & xListener)242 void SAL_CALL OFixedText::addContainerListener( const uno::Reference< container::XContainerListener >& xListener )
243 {
244 m_aProps.addContainerListener(xListener);
245 }
246
removeContainerListener(const uno::Reference<container::XContainerListener> & xListener)247 void SAL_CALL OFixedText::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener )
248 {
249 m_aProps.removeContainerListener(xListener);
250 }
251
252 // XElementAccess
getElementType()253 uno::Type SAL_CALL OFixedText::getElementType( )
254 {
255 return cppu::UnoType<report::XFormatCondition>::get();
256 }
257
hasElements()258 sal_Bool SAL_CALL OFixedText::hasElements( )
259 {
260 return m_aProps.hasElements();
261 }
262
263 // XIndexContainer
insertByIndex(::sal_Int32 Index,const uno::Any & Element)264 void SAL_CALL OFixedText::insertByIndex( ::sal_Int32 Index, const uno::Any& Element )
265 {
266 m_aProps.insertByIndex(Index,Element);
267 }
268
removeByIndex(::sal_Int32 Index)269 void SAL_CALL OFixedText::removeByIndex( ::sal_Int32 Index )
270 {
271 m_aProps.removeByIndex(Index);
272 }
273
274 // XIndexReplace
replaceByIndex(::sal_Int32 Index,const uno::Any & Element)275 void SAL_CALL OFixedText::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element )
276 {
277 m_aProps.replaceByIndex(Index,Element);
278 }
279
280 // XIndexAccess
getCount()281 ::sal_Int32 SAL_CALL OFixedText::getCount( )
282 {
283 return m_aProps.getCount();
284 }
285
getByIndex(::sal_Int32 Index)286 uno::Any SAL_CALL OFixedText::getByIndex( ::sal_Int32 Index )
287 {
288 return m_aProps.getByIndex( Index );
289 }
290
291 // XShape
getPosition()292 awt::Point SAL_CALL OFixedText::getPosition( )
293 {
294 return OShapeHelper::getPosition(this);
295 }
296
setPosition(const awt::Point & aPosition)297 void SAL_CALL OFixedText::setPosition( const awt::Point& aPosition )
298 {
299 OShapeHelper::setPosition(aPosition,this);
300 }
301
getSize()302 awt::Size SAL_CALL OFixedText::getSize( )
303 {
304 return OShapeHelper::getSize(this);
305 }
306
setSize(const awt::Size & aSize)307 void SAL_CALL OFixedText::setSize( const awt::Size& aSize )
308 {
309 OShapeHelper::setSize(aSize,this);
310 }
311
312
313 // XShapeDescriptor
getShapeType()314 OUString SAL_CALL OFixedText::getShapeType( )
315 {
316 ::osl::MutexGuard aGuard(m_aMutex);
317 if ( m_aProps.aComponent.m_xShape.is() )
318 return m_aProps.aComponent.m_xShape->getShapeType();
319 return "com.sun.star.drawing.ControlShape";
320 }
321
322
323 } // namespace reportdesign
324
325
326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
327