lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / reportdesign / source / core / api / FixedText.cxx
blob5a63491dce6921702bf3b171a8f59247d16b71da
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 <strings.hxx>
22 #include <com/sun/star/beans/XPropertyState.hpp>
23 #include <strings.hrc>
24 #include <core_resource.hxx>
25 #include <Tools.hxx>
26 #include <tools/color.hxx>
27 #include <cppuhelper/supportsservice.hxx>
28 #include <FormatCondition.hxx>
29 #include <com/sun/star/text/ParagraphVertAlign.hpp>
30 #include <ReportHelperImpl.hxx>
32 namespace reportdesign
35 using namespace com::sun::star;
37 static uno::Sequence< OUString > lcl_getFixedTextOptionals()
39 OUString pProps[] = { OUString(PROPERTY_DATAFIELD),OUString(PROPERTY_MASTERFIELDS),OUString(PROPERTY_DETAILFIELDS) };
40 return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps));
43 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext)
44 :FixedTextBase(m_aMutex)
45 ,FixedTextPropertySet(_xContext,IMPLEMENTS_PROPERTY_SET,lcl_getFixedTextOptionals())
46 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
48 m_aProps.aComponent.m_sName = RptResId(RID_STR_FIXEDTEXT);
49 m_aProps.aComponent.m_nBorder = 0; // no border
52 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext
53 ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
54 ,uno::Reference< drawing::XShape >& _xShape)
55 :FixedTextBase(m_aMutex)
56 ,FixedTextPropertySet(_xContext,IMPLEMENTS_PROPERTY_SET,lcl_getFixedTextOptionals())
57 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
59 m_aProps.aComponent.m_sName = RptResId(RID_STR_FIXEDTEXT);
60 m_aProps.aComponent.m_nBorder = 0; // no border
61 m_aProps.aComponent.m_xFactory = _xFactory;
62 osl_atomic_increment( &m_refCount );
64 m_aProps.aComponent.setShape(_xShape,this,m_refCount);
66 osl_atomic_decrement( &m_refCount );
69 OFixedText::~OFixedText()
73 IMPLEMENT_FORWARD_REFCOUNT( OFixedText, FixedTextBase )
75 uno::Any SAL_CALL OFixedText::queryInterface( const uno::Type& _rType )
77 uno::Any aReturn = FixedTextBase::queryInterface(_rType);
78 if ( !aReturn.hasValue() )
79 aReturn = FixedTextPropertySet::queryInterface(_rType);
80 if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
81 return aReturn;
83 return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn);
87 void SAL_CALL OFixedText::dispose()
89 FixedTextPropertySet::dispose();
90 cppu::WeakComponentImplHelperBase::dispose();
91 uno::Reference< report::XFixedText> xHoldAlive = this;
94 OUString OFixedText::getImplementationName_Static( )
96 return OUString("com.sun.star.comp.report.OFixedText");
100 OUString SAL_CALL OFixedText::getImplementationName( )
102 return getImplementationName_Static();
105 uno::Sequence< OUString > OFixedText::getSupportedServiceNames_Static( )
107 uno::Sequence< OUString > aServices { SERVICE_FIXEDTEXT };
109 return aServices;
112 uno::Reference< uno::XInterface > OFixedText::create(uno::Reference< uno::XComponentContext > const & xContext)
114 return *(new OFixedText(xContext));
118 uno::Sequence< OUString > SAL_CALL OFixedText::getSupportedServiceNames( )
120 return getSupportedServiceNames_Static();
123 sal_Bool SAL_CALL OFixedText::supportsService(const OUString& ServiceName)
125 return cppu::supportsService(this, ServiceName);
128 // XReportComponent
129 REPORTCOMPONENT_IMPL(OFixedText,m_aProps.aComponent)
130 REPORTCOMPONENT_IMPL2(OFixedText,m_aProps.aComponent)
131 REPORTCOMPONENT_NOMASTERDETAIL(OFixedText)
132 REPORTCONTROLFORMAT_IMPL(OFixedText,m_aProps.aFormatProperties)
134 uno::Reference< beans::XPropertySetInfo > SAL_CALL OFixedText::getPropertySetInfo( )
136 return FixedTextPropertySet::getPropertySetInfo();
139 void SAL_CALL OFixedText::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
141 FixedTextPropertySet::setPropertyValue( aPropertyName, aValue );
144 uno::Any SAL_CALL OFixedText::getPropertyValue( const OUString& PropertyName )
146 return FixedTextPropertySet::getPropertyValue( PropertyName);
149 void SAL_CALL OFixedText::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
151 FixedTextPropertySet::addPropertyChangeListener( aPropertyName, xListener );
154 void SAL_CALL OFixedText::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener )
156 FixedTextPropertySet::removePropertyChangeListener( aPropertyName, aListener );
159 void SAL_CALL OFixedText::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
161 FixedTextPropertySet::addVetoableChangeListener( PropertyName, aListener );
164 void SAL_CALL OFixedText::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
166 FixedTextPropertySet::removeVetoableChangeListener( PropertyName, aListener );
169 // XReportControlModel
170 OUString SAL_CALL OFixedText::getDataField()
172 throw beans::UnknownPropertyException();
175 void SAL_CALL OFixedText::setDataField( const OUString& /*_datafield*/ )
177 throw beans::UnknownPropertyException();
181 sal_Bool SAL_CALL OFixedText::getPrintWhenGroupChange()
183 ::osl::MutexGuard aGuard(m_aMutex);
184 return m_aProps.bPrintWhenGroupChange;
187 void SAL_CALL OFixedText::setPrintWhenGroupChange( sal_Bool _printwhengroupchange )
189 set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange);
192 OUString SAL_CALL OFixedText::getConditionalPrintExpression()
194 ::osl::MutexGuard aGuard(m_aMutex);
195 return m_aProps.aConditionalPrintExpression;
198 void SAL_CALL OFixedText::setConditionalPrintExpression( const OUString& _conditionalprintexpression )
200 set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression);
204 // XCloneable
205 uno::Reference< util::XCloneable > SAL_CALL OFixedText::createClone( )
207 uno::Reference< report::XReportComponent> xSource = this;
208 uno::Reference< report::XFixedText> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FIXEDTEXT),uno::UNO_QUERY_THROW);
209 return xSet.get();
213 // XFixedText
214 OUString SAL_CALL OFixedText::getLabel()
216 ::osl::MutexGuard aGuard(m_aMutex);
217 return m_sLabel;
220 void SAL_CALL OFixedText::setLabel( const OUString& _label )
222 set(PROPERTY_LABEL,_label,m_sLabel);
225 // XChild
226 uno::Reference< uno::XInterface > SAL_CALL OFixedText::getParent( )
228 return OShapeHelper::getParent(this);
231 void SAL_CALL OFixedText::setParent( const uno::Reference< uno::XInterface >& Parent )
233 OShapeHelper::setParent(Parent,this);
236 uno::Reference< report::XFormatCondition > SAL_CALL OFixedText::createFormatCondition( )
238 return new OFormatCondition(m_aProps.aComponent.m_xContext);
241 // XContainer
242 void SAL_CALL OFixedText::addContainerListener( const uno::Reference< container::XContainerListener >& xListener )
244 m_aProps.addContainerListener(xListener);
247 void SAL_CALL OFixedText::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener )
249 m_aProps.removeContainerListener(xListener);
252 // XElementAccess
253 uno::Type SAL_CALL OFixedText::getElementType( )
255 return cppu::UnoType<report::XFormatCondition>::get();
258 sal_Bool SAL_CALL OFixedText::hasElements( )
260 return m_aProps.hasElements();
263 // XIndexContainer
264 void SAL_CALL OFixedText::insertByIndex( ::sal_Int32 Index, const uno::Any& Element )
266 m_aProps.insertByIndex(Index,Element);
269 void SAL_CALL OFixedText::removeByIndex( ::sal_Int32 Index )
271 m_aProps.removeByIndex(Index);
274 // XIndexReplace
275 void SAL_CALL OFixedText::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element )
277 m_aProps.replaceByIndex(Index,Element);
280 // XIndexAccess
281 ::sal_Int32 SAL_CALL OFixedText::getCount( )
283 return m_aProps.getCount();
286 uno::Any SAL_CALL OFixedText::getByIndex( ::sal_Int32 Index )
288 return m_aProps.getByIndex( Index );
291 // XShape
292 awt::Point SAL_CALL OFixedText::getPosition( )
294 return OShapeHelper::getPosition(this);
297 void SAL_CALL OFixedText::setPosition( const awt::Point& aPosition )
299 OShapeHelper::setPosition(aPosition,this);
302 awt::Size SAL_CALL OFixedText::getSize( )
304 return OShapeHelper::getSize(this);
307 void SAL_CALL OFixedText::setSize( const awt::Size& aSize )
309 OShapeHelper::setSize(aSize,this);
313 // XShapeDescriptor
314 OUString SAL_CALL OFixedText::getShapeType( )
316 ::osl::MutexGuard aGuard(m_aMutex);
317 if ( m_aProps.aComponent.m_xShape.is() )
318 return m_aProps.aComponent.m_xShape->getShapeType();
319 return OUString("com.sun.star.drawing.ControlShape");
323 } // namespace reportdesign
326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */