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