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