update dev300-m58
[ooovba.git] / reportdesign / source / core / api / FixedText.cxx
blob8c0d2d4b56c9ecdba55f9caf495d33470fdf74d3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FixedText.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "FixedText.hxx"
31 #include <com/sun/star/beans/PropertyAttribute.hpp>
32 #ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC
33 #include "corestrings.hrc"
34 #endif
35 #include <com/sun/star/beans/XPropertyState.hpp>
36 #ifndef REPORTDESIGN_CORE_RESOURCE_HRC_
37 #include "core_resource.hrc"
38 #endif
39 #include "core_resource.hxx"
40 #include <comphelper/sequence.hxx>
41 #include "Tools.hxx"
42 #include <tools/debug.hxx>
43 #include <comphelper/property.hxx>
44 #include "FormatCondition.hxx"
45 #include <com/sun/star/text/ParagraphVertAlign.hpp>
46 #include "ReportHelperImpl.hxx"
47 // =============================================================================
48 namespace reportdesign
50 // =============================================================================
51 using namespace com::sun::star;
52 using namespace comphelper;
53 uno::Sequence< ::rtl::OUString > lcl_getFixedTextOptionals()
55 ::rtl::OUString pProps[] = { PROPERTY_DATAFIELD,PROPERTY_MASTERFIELDS,PROPERTY_DETAILFIELDS };
56 return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
58 DBG_NAME( rpt_OFixedText )
59 // -----------------------------------------------------------------------------
60 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext)
61 :FixedTextBase(m_aMutex)
62 ,FixedTextPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getFixedTextOptionals())
63 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
65 DBG_CTOR( rpt_OFixedText,NULL);
66 m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FIXEDTEXT,m_aProps.aComponent.m_xContext->getServiceManager());
67 m_aProps.aComponent.m_nBorder = 0; // no border
69 // -----------------------------------------------------------------------------
70 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext
71 ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
72 ,uno::Reference< drawing::XShape >& _xShape)
73 :FixedTextBase(m_aMutex)
74 ,FixedTextPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getFixedTextOptionals())
75 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
77 DBG_CTOR( rpt_OFixedText,NULL);
78 m_aProps.aComponent.m_sName = RPT_RESSTRING(RID_STR_FIXEDTEXT,m_aProps.aComponent.m_xContext->getServiceManager());
79 m_aProps.aComponent.m_nBorder = 0; // no border
80 m_aProps.aComponent.m_xFactory = _xFactory;
81 osl_incrementInterlockedCount( &m_refCount );
83 m_aProps.aComponent.setShape(_xShape,this,m_refCount);
85 osl_decrementInterlockedCount( &m_refCount );
87 // -----------------------------------------------------------------------------
88 OFixedText::~OFixedText()
90 DBG_DTOR( rpt_OFixedText,NULL);
92 // -----------------------------------------------------------------------------
93 IMPLEMENT_FORWARD_REFCOUNT( OFixedText, FixedTextBase )
94 // --------------------------------------------------------------------------------
95 uno::Any SAL_CALL OFixedText::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException)
97 uno::Any aReturn = FixedTextBase::queryInterface(_rType);
98 if ( !aReturn.hasValue() )
99 aReturn = FixedTextPropertySet::queryInterface(_rType);
100 if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
101 return aReturn;
103 return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn);
106 //IMPLEMENT_FORWARD_XINTERFACE2(OFixedText,FixedTextBase,FixedTextPropertySet)
107 // -----------------------------------------------------------------------------
108 void SAL_CALL OFixedText::dispose() throw(uno::RuntimeException)
110 FixedTextPropertySet::dispose();
111 cppu::WeakComponentImplHelperBase::dispose();
112 uno::Reference< report::XFixedText> xHoldAlive = this;
114 // -----------------------------------------------------------------------------
115 ::rtl::OUString OFixedText::getImplementationName_Static( ) throw(uno::RuntimeException)
117 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OFixedText"));
120 //--------------------------------------------------------------------------
121 ::rtl::OUString SAL_CALL OFixedText::getImplementationName( ) throw(uno::RuntimeException)
123 return getImplementationName_Static();
125 //--------------------------------------------------------------------------
126 uno::Sequence< ::rtl::OUString > OFixedText::getSupportedServiceNames_Static( ) throw(uno::RuntimeException)
128 uno::Sequence< ::rtl::OUString > aServices(1);//2);
129 aServices.getArray()[0] = SERVICE_FIXEDTEXT;
130 //aServices.getArray()[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"));
132 return aServices;
134 //------------------------------------------------------------------------------
135 uno::Reference< uno::XInterface > OFixedText::create(uno::Reference< uno::XComponentContext > const & xContext)
137 return *(new OFixedText(xContext));
140 //--------------------------------------------------------------------------
141 uno::Sequence< ::rtl::OUString > SAL_CALL OFixedText::getSupportedServiceNames( ) throw(uno::RuntimeException)
143 return getSupportedServiceNames_Static();
145 //------------------------------------------------------------------------------
146 sal_Bool SAL_CALL OFixedText::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException )
148 return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static());
150 // -----------------------------------------------------------------------------
151 // XReportComponent
152 REPORTCOMPONENT_IMPL(OFixedText,m_aProps.aComponent)
153 REPORTCOMPONENT_IMPL2(OFixedText,m_aProps.aComponent)
154 REPORTCOMPONENT_NOMASTERDETAIL(OFixedText)
155 REPORTCONTROLFORMAT_IMPL(OFixedText,m_aProps.aFormatProperties)
156 // -----------------------------------------------------------------------------
157 uno::Reference< beans::XPropertySetInfo > SAL_CALL OFixedText::getPropertySetInfo( ) throw(uno::RuntimeException)
159 return FixedTextPropertySet::getPropertySetInfo();
161 // -----------------------------------------------------------------------------
162 void SAL_CALL OFixedText::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
164 FixedTextPropertySet::setPropertyValue( aPropertyName, aValue );
166 // -----------------------------------------------------------------------------
167 uno::Any SAL_CALL OFixedText::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
169 return FixedTextPropertySet::getPropertyValue( PropertyName);
171 // -----------------------------------------------------------------------------
172 void SAL_CALL OFixedText::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
174 FixedTextPropertySet::addPropertyChangeListener( aPropertyName, xListener );
176 // -----------------------------------------------------------------------------
177 void SAL_CALL OFixedText::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
179 FixedTextPropertySet::removePropertyChangeListener( aPropertyName, aListener );
181 // -----------------------------------------------------------------------------
182 void SAL_CALL OFixedText::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
184 FixedTextPropertySet::addVetoableChangeListener( PropertyName, aListener );
186 // -----------------------------------------------------------------------------
187 void SAL_CALL OFixedText::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
189 FixedTextPropertySet::removeVetoableChangeListener( PropertyName, aListener );
191 // -----------------------------------------------------------------------------
192 // XReportControlModel
193 ::rtl::OUString SAL_CALL OFixedText::getDataField() throw ( beans::UnknownPropertyException, uno::RuntimeException)
195 throw beans::UnknownPropertyException();
197 // -----------------------------------------------------------------------------
198 void SAL_CALL OFixedText::setDataField( const ::rtl::OUString& /*_datafield*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
200 throw beans::UnknownPropertyException();
202 // -----------------------------------------------------------------------------
204 // -----------------------------------------------------------------------------
205 ::sal_Bool SAL_CALL OFixedText::getPrintWhenGroupChange() throw (beans::UnknownPropertyException, uno::RuntimeException)
207 ::osl::MutexGuard aGuard(m_aMutex);
208 return m_aProps.bPrintWhenGroupChange;
210 // -----------------------------------------------------------------------------
211 void SAL_CALL OFixedText::setPrintWhenGroupChange( ::sal_Bool _printwhengroupchange ) throw (beans::UnknownPropertyException, uno::RuntimeException)
213 set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange);
215 // -----------------------------------------------------------------------------
216 ::rtl::OUString SAL_CALL OFixedText::getConditionalPrintExpression() throw (beans::UnknownPropertyException, uno::RuntimeException)
218 ::osl::MutexGuard aGuard(m_aMutex);
219 return m_aProps.aConditionalPrintExpression;
221 // -----------------------------------------------------------------------------
222 void SAL_CALL OFixedText::setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (beans::UnknownPropertyException, uno::RuntimeException)
224 set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression);
226 // -----------------------------------------------------------------------------
228 // XCloneable
229 uno::Reference< util::XCloneable > SAL_CALL OFixedText::createClone( ) throw (uno::RuntimeException)
231 uno::Reference< report::XReportComponent> xSource = this;
232 uno::Reference< report::XFixedText> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FIXEDTEXT),uno::UNO_QUERY_THROW);
233 return xSet.get();
235 // -----------------------------------------------------------------------------
237 // XFixedText
238 ::rtl::OUString SAL_CALL OFixedText::getLabel() throw (uno::RuntimeException)
240 ::osl::MutexGuard aGuard(m_aMutex);
241 return m_sLabel;
243 // -----------------------------------------------------------------------------
244 void SAL_CALL OFixedText::setLabel( const ::rtl::OUString& _label ) throw (uno::RuntimeException)
246 set(PROPERTY_LABEL,_label,m_sLabel);
248 // -----------------------------------------------------------------------------
249 // XChild
250 uno::Reference< uno::XInterface > SAL_CALL OFixedText::getParent( ) throw (uno::RuntimeException)
252 return OShapeHelper::getParent(this);
254 // -----------------------------------------------------------------------------
255 void SAL_CALL OFixedText::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException)
257 OShapeHelper::setParent(Parent,this);
259 // -----------------------------------------------------------------------------
260 uno::Reference< report::XFormatCondition > SAL_CALL OFixedText::createFormatCondition( ) throw (uno::Exception, uno::RuntimeException)
262 return new OFormatCondition(m_aProps.aComponent.m_xContext);
264 // -----------------------------------------------------------------------------
265 // XContainer
266 void SAL_CALL OFixedText::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException)
268 m_aProps.addContainerListener(xListener);
270 // -----------------------------------------------------------------------------
271 void SAL_CALL OFixedText::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException)
273 m_aProps.removeContainerListener(xListener);
275 // -----------------------------------------------------------------------------
276 // XElementAccess
277 uno::Type SAL_CALL OFixedText::getElementType( ) throw (uno::RuntimeException)
279 return ::getCppuType(static_cast< uno::Reference<report::XFormatCondition>*>(NULL));
281 // -----------------------------------------------------------------------------
282 ::sal_Bool SAL_CALL OFixedText::hasElements( ) throw (uno::RuntimeException)
284 return m_aProps.hasElements();
286 // -----------------------------------------------------------------------------
287 // XIndexContainer
288 void SAL_CALL OFixedText::insertByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
290 m_aProps.insertByIndex(Index,Element);
292 // -----------------------------------------------------------------------------
293 void SAL_CALL OFixedText::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
295 m_aProps.removeByIndex(Index);
297 // -----------------------------------------------------------------------------
298 // XIndexReplace
299 void SAL_CALL OFixedText::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
301 m_aProps.replaceByIndex(Index,Element);
303 // -----------------------------------------------------------------------------
304 // XIndexAccess
305 ::sal_Int32 SAL_CALL OFixedText::getCount( ) throw (uno::RuntimeException)
307 return m_aProps.getCount();
309 // -----------------------------------------------------------------------------
310 uno::Any SAL_CALL OFixedText::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
312 return m_aProps.getByIndex( Index );
314 // -----------------------------------------------------------------------------
315 // XShape
316 awt::Point SAL_CALL OFixedText::getPosition( ) throw (uno::RuntimeException)
318 return OShapeHelper::getPosition(this);
320 // -----------------------------------------------------------------------------
321 void SAL_CALL OFixedText::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException)
323 OShapeHelper::setPosition(aPosition,this);
325 // -----------------------------------------------------------------------------
326 awt::Size SAL_CALL OFixedText::getSize( ) throw (uno::RuntimeException)
328 return OShapeHelper::getSize(this);
330 // -----------------------------------------------------------------------------
331 void SAL_CALL OFixedText::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException)
333 OShapeHelper::setSize(aSize,this);
335 // -----------------------------------------------------------------------------
337 // XShapeDescriptor
338 ::rtl::OUString SAL_CALL OFixedText::getShapeType( ) throw (uno::RuntimeException)
340 ::osl::MutexGuard aGuard(m_aMutex);
341 if ( m_aProps.aComponent.m_xShape.is() )
342 return m_aProps.aComponent.m_xShape->getShapeType();
343 return ::rtl::OUString();
345 // -----------------------------------------------------------------------------
346 // -----------------------------------------------------------------------------
347 // =============================================================================
348 } // namespace reportdesign
349 // =============================================================================