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 "FixedText.hxx"
20 #include <com/sun/star/beans/PropertyAttribute.hpp>
21 #include "corestrings.hrc"
22 #include <com/sun/star/beans/XPropertyState.hpp>
23 #include "core_resource.hrc"
24 #include "core_resource.hxx"
25 #include <comphelper/sequence.hxx>
27 #include <tools/color.hxx>
28 #include <tools/debug.hxx>
29 #include <comphelper/property.hxx>
30 #include "FormatCondition.hxx"
31 #include <com/sun/star/text/ParagraphVertAlign.hpp>
32 #include "ReportHelperImpl.hxx"
33 // =============================================================================
34 namespace reportdesign
36 // =============================================================================
37 using namespace com::sun::star
;
38 using namespace comphelper
;
39 uno::Sequence
< OUString
> lcl_getFixedTextOptionals()
41 OUString pProps
[] = { OUString(PROPERTY_DATAFIELD
),OUString(PROPERTY_MASTERFIELDS
),OUString(PROPERTY_DETAILFIELDS
) };
42 return uno::Sequence
< OUString
>(pProps
,sizeof(pProps
)/sizeof(pProps
[0]));
44 DBG_NAME( rpt_OFixedText
)
45 // -----------------------------------------------------------------------------
46 OFixedText::OFixedText(uno::Reference
< uno::XComponentContext
> const & _xContext
)
47 :FixedTextBase(m_aMutex
)
48 ,FixedTextPropertySet(_xContext
,static_cast< Implements
>(IMPLEMENTS_PROPERTY_SET
),lcl_getFixedTextOptionals())
49 ,m_aProps(m_aMutex
,static_cast< container::XContainer
*>( this ),_xContext
)
51 DBG_CTOR( rpt_OFixedText
,NULL
);
52 m_aProps
.aComponent
.m_sName
= RPT_RESSTRING(RID_STR_FIXEDTEXT
,m_aProps
.aComponent
.m_xContext
->getServiceManager());
53 m_aProps
.aComponent
.m_nBorder
= 0; // no border
55 // -----------------------------------------------------------------------------
56 OFixedText::OFixedText(uno::Reference
< uno::XComponentContext
> const & _xContext
57 ,const uno::Reference
< lang::XMultiServiceFactory
>& _xFactory
58 ,uno::Reference
< drawing::XShape
>& _xShape
)
59 :FixedTextBase(m_aMutex
)
60 ,FixedTextPropertySet(_xContext
,static_cast< Implements
>(IMPLEMENTS_PROPERTY_SET
),lcl_getFixedTextOptionals())
61 ,m_aProps(m_aMutex
,static_cast< container::XContainer
*>( this ),_xContext
)
63 DBG_CTOR( rpt_OFixedText
,NULL
);
64 m_aProps
.aComponent
.m_sName
= RPT_RESSTRING(RID_STR_FIXEDTEXT
,m_aProps
.aComponent
.m_xContext
->getServiceManager());
65 m_aProps
.aComponent
.m_nBorder
= 0; // no border
66 m_aProps
.aComponent
.m_xFactory
= _xFactory
;
67 osl_atomic_increment( &m_refCount
);
69 m_aProps
.aComponent
.setShape(_xShape
,this,m_refCount
);
71 osl_atomic_decrement( &m_refCount
);
73 // -----------------------------------------------------------------------------
74 OFixedText::~OFixedText()
76 DBG_DTOR( rpt_OFixedText
,NULL
);
78 // -----------------------------------------------------------------------------
79 IMPLEMENT_FORWARD_REFCOUNT( OFixedText
, FixedTextBase
)
80 // --------------------------------------------------------------------------------
81 uno::Any SAL_CALL
OFixedText::queryInterface( const uno::Type
& _rType
) throw (uno::RuntimeException
)
83 uno::Any aReturn
= FixedTextBase::queryInterface(_rType
);
84 if ( !aReturn
.hasValue() )
85 aReturn
= FixedTextPropertySet::queryInterface(_rType
);
86 if ( !aReturn
.hasValue() && OReportControlModel::isInterfaceForbidden(_rType
) )
89 return aReturn
.hasValue() ? aReturn
: (m_aProps
.aComponent
.m_xProxy
.is() ? m_aProps
.aComponent
.m_xProxy
->queryAggregation(_rType
) : aReturn
);
92 // -----------------------------------------------------------------------------
93 void SAL_CALL
OFixedText::dispose() throw(uno::RuntimeException
)
95 FixedTextPropertySet::dispose();
96 cppu::WeakComponentImplHelperBase::dispose();
97 uno::Reference
< report::XFixedText
> xHoldAlive
= this;
99 // -----------------------------------------------------------------------------
100 OUString
OFixedText::getImplementationName_Static( ) throw(uno::RuntimeException
)
102 return OUString("com.sun.star.comp.report.OFixedText");
105 //--------------------------------------------------------------------------
106 OUString SAL_CALL
OFixedText::getImplementationName( ) throw(uno::RuntimeException
)
108 return getImplementationName_Static();
110 //--------------------------------------------------------------------------
111 uno::Sequence
< OUString
> OFixedText::getSupportedServiceNames_Static( ) throw(uno::RuntimeException
)
113 uno::Sequence
< OUString
> aServices(1);
114 aServices
.getArray()[0] = SERVICE_FIXEDTEXT
;
118 //------------------------------------------------------------------------------
119 uno::Reference
< uno::XInterface
> OFixedText::create(uno::Reference
< uno::XComponentContext
> const & xContext
)
121 return *(new OFixedText(xContext
));
124 //--------------------------------------------------------------------------
125 uno::Sequence
< OUString
> SAL_CALL
OFixedText::getSupportedServiceNames( ) throw(uno::RuntimeException
)
127 return getSupportedServiceNames_Static();
129 //------------------------------------------------------------------------------
130 sal_Bool SAL_CALL
OFixedText::supportsService(const OUString
& ServiceName
) throw( uno::RuntimeException
)
132 return ::comphelper::existsValue(ServiceName
,getSupportedServiceNames_Static());
134 // -----------------------------------------------------------------------------
136 REPORTCOMPONENT_IMPL(OFixedText
,m_aProps
.aComponent
)
137 REPORTCOMPONENT_IMPL2(OFixedText
,m_aProps
.aComponent
)
138 REPORTCOMPONENT_NOMASTERDETAIL(OFixedText
)
139 REPORTCONTROLFORMAT_IMPL(OFixedText
,m_aProps
.aFormatProperties
)
140 // -----------------------------------------------------------------------------
141 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OFixedText::getPropertySetInfo( ) throw(uno::RuntimeException
)
143 return FixedTextPropertySet::getPropertySetInfo();
145 // -----------------------------------------------------------------------------
146 void SAL_CALL
OFixedText::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
) throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
148 FixedTextPropertySet::setPropertyValue( aPropertyName
, aValue
);
150 // -----------------------------------------------------------------------------
151 uno::Any SAL_CALL
OFixedText::getPropertyValue( const OUString
& PropertyName
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
153 return FixedTextPropertySet::getPropertyValue( PropertyName
);
155 // -----------------------------------------------------------------------------
156 void SAL_CALL
OFixedText::addPropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& xListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
158 FixedTextPropertySet::addPropertyChangeListener( aPropertyName
, xListener
);
160 // -----------------------------------------------------------------------------
161 void SAL_CALL
OFixedText::removePropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
163 FixedTextPropertySet::removePropertyChangeListener( aPropertyName
, aListener
);
165 // -----------------------------------------------------------------------------
166 void SAL_CALL
OFixedText::addVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
168 FixedTextPropertySet::addVetoableChangeListener( PropertyName
, aListener
);
170 // -----------------------------------------------------------------------------
171 void SAL_CALL
OFixedText::removeVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
173 FixedTextPropertySet::removeVetoableChangeListener( PropertyName
, aListener
);
175 // -----------------------------------------------------------------------------
176 // XReportControlModel
177 OUString SAL_CALL
OFixedText::getDataField() throw ( beans::UnknownPropertyException
, uno::RuntimeException
)
179 throw beans::UnknownPropertyException();
181 // -----------------------------------------------------------------------------
182 void SAL_CALL
OFixedText::setDataField( const OUString
& /*_datafield*/ ) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
184 throw beans::UnknownPropertyException();
186 // -----------------------------------------------------------------------------
188 // -----------------------------------------------------------------------------
189 ::sal_Bool SAL_CALL
OFixedText::getPrintWhenGroupChange() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
191 ::osl::MutexGuard
aGuard(m_aMutex
);
192 return m_aProps
.bPrintWhenGroupChange
;
194 // -----------------------------------------------------------------------------
195 void SAL_CALL
OFixedText::setPrintWhenGroupChange( ::sal_Bool _printwhengroupchange
) throw (beans::UnknownPropertyException
, uno::RuntimeException
)
197 set(PROPERTY_PRINTWHENGROUPCHANGE
,_printwhengroupchange
,m_aProps
.bPrintWhenGroupChange
);
199 // -----------------------------------------------------------------------------
200 OUString SAL_CALL
OFixedText::getConditionalPrintExpression() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
202 ::osl::MutexGuard
aGuard(m_aMutex
);
203 return m_aProps
.aConditionalPrintExpression
;
205 // -----------------------------------------------------------------------------
206 void SAL_CALL
OFixedText::setConditionalPrintExpression( const OUString
& _conditionalprintexpression
) throw (beans::UnknownPropertyException
, uno::RuntimeException
)
208 set(PROPERTY_CONDITIONALPRINTEXPRESSION
,_conditionalprintexpression
,m_aProps
.aConditionalPrintExpression
);
210 // -----------------------------------------------------------------------------
213 uno::Reference
< util::XCloneable
> SAL_CALL
OFixedText::createClone( ) throw (uno::RuntimeException
)
215 uno::Reference
< report::XReportComponent
> xSource
= this;
216 uno::Reference
< report::XFixedText
> xSet(cloneObject(xSource
,m_aProps
.aComponent
.m_xFactory
,SERVICE_FIXEDTEXT
),uno::UNO_QUERY_THROW
);
219 // -----------------------------------------------------------------------------
222 OUString SAL_CALL
OFixedText::getLabel() throw (uno::RuntimeException
)
224 ::osl::MutexGuard
aGuard(m_aMutex
);
227 // -----------------------------------------------------------------------------
228 void SAL_CALL
OFixedText::setLabel( const OUString
& _label
) throw (uno::RuntimeException
)
230 set(PROPERTY_LABEL
,_label
,m_sLabel
);
232 // -----------------------------------------------------------------------------
234 uno::Reference
< uno::XInterface
> SAL_CALL
OFixedText::getParent( ) throw (uno::RuntimeException
)
236 return OShapeHelper::getParent(this);
238 // -----------------------------------------------------------------------------
239 void SAL_CALL
OFixedText::setParent( const uno::Reference
< uno::XInterface
>& Parent
) throw (lang::NoSupportException
, uno::RuntimeException
)
241 OShapeHelper::setParent(Parent
,this);
243 // -----------------------------------------------------------------------------
244 uno::Reference
< report::XFormatCondition
> SAL_CALL
OFixedText::createFormatCondition( ) throw (uno::Exception
, uno::RuntimeException
)
246 return new OFormatCondition(m_aProps
.aComponent
.m_xContext
);
248 // -----------------------------------------------------------------------------
250 void SAL_CALL
OFixedText::addContainerListener( const uno::Reference
< container::XContainerListener
>& xListener
) throw (uno::RuntimeException
)
252 m_aProps
.addContainerListener(xListener
);
254 // -----------------------------------------------------------------------------
255 void SAL_CALL
OFixedText::removeContainerListener( const uno::Reference
< container::XContainerListener
>& xListener
) throw (uno::RuntimeException
)
257 m_aProps
.removeContainerListener(xListener
);
259 // -----------------------------------------------------------------------------
261 uno::Type SAL_CALL
OFixedText::getElementType( ) throw (uno::RuntimeException
)
263 return ::getCppuType(static_cast< uno::Reference
<report::XFormatCondition
>*>(NULL
));
265 // -----------------------------------------------------------------------------
266 ::sal_Bool SAL_CALL
OFixedText::hasElements( ) throw (uno::RuntimeException
)
268 return m_aProps
.hasElements();
270 // -----------------------------------------------------------------------------
272 void SAL_CALL
OFixedText::insertByIndex( ::sal_Int32 Index
, const uno::Any
& Element
) throw (lang::IllegalArgumentException
, lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
274 m_aProps
.insertByIndex(Index
,Element
);
276 // -----------------------------------------------------------------------------
277 void SAL_CALL
OFixedText::removeByIndex( ::sal_Int32 Index
) throw (lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
279 m_aProps
.removeByIndex(Index
);
281 // -----------------------------------------------------------------------------
283 void SAL_CALL
OFixedText::replaceByIndex( ::sal_Int32 Index
, const uno::Any
& Element
) throw (lang::IllegalArgumentException
, lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
285 m_aProps
.replaceByIndex(Index
,Element
);
287 // -----------------------------------------------------------------------------
289 ::sal_Int32 SAL_CALL
OFixedText::getCount( ) throw (uno::RuntimeException
)
291 return m_aProps
.getCount();
293 // -----------------------------------------------------------------------------
294 uno::Any SAL_CALL
OFixedText::getByIndex( ::sal_Int32 Index
) throw (lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
296 return m_aProps
.getByIndex( Index
);
298 // -----------------------------------------------------------------------------
300 awt::Point SAL_CALL
OFixedText::getPosition( ) throw (uno::RuntimeException
)
302 return OShapeHelper::getPosition(this);
304 // -----------------------------------------------------------------------------
305 void SAL_CALL
OFixedText::setPosition( const awt::Point
& aPosition
) throw (uno::RuntimeException
)
307 OShapeHelper::setPosition(aPosition
,this);
309 // -----------------------------------------------------------------------------
310 awt::Size SAL_CALL
OFixedText::getSize( ) throw (uno::RuntimeException
)
312 return OShapeHelper::getSize(this);
314 // -----------------------------------------------------------------------------
315 void SAL_CALL
OFixedText::setSize( const awt::Size
& aSize
) throw (beans::PropertyVetoException
, uno::RuntimeException
)
317 OShapeHelper::setSize(aSize
,this);
319 // -----------------------------------------------------------------------------
322 OUString SAL_CALL
OFixedText::getShapeType( ) throw (uno::RuntimeException
)
324 ::osl::MutexGuard
aGuard(m_aMutex
);
325 if ( m_aProps
.aComponent
.m_xShape
.is() )
326 return m_aProps
.aComponent
.m_xShape
->getShapeType();
327 return OUString("com.sun.star.drawing.ControlShape");
329 // -----------------------------------------------------------------------------
330 // -----------------------------------------------------------------------------
331 // =============================================================================
332 } // namespace reportdesign
333 // =============================================================================
335 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */