cURL: follow redirects
[LibreOffice.git] / reportdesign / source / core / api / FixedText.cxx
blobc0fbb05383b2648f3db37fd9d19e17eb096d2b6c
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;
40 uno::Sequence< OUString > lcl_getFixedTextOptionals()
42 OUString pProps[] = { OUString(PROPERTY_DATAFIELD),OUString(PROPERTY_MASTERFIELDS),OUString(PROPERTY_DETAILFIELDS) };
43 return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps));
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 m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FIXEDTEXT);
52 m_aProps.aComponent.m_nBorder = 0; // no border
55 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext
56 ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
57 ,uno::Reference< drawing::XShape >& _xShape)
58 :FixedTextBase(m_aMutex)
59 ,FixedTextPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getFixedTextOptionals())
60 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
62 m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FIXEDTEXT);
63 m_aProps.aComponent.m_nBorder = 0; // no border
64 m_aProps.aComponent.m_xFactory = _xFactory;
65 osl_atomic_increment( &m_refCount );
67 m_aProps.aComponent.setShape(_xShape,this,m_refCount);
69 osl_atomic_decrement( &m_refCount );
72 OFixedText::~OFixedText()
76 IMPLEMENT_FORWARD_REFCOUNT( OFixedText, FixedTextBase )
78 uno::Any SAL_CALL OFixedText::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException, std::exception)
80 uno::Any aReturn = FixedTextBase::queryInterface(_rType);
81 if ( !aReturn.hasValue() )
82 aReturn = FixedTextPropertySet::queryInterface(_rType);
83 if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
84 return aReturn;
86 return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn);
90 void SAL_CALL OFixedText::dispose() throw(uno::RuntimeException, std::exception)
92 FixedTextPropertySet::dispose();
93 cppu::WeakComponentImplHelperBase::dispose();
94 uno::Reference< report::XFixedText> xHoldAlive = this;
97 OUString OFixedText::getImplementationName_Static( ) throw(uno::RuntimeException)
99 return OUString("com.sun.star.comp.report.OFixedText");
103 OUString SAL_CALL OFixedText::getImplementationName( ) throw(uno::RuntimeException, std::exception)
105 return getImplementationName_Static();
108 uno::Sequence< OUString > OFixedText::getSupportedServiceNames_Static( ) throw(uno::RuntimeException)
110 uno::Sequence< OUString > aServices { 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();
184 sal_Bool SAL_CALL OFixedText::getPrintWhenGroupChange() throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
186 ::osl::MutexGuard aGuard(m_aMutex);
187 return m_aProps.bPrintWhenGroupChange;
190 void SAL_CALL OFixedText::setPrintWhenGroupChange( sal_Bool _printwhengroupchange ) throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
192 set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange);
195 OUString SAL_CALL OFixedText::getConditionalPrintExpression() throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
197 ::osl::MutexGuard aGuard(m_aMutex);
198 return m_aProps.aConditionalPrintExpression;
201 void SAL_CALL OFixedText::setConditionalPrintExpression( const OUString& _conditionalprintexpression ) throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
203 set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression);
207 // XCloneable
208 uno::Reference< util::XCloneable > SAL_CALL OFixedText::createClone( ) throw (uno::RuntimeException, std::exception)
210 uno::Reference< report::XReportComponent> xSource = this;
211 uno::Reference< report::XFixedText> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FIXEDTEXT),uno::UNO_QUERY_THROW);
212 return xSet.get();
216 // XFixedText
217 OUString SAL_CALL OFixedText::getLabel() throw (uno::RuntimeException, std::exception)
219 ::osl::MutexGuard aGuard(m_aMutex);
220 return m_sLabel;
223 void SAL_CALL OFixedText::setLabel( const OUString& _label ) throw (uno::RuntimeException, std::exception)
225 set(PROPERTY_LABEL,_label,m_sLabel);
228 // XChild
229 uno::Reference< uno::XInterface > SAL_CALL OFixedText::getParent( ) throw (uno::RuntimeException, std::exception)
231 return OShapeHelper::getParent(this);
234 void SAL_CALL OFixedText::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException, std::exception)
236 OShapeHelper::setParent(Parent,this);
239 uno::Reference< report::XFormatCondition > SAL_CALL OFixedText::createFormatCondition( ) throw (uno::Exception, uno::RuntimeException, std::exception)
241 return new OFormatCondition(m_aProps.aComponent.m_xContext);
244 // XContainer
245 void SAL_CALL OFixedText::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException, std::exception)
247 m_aProps.addContainerListener(xListener);
250 void SAL_CALL OFixedText::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException, std::exception)
252 m_aProps.removeContainerListener(xListener);
255 // XElementAccess
256 uno::Type SAL_CALL OFixedText::getElementType( ) throw (uno::RuntimeException, std::exception)
258 return cppu::UnoType<report::XFormatCondition>::get();
261 sal_Bool SAL_CALL OFixedText::hasElements( ) throw (uno::RuntimeException, std::exception)
263 return m_aProps.hasElements();
266 // XIndexContainer
267 void SAL_CALL OFixedText::insertByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
269 m_aProps.insertByIndex(Index,Element);
272 void SAL_CALL OFixedText::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
274 m_aProps.removeByIndex(Index);
277 // XIndexReplace
278 void SAL_CALL OFixedText::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
280 m_aProps.replaceByIndex(Index,Element);
283 // XIndexAccess
284 ::sal_Int32 SAL_CALL OFixedText::getCount( ) throw (uno::RuntimeException, std::exception)
286 return m_aProps.getCount();
289 uno::Any SAL_CALL OFixedText::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
291 return m_aProps.getByIndex( Index );
294 // XShape
295 awt::Point SAL_CALL OFixedText::getPosition( ) throw (uno::RuntimeException, std::exception)
297 return OShapeHelper::getPosition(this);
300 void SAL_CALL OFixedText::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException, std::exception)
302 OShapeHelper::setPosition(aPosition,this);
305 awt::Size SAL_CALL OFixedText::getSize( ) throw (uno::RuntimeException, std::exception)
307 return OShapeHelper::getSize(this);
310 void SAL_CALL OFixedText::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException, std::exception)
312 OShapeHelper::setSize(aSize,this);
316 // XShapeDescriptor
317 OUString SAL_CALL OFixedText::getShapeType( ) throw (uno::RuntimeException, std::exception)
319 ::osl::MutexGuard aGuard(m_aMutex);
320 if ( m_aProps.aComponent.m_xShape.is() )
321 return m_aProps.aComponent.m_xShape->getShapeType();
322 return OUString("com.sun.star.drawing.ControlShape");
326 } // namespace reportdesign
329 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */