xref: /aoo41x/main/forms/source/component/Grid.cxx (revision cdf0e10c)
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 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_forms.hxx"
30 
31 #include "Columns.hxx"
32 #include "findpos.hxx"
33 #include "Grid.hxx"
34 #include "property.hrc"
35 #include "property.hxx"
36 #include "services.hxx"
37 
38 /** === begin UNO includes === **/
39 #include <com/sun/star/form/FormComponentType.hpp>
40 #include <com/sun/star/form/XForm.hpp>
41 #include <com/sun/star/form/XLoadable.hpp>
42 #include <com/sun/star/text/WritingMode2.hpp>
43 /** === end UNO includes === **/
44 
45 #include <comphelper/basicio.hxx>
46 #include <comphelper/container.hxx>
47 #include <comphelper/extract.hxx>
48 #include <cppuhelper/queryinterface.hxx>
49 #include <toolkit/helper/vclunohelper.hxx>
50 #include <vcl/svapp.hxx>
51 
52 using namespace ::com::sun::star::uno;
53 
54 //.........................................................................
55 namespace frm
56 {
57 //.........................................................................
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::uno;
60 using namespace ::com::sun::star::sdb;
61 using namespace ::com::sun::star::sdbc;
62 using namespace ::com::sun::star::sdbcx;
63 using namespace ::com::sun::star::beans;
64 using namespace ::com::sun::star::container;
65 using namespace ::com::sun::star::form;
66 using namespace ::com::sun::star::awt;
67 using namespace ::com::sun::star::io;
68 using namespace ::com::sun::star::lang;
69 using namespace ::com::sun::star::util;
70 using namespace ::com::sun::star::view;
71 
72 namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
73 
74 const sal_uInt16 ROWHEIGHT			=	0x0001;
75 const sal_uInt16 FONTTYPE			=	0x0002;
76 const sal_uInt16 FONTSIZE			=	0x0004;
77 const sal_uInt16 FONTATTRIBS		=	0x0008;
78 const sal_uInt16 TABSTOP			=	0x0010;
79 const sal_uInt16 TEXTCOLOR			=	0x0020;
80 const sal_uInt16 FONTDESCRIPTOR 	=	0x0040;
81 const sal_uInt16 RECORDMARKER		=	0x0080;
82 const sal_uInt16 BACKGROUNDCOLOR	=	0x0100;
83 
84 //------------------------------------------------------------------
85 InterfaceRef SAL_CALL OGridControlModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
86 {
87 	return *(new OGridControlModel(_rxFactory));
88 }
89 
90 DBG_NAME(OGridControlModel);
91 //------------------------------------------------------------------
92 OGridControlModel::OGridControlModel(const Reference<XMultiServiceFactory>& _rxFactory)
93     :OControlModel(_rxFactory, ::rtl::OUString())
94     ,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<Reference<XPropertySet>*>(NULL)))
95     ,OErrorBroadcaster( OComponentHelper::rBHelper )
96     ,FontControlModel( false )
97     ,m_aSelectListeners(m_aMutex)
98     ,m_aResetListeners(m_aMutex)
99     ,m_aRowSetChangeListeners(m_aMutex)
100     ,m_aDefaultControl( FRM_SUN_CONTROL_GRIDCONTROL )
101     ,m_nBorder(1)
102     ,m_nWritingMode( WritingMode2::CONTEXT )
103     ,m_nContextWritingMode( WritingMode2::CONTEXT )
104     ,m_bEnableVisible(sal_True)
105     ,m_bEnable(sal_True)
106     ,m_bNavigation(sal_True)
107     ,m_bRecordMarker(sal_True)
108     ,m_bPrintable(sal_True)
109     ,m_bAlwaysShowCursor(sal_False)
110     ,m_bDisplaySynchron(sal_True)
111 {
112 	DBG_CTOR(OGridControlModel,NULL);
113 
114 	m_nClassId = FormComponentType::GRIDCONTROL;
115 }
116 
117 //------------------------------------------------------------------
118 OGridControlModel::OGridControlModel( const OGridControlModel* _pOriginal, const Reference< XMultiServiceFactory >& _rxFactory )
119 	:OControlModel( _pOriginal, _rxFactory )
120 	,OInterfaceContainer( _rxFactory, m_aMutex, ::getCppuType( static_cast<Reference<XPropertySet>*>( NULL ) ) )
121 	,OErrorBroadcaster( OComponentHelper::rBHelper )
122     ,FontControlModel( _pOriginal )
123 	,m_aSelectListeners( m_aMutex )
124 	,m_aResetListeners( m_aMutex )
125     ,m_aRowSetChangeListeners( m_aMutex )
126 {
127 	DBG_CTOR(OGridControlModel,NULL);
128 
129 	m_aDefaultControl = _pOriginal->m_aDefaultControl;
130 	m_bEnable = _pOriginal->m_bEnable;
131 	m_bEnableVisible = _pOriginal->m_bEnableVisible;
132 	m_bNavigation = _pOriginal->m_bNavigation;
133 	m_nBorder = _pOriginal->m_nBorder;
134     m_nWritingMode = _pOriginal->m_nWritingMode;
135     m_nContextWritingMode = _pOriginal->m_nContextWritingMode;
136 	m_bRecordMarker = _pOriginal->m_bRecordMarker;
137 	m_bPrintable = _pOriginal->m_bPrintable;
138 	m_bAlwaysShowCursor = _pOriginal->m_bAlwaysShowCursor;
139 	m_bDisplaySynchron = _pOriginal->m_bDisplaySynchron;
140 
141 	// clone the columns
142 	cloneColumns( _pOriginal );
143 
144 	// TODO: clone the events?
145 }
146 
147 //------------------------------------------------------------------
148 OGridControlModel::~OGridControlModel()
149 {
150 	if (!OComponentHelper::rBHelper.bDisposed)
151 	{
152 		acquire();
153 		dispose();
154 	}
155 
156 	DBG_DTOR(OGridControlModel,NULL);
157 }
158 
159 // XCloneable
160 //------------------------------------------------------------------------------
161 Reference< XCloneable > SAL_CALL OGridControlModel::createClone( ) throw (RuntimeException)
162 {
163     OGridControlModel* pClone = new OGridControlModel( this, getContext().getLegacyServiceFactory() );
164     osl_incrementInterlockedCount( &pClone->m_refCount );
165     pClone->OControlModel::clonedFrom( this );
166     // do not call OInterfaceContainer::clonedFrom, it would clone the elements aka columns, which is
167     // already done in the ctor
168     //pClone->OInterfaceContainer::clonedFrom( *this );
169     osl_decrementInterlockedCount( &pClone->m_refCount );
170     return static_cast< XCloneable* >( static_cast< OControlModel* >( pClone ) );
171 }
172 
173 //------------------------------------------------------------------------------
174 void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContainer )
175 {
176 	try
177 	{
178 		Reference< XCloneable > xColCloneable;
179 
180 		const OInterfaceArray::const_iterator pColumnStart = _pOriginalContainer->m_aItems.begin();
181 		const OInterfaceArray::const_iterator pColumnEnd = _pOriginalContainer->m_aItems.end();
182 		for ( OInterfaceArray::const_iterator pColumn = pColumnStart; pColumn != pColumnEnd; ++pColumn )
183 		{
184 			// ask the col for a factory for the clone
185 			xColCloneable = xColCloneable.query( *pColumn );
186 			DBG_ASSERT( xColCloneable.is(), "OGridControlModel::cloneColumns: column is not cloneable!" );
187 
188 			if ( xColCloneable.is() )
189 			{
190 				// create a clone of the column
191 				Reference< XCloneable > xColClone( xColCloneable->createClone() );
192 				DBG_ASSERT( xColClone.is(), "OGridControlModel::cloneColumns: invalid column clone!" );
193 
194 				if ( xColClone.is() )
195 				{
196 					// insert this clone into our own container
197 					insertByIndex( pColumn - pColumnStart, xColClone->queryInterface( m_aElementType ) );
198 				}
199 
200 			}
201 		}
202 	}
203 	catch( const Exception& )
204 	{
205 		DBG_ERROR( "OGridControlModel::cloneColumns: caught an exception while cloning the columns!" );
206 	}
207 }
208 
209 // XServiceInfo
210 //------------------------------------------------------------------------------
211 StringSequence OGridControlModel::getSupportedServiceNames() throw(RuntimeException)
212 {
213 	StringSequence aSupported = OControlModel::getSupportedServiceNames();
214 	aSupported.realloc(aSupported.getLength() + 2);
215 
216 	::rtl::OUString*pArray = aSupported.getArray();
217 	pArray[aSupported.getLength()-2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlModel"));
218 	pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_GRIDCONTROL;
219 	return aSupported;
220 }
221 
222 //------------------------------------------------------------------------------
223 Any SAL_CALL OGridControlModel::queryAggregation( const Type& _rType ) throw (RuntimeException)
224 {
225 	Any aReturn = OGridControlModel_BASE::queryInterface(_rType);
226 
227 	if ( !aReturn.hasValue() )
228 	{
229 		aReturn = OControlModel::queryAggregation( _rType );
230 		if ( !aReturn.hasValue() )
231 		{
232 			aReturn = OInterfaceContainer::queryInterface( _rType );
233 			if ( !aReturn.hasValue() )
234 				aReturn = OErrorBroadcaster::queryInterface( _rType );
235 		}
236 	}
237 	return aReturn;
238 }
239 
240 // XSQLErrorListener
241 //------------------------------------------------------------------------------
242 void SAL_CALL OGridControlModel::errorOccured( const SQLErrorEvent& _rEvent ) throw (RuntimeException)
243 {
244 	// forward the errors which happened to my columns to my own listeners
245 	onError( _rEvent );
246 }
247 
248 // XRowSetSupplier
249 //------------------------------------------------------------------------------
250 Reference< XRowSet > SAL_CALL OGridControlModel::getRowSet(  ) throw (RuntimeException)
251 {
252     return Reference< XRowSet >( getParent(), UNO_QUERY );
253 }
254 
255 //------------------------------------------------------------------------------
256 void SAL_CALL OGridControlModel::setRowSet( const Reference< XRowSet >& /*_rxDataSource*/ ) throw (RuntimeException)
257 {
258     OSL_ENSURE( false, "OGridControlModel::setRowSet: not supported!" );
259 }
260 
261 //--------------------------------------------------------------------
262 void SAL_CALL OGridControlModel::addRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException)
263 {
264     if ( i_Listener.is() )
265         m_aRowSetChangeListeners.addInterface( i_Listener );
266 }
267 
268 //--------------------------------------------------------------------
269 void SAL_CALL OGridControlModel::removeRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException)
270 {
271     m_aRowSetChangeListeners.removeInterface( i_Listener );
272 }
273 
274 // XChild
275 //------------------------------------------------------------------------------
276 void SAL_CALL OGridControlModel::setParent( const InterfaceRef& i_Parent ) throw(NoSupportException, RuntimeException)
277 {
278     ::osl::ClearableMutexGuard aGuard( m_aMutex );
279     if ( i_Parent == getParent() )
280         return;
281 
282     OControlModel::setParent( i_Parent );
283 
284     EventObject aEvent( *this );
285     aGuard.clear();
286     m_aRowSetChangeListeners.notifyEach( &XRowSetChangeListener::onRowSetChanged, aEvent );
287 }
288 
289 //------------------------------------------------------------------------------
290 Sequence< Type > SAL_CALL OGridControlModel::getTypes(	) throw(RuntimeException)
291 {
292 	return concatSequences(
293 		concatSequences(
294 			OControlModel::getTypes(),
295 			OInterfaceContainer::getTypes(),
296 			OErrorBroadcaster::getTypes()
297 		),
298 		OGridControlModel_BASE::getTypes()
299 	);
300 }
301 
302 // OComponentHelper
303 //------------------------------------------------------------------------------
304 void OGridControlModel::disposing()
305 {
306 	OControlModel::disposing();
307 	OErrorBroadcaster::disposing();
308 	OInterfaceContainer::disposing();
309 
310 	setParent(NULL);
311 
312 	EventObject aEvt(static_cast<XWeak*>(this));
313 	m_aSelectListeners.disposeAndClear(aEvt);
314 	m_aResetListeners.disposeAndClear(aEvt);
315     m_aRowSetChangeListeners.disposeAndClear(aEvt);
316 }
317 
318 // XEventListener
319 //------------------------------------------------------------------------------
320 void OGridControlModel::disposing(const EventObject& _rEvent) throw( RuntimeException )
321 {
322 	OControlModel::disposing( _rEvent );
323 	OInterfaceContainer::disposing( _rEvent );
324 }
325 
326 // XSelectionSupplier
327 //-----------------------------------------------------------------------------
328 sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) throw(IllegalArgumentException, RuntimeException)
329 {
330     ::osl::ClearableMutexGuard aGuard( m_aMutex );
331 
332 	Reference<XPropertySet> xSel;
333 	if (rElement.hasValue() && !::cppu::extractInterface(xSel, rElement))
334 	{
335 		throw IllegalArgumentException();
336 	}
337 	InterfaceRef xMe = static_cast<XWeak*>(this);
338 
339 	if (xSel.is())
340 	{
341 		Reference<XChild> xAsChild(xSel, UNO_QUERY);
342 		if (!xAsChild.is() || (xAsChild->getParent() != xMe))
343 		{
344 			throw IllegalArgumentException();
345 		}
346 	}
347 
348 	if ( xSel != m_xSelection )
349     {
350         m_xSelection = xSel;
351         aGuard.clear();
352         m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) );
353         return sal_True;
354     }
355     return sal_False;
356 }
357 
358 //-----------------------------------------------------------------------------
359 Any SAL_CALL OGridControlModel::getSelection() throw(RuntimeException)
360 {
361 	return makeAny(m_xSelection);
362 }
363 
364 //-----------------------------------------------------------------------------
365 void OGridControlModel::addSelectionChangeListener(const Reference< XSelectionChangeListener >& _rxListener) throw( RuntimeException )
366 {
367 	m_aSelectListeners.addInterface(_rxListener);
368 }
369 
370 //-----------------------------------------------------------------------------
371 void OGridControlModel::removeSelectionChangeListener(const Reference< XSelectionChangeListener >& _rxListener) throw( RuntimeException )
372 {
373 	m_aSelectListeners.removeInterface(_rxListener);
374 }
375 
376 // XGridColumnFactory
377 //------------------------------------------------------------------------------
378 Reference<XPropertySet> SAL_CALL OGridControlModel::createColumn(const ::rtl::OUString& ColumnType) throw ( :: com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
379 {
380 	const Sequence< ::rtl::OUString >& rColumnTypes = frm::getColumnTypes();
381 	return createColumn( detail::findPos( ColumnType, rColumnTypes ) );
382 }
383 
384 //------------------------------------------------------------------------------
385 Reference<XPropertySet>  OGridControlModel::createColumn(sal_Int32 nTypeId) const
386 {
387 	Reference<XPropertySet>  xReturn;
388 	switch (nTypeId)
389 	{
390 		case TYPE_CHECKBOX: 		xReturn = new CheckBoxColumn( getContext() ); break;
391 		case TYPE_COMBOBOX: 		xReturn = new ComboBoxColumn( getContext() ); break;
392 		case TYPE_CURRENCYFIELD:	xReturn = new CurrencyFieldColumn( getContext() ); break;
393 		case TYPE_DATEFIELD:		xReturn = new DateFieldColumn( getContext() ); break;
394 		case TYPE_LISTBOX:			xReturn = new ListBoxColumn( getContext() ); break;
395 		case TYPE_NUMERICFIELD: 	xReturn = new NumericFieldColumn( getContext() ); break;
396 		case TYPE_PATTERNFIELD: 	xReturn = new PatternFieldColumn( getContext() ); break;
397 		case TYPE_TEXTFIELD:		xReturn = new TextFieldColumn( getContext() ); break;
398 		case TYPE_TIMEFIELD:		xReturn = new TimeFieldColumn( getContext() ); break;
399 		case TYPE_FORMATTEDFIELD:	xReturn = new FormattedFieldColumn( getContext() ); break;
400 		default:
401 			DBG_ERROR("OGridControlModel::createColumn: Unknown Column");
402 			break;
403 	}
404 	return xReturn;
405 }
406 
407 //------------------------------------------------------------------------------
408 StringSequence SAL_CALL OGridControlModel::getColumnTypes() throw ( ::com::sun::star::uno::RuntimeException)
409 {
410 	return frm::getColumnTypes();
411 }
412 
413 // XReset
414 //-----------------------------------------------------------------------------
415 void SAL_CALL OGridControlModel::reset() throw ( ::com::sun::star::uno::RuntimeException)
416 {
417 	::cppu::OInterfaceIteratorHelper aIter(m_aResetListeners);
418 	EventObject aEvt(static_cast<XWeak*>(this));
419 	sal_Bool bContinue = sal_True;
420 	while (aIter.hasMoreElements() && bContinue)
421 		bContinue =((XResetListener*)aIter.next())->approveReset(aEvt);
422 
423 	if (bContinue)
424 	{
425 		_reset();
426         m_aResetListeners.notifyEach( &XResetListener::resetted, aEvt );
427 	}
428 }
429 
430 //-----------------------------------------------------------------------------
431 void SAL_CALL OGridControlModel::addResetListener(const Reference<XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException)
432 {
433 	m_aResetListeners.addInterface(_rxListener);
434 }
435 
436 //-----------------------------------------------------------------------------
437 void SAL_CALL OGridControlModel::removeResetListener(const Reference<XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException)
438 {
439 	m_aResetListeners.removeInterface(_rxListener);
440 }
441 
442 //-----------------------------------------------------------------------------
443 void OGridControlModel::_reset()
444 {
445 	Reference<XReset> xReset;
446 	sal_Int32 nCount = getCount();
447 	for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++)
448 	{
449 		getByIndex( nIndex ) >>= xReset;
450 		if (xReset.is())
451 			xReset->reset();
452 	}
453 }
454 
455 // XPropertySet
456 //------------------------------------------------------------------------------
457 void OGridControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const
458 {
459 	BEGIN_DESCRIBE_BASE_PROPERTIES( 37 )
460 		DECL_PROP1(NAME,				::rtl::OUString,	BOUND);
461 		DECL_PROP2(CLASSID, 			sal_Int16,			READONLY, TRANSIENT);
462 		DECL_PROP1(TAG, 				::rtl::OUString,	BOUND);
463 		DECL_PROP1(TABINDEX,			sal_Int16,			BOUND);
464 		DECL_PROP3(TABSTOP, 			sal_Bool,			BOUND, MAYBEDEFAULT, MAYBEVOID);
465 		DECL_PROP2(HASNAVIGATION,		sal_Bool,			BOUND, MAYBEDEFAULT);
466 		DECL_PROP1(ENABLED, 			sal_Bool,			BOUND);
467 		DECL_PROP2(ENABLEVISIBLE,		sal_Bool,			BOUND, MAYBEDEFAULT);
468 		DECL_PROP1(BORDER,				sal_Int16,			BOUND);
469 		DECL_PROP2(BORDERCOLOR,	        sal_Int16,			BOUND, MAYBEVOID);
470 		DECL_PROP1(DEFAULTCONTROL,		::rtl::OUString,	BOUND);
471 		DECL_PROP3(TEXTCOLOR,			sal_Int32,			BOUND, MAYBEDEFAULT, MAYBEVOID);
472 		DECL_PROP3(BACKGROUNDCOLOR, 	sal_Int32,			BOUND, MAYBEDEFAULT, MAYBEVOID);
473 		DECL_PROP2(FONT,				FontDescriptor, 	BOUND, MAYBEDEFAULT);
474 		DECL_PROP3(ROWHEIGHT,			sal_Int32,			BOUND, MAYBEDEFAULT, MAYBEVOID);
475 		DECL_PROP1(HELPTEXT,			::rtl::OUString,	BOUND);
476 		DECL_PROP1(FONT_NAME,			::rtl::OUString,	MAYBEDEFAULT);
477 		DECL_PROP1(FONT_STYLENAME,		::rtl::OUString,	MAYBEDEFAULT);
478 		DECL_PROP1(FONT_FAMILY, 		sal_Int16,			MAYBEDEFAULT);
479 		DECL_PROP1(FONT_CHARSET,		sal_Int16,			MAYBEDEFAULT);
480 		DECL_PROP1(FONT_HEIGHT, 		float,				MAYBEDEFAULT);
481 		DECL_PROP1(FONT_WEIGHT, 		float,				MAYBEDEFAULT);
482 		DECL_PROP1(FONT_SLANT,			sal_Int16,			MAYBEDEFAULT);
483 		DECL_PROP1(FONT_UNDERLINE,		sal_Int16,			MAYBEDEFAULT);
484 		DECL_BOOL_PROP1(FONT_WORDLINEMODE,					MAYBEDEFAULT);
485 		DECL_PROP3(TEXTLINECOLOR,		sal_Int32,			BOUND, MAYBEDEFAULT, MAYBEVOID);
486 		DECL_PROP2(FONTEMPHASISMARK,	sal_Int16,			BOUND, MAYBEDEFAULT);
487 		DECL_PROP2(FONTRELIEF,			sal_Int16,			BOUND, MAYBEDEFAULT);
488 		DECL_PROP1(FONT_STRIKEOUT,		sal_Int16,			MAYBEDEFAULT);
489 		DECL_PROP2(RECORDMARKER,		sal_Bool,			BOUND, MAYBEDEFAULT );
490 		DECL_PROP2(PRINTABLE,			sal_Bool,			BOUND, MAYBEDEFAULT );
491 		DECL_PROP4(CURSORCOLOR, 		sal_Int32,			BOUND, MAYBEDEFAULT, MAYBEVOID , TRANSIENT);
492 		DECL_PROP3(ALWAYSSHOWCURSOR,	sal_Bool,			BOUND, MAYBEDEFAULT, TRANSIENT);
493 		DECL_PROP3(DISPLAYSYNCHRON, 	sal_Bool,			BOUND, MAYBEDEFAULT, TRANSIENT);
494 		DECL_PROP2(HELPURL, 			::rtl::OUString,	BOUND, MAYBEDEFAULT);
495         DECL_PROP2(WRITING_MODE,        sal_Int16,          BOUND, MAYBEDEFAULT);
496         DECL_PROP3(CONTEXT_WRITING_MODE,sal_Int16,          BOUND, MAYBEDEFAULT, TRANSIENT);
497     END_DESCRIBE_PROPERTIES();
498 }
499 
500 //------------------------------------------------------------------------------
501 void OGridControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const
502 {
503 	switch (nHandle)
504 	{
505         case PROPERTY_ID_CONTEXT_WRITING_MODE:
506             rValue <<= m_nContextWritingMode;
507             break;
508         case PROPERTY_ID_WRITING_MODE:
509             rValue <<= m_nWritingMode;
510             break;
511 		case PROPERTY_ID_HELPTEXT:
512 			rValue <<= m_sHelpText;
513 			break;
514 		case PROPERTY_ID_HELPURL:
515 			rValue <<= m_sHelpURL;
516 			break;
517 		case PROPERTY_ID_DISPLAYSYNCHRON:
518 			setBOOL(rValue, m_bDisplaySynchron);
519 			break;
520 		case PROPERTY_ID_ALWAYSSHOWCURSOR:
521 			setBOOL(rValue, m_bAlwaysShowCursor);
522 			break;
523 		case PROPERTY_ID_CURSORCOLOR:
524 			rValue = m_aCursorColor;
525 			break;
526 		case PROPERTY_ID_PRINTABLE:
527 			setBOOL(rValue, m_bPrintable);
528 			break;
529 		case PROPERTY_ID_TABSTOP:
530 			rValue = m_aTabStop;
531 			break;
532 		case PROPERTY_ID_HASNAVIGATION:
533 			setBOOL(rValue, m_bNavigation);
534 			break;
535 		case PROPERTY_ID_RECORDMARKER:
536 			setBOOL(rValue, m_bRecordMarker);
537 			break;
538 		case PROPERTY_ID_ENABLED:
539 			setBOOL(rValue, m_bEnable);
540 			break;
541 		case PROPERTY_ID_ENABLEVISIBLE:
542 			setBOOL(rValue, m_bEnableVisible);
543 			break;
544 		case PROPERTY_ID_BORDER:
545 			rValue <<= (sal_Int16)m_nBorder;
546 			break;
547 		case PROPERTY_ID_BORDERCOLOR:
548 			rValue <<= m_aBorderColor;
549 			break;
550 		case PROPERTY_ID_DEFAULTCONTROL:
551 			rValue <<= m_aDefaultControl;
552 			break;
553 		case PROPERTY_ID_BACKGROUNDCOLOR:
554 			rValue = m_aBackgroundColor;
555 			break;
556 		case PROPERTY_ID_ROWHEIGHT:
557 			rValue = m_aRowHeight;
558 			break;
559 
560         default:
561             if ( isFontRelatedProperty( nHandle ) )
562                 FontControlModel::getFastPropertyValue( rValue, nHandle );
563             else
564 			    OControlModel::getFastPropertyValue( rValue, nHandle );
565 	}
566 }
567 
568 //------------------------------------------------------------------------------
569 sal_Bool OGridControlModel::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue,
570 													sal_Int32 nHandle, const Any& rValue )throw( IllegalArgumentException )
571 {
572 	sal_Bool bModified(sal_False);
573 	switch (nHandle)
574 	{
575         case PROPERTY_ID_CONTEXT_WRITING_MODE:
576 			bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_nContextWritingMode );
577             break;
578         case PROPERTY_ID_WRITING_MODE:
579 			bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_nWritingMode );
580             break;
581 		case PROPERTY_ID_HELPTEXT:
582 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sHelpText);
583 			break;
584 		case PROPERTY_ID_HELPURL:
585 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sHelpURL);
586 			break;
587 		case PROPERTY_ID_DISPLAYSYNCHRON:
588 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bDisplaySynchron);
589 			break;
590 		case PROPERTY_ID_ALWAYSSHOWCURSOR:
591 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAlwaysShowCursor);
592 			break;
593 		case PROPERTY_ID_CURSORCOLOR:
594 			if (!rValue.hasValue() || !m_aCursorColor.hasValue())
595 			{
596 				if (rValue.hasValue() && (TypeClass_LONG != rValue.getValueType().getTypeClass()))
597 				{
598 					throw IllegalArgumentException();
599 				}
600 				rOldValue = m_aCursorColor;
601 				rConvertedValue = rValue;
602 				bModified = (rOldValue.getValue() != rConvertedValue.getValue());
603 			}
604 			else
605 				bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, getINT32(m_aCursorColor));
606 			break;
607 		case PROPERTY_ID_PRINTABLE:
608 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bPrintable);
609 			break;
610 		case PROPERTY_ID_TABSTOP:
611 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTabStop, ::getBooleanCppuType());
612 			break;
613 		case PROPERTY_ID_HASNAVIGATION:
614 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bNavigation);
615 			break;
616 		case PROPERTY_ID_RECORDMARKER:
617 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bRecordMarker);
618 			break;
619 		case PROPERTY_ID_ENABLED:
620 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnable);
621 			break;
622 		case PROPERTY_ID_ENABLEVISIBLE:
623 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnableVisible);
624 			break;
625 		case PROPERTY_ID_BORDER:
626 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_nBorder);
627 			break;
628 		case PROPERTY_ID_BORDERCOLOR:
629 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aBorderColor, ::getCppuType((const sal_Int32*)NULL));
630 			break;
631 		case PROPERTY_ID_DEFAULTCONTROL:
632 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefaultControl);
633 			break;
634 		case PROPERTY_ID_BACKGROUNDCOLOR:
635 			bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aBackgroundColor, ::getCppuType((const sal_Int32*)NULL));
636 			break;
637 		case PROPERTY_ID_ROWHEIGHT:
638 			{
639 				bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aRowHeight, ::getCppuType((const sal_Int32*)NULL));
640 
641 				sal_Int32 nNewVal( 0 );
642 				if ( ( rConvertedValue >>= nNewVal ) && ( nNewVal <= 0 ) )
643 				{
644 					rConvertedValue.clear();
645 					bModified = m_aRowHeight.hasValue();
646 				}
647 			}
648 			break;
649 		default:
650             if ( isFontRelatedProperty( nHandle ) )
651                 bModified = FontControlModel::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
652             else
653 			    bModified = OControlModel::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue);
654 	}
655 	return bModified;
656 }
657 
658 //------------------------------------------------------------------------------
659 void OGridControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw ( ::com::sun::star::uno::Exception)
660 {
661 	switch (nHandle)
662 	{
663         case PROPERTY_ID_CONTEXT_WRITING_MODE:
664             rValue >>= m_nContextWritingMode;
665             break;
666         case PROPERTY_ID_WRITING_MODE:
667             rValue >>= m_nWritingMode;
668             break;
669 		case PROPERTY_ID_HELPTEXT:
670 			rValue >>= m_sHelpText;
671 			break;
672 		case PROPERTY_ID_HELPURL:
673 			rValue >>= m_sHelpURL;
674 			break;
675 		case PROPERTY_ID_DISPLAYSYNCHRON:
676 			m_bDisplaySynchron = getBOOL(rValue);
677 			break;
678 		case PROPERTY_ID_ALWAYSSHOWCURSOR:
679 			m_bAlwaysShowCursor = getBOOL(rValue);
680 			break;
681 		case PROPERTY_ID_CURSORCOLOR:
682 			m_aCursorColor = rValue;
683 			break;
684 		case PROPERTY_ID_PRINTABLE:
685 			m_bPrintable = getBOOL(rValue);
686 			break;
687 		case PROPERTY_ID_TABSTOP:
688 			m_aTabStop = rValue;
689 			break;
690 		case PROPERTY_ID_HASNAVIGATION:
691 			m_bNavigation = getBOOL(rValue);
692 			break;
693 		case PROPERTY_ID_ENABLED:
694 			m_bEnable = getBOOL(rValue);
695 			break;
696 		case PROPERTY_ID_ENABLEVISIBLE:
697 			m_bEnableVisible = getBOOL(rValue);
698 			break;
699 		case PROPERTY_ID_RECORDMARKER:
700 			m_bRecordMarker = getBOOL(rValue);
701 			break;
702 		case PROPERTY_ID_BORDER:
703 			rValue >>= m_nBorder;
704 			break;
705 		case PROPERTY_ID_BORDERCOLOR:
706 			m_aBorderColor = rValue;
707 			break;
708 		case PROPERTY_ID_DEFAULTCONTROL:
709 			rValue >>= m_aDefaultControl;
710 			break;
711 		case PROPERTY_ID_BACKGROUNDCOLOR:
712 			m_aBackgroundColor = rValue;
713 			break;
714         case PROPERTY_ID_ROWHEIGHT:
715 			m_aRowHeight = rValue;
716 			break;
717 
718         default:
719             if ( isFontRelatedProperty( nHandle ) )
720             {
721                 FontDescriptor aOldFont( getFont() );
722 
723                 FontControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
724 
725                 if ( isFontAggregateProperty( nHandle ) )
726 	                firePropertyChange( PROPERTY_ID_FONT, makeAny( getFont() ), makeAny( aOldFont ) );
727             }
728             else
729 			    OControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
730 	}
731 
732 }
733 
734 //XPropertyState
735 
736 //------------------------------------------------------------------------------
737 Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
738 {
739 	Any aReturn;
740 	switch (nHandle)
741 	{
742         case PROPERTY_ID_CONTEXT_WRITING_MODE:
743         case PROPERTY_ID_WRITING_MODE:
744             aReturn <<= WritingMode2::CONTEXT;
745             break;
746 
747 		case PROPERTY_ID_DEFAULTCONTROL:
748 			aReturn <<= ::rtl::OUString( STARDIV_ONE_FORM_CONTROL_GRID  );
749 			break;
750 
751 		case PROPERTY_ID_PRINTABLE:
752 		case PROPERTY_ID_HASNAVIGATION:
753 		case PROPERTY_ID_RECORDMARKER:
754 		case PROPERTY_ID_DISPLAYSYNCHRON:
755 		case PROPERTY_ID_ENABLED:
756 		case PROPERTY_ID_ENABLEVISIBLE:
757 			aReturn = makeBoolAny(sal_True);
758 			break;
759 
760 		case PROPERTY_ID_ALWAYSSHOWCURSOR:
761 			aReturn = makeBoolAny(sal_False);
762 			break;
763 
764 		case PROPERTY_ID_HELPURL:
765 		case PROPERTY_ID_HELPTEXT:
766 			aReturn <<= ::rtl::OUString();
767 			break;
768 
769 		case PROPERTY_ID_BORDER:
770 			aReturn <<= (sal_Int16)1;
771 			break;
772 
773 		case PROPERTY_ID_BORDERCOLOR:
774 		case PROPERTY_ID_TABSTOP:
775 		case PROPERTY_ID_BACKGROUNDCOLOR:
776 		case PROPERTY_ID_ROWHEIGHT:
777 		case PROPERTY_ID_CURSORCOLOR:
778 			// void
779 			break;
780 
781 		default:
782             if ( isFontRelatedProperty( nHandle ) )
783                 aReturn = FontControlModel::getPropertyDefaultByHandle( nHandle );
784             else
785 			    aReturn = OControlModel::getPropertyDefaultByHandle(nHandle);
786 	}
787 	return aReturn;
788 }
789 
790 //------------------------------------------------------------------------------
791 OGridColumn* OGridControlModel::getColumnImplementation(const InterfaceRef& _rxIFace) const
792 {
793 	OGridColumn* pImplementation = NULL;
794 	Reference< XUnoTunnel > xUnoTunnel( _rxIFace, UNO_QUERY );
795 	if ( xUnoTunnel.is() )
796 		pImplementation = reinterpret_cast<OGridColumn*>(xUnoTunnel->getSomething(OGridColumn::getUnoTunnelImplementationId()));
797 
798 	return pImplementation;
799 }
800 
801 //------------------------------------------------------------------------------
802 void OGridControlModel::gotColumn( const Reference< XInterface >& _rxColumn )
803 {
804 	Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY );
805 	if ( xBroadcaster.is() )
806 		xBroadcaster->addSQLErrorListener( this );
807 }
808 
809 //------------------------------------------------------------------------------
810 void OGridControlModel::lostColumn(const Reference< XInterface >& _rxColumn)
811 {
812 	if ( m_xSelection == _rxColumn )
813 	{	// the currently selected element was replaced
814 		m_xSelection.clear();
815 		EventObject aEvt( static_cast< XWeak* >( this ) );
816         m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvt );
817 	}
818 
819     Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY );
820 	if ( xBroadcaster.is() )
821 		xBroadcaster->removeSQLErrorListener( this );
822 }
823 
824 //------------------------------------------------------------------------------
825 void OGridControlModel::implRemoved(const InterfaceRef& _rxObject)
826 {
827 	OInterfaceContainer::implRemoved(_rxObject);
828 	lostColumn(_rxObject);
829 }
830 
831 //------------------------------------------------------------------------------
832 void OGridControlModel::implInserted( const ElementDescription* _pElement )
833 {
834 	OInterfaceContainer::implInserted( _pElement );
835 	gotColumn( _pElement->xInterface );
836 }
837 
838 //------------------------------------------------------------------------------
839 void OGridControlModel::impl_replacedElement( const ContainerEvent& _rEvent, ::osl::ClearableMutexGuard& _rInstanceLock )
840 {
841     Reference< XInterface > xOldColumn( _rEvent.ReplacedElement, UNO_QUERY );
842     Reference< XInterface > xNewColumn( _rEvent.Element, UNO_QUERY );
843 
844     bool bNewSelection = ( xOldColumn == m_xSelection );
845 
846     lostColumn( xOldColumn );
847 	gotColumn( xNewColumn );
848 
849     if ( bNewSelection )
850         m_xSelection.set( xNewColumn, UNO_QUERY );
851 
852 	OInterfaceContainer::impl_replacedElement( _rEvent, _rInstanceLock );
853     // <<---- SYNCHRONIZED
854 
855     if ( bNewSelection )
856     {
857         m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) );
858     }
859 }
860 
861 //------------------------------------------------------------------------------
862 ElementDescription* OGridControlModel::createElementMetaData( )
863 {
864 	return new ColumnDescription;
865 }
866 
867 //------------------------------------------------------------------------------
868 void OGridControlModel::approveNewElement( const Reference< XPropertySet >& _rxObject, ElementDescription* _pElement )
869 {
870 	OGridColumn* pCol = getColumnImplementation( _rxObject );
871 	if ( !pCol )
872 		throw IllegalArgumentException();
873 
874 	OInterfaceContainer::approveNewElement( _rxObject, _pElement );
875 
876 	// if we're here, the object passed all tests
877 	if ( _pElement )
878 		static_cast< ColumnDescription* >( _pElement )->pColumn = pCol;
879 }
880 
881 // XPersistObject
882 //------------------------------------------------------------------------------
883 ::rtl::OUString SAL_CALL OGridControlModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
884 {
885 	return FRM_COMPONENT_GRID;	// old (non-sun) name for compatibility !
886 }
887 
888 //------------------------------------------------------------------------------
889 void OGridControlModel::write(const Reference<XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
890 {
891 	OControlModel::write(_rxOutStream);
892 
893 	Reference<XMarkableStream>	xMark(_rxOutStream, UNO_QUERY);
894 
895 	// 1. Version
896 	_rxOutStream->writeShort(0x0008);
897 
898 	// 2. Columns
899 	sal_Int32 nLen = getCount();
900 	_rxOutStream->writeLong(nLen);
901 	OGridColumn* pCol;
902 	for (sal_Int32 i = 0; i < nLen; i++)
903 	{
904 		// zuerst den Servicenamen fuer das darunterliegende Model
905 		pCol = getColumnImplementation(m_aItems[i]);
906 		DBG_ASSERT(pCol != NULL, "OGridControlModel::write : such items should never reach it into my container !");
907 
908 		_rxOutStream << pCol->getModelName();
909 
910 		// dann das Object selbst
911 		sal_Int32 nMark = xMark->createMark();
912 		sal_Int32 nObjLen = 0;
913 		_rxOutStream->writeLong(nObjLen);
914 
915 		// schreiben der Col
916 		pCol->write(_rxOutStream);
917 
918 		// feststellen der Laenge
919 		nObjLen = xMark->offsetToMark(nMark) - 4;
920 		xMark->jumpToMark(nMark);
921 		_rxOutStream->writeLong(nObjLen);
922 		xMark->jumpToFurthest();
923 		xMark->deleteMark(nMark);
924 	}
925 
926 	// 3. Events
927 	writeEvents(_rxOutStream);
928 
929 	// 4. Attribute
930 	// Maskierung fuer alle any Typen
931 	sal_uInt16 nAnyMask = 0;
932 	if (m_aRowHeight.getValueType().getTypeClass() == TypeClass_LONG)
933 		nAnyMask |= ROWHEIGHT;
934 	if ( getFont() != getDefaultFont() )
935 		nAnyMask |= FONTATTRIBS | FONTSIZE | FONTTYPE | FONTDESCRIPTOR;
936 	if (m_aTabStop.getValueType().getTypeClass() == TypeClass_BOOLEAN)
937 		nAnyMask |= TABSTOP;
938 	if ( hasTextColor() )
939 		nAnyMask |= TEXTCOLOR;
940 	if (m_aBackgroundColor.getValueType().getTypeClass() == TypeClass_LONG)
941 		nAnyMask |= BACKGROUNDCOLOR;
942 	if (!m_bRecordMarker)
943 		nAnyMask |= RECORDMARKER;
944 
945 	_rxOutStream->writeShort(nAnyMask);
946 
947 	if (nAnyMask & ROWHEIGHT)
948 		_rxOutStream->writeLong(getINT32(m_aRowHeight));
949 
950 	// old structures
951     const FontDescriptor& aFont = getFont();
952 	if ( nAnyMask & FONTDESCRIPTOR )
953     {
954 		// Attrib
955 		_rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( VCLUnoHelper::ConvertFontWeight( aFont.Weight ) ) );
956 		_rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( aFont.Slant ) );
957 		_rxOutStream->writeShort( aFont.Underline );
958 		_rxOutStream->writeShort( aFont.Strikeout );
959 		_rxOutStream->writeShort( sal_Int16(aFont.Orientation * 10) );
960 		_rxOutStream->writeBoolean( aFont.Kerning );
961 		_rxOutStream->writeBoolean( aFont.WordLineMode );
962 
963 		// Size
964 		_rxOutStream->writeLong( aFont.Width );
965 		_rxOutStream->writeLong( aFont.Height );
966 		_rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( VCLUnoHelper::ConvertFontWidth( aFont.CharacterWidth ) ) );
967 
968 		// Type
969 		_rxOutStream->writeUTF( aFont.Name );
970 		_rxOutStream->writeUTF( aFont.StyleName );
971 		_rxOutStream->writeShort( aFont.Family );
972 		_rxOutStream->writeShort( aFont.CharSet );
973 		_rxOutStream->writeShort( aFont.Pitch );
974     }
975 
976     _rxOutStream << m_aDefaultControl;
977 
978 	_rxOutStream->writeShort(m_nBorder);
979 	_rxOutStream->writeBoolean(m_bEnable);
980 
981 	if (nAnyMask & TABSTOP)
982 		_rxOutStream->writeBoolean(getBOOL(m_aTabStop));
983 
984 	_rxOutStream->writeBoolean(m_bNavigation);
985 
986 	if (nAnyMask & TEXTCOLOR)
987 		_rxOutStream->writeLong( getTextColor() );
988 
989 	// neu ab Version 6
990 	_rxOutStream << m_sHelpText;
991 
992 	if (nAnyMask & FONTDESCRIPTOR)
993 		_rxOutStream << getFont();
994 
995 	if (nAnyMask & RECORDMARKER)
996 		_rxOutStream->writeBoolean(m_bRecordMarker);
997 
998 	// neu ab Version 7
999 	_rxOutStream->writeBoolean(m_bPrintable);
1000 
1001 	// new since 8
1002 	if (nAnyMask & BACKGROUNDCOLOR)
1003 		_rxOutStream->writeLong(getINT32(m_aBackgroundColor));
1004 }
1005 
1006 //------------------------------------------------------------------------------
1007 void OGridControlModel::read(const Reference<XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
1008 {
1009 	OControlModel::read(_rxInStream);
1010 
1011 	Reference<XMarkableStream>	xMark(_rxInStream, UNO_QUERY);
1012 
1013 	// 1. Version
1014 	sal_Int16 nVersion = _rxInStream->readShort();
1015 
1016 	// 2. Einlesen der Spalten
1017 	sal_Int32 nLen = _rxInStream->readLong();
1018 	if (nLen)
1019 	{
1020 		for (sal_Int32 i = 0; i < nLen; i++)
1021 		{
1022 			// Lesen des Modelnamen
1023 
1024 			::rtl::OUString sModelName;
1025 			_rxInStream >> sModelName;
1026 
1027 			Reference<XPropertySet>  xCol(createColumn(getColumnTypeByModelName(sModelName)));
1028 			DBG_ASSERT(xCol.is(), "OGridControlModel::read : unknown column type !");
1029 			sal_Int32 nObjLen = _rxInStream->readLong();
1030 			if (nObjLen)
1031 			{
1032 				sal_Int32 nMark = xMark->createMark();
1033 				if (xCol.is())
1034 				{
1035 					OGridColumn* pCol = getColumnImplementation(xCol);
1036 					pCol->read(_rxInStream);
1037 				}
1038 				xMark->jumpToMark(nMark);
1039 				_rxInStream->skipBytes(nObjLen);
1040 				xMark->deleteMark(nMark);
1041 			}
1042 
1043 			if ( xCol.is() )
1044 				implInsert( i, xCol, sal_False, NULL, sal_False );
1045 		}
1046 	}
1047 
1048 	// In der Basisimplementierung werden die Events nur gelesen, Elemente im Container existieren
1049 	// da aber vor TF_ONE fuer das GridControl immer Events geschrieben wurden, muessen sie auch immer
1050 	// mit gelesen werden
1051 	sal_Int32 nObjLen = _rxInStream->readLong();
1052 	if (nObjLen)
1053 	{
1054 		sal_Int32 nMark = xMark->createMark();
1055 		Reference<XPersistObject>  xObj(m_xEventAttacher, UNO_QUERY);
1056 		if (xObj.is())
1057 			xObj->read(_rxInStream);
1058 		xMark->jumpToMark(nMark);
1059 		_rxInStream->skipBytes(nObjLen);
1060 		xMark->deleteMark(nMark);
1061 	}
1062 
1063 	// Attachement lesen
1064 	for (sal_Int32 i = 0; i < nLen; i++)
1065 	{
1066 		InterfaceRef  xIfc(m_aItems[i], UNO_QUERY);
1067 		Reference<XPropertySet>  xSet(xIfc, UNO_QUERY);
1068 		Any aHelper;
1069 		aHelper <<= xSet;
1070 		m_xEventAttacher->attach( i, xIfc, aHelper );
1071 	}
1072 
1073 	// 4. Einlesen der Attribute
1074 	if (nVersion == 1)
1075 		return;
1076 
1077 	// Maskierung fuer any
1078 	sal_uInt16 nAnyMask = _rxInStream->readShort();
1079 
1080 	if (nAnyMask & ROWHEIGHT)
1081 	{
1082 		sal_Int32 nValue = _rxInStream->readLong();
1083 		m_aRowHeight <<= (sal_Int32)nValue;
1084 	}
1085 
1086     FontDescriptor aFont( getFont() );
1087 	if ( nAnyMask & FONTATTRIBS )
1088 	{
1089 		aFont.Weight = (float)VCLUnoHelper::ConvertFontWeight( _rxInStream->readShort() );
1090 
1091 		aFont.Slant = (FontSlant)_rxInStream->readShort();
1092 		aFont.Underline = _rxInStream->readShort();
1093 		aFont.Strikeout = _rxInStream->readShort();
1094 		aFont.Orientation = ( (float)_rxInStream->readShort() ) / 10;
1095 		aFont.Kerning = _rxInStream->readBoolean();
1096 		aFont.WordLineMode = _rxInStream->readBoolean();
1097 	}
1098 	if ( nAnyMask & FONTSIZE )
1099 	{
1100 		aFont.Width = (sal_Int16)_rxInStream->readLong();
1101 		aFont.Height = (sal_Int16)_rxInStream->readLong();
1102 		aFont.CharacterWidth = (float)VCLUnoHelper::ConvertFontWidth( _rxInStream->readShort() );
1103 	}
1104 	if ( nAnyMask & FONTTYPE )
1105 	{
1106 		aFont.Name = _rxInStream->readUTF();
1107 		aFont.StyleName = _rxInStream->readUTF();
1108 		aFont.Family = _rxInStream->readShort();
1109 		aFont.CharSet = _rxInStream->readShort();
1110 		aFont.Pitch = _rxInStream->readShort();
1111 	}
1112 
1113     if ( nAnyMask & ( FONTATTRIBS | FONTSIZE | FONTTYPE ) )
1114         setFont( aFont );
1115 
1116 	// Name
1117 	_rxInStream >> m_aDefaultControl;
1118 	m_nBorder = _rxInStream->readShort();
1119 	m_bEnable = _rxInStream->readBoolean();
1120 
1121 	if (nAnyMask & TABSTOP)
1122 	{
1123 		m_aTabStop = makeBoolAny(_rxInStream->readBoolean());
1124 	}
1125 
1126 	if (nVersion > 3)
1127 		m_bNavigation = _rxInStream->readBoolean();
1128 
1129 	if (nAnyMask & TEXTCOLOR)
1130 	{
1131 		sal_Int32 nValue = _rxInStream->readLong();
1132         setTextColor( (sal_Int32)nValue );
1133 	}
1134 
1135 	// neu ab Version 6
1136 	if (nVersion > 5)
1137 		_rxInStream >> m_sHelpText;
1138 
1139 	if (nAnyMask & FONTDESCRIPTOR)
1140 	{
1141         FontDescriptor aUNOFont;
1142 		_rxInStream >> aUNOFont;
1143         setFont( aFont );
1144 	}
1145 
1146 	if (nAnyMask & RECORDMARKER)
1147 		m_bRecordMarker = _rxInStream->readBoolean();
1148 
1149 	// neu ab Version 7
1150 	if (nVersion > 6)
1151 		m_bPrintable = _rxInStream->readBoolean();
1152 
1153 	if (nAnyMask & BACKGROUNDCOLOR)
1154 	{
1155 		sal_Int32 nValue = _rxInStream->readLong();
1156 		m_aBackgroundColor <<= (sal_Int32)nValue;
1157 	}
1158 }
1159 
1160 //.........................................................................
1161 }	// namespace frm
1162 //.........................................................................
1163 
1164