bump product version to 5.0.4.1
[LibreOffice.git] / reportdesign / source / core / api / FixedText.cxx
bloba64edfb08b2af9f270a94b938ed3902595832a4c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "Tools.hxx"
26 #include <tools/color.hxx>
27 #include <tools/debug.hxx>
28 #include <comphelper/property.hxx>
29 #include <cppuhelper/supportsservice.hxx>
30 #include "FormatCondition.hxx"
31 #include <com/sun/star/text/ParagraphVertAlign.hpp>
32 #include "ReportHelperImpl.hxx"
34 namespace reportdesign
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]));
45 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext)
46 :FixedTextBase(m_aMutex)
47 ,FixedTextPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getFixedTextOptionals())
48 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
50 m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FIXEDTEXT,m_aProps.aComponent.m_xContext->getServiceManager());
51 m_aProps.aComponent.m_nBorder = 0; // no border
54 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext
55 ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
56 ,uno::Reference< drawing::XShape >& _xShape)
57 :FixedTextBase(m_aMutex)
58 ,FixedTextPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getFixedTextOptionals())
59 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
61 m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FIXEDTEXT,m_aProps.aComponent.m_xContext->getServiceManager());
62 m_aProps.aComponent.m_nBorder = 0; // no border
63 m_aProps.aComponent.m_xFactory = _xFactory;
64 osl_atomic_increment( &m_refCount );
66 m_aProps.aComponent.setShape(_xShape,this,m_refCount);
68 osl_atomic_decrement( &m_refCount );
71 OFixedText::~OFixedText()
75 IMPLEMENT_FORWARD_REFCOUNT( OFixedText, FixedTextBase )
77 uno::Any SAL_CALL OFixedText::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException, std::exception)
79 uno::Any aReturn = FixedTextBase::queryInterface(_rType);
80 if ( !aReturn.hasValue() )
81 aReturn = FixedTextPropertySet::queryInterface(_rType);
82 if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
83 return aReturn;
85 return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn);
89 void SAL_CALL OFixedText::dispose() throw(uno::RuntimeException, std::exception)
91 FixedTextPropertySet::dispose();
92 cppu::WeakComponentImplHelperBase::dispose();
93 uno::Reference< report::XFixedText> xHoldAlive = this;
96 OUString OFixedText::getImplementationName_Static( ) throw(uno::RuntimeException)
98 return OUString("com.sun.star.comp.report.OFixedText");
102 OUString SAL_CALL OFixedText::getImplementationName( ) throw(uno::RuntimeException, std::exception)
104 return getImplementationName_Static();
107 uno::Sequence< OUString > OFixedText::getSupportedServiceNames_Static( ) throw(uno::RuntimeException)
109 uno::Sequence< OUString > aServices(1);
110 aServices.getArray()[0] = SERVICE_FIXEDTEXT;
112 return aServices;
115 uno::Reference< uno::XInterface > OFixedText::create(uno::Reference< uno::XComponentContext > const & xContext)
117 return *(new OFixedText(xContext));
121 uno::Sequence< OUString > SAL_CALL OFixedText::getSupportedServiceNames( ) throw(uno::RuntimeException, std::exception)
123 return getSupportedServiceNames_Static();
126 sal_Bool SAL_CALL OFixedText::supportsService(const OUString& ServiceName) throw( uno::RuntimeException, std::exception )
128 return cppu::supportsService(this, ServiceName);
131 // XReportComponent
132 REPORTCOMPONENT_IMPL(OFixedText,m_aProps.aComponent)
133 REPORTCOMPONENT_IMPL2(OFixedText,m_aProps.aComponent)
134 REPORTCOMPONENT_NOMASTERDETAIL(OFixedText)
135 REPORTCONTROLFORMAT_IMPL(OFixedText,m_aProps.aFormatProperties)
137 uno::Reference< beans::XPropertySetInfo > SAL_CALL OFixedText::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
139 return FixedTextPropertySet::getPropertySetInfo();
142 void SAL_CALL OFixedText::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
144 FixedTextPropertySet::setPropertyValue( aPropertyName, aValue );
147 uno::Any SAL_CALL OFixedText::getPropertyValue( const OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
149 return FixedTextPropertySet::getPropertyValue( PropertyName);
152 void SAL_CALL OFixedText::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
154 FixedTextPropertySet::addPropertyChangeListener( aPropertyName, xListener );
157 void SAL_CALL OFixedText::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
159 FixedTextPropertySet::removePropertyChangeListener( aPropertyName, aListener );
162 void SAL_CALL OFixedText::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
164 FixedTextPropertySet::addVetoableChangeListener( PropertyName, aListener );
167 void SAL_CALL OFixedText::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
169 FixedTextPropertySet::removeVetoableChangeListener( PropertyName, aListener );
172 // XReportControlModel
173 OUString SAL_CALL OFixedText::getDataField() throw ( beans::UnknownPropertyException, uno::RuntimeException, std::exception)
175 throw beans::UnknownPropertyException();
178 void SAL_CALL OFixedText::setDataField( const OUString& /*_datafield*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException, std::exception)
180 throw beans::UnknownPropertyException();
185 sal_Bool SAL_CALL OFixedText::getPrintWhenGroupChange() throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
187 ::osl::MutexGuard aGuard(m_aMutex);
188 return m_aProps.bPrintWhenGroupChange;
191 void SAL_CALL OFixedText::setPrintWhenGroupChange( sal_Bool _printwhengroupchange ) throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
193 set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange);
196 OUString SAL_CALL OFixedText::getConditionalPrintExpression() throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
198 ::osl::MutexGuard aGuard(m_aMutex);
199 return m_aProps.aConditionalPrintExpression;
202 void SAL_CALL OFixedText::setConditionalPrintExpression( const OUString& _conditionalprintexpression ) throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
204 set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression);
208 // XCloneable
209 uno::Reference< util::XCloneable > SAL_CALL OFixedText::createClone( ) throw (uno::RuntimeException, std::exception)
211 uno::Reference< report::XReportComponent> xSource = this;
212 uno::Reference< report::XFixedText> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FIXEDTEXT),uno::UNO_QUERY_THROW);
213 return xSet.get();
217 // XFixedText
218 OUString SAL_CALL OFixedText::getLabel() throw (uno::RuntimeException, std::exception)
220 ::osl::MutexGuard aGuard(m_aMutex);
221 return m_sLabel;
224 void SAL_CALL OFixedText::setLabel( const OUString& _label ) throw (uno::RuntimeException, std::exception)
226 set(PROPERTY_LABEL,_label,m_sLabel);
229 // XChild
230 uno::Reference< uno::XInterface > SAL_CALL OFixedText::getParent( ) throw (uno::RuntimeException, std::exception)
232 return OShapeHelper::getParent(this);
235 void SAL_CALL OFixedText::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException, std::exception)
237 OShapeHelper::setParent(Parent,this);
240 uno::Reference< report::XFormatCondition > SAL_CALL OFixedText::createFormatCondition( ) throw (uno::Exception, uno::RuntimeException, std::exception)
242 return new OFormatCondition(m_aProps.aComponent.m_xContext);
245 // XContainer
246 void SAL_CALL OFixedText::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException, std::exception)
248 m_aProps.addContainerListener(xListener);
251 void SAL_CALL OFixedText::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException, std::exception)
253 m_aProps.removeContainerListener(xListener);
256 // XElementAccess
257 uno::Type SAL_CALL OFixedText::getElementType( ) throw (uno::RuntimeException, std::exception)
259 return cppu::UnoType<report::XFormatCondition>::get();
262 sal_Bool SAL_CALL OFixedText::hasElements( ) throw (uno::RuntimeException, std::exception)
264 return m_aProps.hasElements();
267 // XIndexContainer
268 void SAL_CALL OFixedText::insertByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
270 m_aProps.insertByIndex(Index,Element);
273 void SAL_CALL OFixedText::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
275 m_aProps.removeByIndex(Index);
278 // XIndexReplace
279 void SAL_CALL OFixedText::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
281 m_aProps.replaceByIndex(Index,Element);
284 // XIndexAccess
285 ::sal_Int32 SAL_CALL OFixedText::getCount( ) throw (uno::RuntimeException, std::exception)
287 return m_aProps.getCount();
290 uno::Any SAL_CALL OFixedText::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
292 return m_aProps.getByIndex( Index );
295 // XShape
296 awt::Point SAL_CALL OFixedText::getPosition( ) throw (uno::RuntimeException, std::exception)
298 return OShapeHelper::getPosition(this);
301 void SAL_CALL OFixedText::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException, std::exception)
303 OShapeHelper::setPosition(aPosition,this);
306 awt::Size SAL_CALL OFixedText::getSize( ) throw (uno::RuntimeException, std::exception)
308 return OShapeHelper::getSize(this);
311 void SAL_CALL OFixedText::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException, std::exception)
313 OShapeHelper::setSize(aSize,this);
317 // XShapeDescriptor
318 OUString SAL_CALL OFixedText::getShapeType( ) throw (uno::RuntimeException, std::exception)
320 ::osl::MutexGuard aGuard(m_aMutex);
321 if ( m_aProps.aComponent.m_xShape.is() )
322 return m_aProps.aComponent.m_xShape->getShapeType();
323 return OUString("com.sun.star.drawing.ControlShape");
328 } // namespace reportdesign
331 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */