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 "ListBox.hxx"
31 : : #include "property.hxx"
32 : : #include "property.hrc"
33 : : #include "services.hxx"
34 : : #include "frm_resource.hxx"
35 : : #include "frm_resource.hrc"
36 : : #include "BaseListBox.hxx"
37 : : #include "listenercontainers.hxx"
38 : : #include "componenttools.hxx"
39 : :
40 : : #include <com/sun/star/util/XNumberFormatTypes.hpp>
41 : : #include <com/sun/star/sdbc/XRowSet.hpp>
42 : : #include <com/sun/star/container/XIndexAccess.hpp>
43 : : #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
44 : : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
45 : : #include <com/sun/star/util/NumberFormat.hpp>
46 : : #include <com/sun/star/awt/XWindow.hpp>
47 : : #include <com/sun/star/sdbc/XConnection.hpp>
48 : : #include <com/sun/star/sdb/CommandType.hpp>
49 : :
50 : : #include <comphelper/basicio.hxx>
51 : : #include <comphelper/container.hxx>
52 : : #include <comphelper/numbers.hxx>
53 : : #include <comphelper/listenernotification.hxx>
54 : : #include <connectivity/dbtools.hxx>
55 : : #include <connectivity/formattedcolumnvalue.hxx>
56 : : #include <connectivity/dbconversion.hxx>
57 : : #include <cppuhelper/queryinterface.hxx>
58 : : #include <rtl/logfile.hxx>
59 : : #include <tools/debug.hxx>
60 : : #include <tools/diagnose_ex.h>
61 : : #include <unotools/sharedunocomponent.hxx>
62 : : #include <vcl/svapp.hxx>
63 : :
64 : : #include <boost/optional.hpp>
65 : :
66 : : #include <algorithm>
67 : : #include <functional>
68 : :
69 : :
70 : : //.........................................................................
71 : : namespace frm
72 : : {
73 : : using namespace ::com::sun::star::uno;
74 : : using namespace ::com::sun::star::sdb;
75 : : using namespace ::com::sun::star::sdbc;
76 : : using namespace ::com::sun::star::sdbcx;
77 : : using namespace ::com::sun::star::beans;
78 : : using namespace ::com::sun::star::container;
79 : : using namespace ::com::sun::star::form;
80 : : using namespace ::com::sun::star::awt;
81 : : using namespace ::com::sun::star::io;
82 : : using namespace ::com::sun::star::lang;
83 : : using namespace ::com::sun::star::util;
84 : : using namespace ::com::sun::star::form::binding;
85 : : using namespace ::dbtools;
86 : :
87 : : using ::connectivity::ORowSetValue;
88 : :
89 : : //==============================================================================
90 : : //= helper
91 : : //==============================================================================
92 : : namespace
93 : : {
94 : : //--------------------------------------------------------------------------
95 : : struct RowSetValueToString : public ::std::unary_function< ORowSetValue, ::rtl::OUString >
96 : : {
97 : 1456 : ::rtl::OUString operator()( const ORowSetValue& _value ) const
98 : : {
99 : 1456 : return _value.getString();
100 : : }
101 : : };
102 : :
103 : : //--------------------------------------------------------------------------
104 : : struct AppendRowSetValueString : public ::std::unary_function< ::rtl::OUString, void >
105 : : {
106 : 0 : AppendRowSetValueString( ::rtl::OUString& _string )
107 : 0 : :m_string( _string )
108 : : {
109 : 0 : }
110 : :
111 : 0 : void operator()( const ::rtl::OUString _append )
112 : : {
113 : 0 : m_string += _append;
114 : 0 : }
115 : :
116 : : private:
117 : : ::rtl::OUString& m_string;
118 : : };
119 : :
120 : : //--------------------------------------------------------------------------
121 : 342 : Sequence< ::rtl::OUString > lcl_convertToStringSequence( const ValueList& _values )
122 : : {
123 : 342 : Sequence< ::rtl::OUString > aStrings( _values.size() );
124 : : ::std::transform(
125 : : _values.begin(),
126 : : _values.end(),
127 : : aStrings.getArray(),
128 : : RowSetValueToString()
129 [ + - ][ + - ]: 342 : );
130 : 342 : return aStrings;
131 : : }
132 : : }
133 : :
134 : : //==============================================================================
135 : : //= ItemEventDescription
136 : : //==============================================================================
137 : : typedef ::comphelper::EventHolder< ItemEvent > ItemEventDescription;
138 : :
139 : : //==============================================================================
140 : : //= OListBoxModel
141 : : //==============================================================================
142 : : //------------------------------------------------------------------
143 : 15 : InterfaceRef SAL_CALL OListBoxModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException)
144 : : {
145 [ + - ]: 15 : return *(new OListBoxModel(_rxFactory));
146 : : }
147 : :
148 : : //------------------------------------------------------------------------------
149 : 4 : Sequence< Type> OListBoxModel::_getTypes()
150 : : {
151 : : return TypeBag(
152 : : OBoundControlModel::_getTypes(),
153 : : OEntryListHelper::getTypes(),
154 : : OErrorBroadcaster::getTypes()
155 [ + - ][ + - ]: 4 : ).getTypes();
[ + - ][ + - ]
[ + - ][ + - ]
156 : : }
157 : :
158 : :
159 : : DBG_NAME(OListBoxModel);
160 : : //------------------------------------------------------------------
161 : 15 : OListBoxModel::OListBoxModel(const Reference<XMultiServiceFactory>& _rxFactory)
162 : : :OBoundControlModel( _rxFactory, VCL_CONTROLMODEL_LISTBOX, FRM_SUN_CONTROL_LISTBOX, sal_True, sal_True, sal_True )
163 : : // use the old control name for compytibility reasons
164 : : ,OEntryListHelper( (OControlModel&)*this )
165 : : ,OErrorBroadcaster( OComponentHelper::rBHelper )
166 : 15 : ,m_aListRowSet( getContext() )
167 : : ,m_nNULLPos(-1)
168 [ + - ][ + - ]: 30 : ,m_nBoundColumnType( DataType::SQLNULL )
[ + - ]
[ + - + - ]
[ + - ][ + - ]
[ + - ][ + - ]
169 : : {
170 : : DBG_CTOR(OListBoxModel,NULL);
171 : :
172 : 15 : m_nClassId = FormComponentType::LISTBOX;
173 : 15 : m_eListSourceType = ListSourceType_VALUELIST;
174 [ + - ]: 15 : m_aBoundColumn <<= (sal_Int16)1;
175 [ + - ][ + - ]: 15 : initValueProperty( PROPERTY_SELECT_SEQ, PROPERTY_ID_SELECT_SEQ);
176 : :
177 [ + - ][ + - ]: 15 : startAggregatePropertyListening( PROPERTY_STRINGITEMLIST );
178 : 15 : }
179 : :
180 : : //------------------------------------------------------------------
181 : 2 : OListBoxModel::OListBoxModel( const OListBoxModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory )
182 : : :OBoundControlModel( _pOriginal, _rxFactory )
183 : : ,OEntryListHelper( *_pOriginal, (OControlModel&)*this )
184 : : ,OErrorBroadcaster( OComponentHelper::rBHelper )
185 : 2 : ,m_aListRowSet( getContext() )
186 : : ,m_eListSourceType( _pOriginal->m_eListSourceType )
187 : : ,m_aBoundColumn( _pOriginal->m_aBoundColumn )
188 : : ,m_aListSourceValues( _pOriginal->m_aListSourceValues )
189 : : ,m_aBoundValues( _pOriginal->m_aBoundValues )
190 : : ,m_aDefaultSelectSeq( _pOriginal->m_aDefaultSelectSeq )
191 : : ,m_nNULLPos(-1)
192 [ + - ]: 4 : ,m_nBoundColumnType( DataType::SQLNULL )
[ + - + - ]
[ + - ][ + - ]
[ + - ][ + - ]
193 : : {
194 : : DBG_CTOR(OListBoxModel,NULL);
195 : :
196 [ + - ][ + - ]: 2 : startAggregatePropertyListening( PROPERTY_STRINGITEMLIST );
197 : 2 : }
198 : :
199 : : //------------------------------------------------------------------
200 [ + - ][ + - ]: 17 : OListBoxModel::~OListBoxModel()
[ + - ][ + - ]
[ + - ]
201 : : {
202 [ - + ]: 17 : if (!OComponentHelper::rBHelper.bDisposed)
203 : : {
204 : 0 : acquire();
205 [ # # ]: 0 : dispose();
206 : : }
207 : :
208 : : DBG_DTOR(OListBoxModel,NULL);
209 [ - + ]: 34 : }
210 : :
211 : : // XCloneable
212 : : //------------------------------------------------------------------------------
213 [ + - ][ + - ]: 2 : IMPLEMENT_DEFAULT_CLONING( OListBoxModel )
214 : :
215 : : // XServiceInfo
216 : : //------------------------------------------------------------------------------
217 : 16 : StringSequence SAL_CALL OListBoxModel::getSupportedServiceNames() throw(RuntimeException)
218 : : {
219 : 16 : StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
220 : :
221 : 16 : sal_Int32 nOldLen = aSupported.getLength();
222 [ + - ]: 16 : aSupported.realloc( nOldLen + 8 );
223 [ + - ]: 16 : ::rtl::OUString* pStoreTo = aSupported.getArray() + nOldLen;
224 : :
225 [ + - ]: 16 : *pStoreTo++ = BINDABLE_CONTROL_MODEL;
226 [ + - ]: 16 : *pStoreTo++ = DATA_AWARE_CONTROL_MODEL;
227 [ + - ]: 16 : *pStoreTo++ = VALIDATABLE_CONTROL_MODEL;
228 : :
229 [ + - ]: 16 : *pStoreTo++ = BINDABLE_DATA_AWARE_CONTROL_MODEL;
230 [ + - ]: 16 : *pStoreTo++ = VALIDATABLE_BINDABLE_CONTROL_MODEL;
231 : :
232 [ + - ]: 16 : *pStoreTo++ = FRM_SUN_COMPONENT_LISTBOX;
233 [ + - ]: 16 : *pStoreTo++ = FRM_SUN_COMPONENT_DATABASE_LISTBOX;
234 [ + - ]: 16 : *pStoreTo++ = BINDABLE_DATABASE_LIST_BOX;
235 : :
236 : 16 : return aSupported;
237 : : }
238 : :
239 : : //------------------------------------------------------------------------------
240 : 12031 : Any SAL_CALL OListBoxModel::queryAggregation(const Type& _rType) throw (RuntimeException)
241 : : {
242 : 12031 : Any aReturn = OBoundControlModel::queryAggregation( _rType );
243 [ + + ]: 12031 : if ( !aReturn.hasValue() )
244 [ + - ]: 215 : aReturn = OEntryListHelper::queryInterface( _rType );
245 [ + + ]: 12031 : if ( !aReturn.hasValue() )
246 [ + - ]: 151 : aReturn = OErrorBroadcaster::queryInterface( _rType );
247 : 12031 : return aReturn;
248 : : }
249 : :
250 : : // OComponentHelper
251 : : //------------------------------------------------------------------------------
252 : 17 : void OListBoxModel::disposing()
253 : : {
254 : 17 : OBoundControlModel::disposing();
255 : 17 : OEntryListHelper::disposing();
256 : 17 : OErrorBroadcaster::disposing();
257 : 17 : }
258 : :
259 : : //------------------------------------------------------------------------------
260 : 8072 : void OListBoxModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
261 : : {
262 [ + + + + : 8072 : switch (_nHandle)
+ + + ]
263 : : {
264 : : case PROPERTY_ID_BOUNDCOLUMN:
265 : 52 : _rValue <<= m_aBoundColumn;
266 : 52 : break;
267 : :
268 : : case PROPERTY_ID_LISTSOURCETYPE:
269 : 172 : _rValue <<= m_eListSourceType;
270 : 172 : break;
271 : :
272 : : case PROPERTY_ID_LISTSOURCE:
273 [ + - ]: 172 : _rValue <<= lcl_convertToStringSequence( m_aListSourceValues );
274 : 172 : break;
275 : :
276 : : case PROPERTY_ID_VALUE_SEQ:
277 [ + - ]: 48 : _rValue <<= lcl_convertToStringSequence( m_aBoundValues );
278 : 48 : break;
279 : :
280 : : case PROPERTY_ID_DEFAULT_SELECT_SEQ:
281 : 172 : _rValue <<= m_aDefaultSelectSeq;
282 : 172 : break;
283 : :
284 : : case PROPERTY_ID_STRINGITEMLIST:
285 : 212 : _rValue <<= getStringItemList();
286 : 212 : break;
287 : :
288 : : default:
289 : 7244 : OBoundControlModel::getFastPropertyValue(_rValue, _nHandle);
290 : : }
291 : 8072 : }
292 : :
293 : : //------------------------------------------------------------------------------
294 : 284 : void OListBoxModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (com::sun::star::uno::Exception)
295 : : {
296 [ + + + - : 284 : switch (_nHandle)
+ + + ]
297 : : {
298 : : case PROPERTY_ID_BOUNDCOLUMN :
299 : : DBG_ASSERT((_rValue.getValueType().getTypeClass() == TypeClass_SHORT) || (_rValue.getValueType().getTypeClass() == TypeClass_VOID),
300 : : "OListBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
301 : 2 : m_aBoundColumn = _rValue;
302 : 2 : break;
303 : :
304 : : case PROPERTY_ID_LISTSOURCETYPE :
305 : : DBG_ASSERT(_rValue.getValueType().equals(::getCppuType(static_cast<ListSourceType*>(0))),
306 : : "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
307 : 22 : _rValue >>= m_eListSourceType;
308 : 22 : break;
309 : :
310 : : case PROPERTY_ID_LISTSOURCE:
311 : : {
312 : : // extract
313 [ + - ]: 34 : Sequence< ::rtl::OUString > aListSource;
314 [ + - ]: 34 : OSL_VERIFY( _rValue >>= aListSource );
315 : :
316 : : // copy to member
317 [ + - ]: 34 : ValueList().swap(m_aListSourceValues);
318 : : ::std::copy(
319 : : aListSource.getConstArray(),
320 : 34 : aListSource.getConstArray() + aListSource.getLength(),
321 : : ::std::insert_iterator< ValueList >( m_aListSourceValues, m_aListSourceValues.end() )
322 [ + - + - ]: 68 : );
323 : :
324 : : // propagate
325 [ + + ]: 34 : if ( m_eListSourceType == ListSourceType_VALUELIST )
326 : : {
327 [ + - ]: 16 : setBoundValues(m_aListSourceValues);
328 : : }
329 : : else
330 : : {
331 [ - + ][ # # ]: 18 : if ( m_xCursor.is() && !hasField() && !hasExternalListSource() )
[ # # ][ - + ]
332 : : // listbox is already connected to a database, and no external list source
333 : : // data source changed -> refresh
334 [ # # ]: 0 : loadData( false );
335 [ + - ]: 34 : }
336 : : }
337 : 34 : break;
338 : :
339 : : case PROPERTY_ID_VALUE_SEQ :
340 : : OSL_FAIL( "ValueItemList is read-only!" );
341 [ # # ]: 0 : throw PropertyVetoException();
342 : :
343 : : case PROPERTY_ID_DEFAULT_SELECT_SEQ :
344 : : DBG_ASSERT(_rValue.getValueType().equals(::getCppuType(static_cast< Sequence<sal_Int16>*>(0))),
345 : : "OListBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
346 : 22 : _rValue >>= m_aDefaultSelectSeq;
347 : :
348 : : DBG_ASSERT(m_xAggregateFastSet.is(), "OListBoxModel::setFastPropertyValue_NoBroadcast(DEFAULT_SELECT_SEQ) : invalid aggregate !");
349 [ + - ]: 22 : if ( m_xAggregateFastSet.is() )
350 : 22 : setControlValue( _rValue, eOther );
351 : 22 : break;
352 : :
353 : : case PROPERTY_ID_STRINGITEMLIST:
354 : : {
355 [ + - ]: 32 : ControlModelLock aLock( *this );
356 [ + - ][ + - ]: 32 : setNewStringItemList( _rValue, aLock );
357 : : // TODO: this is bogus. setNewStringItemList expects a guard which has the *only*
358 : : // lock to the mutex, but setFastPropertyValue_NoBroadcast is already called with
359 : : // a lock - so we effectively has two locks here, of which setNewStringItemList can
360 : : // only control one.
361 : : }
362 : 32 : resetNoBroadcast();
363 : 32 : break;
364 : :
365 : : default:
366 : 172 : OBoundControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
367 : : }
368 : 284 : }
369 : :
370 : : //------------------------------------------------------------------------------
371 : 1146 : sal_Bool OListBoxModel::convertFastPropertyValue(
372 : : Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
373 : : throw (IllegalArgumentException)
374 : : {
375 : 1146 : sal_Bool bModified(sal_False);
376 [ + + + - : 1146 : switch (_nHandle)
+ + + ]
377 : : {
378 : : case PROPERTY_ID_BOUNDCOLUMN :
379 : 2 : bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aBoundColumn, ::getCppuType(static_cast<sal_Int16*>(0)));
380 : 2 : break;
381 : :
382 : : case PROPERTY_ID_LISTSOURCETYPE:
383 : 108 : bModified = tryPropertyValueEnum(_rConvertedValue, _rOldValue, _rValue, m_eListSourceType);
384 : 108 : break;
385 : :
386 : : case PROPERTY_ID_LISTSOURCE:
387 [ + - ]: 120 : bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, lcl_convertToStringSequence( m_aListSourceValues ) );
388 : 120 : break;
389 : :
390 : : case PROPERTY_ID_VALUE_SEQ :
391 : : OSL_FAIL( "ValueItemList is read-only!" );
392 [ # # ]: 0 : throw PropertyVetoException();
393 : :
394 : : case PROPERTY_ID_DEFAULT_SELECT_SEQ :
395 : 110 : bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aDefaultSelectSeq);
396 : 110 : break;
397 : :
398 : : case PROPERTY_ID_STRINGITEMLIST:
399 : 118 : bModified = convertNewListSourceProperty( _rConvertedValue, _rOldValue, _rValue );
400 : 118 : break;
401 : :
402 : : default:
403 : 688 : return OBoundControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
404 : : }
405 : 1146 : return bModified;
406 : : }
407 : :
408 : : //------------------------------------------------------------------------------
409 : 98 : void SAL_CALL OListBoxModel::setPropertyValues( const Sequence< ::rtl::OUString >& _rPropertyNames, const Sequence< Any >& _rValues ) throw(PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
410 : : {
411 : : // if both SelectedItems and StringItemList are set, care for this
412 : : // #i27024#
413 : 98 : const Any* pSelectSequenceValue = NULL;
414 : :
415 : 98 : const ::rtl::OUString* pStartPos = _rPropertyNames.getConstArray();
416 : 98 : const ::rtl::OUString* pEndPos = _rPropertyNames.getConstArray() + _rPropertyNames.getLength();
417 : : const ::rtl::OUString* pSelectedItemsPos = ::std::find_if(
418 : : pStartPos, pEndPos,
419 : : ::std::bind2nd( ::std::equal_to< ::rtl::OUString >(), PROPERTY_SELECT_SEQ )
420 [ + - ][ + - ]: 98 : );
421 : : const ::rtl::OUString* pStringItemListPos = ::std::find_if(
422 : : pStartPos, pEndPos,
423 : : ::std::bind2nd( ::std::equal_to< ::rtl::OUString >(), PROPERTY_STRINGITEMLIST )
424 [ + - ][ + - ]: 98 : );
425 [ + - ][ + + ]: 98 : if ( ( pSelectedItemsPos != pEndPos ) && ( pStringItemListPos != pEndPos ) )
426 : : {
427 : : // both properties are present
428 : : // -> remember the value for the select sequence
429 : 94 : pSelectSequenceValue = _rValues.getConstArray() + ( pSelectedItemsPos - pStartPos );
430 : : }
431 : :
432 : 98 : OBoundControlModel::setPropertyValues( _rPropertyNames, _rValues );
433 : :
434 [ + + ]: 96 : if ( pSelectSequenceValue )
435 : : {
436 [ + - ]: 94 : setPropertyValue( PROPERTY_SELECT_SEQ, *pSelectSequenceValue );
437 : : // Note that this is the only reliable way, since one of the properties is implemented
438 : : // by ourself, and one is implemented by the aggregate, we cannot rely on any particular
439 : : // results when setting them both - too many undocumented behavior in all the involved
440 : :
441 : : }
442 : 96 : }
443 : :
444 : : //------------------------------------------------------------------------------
445 : 19 : void OListBoxModel::describeFixedProperties( Sequence< Property >& _rProps ) const
446 : : {
447 : 19 : BEGIN_DESCRIBE_PROPERTIES( 7, OBoundControlModel )
448 [ + - ]: 19 : DECL_PROP1(TABINDEX, sal_Int16, BOUND);
449 [ + - ][ + - ]: 19 : DECL_PROP2(BOUNDCOLUMN, sal_Int16, BOUND, MAYBEVOID);
450 [ + - ]: 19 : DECL_PROP1(LISTSOURCETYPE, ListSourceType, BOUND);
451 [ + - ]: 19 : DECL_PROP1(LISTSOURCE, StringSequence, BOUND);
452 [ + - ][ + - ]: 19 : DECL_PROP3(VALUE_SEQ, StringSequence, BOUND, READONLY, TRANSIENT);
453 [ + - ]: 19 : DECL_PROP1(DEFAULT_SELECT_SEQ, Sequence<sal_Int16>, BOUND);
454 [ + - ]: 19 : DECL_PROP1(STRINGITEMLIST, Sequence< ::rtl::OUString >, BOUND);
455 : : END_DESCRIBE_PROPERTIES();
456 : 19 : }
457 : :
458 : : //------------------------------------------------------------------------------
459 : 82 : void OListBoxModel::_propertyChanged( const PropertyChangeEvent& i_rEvent ) throw ( RuntimeException )
460 : : {
461 [ - + ]: 82 : if ( i_rEvent.PropertyName == PROPERTY_STRINGITEMLIST )
462 : : {
463 [ # # ]: 0 : ControlModelLock aLock( *this );
464 : : // SYNCHRONIZED ----->
465 : : // our aggregate internally changed its StringItemList property - reflect this in our "overridden"
466 : : // version of the property
467 [ # # ]: 0 : setNewStringItemList( i_rEvent.NewValue, aLock );
468 : : // <----- SYNCHRONIZED
469 [ # # ]: 82 : return;
470 : : }
471 : 82 : OBoundControlModel::_propertyChanged( i_rEvent );
472 : : }
473 : :
474 : : //------------------------------------------------------------------------------
475 : 19 : void OListBoxModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const
476 : : {
477 : 19 : OBoundControlModel::describeAggregateProperties( _rAggregateProps );
478 : :
479 : : // superseded properties:
480 [ + - ]: 19 : RemoveProperty( _rAggregateProps, PROPERTY_STRINGITEMLIST );
481 : 19 : }
482 : :
483 : : //------------------------------------------------------------------------------
484 : 2 : ::rtl::OUString SAL_CALL OListBoxModel::getServiceName() throw(RuntimeException)
485 : : {
486 : 2 : return FRM_COMPONENT_LISTBOX; // old (non-sun) name for compatibility !
487 : : }
488 : :
489 : : //------------------------------------------------------------------------------
490 : 2 : void SAL_CALL OListBoxModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
491 : : throw(IOException, RuntimeException)
492 : : {
493 [ + - ]: 2 : OBoundControlModel::write(_rxOutStream);
494 : :
495 : : // Dummy sequence, to stay compatible if SelectSeq is not saved anymore
496 [ + - ]: 2 : Sequence<sal_Int16> aDummySeq;
497 : :
498 : : // Version
499 : : // Version 0x0002: ListSource becomes StringSeq
500 [ + - ][ + - ]: 2 : _rxOutStream->writeShort(0x0004);
501 : :
502 : : // Masking for any
503 : 2 : sal_uInt16 nAnyMask = 0;
504 [ + - ]: 2 : if (m_aBoundColumn.getValueType().getTypeClass() != TypeClass_VOID)
505 : 2 : nAnyMask |= BOUNDCOLUMN;
506 : :
507 [ + - ]: 2 : _rxOutStream << nAnyMask;
508 : :
509 [ + - ][ + - ]: 2 : _rxOutStream << lcl_convertToStringSequence( m_aListSourceValues );
[ + - ]
510 [ + - ]: 2 : _rxOutStream << (sal_Int16)m_eListSourceType;
511 [ + - ]: 2 : _rxOutStream << aDummySeq;
512 [ + - ]: 2 : _rxOutStream << m_aDefaultSelectSeq;
513 : :
514 [ + - ]: 2 : if ((nAnyMask & BOUNDCOLUMN) == BOUNDCOLUMN)
515 : : {
516 : 2 : sal_Int16 nBoundColumn = 0;
517 : 2 : m_aBoundColumn >>= nBoundColumn;
518 [ + - ]: 2 : _rxOutStream << nBoundColumn;
519 : : }
520 [ + - ]: 2 : writeHelpTextCompatibly(_rxOutStream);
521 : :
522 : : // from version 0x0004 : common properties
523 [ + - ][ + - ]: 2 : writeCommonProperties(_rxOutStream);
524 : 2 : }
525 : :
526 : : //------------------------------------------------------------------------------
527 : 2 : void SAL_CALL OListBoxModel::read(const Reference<XObjectInputStream>& _rxInStream) throw(IOException, RuntimeException)
528 : : {
529 : : // We need to respect dependencies for certain variables.
530 : : // Therefore, we need to set them explicitly via setPropertyValue().
531 : :
532 [ + - ]: 2 : OBoundControlModel::read(_rxInStream);
533 [ + - ]: 2 : ControlModelLock aLock( *this );
534 : :
535 : : // since we are "overwriting" the StringItemList of our aggregate (means we have
536 : : // an own place to store the value, instead of relying on our aggregate storing it),
537 : : // we need to respect what the aggregate just read for the StringItemList property.
538 : : try
539 : : {
540 [ + - ]: 2 : if ( m_xAggregateSet.is() )
541 [ + - ][ + - ]: 2 : setNewStringItemList( m_xAggregateSet->getPropertyValue( PROPERTY_STRINGITEMLIST ), aLock );
[ + - ][ + - ]
[ # # ]
542 : : }
543 [ # # ]: 0 : catch( const Exception& )
544 : : {
545 : : OSL_FAIL( "OComboBoxModel::read: caught an exception while examining the aggregate's string item list!" );
546 : : }
547 : :
548 : : // Version
549 [ + - ][ + - ]: 2 : sal_uInt16 nVersion = _rxInStream->readShort();
550 : : DBG_ASSERT(nVersion > 0, "OListBoxModel::read : version 0 ? this should never have been written !");
551 : :
552 [ - + ]: 2 : if (nVersion > 0x0004)
553 : : {
554 : : OSL_FAIL("OListBoxModel::read : invalid (means unknown) version !");
555 [ # # ]: 0 : ValueList().swap(m_aListSourceValues);
556 [ # # ]: 0 : m_aBoundColumn <<= (sal_Int16)0;
557 [ # # ]: 0 : clearBoundValues();
558 : 0 : m_eListSourceType = ListSourceType_VALUELIST;
559 [ # # ]: 0 : m_aDefaultSelectSeq.realloc(0);
560 [ # # ]: 0 : defaultCommonProperties();
561 : 2 : return;
562 : : }
563 : :
564 : : // Masking for any
565 : : sal_uInt16 nAnyMask;
566 [ + - ]: 2 : _rxInStream >> nAnyMask;
567 : :
568 : : // ListSourceSeq
569 [ + - ]: 2 : StringSequence aListSourceSeq;
570 [ - + ]: 2 : if (nVersion == 0x0001)
571 : : {
572 : : // Create ListSourceSeq from String
573 : 0 : ::rtl::OUString sListSource;
574 [ # # ]: 0 : _rxInStream >> sListSource;
575 : :
576 : 0 : sal_Int32 nTokens = 1;
577 : 0 : const sal_Unicode* pStr = sListSource.getStr();
578 [ # # ]: 0 : while ( *pStr )
579 : : {
580 [ # # ]: 0 : if ( *pStr == ';' )
581 : 0 : nTokens++;
582 : 0 : pStr++;
583 : : }
584 [ # # ]: 0 : aListSourceSeq.realloc( nTokens );
585 [ # # ]: 0 : for (sal_uInt16 i=0; i<nTokens; ++i)
586 : : {
587 : 0 : sal_Int32 nTmp = 0;
588 [ # # ]: 0 : aListSourceSeq.getArray()[i] = sListSource.getToken(i,';',nTmp);
589 : 0 : }
590 : : }
591 : : else
592 [ + - ]: 2 : _rxInStream >> aListSourceSeq;
593 : :
594 : : sal_Int16 nListSourceType;
595 [ + - ]: 2 : _rxInStream >> nListSourceType;
596 : 2 : m_eListSourceType = (ListSourceType)nListSourceType;
597 : 2 : Any aListSourceSeqAny;
598 [ + - ]: 2 : aListSourceSeqAny <<= aListSourceSeq;
599 : :
600 [ + - ]: 2 : setFastPropertyValue(PROPERTY_ID_LISTSOURCE, aListSourceSeqAny );
601 : :
602 : : // Dummy sequence, to stay compatible if SelectSeq is not saved anymore
603 [ + - ]: 2 : Sequence<sal_Int16> aDummySeq;
604 [ + - ]: 2 : _rxInStream >> aDummySeq;
605 : :
606 : : // DefaultSelectSeq
607 [ + - ]: 2 : Sequence<sal_Int16> aDefaultSelectSeq;
608 [ + - ]: 2 : _rxInStream >> aDefaultSelectSeq;
609 : 2 : Any aDefaultSelectSeqAny;
610 [ + - ]: 2 : aDefaultSelectSeqAny <<= aDefaultSelectSeq;
611 [ + - ]: 2 : setFastPropertyValue(PROPERTY_ID_DEFAULT_SELECT_SEQ, aDefaultSelectSeqAny);
612 : :
613 : : // BoundColumn
614 [ + - ]: 2 : if ((nAnyMask & BOUNDCOLUMN) == BOUNDCOLUMN)
615 : : {
616 : : sal_Int16 nValue;
617 [ + - ]: 2 : _rxInStream >> nValue;
618 [ + - ]: 2 : m_aBoundColumn <<= nValue;
619 : : }
620 : :
621 [ + - ]: 2 : if (nVersion > 2)
622 [ + - ]: 2 : readHelpTextCompatibly(_rxInStream);
623 : :
624 : : // if our string list is not filled from the value list, we must empty it
625 : : // this can be the case when somebody saves in alive mode
626 [ - + # # ]: 2 : if ( ( m_eListSourceType != ListSourceType_VALUELIST )
[ - + ]
627 : 0 : && !hasExternalListSource()
628 : : )
629 : : {
630 [ # # ][ # # ]: 0 : setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( StringSequence() ) );
[ # # ][ # # ]
631 : : }
632 : :
633 [ + - ]: 2 : if (nVersion > 3)
634 [ + - ]: 2 : readCommonProperties(_rxInStream);
635 : :
636 : : // Display the default values after reading
637 [ + - ]: 2 : if ( !getControlSource().isEmpty() )
638 : : // (not if we don't have a control source - the "State" property acts like it is persistent, then
639 [ + - ][ + - ]: 2 : resetNoBroadcast();
[ + - ][ + - ]
[ + - ][ + - ]
640 : : }
641 : :
642 : : //------------------------------------------------------------------------------
643 : 0 : void OListBoxModel::loadData( bool _bForce )
644 : : {
645 : : RTL_LOGFILE_CONTEXT( aLogContext, "OListBoxModel::loadData" );
646 : : DBG_ASSERT( m_eListSourceType != ListSourceType_VALUELIST, "OListBoxModel::loadData: cannot load value list from DB!" );
647 : : DBG_ASSERT( !hasExternalListSource(), "OListBoxModel::loadData: cannot load from DB when I have an external list source!" );
648 : :
649 : 0 : const sal_Int16 nNULLPosBackup( m_nNULLPos );
650 : 0 : const sal_Int32 nBoundColumnTypeBackup( m_nBoundColumnType );
651 : 0 : m_nNULLPos = -1;
652 : 0 : m_nBoundColumnType = DataType::SQLNULL;
653 : :
654 : : // pre-requisites:
655 : : // PRE1: connection
656 : 0 : Reference< XConnection > xConnection;
657 : : // is the active connection of our form
658 [ # # ]: 0 : Reference< XPropertySet > xFormProps( m_xCursor, UNO_QUERY );
659 [ # # ]: 0 : if ( xFormProps.is() )
660 [ # # ][ # # ]: 0 : xFormProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;
[ # # ][ # # ]
661 : :
662 : : // PRE2: list source
663 : 0 : ::rtl::OUString sListSource;
664 : : // if our list source type is no value list, we need to concatenate
665 : : // the single list source elements
666 : : ::std::for_each(
667 : : m_aListSourceValues.begin(),
668 : : m_aListSourceValues.end(),
669 : : AppendRowSetValueString( sListSource )
670 [ # # ]: 0 : );
671 : :
672 : : // outta here if we don't have all pre-requisites
673 [ # # ][ # # ]: 0 : if ( !xConnection.is() || sListSource.isEmpty() )
[ # # ]
674 : : {
675 [ # # ]: 0 : clearBoundValues();
676 : : return;
677 : : }
678 : :
679 [ # # ]: 0 : ::boost::optional< sal_Int16 > aBoundColumn(0);
680 [ # # ]: 0 : aBoundColumn.reset();
681 [ # # ]: 0 : if ( m_aBoundColumn.getValueType().getTypeClass() == TypeClass_SHORT )
682 : : {
683 : 0 : sal_Int16 nBoundColumn( 0 );
684 : 0 : m_aBoundColumn >>= nBoundColumn;
685 [ # # ]: 0 : aBoundColumn.reset( nBoundColumn );
686 : : }
687 : :
688 [ # # ]: 0 : ::utl::SharedUNOComponent< XResultSet > xListCursor;
689 : : try
690 : : {
691 [ # # ]: 0 : m_aListRowSet.setConnection( xConnection );
692 : :
693 : 0 : sal_Bool bExecute = sal_False;
694 [ # # # # ]: 0 : switch (m_eListSourceType)
695 : : {
696 : : case ListSourceType_TABLEFIELDS:
697 : : // don't work with a statement here, the fields will be collected below
698 : 0 : break;
699 : :
700 : : case ListSourceType_TABLE:
701 : : {
702 [ # # ]: 0 : Reference<XNameAccess> xFieldsByName = getTableFields(xConnection, sListSource);
703 [ # # ]: 0 : Reference<XIndexAccess> xFieldsByIndex(xFieldsByName, UNO_QUERY);
704 : :
705 : : // do we have a bound column if yes we have to select it
706 : : // and the displayed column is the first column othwhise we act as a combobox
707 : 0 : ::rtl::OUString aFieldName;
708 : 0 : ::rtl::OUString aBoundFieldName;
709 : :
710 [ # # ][ # # ]: 0 : if ( !!aBoundColumn && ( *aBoundColumn >= 0 ) && xFieldsByIndex.is() )
[ # # ][ # # ]
[ # # ][ # # ]
711 : : {
712 [ # # ][ # # ]: 0 : if ( *aBoundColumn >= xFieldsByIndex->getCount() )
[ # # ][ # # ]
713 : : break;
714 : :
715 [ # # ][ # # ]: 0 : Reference<XPropertySet> xFieldAsSet(xFieldsByIndex->getByIndex( *aBoundColumn ),UNO_QUERY);
[ # # ][ # # ]
716 [ # # ][ # # ]: 0 : xFieldAsSet->getPropertyValue(PROPERTY_NAME) >>= aBoundFieldName;
[ # # ]
717 [ # # ]: 0 : aBoundColumn.reset( 1 );
718 : :
719 [ # # ][ # # ]: 0 : xFieldAsSet.set(xFieldsByIndex->getByIndex(0),UNO_QUERY);
[ # # ]
720 [ # # ][ # # ]: 0 : xFieldAsSet->getPropertyValue(PROPERTY_NAME) >>= aFieldName;
[ # # ]
721 : : }
722 [ # # ]: 0 : else if (xFieldsByName.is())
723 : : {
724 [ # # ][ # # ]: 0 : if ( xFieldsByName->hasByName( getControlSource() ) )
[ # # ]
725 : 0 : aFieldName = getControlSource();
726 : : else
727 : : {
728 : : // otherwise look for the alias
729 : 0 : Reference< XColumnsSupplier > xSupplyFields;
730 [ # # ][ # # ]: 0 : xFormProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSupplyFields;
[ # # ][ # # ]
731 : :
732 : : // search the field
733 : : DBG_ASSERT(xSupplyFields.is(), "OListBoxModel::loadData : invalid query composer !");
734 : :
735 [ # # ][ # # ]: 0 : Reference<XNameAccess> xFieldNames = xSupplyFields->getColumns();
736 [ # # ][ # # ]: 0 : if ( xFieldNames->hasByName( getControlSource() ) )
[ # # ]
737 : : {
738 : 0 : Reference<XPropertySet> xComposerFieldAsSet;
739 [ # # ][ # # ]: 0 : xFieldNames->getByName( getControlSource() ) >>= xComposerFieldAsSet;
[ # # ]
740 [ # # ][ # # ]: 0 : if (hasProperty(PROPERTY_FIELDSOURCE, xComposerFieldAsSet))
[ # # ]
741 [ # # ][ # # ]: 0 : xComposerFieldAsSet->getPropertyValue(PROPERTY_FIELDSOURCE) >>= aFieldName;
[ # # ]
742 : 0 : }
743 : : }
744 : : }
745 [ # # ]: 0 : if (aFieldName.isEmpty())
746 : : break;
747 : :
748 [ # # ][ # # ]: 0 : Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
749 [ # # ][ # # ]: 0 : ::rtl::OUString aQuote = xMeta->getIdentifierQuoteString();
750 [ # # ]: 0 : ::rtl::OUString aStatement(RTL_CONSTASCII_USTRINGPARAM("SELECT "));
751 [ # # ]: 0 : if (aBoundFieldName.isEmpty()) // act like a combobox
752 [ # # ]: 0 : aStatement += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DISTINCT ") );
753 : :
754 [ # # ]: 0 : aStatement += quoteName(aQuote,aFieldName);
755 [ # # ]: 0 : if (!aBoundFieldName.isEmpty())
756 : : {
757 [ # # ]: 0 : aStatement += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(", ") );
758 [ # # ]: 0 : aStatement += quoteName(aQuote, aBoundFieldName);
759 : : }
760 [ # # ]: 0 : aStatement += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM ") );
761 : :
762 : 0 : ::rtl::OUString sCatalog, sSchema, sTable;
763 [ # # ]: 0 : qualifiedNameComponents( xMeta, sListSource, sCatalog, sSchema, sTable, eInDataManipulation );
764 [ # # ]: 0 : aStatement += composeTableNameForSelect( xConnection, sCatalog, sSchema, sTable );
765 : :
766 [ # # ]: 0 : m_aListRowSet.setEscapeProcessing( sal_False );
767 [ # # ]: 0 : m_aListRowSet.setCommand( aStatement );
768 [ # # ][ # # ]: 0 : bExecute = sal_True;
[ # # ][ # # ]
769 : : }
770 : 0 : break;
771 : :
772 : : case ListSourceType_QUERY:
773 [ # # ]: 0 : m_aListRowSet.setCommandFromQuery( sListSource );
774 : 0 : bExecute = sal_True;
775 : 0 : break;
776 : :
777 : : default:
778 [ # # ]: 0 : m_aListRowSet.setEscapeProcessing( ListSourceType_SQLPASSTHROUGH != m_eListSourceType );
779 [ # # ]: 0 : m_aListRowSet.setCommand( sListSource );
780 : 0 : bExecute = sal_True;
781 : 0 : break;
782 : : }
783 : :
784 [ # # ]: 0 : if (bExecute)
785 : : {
786 [ # # ][ # # ]: 0 : if ( !_bForce && !m_aListRowSet.isDirty() )
[ # # ][ # # ]
787 : : {
788 : : // if none of the settings of the row set changed, compared to the last
789 : : // invocation of loadData, then don't re-fill the list. Instead, assume
790 : : // the list entries are the same.
791 : 0 : m_nNULLPos = nNULLPosBackup;
792 : 0 : m_nBoundColumnType = nBoundColumnTypeBackup;
793 : : return;
794 : : }
795 [ # # ][ # # ]: 0 : xListCursor.reset( m_aListRowSet.execute() );
796 : : }
797 : : }
798 [ # # # # : 0 : catch(const SQLException& eSQL)
# ]
799 : : {
800 [ # # # # ]: 0 : onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST));
801 : : return;
802 : : }
803 [ # # ]: 0 : catch(const Exception& eUnknown)
804 : : {
805 : : (void)eUnknown;
806 : : return;
807 : : }
808 : :
809 : : // Fill display and value lists
810 [ # # ][ # # ]: 0 : ValueList aDisplayList, aValueList;
811 [ # # ][ # # ]: 0 : sal_Bool bUseNULL = hasField() && !isRequired();
812 : :
813 : : try
814 : : {
815 : : OSL_ENSURE( xListCursor.is() || ( ListSourceType_TABLEFIELDS == m_eListSourceType ),
816 : : "OListBoxModel::loadData: logic error!" );
817 [ # # ][ # # ]: 0 : if ( !xListCursor.is() && ( ListSourceType_TABLEFIELDS != m_eListSourceType ) )
[ # # ]
818 : : return;
819 : :
820 [ # # # ]: 0 : switch (m_eListSourceType)
821 : : {
822 : : case ListSourceType_SQL:
823 : : case ListSourceType_SQLPASSTHROUGH:
824 : : case ListSourceType_TABLE:
825 : : case ListSourceType_QUERY:
826 : : {
827 : : // Get field of the ResultSet's 1st column
828 [ # # ]: 0 : Reference<XColumnsSupplier> xSupplyCols(xListCursor, UNO_QUERY);
829 : : DBG_ASSERT(xSupplyCols.is(), "OListBoxModel::loadData : cursor supports the row set service but is no column supplier?!");
830 : 0 : Reference<XIndexAccess> xColumns;
831 [ # # ]: 0 : if (xSupplyCols.is())
832 : : {
833 [ # # ][ # # ]: 0 : xColumns = Reference<XIndexAccess>(xSupplyCols->getColumns(), UNO_QUERY);
[ # # ][ # # ]
834 : : DBG_ASSERT(xColumns.is(), "OListBoxModel::loadData : no columns supplied by the row set !");
835 : : }
836 : :
837 : 0 : Reference< XPropertySet > xDataField;
838 [ # # ]: 0 : if ( xColumns.is() )
839 [ # # ][ # # ]: 0 : xColumns->getByIndex(0) >>= xDataField;
[ # # ]
840 [ # # ]: 0 : if ( !xDataField.is() )
841 : : return;
842 : :
843 [ # # ]: 0 : ::dbtools::FormattedColumnValue aValueFormatter( getContext(), m_xCursor, xDataField );
844 : :
845 : : // Get the field of BoundColumn of the ResultSet
846 : 0 : m_nBoundColumnType = DataType::SQLNULL;
847 [ # # ][ # # ]: 0 : if ( !!aBoundColumn && ( *aBoundColumn >= 0 ) && m_xColumn.is() )
[ # # ][ # # ]
[ # # ][ # # ]
848 : : { // don't look for a bound column if we're not connected to a field
849 : : try
850 : : {
851 [ # # ][ # # ]: 0 : Reference< XPropertySet > xBoundField( xColumns->getByIndex( *aBoundColumn ), UNO_QUERY_THROW );
[ # # ][ # # ]
852 [ # # ][ # # ]: 0 : OSL_VERIFY( xBoundField->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type") ) ) >>= m_nBoundColumnType );
[ # # ][ # # ]
853 : : }
854 [ # # ]: 0 : catch( const Exception& )
855 : : {
856 : : DBG_UNHANDLED_EXCEPTION();
857 : : }
858 : : }
859 : :
860 : : // If the LB is bound to a field and empty entries are valid, we remember the position
861 : : // for an empty entry
862 : : RTL_LOGFILE_CONTEXT( aLogContext, "OListBoxModel::loadData: string collection" );
863 : 0 : ::rtl::OUString aStr;
864 : 0 : sal_Int16 entryPos = 0;
865 : 0 : ORowSetValue aBoundValue;
866 [ # # ]: 0 : Reference< XRow > xCursorRow( xListCursor, UNO_QUERY_THROW );
867 [ # # ][ # # ]: 0 : while ( xListCursor->next() && ( entryPos++ < SHRT_MAX ) ) // SHRT_MAX is the maximum number of entries
[ # # ][ # # ]
[ # # ]
868 : : {
869 [ # # ]: 0 : aStr = aValueFormatter.getFormattedValue();
870 [ # # ][ # # ]: 0 : aDisplayList.push_back( aStr );
[ # # ]
871 : :
872 [ # # ]: 0 : if ( impl_hasBoundComponent() )
873 : : {
874 [ # # ][ # # ]: 0 : aBoundValue.fill( *aBoundColumn + 1, m_nBoundColumnType, xCursorRow );
875 [ # # ]: 0 : aValueList.push_back( aBoundValue );
876 : : }
877 : :
878 [ # # ][ # # ]: 0 : if ( bUseNULL && ( m_nNULLPos == -1 ) && aStr.isEmpty() )
[ # # ][ # # ]
879 : 0 : m_nNULLPos = sal_Int16( aDisplayList.size() - 1 );
880 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ]
881 : : }
882 : 0 : break;
883 : :
884 : : case ListSourceType_TABLEFIELDS:
885 : : {
886 [ # # ]: 0 : Reference<XNameAccess> xFieldNames = getTableFields(xConnection, sListSource);
887 [ # # ]: 0 : if (xFieldNames.is())
888 : : {
889 [ # # ][ # # ]: 0 : StringSequence seqNames = xFieldNames->getElementNames();
890 : : ::std::copy(
891 : : seqNames.getConstArray(),
892 : 0 : seqNames.getConstArray() + seqNames.getLength(),
893 : : ::std::insert_iterator< ValueList >( aDisplayList, aDisplayList.end() )
894 [ # # # # ]: 0 : );
[ # # ]
895 : 0 : }
896 : : }
897 : 0 : break;
898 : : default:
899 : : OSL_FAIL( "OListBoxModel::loadData: unreachable!" );
900 : 0 : break;
901 : : }
902 : : }
903 [ # # # # : 0 : catch(const SQLException& eSQL)
# ]
904 : : {
905 [ # # # # ]: 0 : onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST));
906 : : return;
907 : : }
908 [ # # ]: 0 : catch( const Exception& )
909 : : {
910 : : DBG_UNHANDLED_EXCEPTION();
911 : : return;
912 : : }
913 : :
914 : :
915 : : // Create Values sequence
916 : : // Add NULL entry
917 [ # # ][ # # ]: 0 : if (bUseNULL && m_nNULLPos == -1)
918 : : {
919 [ # # ]: 0 : if ( impl_hasBoundComponent() )
920 [ # # ][ # # ]: 0 : aValueList.insert( aValueList.begin(), ORowSetValue() );
921 : :
922 [ # # ][ # # ]: 0 : aDisplayList.insert( aDisplayList.begin(), ORowSetValue( ::rtl::OUString() ) );
[ # # ]
923 : 0 : m_nNULLPos = 0;
924 : : }
925 : :
926 [ # # ]: 0 : setBoundValues(aValueList);
927 : :
928 [ # # ][ # # ]: 0 : setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( lcl_convertToStringSequence( aDisplayList ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
929 : : }
930 : :
931 : : //------------------------------------------------------------------------------
932 : 0 : void OListBoxModel::onConnectedDbColumn( const Reference< XInterface >& /*_rxForm*/ )
933 : : {
934 : : // list boxes which are bound to a db column don't have multi selection
935 : : // - this would be unable to reflect in the db column
936 [ # # ]: 0 : if ( hasField() )
937 : : {
938 [ # # ]: 0 : setFastPropertyValue( PROPERTY_ID_MULTISELECTION, ::cppu::bool2any( ( sal_False ) ) );
939 : : }
940 : :
941 [ # # ]: 0 : if ( !hasExternalListSource() )
942 : 0 : impl_refreshDbEntryList( false );
943 : 0 : }
944 : :
945 : : //------------------------------------------------------------------------------
946 : 0 : void OListBoxModel::onDisconnectedDbColumn()
947 : : {
948 [ # # ]: 0 : if ( m_eListSourceType != ListSourceType_VALUELIST )
949 : : {
950 : 0 : clearBoundValues();
951 : 0 : m_nNULLPos = -1;
952 : 0 : m_nBoundColumnType = DataType::SQLNULL;
953 : :
954 [ # # ]: 0 : if ( !hasExternalListSource() )
955 [ # # ][ # # ]: 0 : setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( StringSequence() ) );
956 : :
957 : 0 : m_aListRowSet.dispose();
958 : : }
959 : 0 : }
960 : :
961 : : //------------------------------------------------------------------------------
962 : 16 : void OListBoxModel::setBoundValues(const ValueList &l)
963 : : {
964 : 16 : m_aConvertedBoundValues.clear();
965 : 16 : m_aBoundValues = l;
966 : 16 : }
967 : :
968 : : //------------------------------------------------------------------------------
969 : 0 : void OListBoxModel::clearBoundValues()
970 : : {
971 : 0 : ValueList().swap(m_aConvertedBoundValues);
972 : 0 : ValueList().swap(m_aBoundValues);
973 : 0 : }
974 : :
975 : : //------------------------------------------------------------------------------
976 : 0 : void OListBoxModel::convertBoundValues(const sal_Int32 nFieldType) const
977 : : {
978 [ # # ]: 0 : m_aConvertedBoundValues.resize(m_aBoundValues.size());
979 : 0 : ValueList::const_iterator src = m_aBoundValues.begin();
980 : 0 : const ValueList::const_iterator end = m_aBoundValues.end();
981 : 0 : ValueList::iterator dst = m_aConvertedBoundValues.begin();
982 [ # # ][ # # ]: 0 : for (; src != end; ++src, ++dst )
[ # # ][ # # ]
983 : : {
984 [ # # ][ # # ]: 0 : *dst = *src;
[ # # ]
985 [ # # ][ # # ]: 0 : dst->setTypeKind(nFieldType);
986 : : }
987 : 0 : m_nConvertedBoundValuesType = nFieldType;
988 : : OSL_ENSURE(dst == m_aConvertedBoundValues.end(), "OListBoxModel::convertBoundValues expected to have overwritten all of m_aConvertedBoundValues, but did not.");
989 : 0 : }
990 : : //------------------------------------------------------------------------------
991 : 0 : sal_Int32 OListBoxModel::getValueType() const
992 : : {
993 [ # # ]: 0 : return impl_hasBoundComponent() ? m_nBoundColumnType : getFieldType();
994 : : }
995 : : //------------------------------------------------------------------------------
996 : 0 : ValueList OListBoxModel::impl_getValues() const
997 : : {
998 : 0 : const sal_Int32 nFieldType = getValueType();
999 : :
1000 [ # # ][ # # ]: 0 : if ( !m_aConvertedBoundValues.empty() && m_nConvertedBoundValuesType == nFieldType )
[ # # ]
1001 [ # # ]: 0 : return m_aConvertedBoundValues;
1002 : :
1003 [ # # ]: 0 : if ( !m_aBoundValues.empty() )
1004 : : {
1005 [ # # ]: 0 : convertBoundValues(nFieldType);
1006 [ # # ]: 0 : return m_aConvertedBoundValues;
1007 : : }
1008 : :
1009 [ # # ]: 0 : Sequence< ::rtl::OUString > aStringItems( getStringItemList() );
1010 [ # # ]: 0 : ValueList aValues( aStringItems.getLength() );
1011 : 0 : ValueList::iterator dst = aValues.begin();
1012 : 0 : const ::rtl::OUString *src (aStringItems.getConstArray());
1013 : 0 : const ::rtl::OUString * const end = src + aStringItems.getLength();
1014 [ # # ][ # # ]: 0 : for (; src < end; ++src, ++dst )
1015 : : {
1016 [ # # ][ # # ]: 0 : *dst = *src;
1017 [ # # ][ # # ]: 0 : dst->setTypeKind(nFieldType);
1018 : : }
1019 [ # # ]: 0 : return aValues;
1020 : : }
1021 : : //------------------------------------------------------------------------------
1022 : 0 : ORowSetValue OListBoxModel::getFirstSelectedValue() const
1023 : : {
1024 [ # # ][ # # ]: 0 : static const ORowSetValue s_aEmptyVaue;
1025 : :
1026 : : DBG_ASSERT( m_xAggregateFastSet.is(), "OListBoxModel::getFirstSelectedValue: invalid aggregate!" );
1027 [ # # ]: 0 : if ( !m_xAggregateFastSet.is() )
1028 [ # # ]: 0 : return s_aEmptyVaue;
1029 : :
1030 [ # # ]: 0 : Sequence< sal_Int16 > aSelectedIndices;
1031 [ # # ][ # # ]: 0 : OSL_VERIFY( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) >>= aSelectedIndices );
[ # # ]
1032 [ # # ]: 0 : if ( !aSelectedIndices.getLength() )
1033 : : // nothing selected at all
1034 [ # # ]: 0 : return s_aEmptyVaue;
1035 : :
1036 [ # # ][ # # ]: 0 : if ( ( m_nNULLPos != -1 ) && ( aSelectedIndices[0] == m_nNULLPos ) )
[ # # ][ # # ]
1037 : : // the dedicated "NULL" entry is selected
1038 [ # # ]: 0 : return s_aEmptyVaue;
1039 : :
1040 [ # # ]: 0 : ValueList aValues( impl_getValues() );
1041 : :
1042 [ # # ]: 0 : size_t selectedValue = aSelectedIndices[0];
1043 [ # # ]: 0 : if ( selectedValue >= aValues.size() )
1044 : : {
1045 : : OSL_FAIL( "OListBoxModel::getFirstSelectedValue: inconsistent selection/valuelist!" );
1046 [ # # ]: 0 : return s_aEmptyVaue;
1047 : : }
1048 : :
1049 [ # # ][ # # ]: 0 : return aValues[ selectedValue ];
[ # # ]
1050 : : }
1051 : :
1052 : : //------------------------------------------------------------------------------
1053 : 0 : sal_Bool OListBoxModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
1054 : : {
1055 : : // current selection list
1056 [ # # ]: 0 : const ORowSetValue aCurrentValue( getFirstSelectedValue() );
1057 [ # # ][ # # ]: 0 : if ( aCurrentValue != m_aSaveValue )
1058 : : {
1059 [ # # ]: 0 : if ( aCurrentValue.isNull() )
1060 [ # # ][ # # ]: 0 : m_xColumnUpdate->updateNull();
1061 : : else
1062 : : {
1063 : : try
1064 : : {
1065 [ # # ][ # # ]: 0 : m_xColumnUpdate->updateObject( aCurrentValue.makeAny() );
[ # # ][ # # ]
1066 : : }
1067 [ # # ]: 0 : catch ( const Exception& )
1068 : : {
1069 : 0 : return sal_False;
1070 : : }
1071 : : }
1072 [ # # ]: 0 : m_aSaveValue = aCurrentValue;
1073 : : }
1074 [ # # ]: 0 : return sal_True;
1075 : : }
1076 : :
1077 : : // XPropertiesChangeListener
1078 : : //------------------------------------------------------------------------------
1079 : 0 : Any OListBoxModel::translateDbColumnToControlValue()
1080 : : {
1081 : 0 : Reference< XPropertySet > xBoundField( getField() );
1082 [ # # ]: 0 : if ( !xBoundField.is() )
1083 : : {
1084 : : OSL_FAIL( "OListBoxModel::translateDbColumnToControlValue: no field? How could that happen?!" );
1085 : 0 : return Any();
1086 : : }
1087 : :
1088 [ # # ]: 0 : Sequence< sal_Int16 > aSelectionIndicies;
1089 : :
1090 : 0 : ORowSetValue aCurrentValue;
1091 [ # # ]: 0 : aCurrentValue.fill( getValueType(), m_xColumn );
1092 : :
1093 : : // reset selection for NULL values
1094 [ # # ]: 0 : if ( aCurrentValue.isNull() )
1095 : : {
1096 [ # # ]: 0 : if ( m_nNULLPos != -1 )
1097 : : {
1098 [ # # ]: 0 : aSelectionIndicies.realloc(1);
1099 [ # # ]: 0 : aSelectionIndicies[0] = m_nNULLPos;
1100 : : }
1101 : : }
1102 : : else
1103 : : {
1104 [ # # ]: 0 : ValueList aValues( impl_getValues() );
1105 [ # # ][ # # ]: 0 : ValueList::const_iterator curValuePos = ::std::find( aValues.begin(), aValues.end(), aCurrentValue );
1106 [ # # ][ # # ]: 0 : if ( curValuePos != aValues.end() )
1107 : : {
1108 [ # # ]: 0 : aSelectionIndicies.realloc( 1 );
1109 [ # # ][ # # ]: 0 : aSelectionIndicies[0] = curValuePos - aValues.begin();
1110 : 0 : }
1111 : : }
1112 : :
1113 [ # # ]: 0 : m_aSaveValue = aCurrentValue;
1114 : :
1115 [ # # ][ # # ]: 0 : return makeAny( aSelectionIndicies );
[ # # ]
1116 : : }
1117 : :
1118 : : // XReset
1119 : : //------------------------------------------------------------------------------
1120 : 38 : Any OListBoxModel::getDefaultForReset() const
1121 : : {
1122 : 38 : Any aValue;
1123 [ + + ]: 38 : if (m_aDefaultSelectSeq.getLength())
1124 [ + - ]: 20 : aValue <<= m_aDefaultSelectSeq;
1125 [ - + ]: 18 : else if (m_nNULLPos != -1) // bound Listbox
1126 : : {
1127 [ # # ]: 0 : Sequence<sal_Int16> aSeq(1);
1128 [ # # ]: 0 : aSeq.getArray()[0] = m_nNULLPos;
1129 [ # # ][ # # ]: 0 : aValue <<= aSeq;
1130 : : }
1131 : : else
1132 : : {
1133 [ + - ]: 18 : Sequence<sal_Int16> aSeq;
1134 [ + - ][ + - ]: 18 : aValue <<= aSeq;
1135 : : }
1136 : :
1137 : 38 : return aValue;
1138 : : }
1139 : :
1140 : : //--------------------------------------------------------------------
1141 : 38 : void OListBoxModel::resetNoBroadcast()
1142 : : {
1143 : 38 : OBoundControlModel::resetNoBroadcast();
1144 : 38 : m_aSaveValue.setNull();
1145 : 38 : }
1146 : :
1147 : : //--------------------------------------------------------------------
1148 : 0 : void SAL_CALL OListBoxModel::disposing( const EventObject& _rSource ) throw ( RuntimeException )
1149 : : {
1150 [ # # ]: 0 : if ( !OEntryListHelper::handleDisposing( _rSource ) )
1151 : 0 : OBoundControlModel::disposing( _rSource );
1152 : 0 : }
1153 : :
1154 : : //--------------------------------------------------------------------
1155 : : namespace
1156 : : {
1157 : : // The type of how we should transfer our selection to external value bindings
1158 : : enum ExchangeType
1159 : : {
1160 : : eIndexList, /// as list of indexes of selected entries
1161 : : eIndex, /// as index of the selected entry
1162 : : eEntryList, /// as list of string representations of selected entries
1163 : : eEntry /// as string representation of the selected entry
1164 : : };
1165 : :
1166 : : //--------------------------------------------------------------------
1167 : 4 : ExchangeType lcl_getCurrentExchangeType( const Type& _rExchangeType )
1168 : : {
1169 [ - - + - ]: 4 : switch ( _rExchangeType.getTypeClass() )
1170 : : {
1171 : : case TypeClass_STRING:
1172 : 0 : return eEntry;
1173 : : case TypeClass_LONG:
1174 : 0 : return eIndex;
1175 : : case TypeClass_SEQUENCE:
1176 : : {
1177 [ + - ]: 4 : Type aElementType = ::comphelper::getSequenceElementType( _rExchangeType );
1178 [ - + - ]: 4 : switch ( aElementType.getTypeClass() )
1179 : : {
1180 : : case TypeClass_STRING:
1181 : 0 : return eEntryList;
1182 : : case TypeClass_LONG:
1183 : 4 : return eIndexList;
1184 : : default:
1185 : 0 : break;
1186 [ - + ]: 4 : }
1187 : : }
1188 : : default:
1189 : 0 : break;
1190 : : }
1191 : : OSL_FAIL( "lcl_getCurrentExchangeType: unsupported (unexpected) exchange type!" );
1192 : 4 : return eEntry;
1193 : : }
1194 : : }
1195 : :
1196 : : //--------------------------------------------------------------------
1197 : 4 : Any OListBoxModel::translateExternalValueToControlValue( const Any& _rExternalValue ) const
1198 : : {
1199 [ + - ]: 4 : Sequence< sal_Int16 > aSelectIndexes;
1200 : :
1201 [ + - ][ + - : 4 : switch ( lcl_getCurrentExchangeType( getExternalValueType() ) )
- - - ]
1202 : : {
1203 : : case eIndexList:
1204 : : {
1205 : : // unfortunately, our select sequence is a sequence<short>, while the external binding
1206 : : // supplies sequence<int> only -> transform this
1207 [ + - ]: 4 : Sequence< sal_Int32 > aSelectIndexesPure;
1208 [ + - ]: 4 : OSL_VERIFY( _rExternalValue >>= aSelectIndexesPure );
1209 [ + - ]: 4 : aSelectIndexes.realloc( aSelectIndexesPure.getLength() );
1210 : : ::std::copy(
1211 : : aSelectIndexesPure.getConstArray(),
1212 : 4 : aSelectIndexesPure.getConstArray() + aSelectIndexesPure.getLength(),
1213 : : aSelectIndexes.getArray()
1214 [ + - + - ]: 8 : );
[ + - ]
1215 : : }
1216 : 4 : break;
1217 : :
1218 : : case eIndex:
1219 : : {
1220 : 0 : sal_Int32 nSelectIndex = -1;
1221 : 0 : OSL_VERIFY( _rExternalValue >>= nSelectIndex );
1222 [ # # ][ # # ]: 0 : if ( ( nSelectIndex >= 0 ) && ( nSelectIndex < getStringItemList().getLength() ) )
[ # # ]
1223 : : {
1224 [ # # ]: 0 : aSelectIndexes.realloc( 1 );
1225 [ # # ]: 0 : aSelectIndexes[ 0 ] = static_cast< sal_Int16 >( nSelectIndex );
1226 : : }
1227 : : }
1228 : 0 : break;
1229 : :
1230 : : case eEntryList:
1231 : : {
1232 : : // we can retrieve a string list from the binding for multiple selection
1233 [ # # ]: 0 : Sequence< ::rtl::OUString > aSelectEntries;
1234 [ # # ]: 0 : OSL_VERIFY( _rExternalValue >>= aSelectEntries );
1235 : :
1236 [ # # ]: 0 : ::std::set< sal_Int16 > aSelectionSet;
1237 : :
1238 : : // find the selection entries in our item list
1239 [ # # ]: 0 : const ::rtl::OUString* pSelectEntries = aSelectEntries.getArray();
1240 : 0 : const ::rtl::OUString* pSelectEntriesEnd = pSelectEntries + aSelectEntries.getLength();
1241 [ # # ]: 0 : while ( pSelectEntries != pSelectEntriesEnd )
1242 : : {
1243 : : // the indexes where the current string appears in our string items
1244 [ # # ]: 0 : Sequence< sal_Int16 > aThisEntryIndexes;
1245 [ # # ][ # # ]: 0 : aThisEntryIndexes = findValue( getStringItemList(), *pSelectEntries++, sal_False );
[ # # ]
1246 : :
1247 : : // insert all the indexes of this entry into our set
1248 : : ::std::copy(
1249 : : aThisEntryIndexes.getConstArray(),
1250 : 0 : aThisEntryIndexes.getConstArray() + aThisEntryIndexes.getLength(),
1251 : : ::std::insert_iterator< ::std::set< sal_Int16 > >( aSelectionSet, aSelectionSet.begin() )
1252 [ # # # # ]: 0 : );
1253 [ # # ]: 0 : }
1254 : :
1255 : : // copy the indexes to the sequence
1256 [ # # ]: 0 : aSelectIndexes.realloc( aSelectionSet.size() );
1257 : : ::std::copy(
1258 : : aSelectionSet.begin(),
1259 : : aSelectionSet.end(),
1260 : : aSelectIndexes.getArray()
1261 [ # # ][ # # ]: 0 : );
[ # # ]
1262 : : }
1263 : 0 : break;
1264 : :
1265 : : case eEntry:
1266 : : {
1267 : 0 : ::rtl::OUString sStringToSelect;
1268 : 0 : OSL_VERIFY( _rExternalValue >>= sStringToSelect );
1269 : :
1270 [ # # ][ # # ]: 0 : aSelectIndexes = findValue( getStringItemList(), sStringToSelect, sal_False );
[ # # ]
1271 : : }
1272 : 0 : break;
1273 : : }
1274 : :
1275 [ + - ][ + - ]: 4 : return makeAny( aSelectIndexes );
1276 : : }
1277 : :
1278 : : //--------------------------------------------------------------------
1279 : : namespace
1280 : : {
1281 : : //................................................................
1282 : : struct ExtractStringFromSequence_Safe : public ::std::unary_function< sal_Int16, ::rtl::OUString >
1283 : : {
1284 : : protected:
1285 : : const Sequence< ::rtl::OUString >& m_rList;
1286 : :
1287 : : public:
1288 : 0 : ExtractStringFromSequence_Safe( const Sequence< ::rtl::OUString >& _rList ) : m_rList( _rList ) { }
1289 : :
1290 : 0 : ::rtl::OUString operator ()( sal_Int16 _nIndex )
1291 : : {
1292 : : OSL_ENSURE( _nIndex < m_rList.getLength(), "ExtractStringFromSequence_Safe: inconsistence!" );
1293 [ # # ]: 0 : if ( _nIndex < m_rList.getLength() )
1294 : 0 : return m_rList[ _nIndex ];
1295 : 0 : return ::rtl::OUString();
1296 : : }
1297 : : };
1298 : :
1299 : : //................................................................
1300 : 2 : Any lcl_getSingleSelectedEntry( const Sequence< sal_Int16 >& _rSelectSequence, const Sequence< ::rtl::OUString >& _rStringList )
1301 : : {
1302 : 2 : Any aReturn;
1303 : :
1304 : : // by definition, multiple selected entries are transfered as NULL if the
1305 : : // binding does not support string lists
1306 [ + - ]: 2 : if ( _rSelectSequence.getLength() <= 1 )
1307 : : {
1308 : 2 : ::rtl::OUString sSelectedEntry;
1309 : :
1310 [ - + ]: 2 : if ( _rSelectSequence.getLength() == 1 )
1311 [ # # ]: 0 : sSelectedEntry = ExtractStringFromSequence_Safe( _rStringList )( _rSelectSequence[0] );
1312 : :
1313 [ + - ]: 2 : aReturn <<= sSelectedEntry;
1314 : : }
1315 : :
1316 : 2 : return aReturn;
1317 : : }
1318 : :
1319 : : //................................................................
1320 : 0 : Any lcl_getMultiSelectedEntries( const Sequence< sal_Int16 >& _rSelectSequence, const Sequence< ::rtl::OUString >& _rStringList )
1321 : : {
1322 [ # # ]: 0 : Sequence< ::rtl::OUString > aSelectedEntriesTexts( _rSelectSequence.getLength() );
1323 : : ::std::transform(
1324 : : _rSelectSequence.getConstArray(),
1325 : 0 : _rSelectSequence.getConstArray() + _rSelectSequence.getLength(),
1326 : : aSelectedEntriesTexts.getArray(),
1327 : : ExtractStringFromSequence_Safe( _rStringList )
1328 [ # # # # ]: 0 : );
1329 [ # # ][ # # ]: 0 : return makeAny( aSelectedEntriesTexts );
1330 : : }
1331 : : }
1332 : :
1333 : : //--------------------------------------------------------------------
1334 : 0 : Any OListBoxModel::translateControlValueToExternalValue( ) const
1335 : : {
1336 : : OSL_PRECOND( hasExternalValueBinding(), "OListBoxModel::translateControlValueToExternalValue: no binding!" );
1337 : :
1338 [ # # ]: 0 : Sequence< sal_Int16 > aSelectSequence;
1339 [ # # ][ # # ]: 0 : const_cast< OListBoxModel* >( this )->getPropertyValue( PROPERTY_SELECT_SEQ ) >>= aSelectSequence;
[ # # ]
1340 : :
1341 : 0 : Any aReturn;
1342 [ # # # # : 0 : switch ( lcl_getCurrentExchangeType( getExternalValueType() ) )
# ][ # # ]
1343 : : {
1344 : : case eIndexList:
1345 : : {
1346 : : // unfortunately, the select sequence is a sequence<short>, but our binding
1347 : : // expects int's
1348 [ # # ]: 0 : Sequence< sal_Int32 > aTransformed( aSelectSequence.getLength() );
1349 : : ::std::copy(
1350 : : aSelectSequence.getConstArray(),
1351 : 0 : aSelectSequence.getConstArray() + aSelectSequence.getLength(),
1352 : : aTransformed.getArray()
1353 [ # # # # ]: 0 : );
1354 [ # # ][ # # ]: 0 : aReturn <<= aTransformed;
1355 : : }
1356 : 0 : break;
1357 : :
1358 : : case eIndex:
1359 [ # # ]: 0 : if ( aSelectSequence.getLength() <= 1 )
1360 : : {
1361 : 0 : sal_Int32 nIndex = -1;
1362 : :
1363 [ # # ]: 0 : if ( aSelectSequence.getLength() == 1 )
1364 [ # # ]: 0 : nIndex = aSelectSequence[0];
1365 : :
1366 [ # # ]: 0 : aReturn <<= nIndex;
1367 : : }
1368 : 0 : break;
1369 : :
1370 : : case eEntryList:
1371 [ # # ]: 0 : aReturn = lcl_getMultiSelectedEntries( aSelectSequence, getStringItemList() );
1372 : 0 : break;
1373 : :
1374 : : case eEntry:
1375 [ # # ]: 0 : aReturn = lcl_getSingleSelectedEntry( aSelectSequence, getStringItemList() );
1376 : 0 : break;
1377 : : }
1378 : :
1379 [ # # ]: 0 : return aReturn;
1380 : : }
1381 : :
1382 : : //--------------------------------------------------------------------
1383 : 2 : Any OListBoxModel::getCurrentFormComponentValue() const
1384 : : {
1385 [ - + ]: 2 : if ( hasValidator() )
1386 [ # # ]: 0 : return OBoundControlModel::getCurrentFormComponentValue();
1387 : :
1388 : 2 : Any aCurretnValue;
1389 : :
1390 : : try
1391 : : {
1392 [ + - ]: 2 : Sequence< sal_Int16 > aSelectSequence;
1393 [ + - ][ + - ]: 2 : OSL_VERIFY( const_cast< OListBoxModel* >( this )->getPropertyValue( PROPERTY_SELECT_SEQ ) >>= aSelectSequence );
[ + - ]
1394 : :
1395 : 2 : sal_Bool bMultiSelection( sal_False );
1396 [ + - ][ + - ]: 2 : OSL_VERIFY( const_cast< OListBoxModel* >( this )->getPropertyValue( PROPERTY_MULTISELECTION ) >>= bMultiSelection );
1397 : :
1398 [ - + ]: 2 : if ( bMultiSelection )
1399 [ # # ]: 0 : aCurretnValue = lcl_getMultiSelectedEntries( aSelectSequence, getStringItemList() );
1400 : : else
1401 [ + - ][ + - ]: 2 : aCurretnValue = lcl_getSingleSelectedEntry( aSelectSequence, getStringItemList() );
[ # # ]
1402 : : }
1403 [ # # ]: 0 : catch( const Exception& )
1404 : : {
1405 : : DBG_UNHANDLED_EXCEPTION();
1406 : : }
1407 : :
1408 : 2 : return aCurretnValue;
1409 : : }
1410 : :
1411 : : //--------------------------------------------------------------------
1412 : 8 : Sequence< Type > OListBoxModel::getSupportedBindingTypes()
1413 : : {
1414 : 8 : Sequence< Type > aTypes(4);
1415 [ + - ][ + - ]: 8 : aTypes[0] = ::getCppuType( static_cast< Sequence< sal_Int32 >* >( NULL ) );
1416 [ + - ][ + - ]: 8 : aTypes[1] = ::getCppuType( static_cast< sal_Int32* >( NULL ) );
1417 [ + - ][ + - ]: 8 : aTypes[2] = ::getCppuType( static_cast< Sequence< ::rtl::OUString >* >( NULL ) );
1418 [ + - ][ + - ]: 8 : aTypes[3] = ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
1419 : 8 : return aTypes;
1420 : : }
1421 : :
1422 : : //--------------------------------------------------------------------
1423 : 34 : void OListBoxModel::stringItemListChanged( ControlModelLock& _rInstanceLock )
1424 : : {
1425 [ - + ]: 34 : if ( !m_xAggregateSet.is() )
1426 : 34 : return;
1427 : :
1428 : 34 : suspendValueListening();
1429 : : try
1430 : : {
1431 [ + - ][ + - ]: 34 : m_xAggregateSet->setPropertyValue( PROPERTY_STRINGITEMLIST, makeAny( getStringItemList() ) );
[ + - ][ # # ]
[ + - ]
1432 : : }
1433 : 0 : catch( const Exception& )
1434 : : {
1435 : : DBG_UNHANDLED_EXCEPTION();
1436 : : }
1437 : 34 : resumeValueListening();
1438 : :
1439 : : // update the selection here
1440 [ - + ]: 34 : if ( hasExternalValueBinding( ) )
1441 : 0 : transferExternalValueToControl( _rInstanceLock );
1442 : : else
1443 : : {
1444 [ + - ]: 34 : if ( hasField() )
1445 : : {
1446 : : // TODO: update the selection in case we're bound to a database column
1447 : : }
1448 : : else
1449 : : {
1450 [ + + ]: 34 : if ( m_aDefaultSelectSeq.getLength() )
1451 [ + - ]: 20 : setControlValue( makeAny( m_aDefaultSelectSeq ), eOther );
1452 : : }
1453 : : }
1454 : : }
1455 : :
1456 : : //--------------------------------------------------------------------
1457 : 0 : void OListBoxModel::connectedExternalListSource( )
1458 : : {
1459 : : // TODO?
1460 : 0 : }
1461 : :
1462 : : //--------------------------------------------------------------------
1463 : 0 : void OListBoxModel::disconnectedExternalListSource( )
1464 : : {
1465 : : // TODO: in case we're part of an already loaded form, we should probably simulate
1466 : : // an onConnectedDbColumn, so our list get's filled with the data as indicated
1467 : : // by our SQL-binding related properties
1468 : 0 : }
1469 : :
1470 : : //--------------------------------------------------------------------
1471 : 0 : void OListBoxModel::impl_refreshDbEntryList( bool _bForce )
1472 : : {
1473 : : DBG_ASSERT( !hasExternalListSource(), "OListBoxModel::impl_refreshDbEntryList: invalid call!" );
1474 : :
1475 [ # # ]: 0 : if ( !hasExternalListSource( )
[ # # # # ]
[ # # ]
1476 : : && ( m_eListSourceType != ListSourceType_VALUELIST )
1477 : 0 : && ( m_xCursor.is() )
1478 : : )
1479 : : {
1480 : 0 : loadData( _bForce );
1481 : : }
1482 : 0 : }
1483 : :
1484 : : //--------------------------------------------------------------------
1485 : 0 : void OListBoxModel::refreshInternalEntryList()
1486 : : {
1487 : 0 : impl_refreshDbEntryList( true );
1488 [ # # ][ # # ]: 0 : if ( hasField() && m_xCursor.is() )
[ # # ]
1489 : 0 : initFromField( m_xCursor );
1490 : 0 : }
1491 : :
1492 : : //==================================================================
1493 : : // OListBoxControl
1494 : : //==================================================================
1495 : :
1496 : : //------------------------------------------------------------------
1497 : 12 : InterfaceRef SAL_CALL OListBoxControl_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException)
1498 : : {
1499 [ + - ]: 12 : return *(new OListBoxControl(_rxFactory));
1500 : : }
1501 : :
1502 : : //------------------------------------------------------------------------------
1503 : 0 : Sequence< Type> OListBoxControl::_getTypes()
1504 : : {
1505 : : return TypeBag(
1506 : : OBoundControl::_getTypes(),
1507 : : OListBoxControl_BASE::getTypes()
1508 [ # # ][ # # ]: 0 : ).getTypes();
[ # # ][ # # ]
1509 : : }
1510 : :
1511 : : //------------------------------------------------------------------
1512 : 1943 : Any SAL_CALL OListBoxControl::queryAggregation(const Type& _rType) throw (RuntimeException)
1513 : : {
1514 : 1943 : Any aReturn = OListBoxControl_BASE::queryInterface( _rType );
1515 : :
1516 [ + + ]: 2277 : if ( !aReturn.hasValue()
[ + + - + ]
1517 [ + - ]: 334 : || _rType.equals( XTypeProvider::static_type() )
1518 : : )
1519 [ + - ]: 1609 : aReturn = OBoundControl::queryAggregation( _rType );
1520 : :
1521 : 1943 : return aReturn;
1522 : : }
1523 : :
1524 : : DBG_NAME(OListBoxControl);
1525 : : //------------------------------------------------------------------------------
1526 : 12 : OListBoxControl::OListBoxControl(const Reference<XMultiServiceFactory>& _rxFactory)
1527 : : :OBoundControl( _rxFactory, VCL_CONTROL_LISTBOX, sal_False )
1528 : : ,m_aChangeListeners( m_aMutex )
1529 [ + - ][ + - ]: 12 : ,m_aItemListeners( m_aMutex )
[ + - ][ + - ]
1530 : : {
1531 : : DBG_CTOR(OListBoxControl,NULL);
1532 : :
1533 [ + - ]: 12 : increment(m_refCount);
1534 : : {
1535 : : // Register as FocusListener
1536 : 12 : Reference<XWindow> xComp;
1537 [ + - ][ + - ]: 12 : if (query_aggregation(m_xAggregate, xComp))
1538 [ + - ][ + - ]: 12 : xComp->addFocusListener(this);
[ + - ]
1539 : :
1540 : : // Register as ItemListener
1541 [ + - ][ + - ]: 12 : if ( query_aggregation( m_xAggregate, m_xAggregateListBox ) )
1542 [ + - ][ + - ]: 12 : m_xAggregateListBox->addItemListener(this);
[ + - ]
1543 : : }
1544 : : // Refcount at 2 for registered Listener
1545 [ + - ]: 12 : decrement(m_refCount);
1546 : :
1547 [ + - ]: 12 : doSetDelegator();
1548 : :
1549 [ + - ]: 12 : m_aChangeTimer.SetTimeout(500);
1550 [ + - ]: 12 : m_aChangeTimer.SetTimeoutHdl(LINK(this,OListBoxControl,OnTimeout));
1551 : 12 : }
1552 : :
1553 : : //------------------------------------------------------------------------------
1554 [ + - ][ + - ]: 12 : OListBoxControl::~OListBoxControl()
[ + - ][ + - ]
1555 : : {
1556 [ - + ]: 12 : if (!OComponentHelper::rBHelper.bDisposed)
1557 : : {
1558 : 0 : acquire();
1559 [ # # ]: 0 : dispose();
1560 : : }
1561 : :
1562 [ + - ]: 12 : doResetDelegator();
1563 : 12 : m_xAggregateListBox.clear();
1564 : :
1565 : : DBG_DTOR(OListBoxControl,NULL);
1566 [ - + ]: 24 : }
1567 : :
1568 : : //------------------------------------------------------------------------------
1569 : 0 : StringSequence SAL_CALL OListBoxControl::getSupportedServiceNames() throw(RuntimeException)
1570 : : {
1571 : 0 : StringSequence aSupported = OBoundControl::getSupportedServiceNames();
1572 [ # # ]: 0 : aSupported.realloc(aSupported.getLength() + 1);
1573 : :
1574 [ # # ]: 0 : ::rtl::OUString* pArray = aSupported.getArray();
1575 [ # # ]: 0 : pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_LISTBOX;
1576 : 0 : return aSupported;
1577 : : }
1578 : :
1579 : :
1580 : : // XFocusListener
1581 : : //------------------------------------------------------------------------------
1582 : 0 : void SAL_CALL OListBoxControl::focusGained(const FocusEvent& /*_rEvent*/) throw(RuntimeException)
1583 : : {
1584 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
1585 [ # # ][ # # ]: 0 : if ( m_aChangeListeners.getLength() ) // only if there are listeners
1586 : : {
1587 [ # # ][ # # ]: 0 : Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
1588 [ # # ]: 0 : if (xSet.is())
1589 : : {
1590 : : // memorize the current selection for posting the change event
1591 [ # # ][ # # ]: 0 : m_aCurrentSelection = xSet->getPropertyValue(PROPERTY_SELECT_SEQ);
[ # # ]
1592 : 0 : }
1593 [ # # ]: 0 : }
1594 : 0 : }
1595 : :
1596 : : //------------------------------------------------------------------------------
1597 : 0 : void SAL_CALL OListBoxControl::focusLost(const FocusEvent& /*_rEvent*/) throw(RuntimeException)
1598 : : {
1599 : 0 : m_aCurrentSelection.clear();
1600 : 0 : }
1601 : :
1602 : : // XItemListener
1603 : : //------------------------------------------------------------------------------
1604 : 52 : void SAL_CALL OListBoxControl::itemStateChanged(const ItemEvent& _rEvent) throw(RuntimeException)
1605 : : {
1606 : : // forward this to our listeners
1607 [ + - ][ + - ]: 52 : Reference< XChild > xChild( getModel(), UNO_QUERY );
1608 [ + - ][ + - ]: 52 : if ( xChild.is() && xChild->getParent().is() )
[ + - ][ + - ]
[ + - # # ]
[ + - ]
1609 : : {
1610 [ + - ]: 52 : ::osl::MutexGuard aGuard( m_aMutex );
1611 [ + - ][ + - ]: 52 : if ( m_aItemListeners.getLength() )
1612 : : {
1613 [ + + ]: 52 : if ( !m_pItemBroadcaster.is() )
1614 : : {
1615 : : m_pItemBroadcaster.set(
1616 [ + - ][ + - ]: 2 : new ::comphelper::AsyncEventNotifier("ListBox"));
[ + - ]
1617 [ + - ]: 2 : m_pItemBroadcaster->launch();
1618 : : }
1619 [ + - ][ + - ]: 52 : m_pItemBroadcaster->addEvent( new ItemEventDescription( _rEvent ), this );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1620 [ + - ]: 52 : }
1621 : : }
1622 : : else
1623 [ # # ]: 0 : m_aItemListeners.notifyEach( &XItemListener::itemStateChanged, _rEvent );
1624 : :
1625 : : // and do the handling for the ChangeListeners
1626 [ + - ]: 52 : ::osl::ClearableMutexGuard aGuard(m_aMutex);
1627 [ - + ]: 52 : if ( m_aChangeTimer.IsActive() )
1628 : : {
1629 [ # # ][ # # ]: 0 : Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
1630 [ # # ][ # # ]: 0 : m_aCurrentSelection = xSet->getPropertyValue(PROPERTY_SELECT_SEQ);
[ # # ]
1631 : :
1632 [ # # ]: 0 : m_aChangeTimer.Stop();
1633 [ # # ]: 0 : m_aChangeTimer.Start();
1634 : : }
1635 : : else
1636 : : {
1637 [ + - ][ - + ]: 52 : if ( m_aChangeListeners.getLength() && m_aCurrentSelection.hasValue() )
[ # # ][ - + ]
1638 : : {
1639 [ # # ][ # # ]: 0 : Reference<XPropertySet> xSet(getModel(), UNO_QUERY);
1640 [ # # ]: 0 : if (xSet.is())
1641 : : {
1642 : : // Has the selection been changed?
1643 : 0 : sal_Bool bModified(sal_False);
1644 [ # # ][ # # ]: 0 : Any aValue = xSet->getPropertyValue(PROPERTY_SELECT_SEQ);
[ # # ]
1645 : :
1646 : 0 : Sequence<sal_Int16>& rSelection = *(Sequence<sal_Int16> *)aValue.getValue();
1647 : 0 : Sequence<sal_Int16>& rOldSelection = *(Sequence<sal_Int16> *)m_aCurrentSelection.getValue();
1648 : 0 : sal_Int32 nLen = rSelection.getLength();
1649 [ # # ]: 0 : if (nLen != rOldSelection.getLength())
1650 : 0 : bModified = sal_True;
1651 : : else
1652 : : {
1653 : 0 : const sal_Int16* pVal = rSelection.getConstArray();
1654 : 0 : const sal_Int16* pCompVal = rOldSelection.getConstArray();
1655 : :
1656 [ # # ][ # # ]: 0 : while (nLen-- && !bModified)
[ # # ]
1657 : 0 : bModified = pVal[nLen] != pCompVal[nLen];
1658 : : }
1659 : :
1660 [ # # ]: 0 : if (bModified)
1661 : : {
1662 : 0 : m_aCurrentSelection = aValue;
1663 [ # # ]: 0 : m_aChangeTimer.Start();
1664 : 0 : }
1665 : 0 : }
1666 : : }
1667 [ - + ]: 52 : else if (m_aCurrentSelection.hasValue())
1668 : 0 : m_aCurrentSelection.clear();
1669 [ + - ]: 52 : }
1670 : 52 : }
1671 : :
1672 : : // XEventListener
1673 : : //------------------------------------------------------------------------------
1674 : 66 : void SAL_CALL OListBoxControl::disposing(const EventObject& _rSource) throw (RuntimeException)
1675 : : {
1676 : 66 : OBoundControl::disposing(_rSource);
1677 : 66 : }
1678 : :
1679 : : // XChangeBroadcaster
1680 : : //------------------------------------------------------------------------------
1681 : 0 : void SAL_CALL OListBoxControl::addChangeListener(const Reference<XChangeListener>& _rxListener) throw(RuntimeException)
1682 : : {
1683 : 0 : m_aChangeListeners.addInterface( _rxListener );
1684 : 0 : }
1685 : :
1686 : : //------------------------------------------------------------------------------
1687 : 0 : void SAL_CALL OListBoxControl::removeChangeListener(const Reference<XChangeListener>& _rxListener) throw(RuntimeException)
1688 : : {
1689 : 0 : m_aChangeListeners.removeInterface( _rxListener );
1690 : 0 : }
1691 : :
1692 : : // OComponentHelper
1693 : : //------------------------------------------------------------------------------
1694 : 12 : void OListBoxControl::disposing()
1695 : : {
1696 [ - + ]: 12 : if (m_aChangeTimer.IsActive())
1697 [ # # ]: 0 : m_aChangeTimer.Stop();
1698 : :
1699 [ + - ][ + - ]: 12 : EventObject aEvent( *this );
1700 [ + - ]: 12 : m_aChangeListeners.disposeAndClear( aEvent );
1701 [ + - ]: 12 : m_aItemListeners.disposeAndClear( aEvent );
1702 : :
1703 : 12 : rtl::Reference< comphelper::AsyncEventNotifier > t;
1704 : : {
1705 [ + - ]: 12 : ::osl::MutexGuard aGuard( m_aMutex );
1706 [ + + ]: 12 : if ( m_pItemBroadcaster.is() )
1707 : : {
1708 [ + - ]: 2 : t = m_pItemBroadcaster;
1709 [ + - ][ + - ]: 2 : m_pItemBroadcaster->removeEventsForProcessor( this );
[ + - ]
1710 [ + - ]: 2 : m_pItemBroadcaster->terminate();
1711 [ + - ]: 2 : m_pItemBroadcaster = NULL;
1712 [ + - ]: 12 : }
1713 : : }
1714 [ + + ]: 12 : if (t.is()) {
1715 [ + - ]: 2 : t->join();
1716 : : }
1717 : :
1718 [ + - ][ + - ]: 12 : OBoundControl::disposing();
[ + - ]
1719 : 12 : }
1720 : :
1721 : : //------------------------------------------------------------------------------
1722 : 52 : void OListBoxControl::processEvent( const AnyEvent& _rEvent )
1723 : : {
1724 [ + - ]: 52 : Reference< XListBox > xKeepAlive( this );
1725 : : {
1726 [ + - ]: 52 : ::osl::MutexGuard aGuard( m_aMutex );
1727 [ - + ]: 52 : if ( OComponentHelper::rBHelper.bDisposed )
1728 [ + - ][ + - ]: 104 : return;
1729 : : }
1730 : 52 : const ItemEventDescription& rItemEvent = static_cast< const ItemEventDescription& >( _rEvent );
1731 [ + - ][ + - ]: 52 : m_aItemListeners.notifyEach( &XItemListener::itemStateChanged, rItemEvent.getEventObject() );
1732 : : }
1733 : :
1734 : : //------------------------------------------------------------------------------
1735 : 0 : IMPL_LINK(OListBoxControl, OnTimeout, void*, /*EMPTYTAG*/)
1736 : : {
1737 [ # # ][ # # ]: 0 : m_aChangeListeners.notifyEach( &XChangeListener::changed, EventObject( *this ) );
[ # # ]
1738 : 0 : return 0L;
1739 : : }
1740 : :
1741 : : //--------------------------------------------------------------------
1742 : 4 : void SAL_CALL OListBoxControl::addItemListener( const Reference< XItemListener >& l ) throw (RuntimeException)
1743 : : {
1744 : 4 : m_aItemListeners.addInterface( l );
1745 : 4 : }
1746 : :
1747 : : //--------------------------------------------------------------------
1748 : 0 : void SAL_CALL OListBoxControl::removeItemListener( const Reference< XItemListener >& l ) throw (RuntimeException)
1749 : : {
1750 : 0 : m_aItemListeners.removeInterface( l );
1751 : 0 : }
1752 : :
1753 : : //--------------------------------------------------------------------
1754 : 2 : void SAL_CALL OListBoxControl::addActionListener( const Reference< XActionListener >& l ) throw (RuntimeException)
1755 : : {
1756 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1757 : 2 : m_xAggregateListBox->addActionListener( l );
1758 : 2 : }
1759 : :
1760 : : //--------------------------------------------------------------------
1761 : 0 : void SAL_CALL OListBoxControl::removeActionListener( const Reference< XActionListener >& l ) throw (RuntimeException)
1762 : : {
1763 [ # # ]: 0 : if ( m_xAggregateListBox.is() )
1764 : 0 : m_xAggregateListBox->removeActionListener( l );
1765 : 0 : }
1766 : :
1767 : : //--------------------------------------------------------------------
1768 : 6 : void SAL_CALL OListBoxControl::addItem( const ::rtl::OUString& aItem, ::sal_Int16 nPos ) throw (RuntimeException)
1769 : : {
1770 [ + - ]: 6 : if ( m_xAggregateListBox.is() )
1771 : 6 : m_xAggregateListBox->addItem( aItem, nPos );
1772 : 6 : }
1773 : :
1774 : : //--------------------------------------------------------------------
1775 : 2 : void SAL_CALL OListBoxControl::addItems( const Sequence< ::rtl::OUString >& aItems, ::sal_Int16 nPos ) throw (RuntimeException)
1776 : : {
1777 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1778 : 2 : m_xAggregateListBox->addItems( aItems, nPos );
1779 : 2 : }
1780 : :
1781 : : //--------------------------------------------------------------------
1782 : 2 : void SAL_CALL OListBoxControl::removeItems( ::sal_Int16 nPos, ::sal_Int16 nCount ) throw (RuntimeException)
1783 : : {
1784 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1785 : 2 : m_xAggregateListBox->removeItems( nPos, nCount );
1786 : 2 : }
1787 : :
1788 : : //--------------------------------------------------------------------
1789 : 22 : ::sal_Int16 SAL_CALL OListBoxControl::getItemCount( ) throw (RuntimeException)
1790 : : {
1791 [ + - ]: 22 : if ( m_xAggregateListBox.is() )
1792 : 22 : return m_xAggregateListBox->getItemCount();
1793 : 22 : return 0;
1794 : : }
1795 : :
1796 : : //--------------------------------------------------------------------
1797 : 6 : ::rtl::OUString SAL_CALL OListBoxControl::getItem( ::sal_Int16 nPos ) throw (RuntimeException)
1798 : : {
1799 [ + - ]: 6 : if ( m_xAggregateListBox.is() )
1800 : 6 : return m_xAggregateListBox->getItem( nPos );
1801 : 6 : return ::rtl::OUString( );
1802 : : }
1803 : :
1804 : : //--------------------------------------------------------------------
1805 : 2 : Sequence< ::rtl::OUString > SAL_CALL OListBoxControl::getItems( ) throw (RuntimeException)
1806 : : {
1807 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1808 : 2 : return m_xAggregateListBox->getItems();
1809 : 2 : return Sequence< ::rtl::OUString >( );
1810 : : }
1811 : :
1812 : : //--------------------------------------------------------------------
1813 : 2 : ::sal_Int16 SAL_CALL OListBoxControl::getSelectedItemPos( ) throw (RuntimeException)
1814 : : {
1815 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1816 : 2 : return m_xAggregateListBox->getSelectedItemPos();
1817 : 2 : return 0;
1818 : : }
1819 : :
1820 : : //--------------------------------------------------------------------
1821 : 2 : Sequence< ::sal_Int16 > SAL_CALL OListBoxControl::getSelectedItemsPos( ) throw (RuntimeException)
1822 : : {
1823 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1824 : 2 : return m_xAggregateListBox->getSelectedItemsPos();
1825 : 2 : return Sequence< ::sal_Int16 >( );
1826 : : }
1827 : :
1828 : : //--------------------------------------------------------------------
1829 : 2 : ::rtl::OUString SAL_CALL OListBoxControl::getSelectedItem( ) throw (RuntimeException)
1830 : : {
1831 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1832 : 2 : return m_xAggregateListBox->getSelectedItem();
1833 : 2 : return ::rtl::OUString( );
1834 : : }
1835 : :
1836 : : //--------------------------------------------------------------------
1837 : 2 : Sequence< ::rtl::OUString > SAL_CALL OListBoxControl::getSelectedItems( ) throw (RuntimeException)
1838 : : {
1839 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1840 : 2 : return m_xAggregateListBox->getSelectedItems();
1841 : 2 : return Sequence< ::rtl::OUString >( );
1842 : : }
1843 : :
1844 : : //--------------------------------------------------------------------
1845 : 34 : void SAL_CALL OListBoxControl::selectItemPos( ::sal_Int16 nPos, ::sal_Bool bSelect ) throw (RuntimeException)
1846 : : {
1847 [ + - ]: 34 : if ( m_xAggregateListBox.is() )
1848 : 34 : m_xAggregateListBox->selectItemPos( nPos, bSelect );
1849 : 34 : }
1850 : :
1851 : : //--------------------------------------------------------------------
1852 : 6 : void SAL_CALL OListBoxControl::selectItemsPos( const Sequence< ::sal_Int16 >& aPositions, ::sal_Bool bSelect ) throw (RuntimeException)
1853 : : {
1854 [ + - ]: 6 : if ( m_xAggregateListBox.is() )
1855 : 6 : m_xAggregateListBox->selectItemsPos( aPositions, bSelect );
1856 : 6 : }
1857 : :
1858 : : //--------------------------------------------------------------------
1859 : 4 : void SAL_CALL OListBoxControl::selectItem( const ::rtl::OUString& aItem, ::sal_Bool bSelect ) throw (RuntimeException)
1860 : : {
1861 [ + - ]: 4 : if ( m_xAggregateListBox.is() )
1862 : 4 : m_xAggregateListBox->selectItem( aItem, bSelect );
1863 : 4 : }
1864 : :
1865 : : //--------------------------------------------------------------------
1866 : 2 : ::sal_Bool SAL_CALL OListBoxControl::isMutipleMode( ) throw (RuntimeException)
1867 : : {
1868 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1869 : 2 : return m_xAggregateListBox->isMutipleMode();
1870 : 2 : return sal_False;
1871 : : }
1872 : :
1873 : : //--------------------------------------------------------------------
1874 : 2 : void SAL_CALL OListBoxControl::setMultipleMode( ::sal_Bool bMulti ) throw (RuntimeException)
1875 : : {
1876 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1877 : 2 : m_xAggregateListBox->setMultipleMode( bMulti );
1878 : 2 : }
1879 : :
1880 : : //--------------------------------------------------------------------
1881 : 4 : ::sal_Int16 SAL_CALL OListBoxControl::getDropDownLineCount( ) throw (RuntimeException)
1882 : : {
1883 [ + - ]: 4 : if ( m_xAggregateListBox.is() )
1884 : 4 : return m_xAggregateListBox->getDropDownLineCount();
1885 : 4 : return 0;
1886 : : }
1887 : :
1888 : : //--------------------------------------------------------------------
1889 : 2 : void SAL_CALL OListBoxControl::setDropDownLineCount( ::sal_Int16 nLines ) throw (RuntimeException)
1890 : : {
1891 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1892 : 2 : m_xAggregateListBox->setDropDownLineCount( nLines );
1893 : 2 : }
1894 : :
1895 : : //--------------------------------------------------------------------
1896 : 2 : void SAL_CALL OListBoxControl::makeVisible( ::sal_Int16 nEntry ) throw (RuntimeException)
1897 : : {
1898 [ + - ]: 2 : if ( m_xAggregateListBox.is() )
1899 : 2 : m_xAggregateListBox->makeVisible( nEntry );
1900 : 2 : }
1901 : :
1902 : : //.........................................................................
1903 : : }
1904 : : //.........................................................................
1905 : :
1906 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|