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
29namespace reportdesign
30{
31
32 using namespace com::sun::star;
33
34static 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
40OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext)
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
49OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext
50 ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
51 ,uno::Reference< drawing::XShape >& _xShape)
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
66OFixedText::~OFixedText()
67{
68}
69
71
72uno::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
84void SAL_CALL OFixedText::dispose()
85{
86 FixedTextPropertySet::dispose();
87 cppu::WeakComponentImplHelperBase::dispose();
88 uno::Reference< report::XFixedText> xHoldAlive = this;
89}
90
91OUString OFixedText::getImplementationName_Static( )
92{
93 return "com.sun.star.comp.report.OFixedText";
94}
95
96
97OUString SAL_CALL OFixedText::getImplementationName( )
98{
99 return getImplementationName_Static();
100}
101
102uno::Sequence< OUString > OFixedText::getSupportedServiceNames_Static( )
103{
104 uno::Sequence< OUString > aServices { SERVICE_FIXEDTEXT };
105
106 return aServices;
107}
108
109uno::Reference< uno::XInterface > OFixedText::create(uno::Reference< uno::XComponentContext > const & xContext)
110{
111 return *(new OFixedText(xContext));
112}
113
114
115uno::Sequence< OUString > SAL_CALL OFixedText::getSupportedServiceNames( )
116{
117 return getSupportedServiceNames_Static();
118}
119
120sal_Bool SAL_CALL OFixedText::supportsService(const OUString& ServiceName)
121{
123}
124
125// XReportComponent
127REPORTCOMPONENT_IMPL2(OFixedText,m_aProps.aComponent)
129REPORTCONTROLFORMAT_IMPL(OFixedText,m_aProps.aFormatProperties)
130
131uno::Reference< beans::XPropertySetInfo > SAL_CALL OFixedText::getPropertySetInfo( )
132{
133 return FixedTextPropertySet::getPropertySetInfo();
134}
135
136void SAL_CALL OFixedText::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
137{
138 FixedTextPropertySet::setPropertyValue( aPropertyName, aValue );
139}
140
141uno::Any SAL_CALL OFixedText::getPropertyValue( const OUString& PropertyName )
142{
143 return FixedTextPropertySet::getPropertyValue( PropertyName);
144}
145
146void SAL_CALL OFixedText::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
147{
148 FixedTextPropertySet::addPropertyChangeListener( aPropertyName, xListener );
149}
150
151void SAL_CALL OFixedText::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener )
152{
153 FixedTextPropertySet::removePropertyChangeListener( aPropertyName, aListener );
154}
155
156void SAL_CALL OFixedText::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
157{
158 FixedTextPropertySet::addVetoableChangeListener( PropertyName, aListener );
159}
160
161void SAL_CALL OFixedText::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
162{
163 FixedTextPropertySet::removeVetoableChangeListener( PropertyName, aListener );
164}
165
166// XReportControlModel
167OUString SAL_CALL OFixedText::getDataField()
168{
169 throw beans::UnknownPropertyException();
170}
171
172void SAL_CALL OFixedText::setDataField( const OUString& /*_datafield*/ )
173{
174 throw beans::UnknownPropertyException();
175}
176
177
178sal_Bool SAL_CALL OFixedText::getPrintWhenGroupChange()
179{
180 ::osl::MutexGuard aGuard(m_aMutex);
181 return m_aProps.bPrintWhenGroupChange;
182}
183
184void SAL_CALL OFixedText::setPrintWhenGroupChange( sal_Bool _printwhengroupchange )
185{
186 set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange);
187}
188
189OUString SAL_CALL OFixedText::getConditionalPrintExpression()
190{
191 ::osl::MutexGuard aGuard(m_aMutex);
192 return m_aProps.aConditionalPrintExpression;
193}
194
195void SAL_CALL OFixedText::setConditionalPrintExpression( const OUString& _conditionalprintexpression )
196{
197 set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression);
198}
199
200
201// XCloneable
202uno::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
211OUString SAL_CALL OFixedText::getLabel()
212{
213 ::osl::MutexGuard aGuard(m_aMutex);
214 return m_sLabel;
215}
216
217void SAL_CALL OFixedText::setLabel( const OUString& _label )
218{
219 set(PROPERTY_LABEL,_label,m_sLabel);
220}
221
222// XChild
223uno::Reference< uno::XInterface > SAL_CALL OFixedText::getParent( )
224{
225 return OShapeHelper::getParent(this);
226}
227
228void SAL_CALL OFixedText::setParent( const uno::Reference< uno::XInterface >& Parent )
229{
230 OShapeHelper::setParent(Parent,this);
231}
232
233uno::Reference< report::XFormatCondition > SAL_CALL OFixedText::createFormatCondition( )
234{
235 return new OFormatCondition(m_aProps.aComponent.m_xContext);
236}
237
238// XContainer
239void SAL_CALL OFixedText::addContainerListener( const uno::Reference< container::XContainerListener >& xListener )
240{
241 m_aProps.addContainerListener(xListener);
242}
243
244void SAL_CALL OFixedText::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener )
245{
246 m_aProps.removeContainerListener(xListener);
247}
248
249// XElementAccess
250uno::Type SAL_CALL OFixedText::getElementType( )
251{
253}
254
255sal_Bool SAL_CALL OFixedText::hasElements( )
256{
257 return m_aProps.hasElements();
258}
259
260// XIndexContainer
261void SAL_CALL OFixedText::insertByIndex( ::sal_Int32 Index, const uno::Any& Element )
262{
263 m_aProps.insertByIndex(Index,Element);
264}
265
266void SAL_CALL OFixedText::removeByIndex( ::sal_Int32 Index )
267{
268 m_aProps.removeByIndex(Index);
269}
270
271// XIndexReplace
272void 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
283uno::Any SAL_CALL OFixedText::getByIndex( ::sal_Int32 Index )
284{
285 return m_aProps.getByIndex( Index );
286}
287
288// XShape
289awt::Point SAL_CALL OFixedText::getPosition( )
290{
291 return OShapeHelper::getPosition(this);
292}
293
294void SAL_CALL OFixedText::setPosition( const awt::Point& aPosition )
295{
296 OShapeHelper::setPosition(aPosition,this);
297}
298
299awt::Size SAL_CALL OFixedText::getSize( )
300{
301 return OShapeHelper::getSize(this);
302}
303
304void SAL_CALL OFixedText::setSize( const awt::Size& aSize )
305{
306 OShapeHelper::setSize(aSize,this);
307}
308
309
310// XShapeDescriptor
311OUString 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: */
struct _ADOIndex Index
#define REPORTCONTROLFORMAT_IMPL(clazz, varName)
#define REPORTCOMPONENT_IMPL2(clazz, arg)
#define REPORTCOMPONENT_NOMASTERDETAIL(clazz)
#define REPORTCOMPONENT_IMPL(clazz, arg)
css::uno::Type const & get()
implementation of a
Definition: FixedText.hxx:46
OFixedText(const OFixedText &)=delete
OUString RptResId(TranslateId aId)
std::mutex m_aMutex
#define SAL_N_ELEMENTS(arr)
void set(css::uno::UnoInterfaceReference const &value)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
static uno::Sequence< OUString > lcl_getFixedTextOptionals()
Definition: FixedText.cxx:34
uno::Reference< util::XCloneable > cloneObject(const uno::Reference< report::XReportComponent > &_xReportComponent, const uno::Reference< lang::XMultiServiceFactory > &_xFactory, const OUString &_sServiceName)
Definition: Tools.cxx:53
::cppu::WeakComponentImplHelper< css::report::XFixedText,css::lang::XServiceInfo > FixedTextBase
Definition: FixedText.hxx:37
::cppu::PropertySetMixin< css::report::XFixedText > FixedTextPropertySet
Definition: FixedText.hxx:35
uno::Sequence< beans::Property > m_aProps
constexpr OUStringLiteral PROPERTY_LABEL
Definition: strings.hxx:89
constexpr OUStringLiteral PROPERTY_DATAFIELD
Definition: strings.hxx:78
constexpr OUStringLiteral SERVICE_FIXEDTEXT
Definition: strings.hxx:22
constexpr OUStringLiteral PROPERTY_DETAILFIELDS
Definition: strings.hxx:57
constexpr OUStringLiteral PROPERTY_MASTERFIELDS
Definition: strings.hxx:56
constexpr OUStringLiteral PROPERTY_PRINTWHENGROUPCHANGE
Definition: strings.hxx:111
constexpr OUStringLiteral PROPERTY_CONDITIONALPRINTEXPRESSION
Definition: strings.hxx:108
bool hasValue()
unsigned char sal_Bool
#define IMPLEMENT_FORWARD_REFCOUNT(classname, refcountbase)
Reference< XComponentContext > _xContext