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 SAL_CALL OFixedText::getImplementationName( )
92 {
93  return "com.sun.star.comp.report.OFixedText";
94 }
95 
96 uno::Sequence< OUString > SAL_CALL OFixedText::getSupportedServiceNames( )
97 {
98  return { SERVICE_FIXEDTEXT };
99 }
100 
101 sal_Bool SAL_CALL OFixedText::supportsService(const OUString& ServiceName)
102 {
103  return cppu::supportsService(this, ServiceName);
104 }
105 
106 // XReportComponent
107 REPORTCOMPONENT_IMPL(OFixedText,m_aProps.aComponent)
108 REPORTCOMPONENT_IMPL2(OFixedText,m_aProps.aComponent)
110 REPORTCONTROLFORMAT_IMPL(OFixedText,m_aProps.aFormatProperties)
111 
112 uno::Reference< beans::XPropertySetInfo > SAL_CALL OFixedText::getPropertySetInfo( )
113 {
114  return FixedTextPropertySet::getPropertySetInfo();
115 }
116 
117 void SAL_CALL OFixedText::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
118 {
119  FixedTextPropertySet::setPropertyValue( aPropertyName, aValue );
120 }
121 
122 uno::Any SAL_CALL OFixedText::getPropertyValue( const OUString& PropertyName )
123 {
124  return FixedTextPropertySet::getPropertyValue( PropertyName);
125 }
126 
127 void SAL_CALL OFixedText::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
128 {
129  FixedTextPropertySet::addPropertyChangeListener( aPropertyName, xListener );
130 }
131 
132 void SAL_CALL OFixedText::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener )
133 {
134  FixedTextPropertySet::removePropertyChangeListener( aPropertyName, aListener );
135 }
136 
137 void SAL_CALL OFixedText::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
138 {
139  FixedTextPropertySet::addVetoableChangeListener( PropertyName, aListener );
140 }
141 
142 void SAL_CALL OFixedText::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
143 {
144  FixedTextPropertySet::removeVetoableChangeListener( PropertyName, aListener );
145 }
146 
147 // XReportControlModel
148 OUString SAL_CALL OFixedText::getDataField()
149 {
150  throw beans::UnknownPropertyException();
151 }
152 
153 void SAL_CALL OFixedText::setDataField( const OUString& /*_datafield*/ )
154 {
155  throw beans::UnknownPropertyException();
156 }
157 
158 
159 sal_Bool SAL_CALL OFixedText::getPrintWhenGroupChange()
160 {
161  ::osl::MutexGuard aGuard(m_aMutex);
162  return m_aProps.bPrintWhenGroupChange;
163 }
164 
165 void SAL_CALL OFixedText::setPrintWhenGroupChange( sal_Bool _printwhengroupchange )
166 {
167  set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange);
168 }
169 
170 OUString SAL_CALL OFixedText::getConditionalPrintExpression()
171 {
172  ::osl::MutexGuard aGuard(m_aMutex);
173  return m_aProps.aConditionalPrintExpression;
174 }
175 
176 void SAL_CALL OFixedText::setConditionalPrintExpression( const OUString& _conditionalprintexpression )
177 {
178  set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression);
179 }
180 
181 
182 // XCloneable
183 uno::Reference< util::XCloneable > SAL_CALL OFixedText::createClone( )
184 {
185  uno::Reference< report::XReportComponent> xSource = this;
186  uno::Reference< report::XFixedText> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FIXEDTEXT),uno::UNO_QUERY_THROW);
187  return xSet;
188 }
189 
190 
191 // XFixedText
192 OUString SAL_CALL OFixedText::getLabel()
193 {
194  ::osl::MutexGuard aGuard(m_aMutex);
195  return m_sLabel;
196 }
197 
198 void SAL_CALL OFixedText::setLabel( const OUString& _label )
199 {
200  set(PROPERTY_LABEL,_label,m_sLabel);
201 }
202 
203 // XChild
204 uno::Reference< uno::XInterface > SAL_CALL OFixedText::getParent( )
205 {
206  return OShapeHelper::getParent(this);
207 }
208 
209 void SAL_CALL OFixedText::setParent( const uno::Reference< uno::XInterface >& Parent )
210 {
211  OShapeHelper::setParent(Parent,this);
212 }
213 
214 uno::Reference< report::XFormatCondition > SAL_CALL OFixedText::createFormatCondition( )
215 {
216  return new OFormatCondition(m_aProps.aComponent.m_xContext);
217 }
218 
219 // XContainer
220 void SAL_CALL OFixedText::addContainerListener( const uno::Reference< container::XContainerListener >& xListener )
221 {
222  m_aProps.addContainerListener(xListener);
223 }
224 
225 void SAL_CALL OFixedText::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener )
226 {
227  m_aProps.removeContainerListener(xListener);
228 }
229 
230 // XElementAccess
231 uno::Type SAL_CALL OFixedText::getElementType( )
232 {
234 }
235 
236 sal_Bool SAL_CALL OFixedText::hasElements( )
237 {
238  return m_aProps.hasElements();
239 }
240 
241 // XIndexContainer
242 void SAL_CALL OFixedText::insertByIndex( ::sal_Int32 Index, const uno::Any& Element )
243 {
244  m_aProps.insertByIndex(Index,Element);
245 }
246 
247 void SAL_CALL OFixedText::removeByIndex( ::sal_Int32 Index )
248 {
249  m_aProps.removeByIndex(Index);
250 }
251 
252 // XIndexReplace
253 void SAL_CALL OFixedText::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element )
254 {
255  m_aProps.replaceByIndex(Index,Element);
256 }
257 
258 // XIndexAccess
259 ::sal_Int32 SAL_CALL OFixedText::getCount( )
260 {
261  return m_aProps.getCount();
262 }
263 
264 uno::Any SAL_CALL OFixedText::getByIndex( ::sal_Int32 Index )
265 {
266  return m_aProps.getByIndex( Index );
267 }
268 
269 // XShape
270 awt::Point SAL_CALL OFixedText::getPosition( )
271 {
272  return OShapeHelper::getPosition(this);
273 }
274 
275 void SAL_CALL OFixedText::setPosition( const awt::Point& aPosition )
276 {
277  OShapeHelper::setPosition(aPosition,this);
278 }
279 
280 awt::Size SAL_CALL OFixedText::getSize( )
281 {
282  return OShapeHelper::getSize(this);
283 }
284 
285 void SAL_CALL OFixedText::setSize( const awt::Size& aSize )
286 {
287  OShapeHelper::setSize(aSize,this);
288 }
289 
290 
291 // XShapeDescriptor
292 OUString SAL_CALL OFixedText::getShapeType( )
293 {
294  ::osl::MutexGuard aGuard(m_aMutex);
295  if ( m_aProps.aComponent.m_xShape.is() )
296  return m_aProps.aComponent.m_xShape->getShapeType();
297  return "com.sun.star.drawing.ControlShape";
298 }
299 
300 
301 } // namespace reportdesign
302 
303 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
305  css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
306 {
307  return cppu::acquire(new reportdesign::OFixedText(context));
308 }
309 
310 
311 /* 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
implementation of a
Definition: FixedText.hxx:43
::cppu::WeakComponentImplHelper< css::report::XFixedText,css::lang::XServiceInfo > FixedTextBase
Definition: FixedText.hxx:37
#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)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * reportdesign_OFixedText_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: FixedText.cxx:304
#define REPORTCOMPONENT_IMPL2(clazz, arg)
unsigned char sal_Bool
OFixedText(const OFixedText &)=delete
css::uno::Type const & get()
OUString RptResId(const char *pId)
#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