xref: /AOO41X/main/reportdesign/source/core/api/FixedText.cxx (revision 31682d324c3d6876f4c2aa2e7bf61ba930bce25d)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #include "FixedText.hxx"
28 #include <com/sun/star/beans/PropertyAttribute.hpp>
29 #ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC
30 #include "corestrings.hrc"
31 #endif
32 #include <com/sun/star/beans/XPropertyState.hpp>
33 #ifndef REPORTDESIGN_CORE_RESOURCE_HRC_
34 #include "core_resource.hrc"
35 #endif
36 #include "core_resource.hxx"
37 #include <comphelper/sequence.hxx>
38 #include "Tools.hxx"
39 #include <tools/debug.hxx>
40 #include <comphelper/property.hxx>
41 #include "FormatCondition.hxx"
42 #include <com/sun/star/text/ParagraphVertAlign.hpp>
43 #include "ReportHelperImpl.hxx"
44 // =============================================================================
45 namespace reportdesign
46 {
47 // =============================================================================
48 	using namespace com::sun::star;
49 	using namespace comphelper;
50 uno::Sequence< ::rtl::OUString > lcl_getFixedTextOptionals()
51 {
52 	::rtl::OUString pProps[] = { PROPERTY_DATAFIELD,PROPERTY_MASTERFIELDS,PROPERTY_DETAILFIELDS };
53 	return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
54 }
55 DBG_NAME( rpt_OFixedText )
56 // -----------------------------------------------------------------------------
57 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext)
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)
61 {
62 	DBG_CTOR( rpt_OFixedText,NULL);
63 	m_aProps.aComponent.m_sName  = RPT_RESSTRING(RID_STR_FIXEDTEXT,m_aProps.aComponent.m_xContext->getServiceManager());
64 	m_aProps.aComponent.m_nBorder = 0; // no border
65 }
66 // -----------------------------------------------------------------------------
67 OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext
68                        ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
69                        ,uno::Reference< drawing::XShape >& _xShape)
70 :FixedTextBase(m_aMutex)
71 ,FixedTextPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getFixedTextOptionals())
72 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
73 {
74 	DBG_CTOR( rpt_OFixedText,NULL);
75 	m_aProps.aComponent.m_sName  = RPT_RESSTRING(RID_STR_FIXEDTEXT,m_aProps.aComponent.m_xContext->getServiceManager());
76 	m_aProps.aComponent.m_nBorder = 0; // no border
77     m_aProps.aComponent.m_xFactory = _xFactory;
78     osl_incrementInterlockedCount( &m_refCount );
79     {
80         m_aProps.aComponent.setShape(_xShape,this,m_refCount);
81     }
82     osl_decrementInterlockedCount( &m_refCount );
83 }
84 // -----------------------------------------------------------------------------
85 OFixedText::~OFixedText()
86 {
87     DBG_DTOR( rpt_OFixedText,NULL);
88 }
89 // -----------------------------------------------------------------------------
90 IMPLEMENT_FORWARD_REFCOUNT( OFixedText, FixedTextBase )
91 // --------------------------------------------------------------------------------
92 uno::Any SAL_CALL OFixedText::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException)
93 {
94 	uno::Any aReturn = FixedTextBase::queryInterface(_rType);
95     if ( !aReturn.hasValue() )
96         aReturn = FixedTextPropertySet::queryInterface(_rType);
97     if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
98         return aReturn;
99 
100 	return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn);
101 }
102 
103 //IMPLEMENT_FORWARD_XINTERFACE2(OFixedText,FixedTextBase,FixedTextPropertySet)
104 // -----------------------------------------------------------------------------
105 void SAL_CALL OFixedText::dispose() throw(uno::RuntimeException)
106 {
107 	FixedTextPropertySet::dispose();
108 	cppu::WeakComponentImplHelperBase::dispose();
109     uno::Reference< report::XFixedText> xHoldAlive = this;
110 }
111 // -----------------------------------------------------------------------------
112 ::rtl::OUString OFixedText::getImplementationName_Static(  ) throw(uno::RuntimeException)
113 {
114 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OFixedText"));
115 }
116 
117 //--------------------------------------------------------------------------
118 ::rtl::OUString SAL_CALL OFixedText::getImplementationName(  ) throw(uno::RuntimeException)
119 {
120 	return getImplementationName_Static();
121 }
122 //--------------------------------------------------------------------------
123 uno::Sequence< ::rtl::OUString > OFixedText::getSupportedServiceNames_Static(  ) throw(uno::RuntimeException)
124 {
125 	uno::Sequence< ::rtl::OUString > aServices(1);//2);
126 	aServices.getArray()[0] = SERVICE_FIXEDTEXT;
127     //aServices.getArray()[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"));
128 
129 	return aServices;
130 }
131 //------------------------------------------------------------------------------
132 uno::Reference< uno::XInterface > OFixedText::create(uno::Reference< uno::XComponentContext > const & xContext)
133 {
134 	return *(new OFixedText(xContext));
135 }
136 
137 //--------------------------------------------------------------------------
138 uno::Sequence< ::rtl::OUString > SAL_CALL OFixedText::getSupportedServiceNames(  ) throw(uno::RuntimeException)
139 {
140 	return getSupportedServiceNames_Static();
141 }
142 //------------------------------------------------------------------------------
143 sal_Bool SAL_CALL OFixedText::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException )
144 {
145 	return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static());
146 }
147 // -----------------------------------------------------------------------------
148 // XReportComponent
149 REPORTCOMPONENT_IMPL(OFixedText,m_aProps.aComponent)
150 REPORTCOMPONENT_IMPL2(OFixedText,m_aProps.aComponent)
151 REPORTCOMPONENT_NOMASTERDETAIL(OFixedText)
152 REPORTCONTROLFORMAT_IMPL(OFixedText,m_aProps.aFormatProperties)
153 // -----------------------------------------------------------------------------
154 uno::Reference< beans::XPropertySetInfo > SAL_CALL OFixedText::getPropertySetInfo(  ) throw(uno::RuntimeException)
155 {
156 	return FixedTextPropertySet::getPropertySetInfo();
157 }
158 // -----------------------------------------------------------------------------
159 void SAL_CALL OFixedText::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
160 {
161 	FixedTextPropertySet::setPropertyValue( aPropertyName, aValue );
162 }
163 // -----------------------------------------------------------------------------
164 uno::Any SAL_CALL OFixedText::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
165 {
166 	return FixedTextPropertySet::getPropertyValue( PropertyName);
167 }
168 // -----------------------------------------------------------------------------
169 void SAL_CALL OFixedText::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
170 {
171 	FixedTextPropertySet::addPropertyChangeListener( aPropertyName, xListener );
172 }
173 // -----------------------------------------------------------------------------
174 void SAL_CALL OFixedText::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
175 {
176 	FixedTextPropertySet::removePropertyChangeListener( aPropertyName, aListener );
177 }
178 // -----------------------------------------------------------------------------
179 void SAL_CALL OFixedText::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
180 {
181 	FixedTextPropertySet::addVetoableChangeListener( PropertyName, aListener );
182 }
183 // -----------------------------------------------------------------------------
184 void SAL_CALL OFixedText::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
185 {
186 	FixedTextPropertySet::removeVetoableChangeListener( PropertyName, aListener );
187 }
188 // -----------------------------------------------------------------------------
189 // XReportControlModel
190 ::rtl::OUString SAL_CALL OFixedText::getDataField() throw ( beans::UnknownPropertyException, uno::RuntimeException)
191 {
192 	throw beans::UnknownPropertyException();
193 }
194 // -----------------------------------------------------------------------------
195 void SAL_CALL OFixedText::setDataField( const ::rtl::OUString& /*_datafield*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
196 {
197 	throw beans::UnknownPropertyException();
198 }
199 // -----------------------------------------------------------------------------
200 
201 // -----------------------------------------------------------------------------
202 ::sal_Bool SAL_CALL OFixedText::getPrintWhenGroupChange() throw (beans::UnknownPropertyException, uno::RuntimeException)
203 {
204 	::osl::MutexGuard aGuard(m_aMutex);
205 	return m_aProps.bPrintWhenGroupChange;
206 }
207 // -----------------------------------------------------------------------------
208 void SAL_CALL OFixedText::setPrintWhenGroupChange( ::sal_Bool _printwhengroupchange ) throw (beans::UnknownPropertyException, uno::RuntimeException)
209 {
210 	set(PROPERTY_PRINTWHENGROUPCHANGE,_printwhengroupchange,m_aProps.bPrintWhenGroupChange);
211 }
212 // -----------------------------------------------------------------------------
213 ::rtl::OUString SAL_CALL OFixedText::getConditionalPrintExpression() throw (beans::UnknownPropertyException, uno::RuntimeException)
214 {
215 	::osl::MutexGuard aGuard(m_aMutex);
216 	return m_aProps.aConditionalPrintExpression;
217 }
218 // -----------------------------------------------------------------------------
219 void SAL_CALL OFixedText::setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (beans::UnknownPropertyException, uno::RuntimeException)
220 {
221 	set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_aProps.aConditionalPrintExpression);
222 }
223 // -----------------------------------------------------------------------------
224 
225 // XCloneable
226 uno::Reference< util::XCloneable > SAL_CALL OFixedText::createClone(  ) throw (uno::RuntimeException)
227 {
228     uno::Reference< report::XReportComponent> xSource = this;
229     uno::Reference< report::XFixedText> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FIXEDTEXT),uno::UNO_QUERY_THROW);
230 	return xSet.get();
231 }
232 // -----------------------------------------------------------------------------
233 
234 // XFixedText
235 ::rtl::OUString SAL_CALL OFixedText::getLabel() throw (uno::RuntimeException)
236 {
237 	::osl::MutexGuard aGuard(m_aMutex);
238 	return m_sLabel;
239 }
240 // -----------------------------------------------------------------------------
241 void SAL_CALL OFixedText::setLabel( const ::rtl::OUString& _label ) throw (uno::RuntimeException)
242 {
243 	set(PROPERTY_LABEL,_label,m_sLabel);
244 }
245 // -----------------------------------------------------------------------------
246 // XChild
247 uno::Reference< uno::XInterface > SAL_CALL OFixedText::getParent(  ) throw (uno::RuntimeException)
248 {
249     return OShapeHelper::getParent(this);
250 }
251 // -----------------------------------------------------------------------------
252 void SAL_CALL OFixedText::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException)
253 {
254 	OShapeHelper::setParent(Parent,this);
255 }
256 // -----------------------------------------------------------------------------
257 uno::Reference< report::XFormatCondition > SAL_CALL OFixedText::createFormatCondition(  ) throw (uno::Exception, uno::RuntimeException)
258 {
259 	return new OFormatCondition(m_aProps.aComponent.m_xContext);
260 }
261 // -----------------------------------------------------------------------------
262 // XContainer
263 void SAL_CALL OFixedText::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException)
264 {
265 	m_aProps.addContainerListener(xListener);
266 }
267 // -----------------------------------------------------------------------------
268 void SAL_CALL OFixedText::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException)
269 {
270 	m_aProps.removeContainerListener(xListener);
271 }
272 // -----------------------------------------------------------------------------
273 // XElementAccess
274 uno::Type SAL_CALL OFixedText::getElementType(  ) throw (uno::RuntimeException)
275 {
276 	return ::getCppuType(static_cast< uno::Reference<report::XFormatCondition>*>(NULL));
277 }
278 // -----------------------------------------------------------------------------
279 ::sal_Bool SAL_CALL OFixedText::hasElements(  ) throw (uno::RuntimeException)
280 {
281 	return m_aProps.hasElements();
282 }
283 // -----------------------------------------------------------------------------
284 // XIndexContainer
285 void SAL_CALL OFixedText::insertByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
286 {
287     m_aProps.insertByIndex(Index,Element);
288 }
289 // -----------------------------------------------------------------------------
290 void SAL_CALL OFixedText::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
291 {
292     m_aProps.removeByIndex(Index);
293 }
294 // -----------------------------------------------------------------------------
295 // XIndexReplace
296 void SAL_CALL OFixedText::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
297 {
298     m_aProps.replaceByIndex(Index,Element);
299 }
300 // -----------------------------------------------------------------------------
301 // XIndexAccess
302 ::sal_Int32 SAL_CALL OFixedText::getCount(  ) throw (uno::RuntimeException)
303 {
304 	return m_aProps.getCount();
305 }
306 // -----------------------------------------------------------------------------
307 uno::Any SAL_CALL OFixedText::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
308 {
309     return m_aProps.getByIndex( Index );
310 }
311 // -----------------------------------------------------------------------------
312 // XShape
313 awt::Point SAL_CALL OFixedText::getPosition(  ) throw (uno::RuntimeException)
314 {
315 	return OShapeHelper::getPosition(this);
316 }
317 // -----------------------------------------------------------------------------
318 void SAL_CALL OFixedText::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException)
319 {
320     OShapeHelper::setPosition(aPosition,this);
321 }
322 // -----------------------------------------------------------------------------
323 awt::Size SAL_CALL OFixedText::getSize(  ) throw (uno::RuntimeException)
324 {
325 	return OShapeHelper::getSize(this);
326 }
327 // -----------------------------------------------------------------------------
328 void SAL_CALL OFixedText::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException)
329 {
330     OShapeHelper::setSize(aSize,this);
331 }
332 // -----------------------------------------------------------------------------
333 
334 // XShapeDescriptor
335 ::rtl::OUString SAL_CALL OFixedText::getShapeType(  ) throw (uno::RuntimeException)
336 {
337 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ControlShape"));
338 }
339 // -----------------------------------------------------------------------------
340 // -----------------------------------------------------------------------------
341 // =============================================================================
342 } // namespace reportdesign
343 // =============================================================================
344 
345