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