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