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