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