Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "Columns.hxx"
30 : : #include "property.hrc"
31 : : #include "property.hxx"
32 : : #include "componenttools.hxx"
33 : : #include "ids.hxx"
34 : : #include "findpos.hxx"
35 : : #include <com/sun/star/io/XPersistObject.hpp>
36 : : #include <com/sun/star/io/XObjectOutputStream.hpp>
37 : : #include <com/sun/star/io/XObjectInputStream.hpp>
38 : : #include <com/sun/star/io/XMarkableStream.hpp>
39 : : #include <com/sun/star/form/XFormComponent.hpp>
40 : : #include <com/sun/star/lang/XServiceInfo.hpp>
41 : : #include <com/sun/star/form/binding/XBindableValue.hpp>
42 : : #include <com/sun/star/beans/XPropertyContainer.hpp>
43 : : #include <com/sun/star/text/XText.hpp>
44 : : #include <comphelper/sequence.hxx>
45 : : #include <comphelper/property.hxx>
46 : : #include <comphelper/basicio.hxx>
47 : : #include <comphelper/types.hxx>
48 : : #include <comphelper/servicehelper.hxx>
49 : : #include "services.hxx"
50 : : #include "frm_resource.hrc"
51 : : #include <tools/debug.hxx>
52 : : #include <rtl/memory.h>
53 : :
54 : : //.........................................................................
55 : : namespace frm
56 : : {
57 : : //.........................................................................
58 : : using namespace ::com::sun::star::uno;
59 : : using namespace ::com::sun::star::beans;
60 : : using namespace ::com::sun::star::container;
61 : : using namespace ::com::sun::star::form;
62 : : using namespace ::com::sun::star::awt;
63 : : using namespace ::com::sun::star::io;
64 : : using namespace ::com::sun::star::lang;
65 : : using namespace ::com::sun::star::util;
66 : : using namespace ::com::sun::star::text;
67 : : using namespace ::com::sun::star::form::binding;
68 : :
69 : : const sal_uInt16 WIDTH = 0x0001;
70 : : const sal_uInt16 ALIGN = 0x0002;
71 : : const sal_uInt16 OLD_HIDDEN = 0x0004;
72 : : const sal_uInt16 COMPATIBLE_HIDDEN = 0x0008;
73 : :
74 : : //------------------------------------------------------------------------------
75 : 120 : const StringSequence& getColumnTypes()
76 : : {
77 [ + + ][ + - ]: 120 : static StringSequence aColumnTypes(10);
[ + - ][ # # ]
78 [ + + ]: 120 : if (aColumnTypes.getConstArray()[0].isEmpty())
79 : : {
80 : 4 : ::rtl::OUString* pNames = aColumnTypes.getArray();
81 : 4 : pNames[TYPE_CHECKBOX] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CheckBox" ) );
82 : 4 : pNames[TYPE_COMBOBOX] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ComboBox" ) );
83 : 4 : pNames[TYPE_CURRENCYFIELD] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CurrencyField" ) );
84 : 4 : pNames[TYPE_DATEFIELD] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateField" ) );
85 : 4 : pNames[TYPE_FORMATTEDFIELD] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormattedField" ) );
86 : 4 : pNames[TYPE_LISTBOX] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ListBox" ) );
87 : 4 : pNames[TYPE_NUMERICFIELD] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NumericField" ) );
88 : 4 : pNames[TYPE_PATTERNFIELD] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PatternField" ) );
89 : 4 : pNames[TYPE_TEXTFIELD] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextField" ) );
90 : 4 : pNames[TYPE_TIMEFIELD] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TimeField" ) );
91 : : }
92 : 120 : return aColumnTypes;
93 : : }
94 : :
95 : : //------------------------------------------------------------------------------
96 : 4 : sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName)
97 : : {
98 [ + - ]: 4 : const ::rtl::OUString aModelPrefix (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.") );
99 [ + - ]: 4 : const ::rtl::OUString aCompatibleModelPrefix (RTL_CONSTASCII_USTRINGPARAM("stardiv.one.form.component.") );
100 : :
101 : 4 : sal_Int32 nTypeId = -1;
102 [ + - ][ - + ]: 4 : if (aModelName == FRM_COMPONENT_EDIT)
103 : 0 : nTypeId = TYPE_TEXTFIELD;
104 : : else
105 : : {
106 : 4 : sal_Int32 nPrefixPos = aModelName.indexOf(aModelPrefix);
107 : : #ifdef DBG_UTIL
108 : : sal_Int32 nCompatiblePrefixPos = aModelName.indexOf(aCompatibleModelPrefix);
109 : : #endif
110 : : DBG_ASSERT( (nPrefixPos != -1) || (nCompatiblePrefixPos != -1),
111 : : "::getColumnTypeByModelName() : wrong servivce !");
112 : :
113 : : ::rtl::OUString aColumnType = (nPrefixPos != -1)
114 : : ? aModelName.copy(aModelPrefix.getLength())
115 [ + - ]: 4 : : aModelName.copy(aCompatibleModelPrefix.getLength());
116 : :
117 [ + - ]: 4 : const StringSequence& rColumnTypes = getColumnTypes();
118 [ + - ]: 4 : nTypeId = ::detail::findPos(aColumnType, rColumnTypes);
119 : : }
120 : 4 : return nTypeId;
121 : : }
122 : :
123 : : /*************************************************************************/
124 : :
125 : : namespace
126 : : {
127 : : class theOGridColumnImplementationId : public rtl::Static< UnoTunnelIdInit, theOGridColumnImplementationId > {};
128 : : }
129 : :
130 : 236 : const Sequence<sal_Int8>& OGridColumn::getUnoTunnelImplementationId()
131 : : {
132 : 236 : return theOGridColumnImplementationId::get().getSeq();
133 : : }
134 : :
135 : : //------------------------------------------------------------------
136 : 118 : sal_Int64 SAL_CALL OGridColumn::getSomething( const Sequence<sal_Int8>& _rIdentifier) throw(RuntimeException)
137 : : {
138 : 118 : sal_Int64 nReturn(0);
139 : :
140 [ + - + - ]: 236 : if ( (_rIdentifier.getLength() == 16)
[ + - ]
141 : 118 : && (0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ))
142 : : )
143 : : {
144 : 118 : nReturn = reinterpret_cast<sal_Int64>(this);
145 : : }
146 : : else
147 : : {
148 : 0 : Reference< XUnoTunnel > xAggTunnel;
149 [ # # ][ # # ]: 0 : if ( query_aggregation( m_xAggregate, xAggTunnel ) )
150 [ # # ][ # # ]: 0 : return xAggTunnel->getSomething( _rIdentifier );
[ # # ]
151 : : }
152 : 118 : return nReturn;
153 : : }
154 : :
155 : : //------------------------------------------------------------------
156 : 0 : Sequence<sal_Int8> SAL_CALL OGridColumn::getImplementationId() throw(RuntimeException)
157 : : {
158 [ # # ]: 0 : return OImplementationIds::getImplementationId(getTypes());
159 : : }
160 : :
161 : : //------------------------------------------------------------------
162 : 0 : Sequence<Type> SAL_CALL OGridColumn::getTypes() throw(RuntimeException)
163 : : {
164 [ # # ][ # # ]: 0 : TypeBag aTypes( OGridColumn_BASE::getTypes() );
[ # # ]
165 : : // erase the types which we do not support
166 [ # # ][ # # ]: 0 : aTypes.removeType( XFormComponent::static_type() );
167 [ # # ][ # # ]: 0 : aTypes.removeType( XServiceInfo::static_type() );
168 [ # # ][ # # ]: 0 : aTypes.removeType( XBindableValue::static_type() );
169 [ # # ][ # # ]: 0 : aTypes.removeType( XPropertyContainer::static_type() );
170 : :
171 : : // but re-add their base class(es)
172 [ # # ][ # # ]: 0 : aTypes.addType( XChild::static_type() );
173 : :
174 : 0 : Reference< XTypeProvider > xProv;
175 [ # # ][ # # ]: 0 : if ( query_aggregation( m_xAggregate, xProv ))
176 [ # # ][ # # ]: 0 : aTypes.addTypes( xProv->getTypes() );
[ # # ][ # # ]
177 : :
178 [ # # ][ # # ]: 0 : aTypes.removeType( XTextRange::static_type() );
179 [ # # ][ # # ]: 0 : aTypes.removeType( XSimpleText::static_type() );
180 [ # # ][ # # ]: 0 : aTypes.removeType( XText::static_type() );
181 : :
182 [ # # ]: 0 : return aTypes.getTypes();
183 : : }
184 : :
185 : : //------------------------------------------------------------------
186 : 10282 : Any SAL_CALL OGridColumn::queryAggregation( const Type& _rType ) throw (RuntimeException)
187 : : {
188 : 10282 : Any aReturn;
189 : : // some functionality at our aggregate cannot be reasonably fullfilled here.
190 [ + - + - : 51410 : if ( _rType.equals(::getCppuType(static_cast< Reference< XFormComponent >* >(NULL)))
+ - + - ]
[ - + ][ - + ]
[ + - ]
191 [ + - ]: 10282 : || _rType.equals(::getCppuType(static_cast< Reference< XServiceInfo >* >(NULL)))
192 [ + - ]: 10282 : || _rType.equals(::getCppuType(static_cast< Reference< XBindableValue >* >(NULL)))
193 [ + - ]: 10282 : || _rType.equals(::getCppuType(static_cast< Reference< XPropertyContainer >* >(NULL)))
194 [ + - ][ + - ]: 10282 : || comphelper::isAssignableFrom(::getCppuType(static_cast< Reference< XTextRange >* >(NULL)),_rType)
195 : : )
196 : 0 : return aReturn;
197 : :
198 [ + - ]: 10282 : aReturn = OGridColumn_BASE::queryAggregation(_rType);
199 [ + + ]: 10282 : if (!aReturn.hasValue())
200 : : {
201 [ + - ]: 5554 : aReturn = OPropertySetAggregationHelper::queryInterface(_rType);
202 [ + - ][ + + ]: 5554 : if (!aReturn.hasValue() && m_xAggregate.is())
[ + + ]
203 [ + - ][ + - ]: 1376 : aReturn = m_xAggregate->queryAggregation(_rType);
204 : : }
205 : :
206 : 10282 : return aReturn;
207 : : }
208 : :
209 : : DBG_NAME(OGridColumn);
210 : : //------------------------------------------------------------------------------
211 : 118 : OGridColumn::OGridColumn( const comphelper::ComponentContext& _rContext, const ::rtl::OUString& _sModelName )
212 : : :OGridColumn_BASE(m_aMutex)
213 : : ,OPropertySetAggregationHelper(OGridColumn_BASE::rBHelper)
214 : : ,m_aHidden( makeAny( sal_False ) )
215 : : ,m_aContext( _rContext )
216 [ + - ][ + - ]: 118 : ,m_aModelName(_sModelName)
[ + - ][ + - ]
217 : : {
218 : : DBG_CTOR(OGridColumn,NULL);
219 : :
220 : : // Create the UnoControlModel
221 [ + - ]: 118 : if ( !m_aModelName.isEmpty() ) // is there a to-be-aggregated model?
222 : : {
223 [ + - ]: 118 : increment( m_refCount );
224 : :
225 : : {
226 [ + - ][ + - ]: 118 : m_xAggregate.set( m_aContext.createComponent( m_aModelName ), UNO_QUERY );
227 [ + - ]: 118 : setAggregation( m_xAggregate );
228 : : }
229 : :
230 [ + - ]: 118 : if ( m_xAggregate.is() )
231 : : { // don't omit those brackets - they ensure that the following temporary is properly deleted
232 [ + - ][ + - ]: 118 : m_xAggregate->setDelegator( static_cast< ::cppu::OWeakObject* >( this ) );
[ + - ]
233 : : }
234 : :
235 : : // Set refcount back to zero
236 [ + - ]: 118 : decrement( m_refCount );
237 : : }
238 : 118 : }
239 : :
240 : : //------------------------------------------------------------------------------
241 : 4 : OGridColumn::OGridColumn( const OGridColumn* _pOriginal )
242 : : :OGridColumn_BASE( m_aMutex )
243 : : ,OPropertySetAggregationHelper( OGridColumn_BASE::rBHelper )
244 [ + - ][ + - ]: 4 : ,m_aContext( _pOriginal->m_aContext )
[ + - ]
245 : : {
246 : : DBG_CTOR(OGridColumn,NULL);
247 : :
248 : 4 : m_aWidth = _pOriginal->m_aWidth;
249 : 4 : m_aAlign = _pOriginal->m_aAlign;
250 : 4 : m_aHidden = _pOriginal->m_aHidden;
251 : 4 : m_aModelName = _pOriginal->m_aModelName;
252 : 4 : m_aLabel = _pOriginal->m_aLabel;
253 : :
254 [ + - ]: 4 : increment( m_refCount );
255 : : {
256 : : {
257 [ + - ][ + - ]: 4 : m_xAggregate = createAggregateClone( _pOriginal );
[ + - ]
258 [ + - ]: 4 : setAggregation( m_xAggregate );
259 : : }
260 : :
261 [ + - ]: 4 : if ( m_xAggregate.is() )
262 : : { // don't omit this brackets - they ensure that the following temporary is properly deleted
263 [ + - ][ + - ]: 4 : m_xAggregate->setDelegator( static_cast< ::cppu::OWeakObject* >( this ) );
[ + - ]
264 : : }
265 : : }
266 [ + - ]: 4 : decrement( m_refCount );
267 : 4 : }
268 : :
269 : : //------------------------------------------------------------------------------
270 [ + - ][ + - ]: 104 : OGridColumn::~OGridColumn()
[ + - ][ + - ]
271 : : {
272 [ - + ]: 104 : if (!OGridColumn_BASE::rBHelper.bDisposed)
273 : : {
274 : 0 : acquire();
275 [ # # ]: 0 : dispose();
276 : : }
277 : :
278 : : // Free the aggregate
279 [ + - ]: 104 : if (m_xAggregate.is())
280 : : {
281 : 104 : InterfaceRef xIface;
282 [ + - ][ + - ]: 104 : m_xAggregate->setDelegator(xIface);
283 : : }
284 : :
285 : : DBG_DTOR(OGridColumn,NULL);
286 [ - + ]: 104 : }
287 : :
288 : : // XEventListener
289 : : //------------------------------------------------------------------------------
290 : 288 : void SAL_CALL OGridColumn::disposing(const EventObject& _rSource) throw(RuntimeException)
291 : : {
292 [ + - ]: 288 : OPropertySetAggregationHelper::disposing(_rSource);
293 : :
294 : 288 : Reference<XEventListener> xEvtLstner;
295 [ + - ][ + - ]: 288 : if (query_aggregation(m_xAggregate, xEvtLstner))
296 [ + - ][ + - ]: 288 : xEvtLstner->disposing(_rSource);
297 : 288 : }
298 : :
299 : : // OGridColumn_BASE
300 : : //-----------------------------------------------------------------------------
301 : 104 : void OGridColumn::disposing()
302 : : {
303 [ + - ]: 104 : OGridColumn_BASE::disposing();
304 [ + - ]: 104 : OPropertySetAggregationHelper::disposing();
305 : :
306 : 104 : Reference<XComponent> xComp;
307 [ + - ][ + - ]: 104 : if (query_aggregation(m_xAggregate, xComp))
308 [ + - ][ + - ]: 104 : xComp->dispose();
309 : 104 : }
310 : :
311 : : //------------------------------------------------------------------------------
312 : 8 : void OGridColumn::clearAggregateProperties( Sequence< Property >& _rProps, sal_Bool bAllowDropDown )
313 : : {
314 : : // some properties are not to be exposed to the outer world
315 [ + - ]: 8 : ::std::set< ::rtl::OUString > aForbiddenProperties;
316 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_ALIGN );
317 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_AUTOCOMPLETE );
318 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_BACKGROUNDCOLOR );
319 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_BORDER );
320 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_BORDERCOLOR );
321 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_ECHO_CHAR );
322 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FILLCOLOR );
323 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT );
324 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT_NAME );
325 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT_STYLENAME );
326 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT_FAMILY );
327 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT_CHARSET );
328 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT_HEIGHT );
329 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT_WEIGHT );
330 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT_SLANT );
331 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT_UNDERLINE );
332 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT_STRIKEOUT );
333 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONT_WORDLINEMODE );
334 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_TEXTLINECOLOR );
335 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONTEMPHASISMARK );
336 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_FONTRELIEF );
337 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_HARDLINEBREAKS );
338 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_HSCROLL );
339 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_LABEL );
340 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_LINECOLOR );
341 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_MULTISELECTION );
342 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_PRINTABLE );
343 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_TABINDEX );
344 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_TABSTOP );
345 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_TEXTCOLOR );
346 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_VSCROLL );
347 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_CONTROLLABEL );
348 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_RICH_TEXT );
349 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_VERTICAL_ALIGN );
350 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_IMAGE_URL );
351 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( PROPERTY_IMAGE_POSITION );
352 [ + - ][ + - ]: 8 : aForbiddenProperties.insert( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableVisible" ) ) );
353 [ + + ]: 8 : if ( !bAllowDropDown )
354 [ + - ][ + - ]: 6 : aForbiddenProperties.insert( PROPERTY_DROPDOWN );
355 : :
356 [ + - ]: 8 : Sequence< Property > aNewProps( _rProps.getLength() );
357 [ + - ]: 8 : Property* pNewProps = aNewProps.getArray();
358 : :
359 : 8 : const Property* pProps = _rProps.getConstArray();
360 : 8 : const Property* pPropsEnd = pProps + _rProps.getLength();
361 [ + + ]: 756 : for ( ; pProps != pPropsEnd; ++pProps )
362 : : {
363 [ + - ][ + + ]: 748 : if ( aForbiddenProperties.find( pProps->Name ) == aForbiddenProperties.end() )
364 : 528 : *pNewProps++ = *pProps;
365 : : }
366 : :
367 [ + - ][ + - ]: 8 : aNewProps.realloc( pNewProps - aNewProps.getArray() );
368 [ + - ][ + - ]: 8 : _rProps = aNewProps;
369 : 8 : }
370 : :
371 : : //------------------------------------------------------------------------------
372 : 8 : void OGridColumn::setOwnProperties(Sequence<Property>& aDescriptor)
373 : : {
374 : 8 : aDescriptor.realloc(5);
375 : 8 : Property* pProperties = aDescriptor.getArray();
376 [ + - ]: 8 : DECL_PROP1(LABEL, ::rtl::OUString, BOUND);
377 [ + - ][ + - ]: 8 : DECL_PROP3(WIDTH, sal_Int32, BOUND, MAYBEVOID, MAYBEDEFAULT);
378 [ + - ][ + - ]: 8 : DECL_PROP3(ALIGN, sal_Int16, BOUND, MAYBEVOID, MAYBEDEFAULT);
379 [ + - ][ + - ]: 8 : DECL_BOOL_PROP2(HIDDEN, BOUND, MAYBEDEFAULT);
380 [ + - ]: 8 : DECL_PROP1(COLUMNSERVICENAME, ::rtl::OUString, READONLY);
381 : 8 : }
382 : :
383 : : // Reference<XPropertySet>
384 : : //------------------------------------------------------------------------------
385 : 526 : void OGridColumn::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const
386 : : {
387 [ + + + + : 526 : switch (nHandle)
+ - ]
388 : : {
389 : : case PROPERTY_ID_COLUMNSERVICENAME:
390 : 62 : rValue <<= m_aModelName;
391 : 62 : break;
392 : : case PROPERTY_ID_LABEL:
393 : 138 : rValue <<= m_aLabel;
394 : 138 : break;
395 : : case PROPERTY_ID_WIDTH:
396 : 138 : rValue = m_aWidth;
397 : 138 : break;
398 : : case PROPERTY_ID_ALIGN:
399 : 62 : rValue = m_aAlign;
400 : 62 : break;
401 : : case PROPERTY_ID_HIDDEN:
402 : 126 : rValue = m_aHidden;
403 : 126 : break;
404 : : default:
405 : 0 : OPropertySetAggregationHelper::getFastPropertyValue(rValue, nHandle);
406 : : }
407 : 526 : }
408 : :
409 : : //------------------------------------------------------------------------------
410 : 248 : sal_Bool OGridColumn::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue,
411 : : sal_Int32 nHandle, const Any& rValue )throw( IllegalArgumentException )
412 : : {
413 : 248 : sal_Bool bModified(sal_False);
414 [ + + + + : 248 : switch (nHandle)
- ]
415 : : {
416 : : case PROPERTY_ID_LABEL:
417 : 62 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aLabel);
418 : 62 : break;
419 : : case PROPERTY_ID_WIDTH:
420 : 62 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aWidth, ::getCppuType((const sal_Int32*)NULL));
421 : 62 : break;
422 : : case PROPERTY_ID_ALIGN:
423 : 62 : bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aAlign, ::getCppuType( (const sal_Int32*)NULL ) );
424 : : // strange enough, css.awt.TextAlign is a 32-bit integer, while the Align property (both here for grid controls
425 : : // and for ordinary toolkit controls) is a 16-bit integer. So, allow for 32 bit, but normalize it to 16 bit
426 [ + - ]: 62 : if ( bModified )
427 : : {
428 : 62 : sal_Int32 nAlign( 0 );
429 [ + - ]: 62 : if ( rConvertedValue >>= nAlign )
430 [ + - ]: 62 : rConvertedValue <<= (sal_Int16)nAlign;
431 : : }
432 : 62 : break;
433 : : case PROPERTY_ID_HIDDEN:
434 : 62 : bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, getBOOL(m_aHidden));
435 : 62 : break;
436 : : }
437 : 248 : return bModified;
438 : : }
439 : :
440 : : //------------------------------------------------------------------------------
441 : 144 : void OGridColumn::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (::com::sun::star::uno::Exception)
442 : : {
443 [ + + + - : 144 : switch (nHandle)
- ]
444 : : {
445 : : case PROPERTY_ID_LABEL:
446 : : DBG_ASSERT(rValue.getValueType().getTypeClass() == TypeClass_STRING, "invalid type" );
447 : 62 : rValue >>= m_aLabel;
448 : 62 : break;
449 : : case PROPERTY_ID_WIDTH:
450 : 20 : m_aWidth = rValue;
451 : 20 : break;
452 : : case PROPERTY_ID_ALIGN:
453 : 62 : m_aAlign = rValue;
454 : 62 : break;
455 : : case PROPERTY_ID_HIDDEN:
456 : 0 : m_aHidden = rValue;
457 : 0 : break;
458 : : }
459 : 144 : }
460 : :
461 : :
462 : : // XPropertyState
463 : : //------------------------------------------------------------------------------
464 : 0 : Any OGridColumn::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
465 : : {
466 [ # # # ]: 0 : switch (nHandle)
467 : : {
468 : : case PROPERTY_ID_WIDTH:
469 : : case PROPERTY_ID_ALIGN:
470 : 0 : return Any();
471 : : case PROPERTY_ID_HIDDEN:
472 [ # # ]: 0 : return makeAny((sal_Bool)sal_False);
473 : : default:
474 : 0 : return OPropertySetAggregationHelper::getPropertyDefaultByHandle(nHandle);
475 : : }
476 : : }
477 : :
478 : : // XCloneable
479 : : //------------------------------------------------------------------------------
480 : 4 : Reference< XCloneable > SAL_CALL OGridColumn::createClone( ) throw (RuntimeException)
481 : : {
482 : 4 : OGridColumn* pNewColumn = createCloneColumn();
483 [ + - ]: 4 : return pNewColumn;
484 : : }
485 : :
486 : : // XPersistObject
487 : : //------------------------------------------------------------------------------
488 : 4 : void SAL_CALL OGridColumn::write(const Reference<XObjectOutputStream>& _rxOutStream)
489 : : {
490 : : // 1. Write the UnoControl
491 [ + - ]: 4 : Reference<XMarkableStream> xMark(_rxOutStream, UNO_QUERY);
492 [ + - ][ + - ]: 4 : sal_Int32 nMark = xMark->createMark();
493 : :
494 : 4 : sal_Int32 nLen = 0;
495 [ + - ][ + - ]: 4 : _rxOutStream->writeLong(nLen);
496 : :
497 : 4 : Reference<XPersistObject> xPersist;
498 [ + - ][ + - ]: 4 : if (query_aggregation(m_xAggregate, xPersist))
499 [ + - ][ + - ]: 4 : xPersist->write(_rxOutStream);
500 : :
501 : : // Calculate the length
502 [ + - ][ + - ]: 4 : nLen = xMark->offsetToMark(nMark) - 4;
503 [ + - ][ + - ]: 4 : xMark->jumpToMark(nMark);
504 [ + - ][ + - ]: 4 : _rxOutStream->writeLong(nLen);
505 [ + - ][ + - ]: 4 : xMark->jumpToFurthest();
506 [ + - ][ + - ]: 4 : xMark->deleteMark(nMark);
507 : :
508 : : // 2. Write a version number
509 [ + - ][ + - ]: 4 : _rxOutStream->writeShort(0x0002);
510 : :
511 : 4 : sal_uInt16 nAnyMask = 0;
512 [ - + ]: 4 : if (m_aWidth.getValueType().getTypeClass() == TypeClass_LONG)
513 : 0 : nAnyMask |= WIDTH;
514 : :
515 [ - + ]: 4 : if (m_aAlign.getValueTypeClass() == TypeClass_SHORT)
516 : 0 : nAnyMask |= ALIGN;
517 : :
518 : 4 : nAnyMask |= COMPATIBLE_HIDDEN;
519 : :
520 [ + - ][ + - ]: 4 : _rxOutStream->writeShort(nAnyMask);
521 : :
522 [ - + ]: 4 : if (nAnyMask & WIDTH)
523 [ # # ][ # # ]: 0 : _rxOutStream->writeLong(getINT32(m_aWidth));
[ # # ]
524 [ - + ]: 4 : if (nAnyMask & ALIGN)
525 [ # # ][ # # ]: 0 : _rxOutStream->writeShort(getINT16(m_aAlign));
[ # # ]
526 : :
527 : : // Name
528 [ + - ]: 4 : _rxOutStream << m_aLabel;
529 : :
530 : : // the new place for the hidden flag : after m_aLabel, so older office version read the correct label, too
531 [ + - ]: 4 : if (nAnyMask & COMPATIBLE_HIDDEN)
532 [ + - ][ + - ]: 4 : _rxOutStream->writeBoolean(getBOOL(m_aHidden));
[ + - ]
533 : 4 : }
534 : :
535 : : //------------------------------------------------------------------------------
536 : 4 : void SAL_CALL OGridColumn::read(const Reference<XObjectInputStream>& _rxInStream)
537 : : {
538 : : // 1. Read the UnoControl
539 : 4 : sal_Int32 nLen = _rxInStream->readLong();
540 [ + - ]: 4 : if (nLen)
541 : : {
542 [ + - ]: 4 : Reference<XMarkableStream> xMark(_rxInStream, UNO_QUERY);
543 [ + - ][ + - ]: 4 : sal_Int32 nMark = xMark->createMark();
544 : 4 : Reference<XPersistObject> xPersist;
545 [ + - ][ + - ]: 4 : if (query_aggregation(m_xAggregate, xPersist))
546 [ + - ][ + - ]: 4 : xPersist->read(_rxInStream);
547 : :
548 [ + - ][ + - ]: 4 : xMark->jumpToMark(nMark);
549 [ + - ][ + - ]: 4 : _rxInStream->skipBytes(nLen);
550 [ + - ][ + - ]: 4 : xMark->deleteMark(nMark);
551 : : }
552 : :
553 : : // 2. Write a version number
554 : 4 : sal_uInt16 nVersion = _rxInStream->readShort(); (void)nVersion;
555 : 4 : sal_uInt16 nAnyMask = _rxInStream->readShort();
556 : :
557 [ - + ]: 4 : if (nAnyMask & WIDTH)
558 : : {
559 : 0 : sal_Int32 nValue = _rxInStream->readLong();
560 [ # # ]: 0 : m_aWidth <<= (sal_Int32)nValue;
561 : : }
562 : :
563 [ - + ]: 4 : if (nAnyMask & ALIGN)
564 : : {
565 [ # # ][ # # ]: 0 : sal_Int16 nValue = _rxInStream->readShort();
566 [ # # ]: 0 : m_aAlign <<= nValue;
567 : : }
568 [ - + ]: 4 : if (nAnyMask & OLD_HIDDEN)
569 : : {
570 : 0 : sal_Bool bValue = _rxInStream->readBoolean();
571 [ # # ]: 0 : m_aHidden <<= (sal_Bool)bValue;
572 : : }
573 : :
574 : : // Name
575 : 4 : _rxInStream >> m_aLabel;
576 : :
577 [ + - ]: 4 : if (nAnyMask & COMPATIBLE_HIDDEN)
578 : : {
579 : 4 : sal_Bool bValue = _rxInStream->readBoolean();
580 [ + - ]: 4 : m_aHidden <<= (sal_Bool)bValue;
581 : : }
582 : 4 : }
583 : :
584 : : //------------------------------------------------------------------------------
585 [ + - ][ + - ]: 5626 : IMPL_COLUMN(TextFieldColumn, FRM_SUN_COMPONENT_TEXTFIELD, sal_False);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
586 [ # # ][ # # ]: 0 : IMPL_COLUMN(PatternFieldColumn, FRM_SUN_COMPONENT_PATTERNFIELD, sal_False);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
587 [ + - ][ + - ]: 644 : IMPL_COLUMN(DateFieldColumn, FRM_SUN_COMPONENT_DATEFIELD, sal_True);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
588 [ # # ][ # # ]: 0 : IMPL_COLUMN(TimeFieldColumn, FRM_SUN_COMPONENT_TIMEFIELD, sal_False);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
589 [ # # ][ # # ]: 0 : IMPL_COLUMN(NumericFieldColumn, FRM_SUN_COMPONENT_NUMERICFIELD, sal_False);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
590 [ # # ][ # # ]: 0 : IMPL_COLUMN(CurrencyFieldColumn, FRM_SUN_COMPONENT_CURRENCYFIELD, sal_False);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
591 [ # # ][ # # ]: 0 : IMPL_COLUMN(CheckBoxColumn, FRM_SUN_COMPONENT_CHECKBOX, sal_False);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
592 [ # # ][ # # ]: 0 : IMPL_COLUMN(ComboBoxColumn, FRM_SUN_COMPONENT_COMBOBOX, sal_False);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
593 [ # # ][ # # ]: 0 : IMPL_COLUMN(ListBoxColumn, FRM_SUN_COMPONENT_LISTBOX, sal_False);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
594 [ # # ][ + - ]: 4414 : IMPL_COLUMN(FormattedFieldColumn, FRM_SUN_COMPONENT_FORMATTEDFIELD, sal_False);
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ][ + - ]
[ + - ]
595 : :
596 : : //.........................................................................
597 : : } // namespace frm
598 : : //.........................................................................
599 : :
600 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|