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