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