Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 : : *
5 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
6 : : *
7 : : * OpenOffice.org - a multi-platform office productivity suite
8 : : *
9 : : * This file is part of OpenOffice.org.
10 : : *
11 : : * OpenOffice.org is free software: you can redistribute it and/or modify
12 : : * it under the terms of the GNU Lesser General Public License version 3
13 : : * only, as published by the Free Software Foundation.
14 : : *
15 : : * OpenOffice.org is distributed in the hope that it will be useful,
16 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : : * GNU Lesser General Public License version 3 for more details
19 : : * (a copy is included in the LICENSE file that accompanied this code).
20 : : *
21 : : * You should have received a copy of the GNU Lesser General Public License
22 : : * version 3 along with OpenOffice.org. If not, see
23 : : * <http://www.openoffice.org/license.html>
24 : : * for a copy of the LGPLv3 License.
25 : : *
26 : : ************************************************************************/
27 : :
28 : :
29 : : #include "toolkit/controls/animatedimages.hxx"
30 : : #include "toolkit/helper/servicenames.hxx"
31 : : #include "toolkit/helper/property.hxx"
32 : : #include "toolkit/helper/unopropertyarrayhelper.hxx"
33 : :
34 : : #include <com/sun/star/lang/DisposedException.hpp>
35 : : #include <com/sun/star/awt/VisualEffect.hpp>
36 : : #include <com/sun/star/awt/ImageScaleMode.hpp>
37 : : #include <com/sun/star/util/XModifyListener.hpp>
38 : :
39 : : //......................................................................................................................
40 : : namespace toolkit
41 : : {
42 : : //......................................................................................................................
43 : :
44 : : /** === begin UNO using === **/
45 : : using ::com::sun::star::uno::Reference;
46 : : using ::com::sun::star::uno::XInterface;
47 : : using ::com::sun::star::uno::UNO_QUERY;
48 : : using ::com::sun::star::uno::UNO_QUERY_THROW;
49 : : using ::com::sun::star::uno::UNO_SET_THROW;
50 : : using ::com::sun::star::uno::Exception;
51 : : using ::com::sun::star::uno::RuntimeException;
52 : : using ::com::sun::star::uno::Any;
53 : : using ::com::sun::star::uno::makeAny;
54 : : using ::com::sun::star::uno::Sequence;
55 : : using ::com::sun::star::uno::Type;
56 : : using ::com::sun::star::container::ContainerEvent;
57 : : using ::com::sun::star::container::XContainerListener;
58 : : using ::com::sun::star::beans::XPropertySetInfo;
59 : : using ::com::sun::star::lang::DisposedException;
60 : : using ::com::sun::star::lang::IndexOutOfBoundsException;
61 : : using ::com::sun::star::lang::EventObject;
62 : : using ::com::sun::star::awt::XControlModel;
63 : : using ::com::sun::star::awt::XAnimatedImages;
64 : : using ::com::sun::star::lang::IllegalArgumentException;
65 : : using ::com::sun::star::awt::XWindowPeer;
66 : : using ::com::sun::star::util::XModifyListener;
67 : : using ::com::sun::star::awt::XToolkit;
68 : : using ::com::sun::star::lang::XMultiServiceFactory;
69 : : /** === end UNO using === **/
70 : : namespace VisualEffect = ::com::sun::star::awt::VisualEffect;
71 : : namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
72 : :
73 : : //==================================================================================================================
74 : : //= AnimatedImagesControl
75 : : //==================================================================================================================
76 : : //------------------------------------------------------------------------------------------------------------------
77 : 0 : AnimatedImagesControl::AnimatedImagesControl( Reference< XMultiServiceFactory > const & i_factory )
78 : 0 : :AnimatedImagesControl_Base( i_factory )
79 : : {
80 : 0 : }
81 : :
82 : : //------------------------------------------------------------------------------------------------------------------
83 : 0 : ::rtl::OUString AnimatedImagesControl::GetComponentServiceName()
84 : : {
85 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AnimatedImages" ) );
86 : : }
87 : :
88 : : //------------------------------------------------------------------------------------------------------------------
89 : 0 : void SAL_CALL AnimatedImagesControl::startAnimation( ) throw (RuntimeException)
90 : : {
91 [ # # ][ # # ]: 0 : Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY );
92 [ # # ]: 0 : if ( xAnimation.is() )
93 [ # # ][ # # ]: 0 : xAnimation->startAnimation();
94 : 0 : }
95 : :
96 : : //------------------------------------------------------------------------------------------------------------------
97 : 0 : void SAL_CALL AnimatedImagesControl::stopAnimation( ) throw (RuntimeException)
98 : : {
99 [ # # ][ # # ]: 0 : Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY );
100 [ # # ]: 0 : if ( xAnimation.is() )
101 [ # # ][ # # ]: 0 : xAnimation->stopAnimation();
102 : 0 : }
103 : :
104 : : //------------------------------------------------------------------------------------------------------------------
105 : 0 : ::sal_Bool SAL_CALL AnimatedImagesControl::isAnimationRunning( ) throw (RuntimeException)
106 : : {
107 [ # # ][ # # ]: 0 : Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY );
108 [ # # ]: 0 : if ( xAnimation.is() )
109 [ # # ][ # # ]: 0 : return xAnimation->isAnimationRunning();
110 : 0 : return sal_False;
111 : : }
112 : :
113 : : //------------------------------------------------------------------------------------------------------------------
114 : 0 : ::rtl::OUString SAL_CALL AnimatedImagesControl::getImplementationName( ) throw(RuntimeException)
115 : : {
116 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.AnimatedImagesControl" ) );
117 : : }
118 : :
119 : : //------------------------------------------------------------------------------------------------------------------
120 : 0 : Sequence< ::rtl::OUString > SAL_CALL AnimatedImagesControl::getSupportedServiceNames() throw(RuntimeException)
121 : : {
122 : 0 : Sequence< ::rtl::OUString > aServices( AnimatedImagesControl_Base::getSupportedServiceNames() );
123 [ # # ]: 0 : aServices.realloc( aServices.getLength() + 1 );
124 [ # # ]: 0 : aServices[ aServices.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControl );
125 : 0 : return aServices;
126 : : }
127 : :
128 : : //------------------------------------------------------------------------------------------------------------------
129 : : namespace
130 : : {
131 : 0 : void lcl_updatePeer( Reference< XWindowPeer > const& i_peer, Reference< XControlModel > const& i_model )
132 : : {
133 [ # # ]: 0 : const Reference< XModifyListener > xPeerModify( i_peer, UNO_QUERY );
134 [ # # ]: 0 : if ( xPeerModify.is() )
135 : : {
136 [ # # ]: 0 : EventObject aEvent;
137 [ # # ]: 0 : aEvent.Source = i_model;
138 [ # # ][ # # ]: 0 : xPeerModify->modified( aEvent );
[ # # ]
139 : 0 : }
140 : 0 : }
141 : : }
142 : :
143 : : //------------------------------------------------------------------------------------------------------------------
144 : 0 : sal_Bool SAL_CALL AnimatedImagesControl::setModel( const Reference< XControlModel >& i_rModel ) throw ( RuntimeException )
145 : : {
146 [ # # ][ # # ]: 0 : const Reference< XAnimatedImages > xOldContainer( getModel(), UNO_QUERY );
147 [ # # ]: 0 : const Reference< XAnimatedImages > xNewContainer( i_rModel, UNO_QUERY );
148 : :
149 [ # # ][ # # ]: 0 : if ( !AnimatedImagesControl_Base::setModel( i_rModel ) )
150 : 0 : return sal_False;
151 : :
152 [ # # ]: 0 : if ( xOldContainer.is() )
153 [ # # ][ # # ]: 0 : xOldContainer->removeContainerListener( this );
[ # # ]
154 : :
155 [ # # ]: 0 : if ( xNewContainer.is() )
156 [ # # ][ # # ]: 0 : xNewContainer->addContainerListener( this );
[ # # ]
157 : :
158 [ # # ][ # # ]: 0 : lcl_updatePeer( getPeer(), getModel() );
[ # # ]
159 : :
160 : 0 : return sal_True;
161 : : }
162 : :
163 : : //------------------------------------------------------------------------------------------------------------------
164 : 0 : void SAL_CALL AnimatedImagesControl::createPeer( const Reference< XToolkit >& i_toolkit, const Reference< XWindowPeer >& i_parentPeer ) throw(RuntimeException)
165 : : {
166 : 0 : AnimatedImagesControl_Base::createPeer( i_toolkit, i_parentPeer );
167 : :
168 [ # # ][ # # ]: 0 : lcl_updatePeer( getPeer(), getModel() );
169 : 0 : }
170 : :
171 : : //------------------------------------------------------------------------------------------------------------------
172 : 0 : void SAL_CALL AnimatedImagesControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException)
173 : : {
174 [ # # ][ # # ]: 0 : const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY );
175 [ # # ]: 0 : if ( xPeerListener.is() )
176 [ # # ][ # # ]: 0 : xPeerListener->elementInserted( i_event );
177 : 0 : }
178 : :
179 : : //------------------------------------------------------------------------------------------------------------------
180 : 0 : void SAL_CALL AnimatedImagesControl::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException)
181 : : {
182 [ # # ][ # # ]: 0 : const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY );
183 [ # # ]: 0 : if ( xPeerListener.is() )
184 [ # # ][ # # ]: 0 : xPeerListener->elementRemoved( i_event );
185 : 0 : }
186 : :
187 : : //------------------------------------------------------------------------------------------------------------------
188 : 0 : void SAL_CALL AnimatedImagesControl::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException)
189 : : {
190 [ # # ][ # # ]: 0 : const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY );
191 [ # # ]: 0 : if ( xPeerListener.is() )
192 [ # # ][ # # ]: 0 : xPeerListener->elementReplaced( i_event );
193 : 0 : }
194 : :
195 : : //------------------------------------------------------------------------------------------------------------------
196 : 0 : void SAL_CALL AnimatedImagesControl::disposing( const EventObject& i_event ) throw (RuntimeException)
197 : : {
198 : 0 : UnoControlBase::disposing( i_event );
199 : 0 : }
200 : :
201 : : //==================================================================================================================
202 : : //= AnimatedImagesControlModel_Data
203 : : //==================================================================================================================
204 : 0 : struct AnimatedImagesControlModel_Data
205 : : {
206 : : ::std::vector< Sequence< ::rtl::OUString > > aImageSets;
207 : : };
208 : :
209 : : namespace
210 : : {
211 : 0 : void lcl_checkIndex( const AnimatedImagesControlModel_Data& i_data, const sal_Int32 i_index, const Reference< XInterface >& i_context,
212 : : const bool i_forInsert = false )
213 : : {
214 [ # # ][ # # ]: 0 : if ( ( i_index < 0 ) || ( size_t( i_index ) > i_data.aImageSets.size() + ( i_forInsert ? 1 : 0 ) ) )
[ # # ][ # # ]
215 [ # # ]: 0 : throw IndexOutOfBoundsException( ::rtl::OUString(), i_context );
216 : 0 : }
217 : :
218 : 0 : void lcl_notify( ::osl::ClearableMutexGuard& i_guard, ::cppu::OBroadcastHelper& i_broadcaseHelper,
219 : : void ( SAL_CALL XContainerListener::*i_notificationMethod )( const ContainerEvent& ),
220 : : const sal_Int32 i_accessor, const Sequence< ::rtl::OUString >& i_imageURLs, const Reference< XInterface >& i_context )
221 : : {
222 [ # # ][ # # ]: 0 : ::cppu::OInterfaceContainerHelper* pContainerListeners = i_broadcaseHelper.getContainer( XContainerListener::static_type() );
223 [ # # ]: 0 : if ( pContainerListeners == NULL )
224 : 0 : return;
225 : :
226 [ # # ]: 0 : ContainerEvent aEvent;
227 [ # # ]: 0 : aEvent.Source = i_context;
228 [ # # ]: 0 : aEvent.Accessor <<= i_accessor;
229 [ # # ]: 0 : aEvent.Element <<= i_imageURLs;
230 : :
231 [ # # ]: 0 : i_guard.clear();
232 [ # # ][ # # ]: 0 : pContainerListeners->notifyEach( i_notificationMethod, aEvent );
233 : : }
234 : : }
235 : :
236 : : //==================================================================================================================
237 : : //= AnimatedImagesControlModel
238 : : //==================================================================================================================
239 : : //------------------------------------------------------------------------------------------------------------------
240 : 0 : AnimatedImagesControlModel::AnimatedImagesControlModel( Reference< XMultiServiceFactory > const & i_factory )
241 : : :AnimatedImagesControlModel_Base( i_factory )
242 [ # # ][ # # ]: 0 : ,m_pData( new AnimatedImagesControlModel_Data )
243 : : {
244 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_AUTO_REPEAT );
245 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_BORDER );
246 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
247 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
248 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
249 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
250 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
251 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_HELPURL );
252 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_IMAGE_SCALE_MODE );
253 [ # # ]: 0 : ImplRegisterProperty( BASEPROPERTY_STEP_TIME );
254 : 0 : }
255 : :
256 : : //------------------------------------------------------------------------------------------------------------------
257 : 0 : AnimatedImagesControlModel::AnimatedImagesControlModel( const AnimatedImagesControlModel& i_copySource )
258 : : :AnimatedImagesControlModel_Base( i_copySource )
259 [ # # ][ # # ]: 0 : ,m_pData( new AnimatedImagesControlModel_Data( *i_copySource.m_pData ) )
260 : : {
261 : 0 : }
262 : :
263 : : //------------------------------------------------------------------------------------------------------------------
264 [ # # ]: 0 : AnimatedImagesControlModel::~AnimatedImagesControlModel()
265 : : {
266 [ # # ]: 0 : }
267 : :
268 : : //------------------------------------------------------------------------------------------------------------------
269 : 0 : UnoControlModel* AnimatedImagesControlModel::Clone() const
270 : : {
271 [ # # ]: 0 : return new AnimatedImagesControlModel( *this );
272 : : }
273 : :
274 : : //------------------------------------------------------------------------------------------------------------------
275 : 0 : Reference< XPropertySetInfo > SAL_CALL AnimatedImagesControlModel::getPropertySetInfo( ) throw(RuntimeException)
276 : : {
277 [ # # ][ # # ]: 0 : static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
[ # # ][ # # ]
[ # # ]
278 : 0 : return xInfo;
279 : : }
280 : :
281 : : //------------------------------------------------------------------------------------------------------------------
282 : 0 : ::rtl::OUString SAL_CALL AnimatedImagesControlModel::getServiceName() throw(RuntimeException)
283 : : {
284 : 0 : return ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControlModel );
285 : : }
286 : :
287 : : //------------------------------------------------------------------------------------------------------------------
288 : 0 : ::rtl::OUString SAL_CALL AnimatedImagesControlModel::getImplementationName( ) throw(RuntimeException)
289 : : {
290 : 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.toolkit.AnimatedImagesControlModel"));
291 : : }
292 : :
293 : : //------------------------------------------------------------------------------------------------------------------
294 : 0 : Sequence< ::rtl::OUString > SAL_CALL AnimatedImagesControlModel::getSupportedServiceNames() throw(RuntimeException)
295 : : {
296 : 0 : Sequence< ::rtl::OUString > aServiceNames(2);
297 [ # # ]: 0 : aServiceNames[0] = ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControlModel );
298 [ # # ][ # # ]: 0 : aServiceNames[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlModel"));
299 : 0 : return aServiceNames;
300 : : }
301 : :
302 : : //------------------------------------------------------------------------------------------------------------------
303 : 0 : void SAL_CALL AnimatedImagesControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 i_handle, const Any& i_value ) throw (Exception)
304 : : {
305 [ # # ]: 0 : switch ( i_handle )
306 : : {
307 : : case BASEPROPERTY_IMAGE_SCALE_MODE:
308 : : {
309 : 0 : sal_Int16 nImageScaleMode( ImageScaleMode::Anisotropic );
310 : 0 : OSL_VERIFY( i_value >>= nImageScaleMode ); // convertFastPropertyValue ensures that this has the proper type
311 [ # # ][ # # ]: 0 : if ( ( nImageScaleMode != ImageScaleMode::None )
[ # # ]
312 : : && ( nImageScaleMode != ImageScaleMode::Isotropic )
313 : : && ( nImageScaleMode != ImageScaleMode::Anisotropic )
314 : : )
315 [ # # ][ # # ]: 0 : throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
316 : : }
317 : 0 : break;
318 : : }
319 : :
320 : 0 : AnimatedImagesControlModel_Base::setFastPropertyValue_NoBroadcast( i_handle, i_value );
321 : 0 : }
322 : :
323 : : //------------------------------------------------------------------------------------------------------------------
324 : 0 : Any AnimatedImagesControlModel::ImplGetDefaultValue( sal_uInt16 i_propertyId ) const
325 : : {
326 [ # # # # : 0 : switch ( i_propertyId )
# # ]
327 : : {
328 : : case BASEPROPERTY_DEFAULTCONTROL:
329 [ # # ]: 0 : return makeAny( ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControl ) );
330 : :
331 : : case BASEPROPERTY_BORDER:
332 : 0 : return makeAny( VisualEffect::NONE );
333 : :
334 : : case BASEPROPERTY_STEP_TIME:
335 [ # # ]: 0 : return makeAny( (sal_Int32) 100 );
336 : :
337 : : case BASEPROPERTY_AUTO_REPEAT:
338 [ # # ]: 0 : return makeAny( (sal_Bool)sal_True );
339 : :
340 : : case BASEPROPERTY_IMAGE_SCALE_MODE:
341 : 0 : return makeAny( ImageScaleMode::None );
342 : :
343 : : default:
344 : 0 : return UnoControlModel::ImplGetDefaultValue( i_propertyId );
345 : : }
346 : : }
347 : :
348 : : //------------------------------------------------------------------------------------------------------------------
349 : 0 : ::cppu::IPropertyArrayHelper& SAL_CALL AnimatedImagesControlModel::getInfoHelper()
350 : : {
351 : : static UnoPropertyArrayHelper* pHelper = NULL;
352 [ # # ]: 0 : if ( !pHelper )
353 : : {
354 [ # # ]: 0 : Sequence< sal_Int32 > aIDs = ImplGetPropertyIds();
355 [ # # ][ # # ]: 0 : pHelper = new UnoPropertyArrayHelper( aIDs );
356 : : }
357 : 0 : return *pHelper;
358 : : }
359 : :
360 : : //------------------------------------------------------------------------------------------------------------------
361 : 0 : ::sal_Int32 SAL_CALL AnimatedImagesControlModel::getStepTime() throw (RuntimeException)
362 : : {
363 : 0 : sal_Int32 nStepTime( 100 );
364 [ # # ][ # # ]: 0 : OSL_VERIFY( getPropertyValue( GetPropertyName( BASEPROPERTY_STEP_TIME ) ) >>= nStepTime );
365 : 0 : return nStepTime;
366 : : }
367 : :
368 : : //------------------------------------------------------------------------------------------------------------------
369 : 0 : void SAL_CALL AnimatedImagesControlModel::setStepTime( ::sal_Int32 i_stepTime ) throw (RuntimeException)
370 : : {
371 [ # # ][ # # ]: 0 : setPropertyValue( GetPropertyName( BASEPROPERTY_STEP_TIME ), makeAny( i_stepTime ) );
372 : 0 : }
373 : :
374 : : //------------------------------------------------------------------------------------------------------------------
375 : 0 : ::sal_Bool SAL_CALL AnimatedImagesControlModel::getAutoRepeat() throw (RuntimeException)
376 : : {
377 : 0 : sal_Bool bAutoRepeat( sal_True );
378 [ # # ][ # # ]: 0 : OSL_VERIFY( getPropertyValue( GetPropertyName( BASEPROPERTY_AUTO_REPEAT ) ) >>= bAutoRepeat );
379 : 0 : return bAutoRepeat;
380 : : }
381 : :
382 : : //------------------------------------------------------------------------------------------------------------------
383 : 0 : void SAL_CALL AnimatedImagesControlModel::setAutoRepeat( ::sal_Bool i_autoRepeat ) throw (RuntimeException)
384 : : {
385 [ # # ][ # # ]: 0 : setPropertyValue( GetPropertyName( BASEPROPERTY_AUTO_REPEAT ), makeAny( i_autoRepeat ) );
386 : 0 : }
387 : :
388 : : //------------------------------------------------------------------------------------------------------------------
389 : 0 : ::sal_Int16 SAL_CALL AnimatedImagesControlModel::getScaleMode() throw (RuntimeException)
390 : : {
391 : 0 : sal_Int16 nImageScaleMode( ImageScaleMode::Anisotropic );
392 [ # # ][ # # ]: 0 : OSL_VERIFY( getPropertyValue( GetPropertyName( BASEPROPERTY_IMAGE_SCALE_MODE ) ) >>= nImageScaleMode );
393 : 0 : return nImageScaleMode;
394 : : }
395 : :
396 : : //------------------------------------------------------------------------------------------------------------------
397 : 0 : void SAL_CALL AnimatedImagesControlModel::setScaleMode( ::sal_Int16 i_scaleMode ) throw (IllegalArgumentException, RuntimeException)
398 : : {
399 [ # # ][ # # ]: 0 : setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGE_SCALE_MODE ), makeAny( i_scaleMode ) );
400 : 0 : }
401 : :
402 : : //------------------------------------------------------------------------------------------------------------------
403 : 0 : ::sal_Int32 SAL_CALL AnimatedImagesControlModel::getImageSetCount( ) throw (RuntimeException)
404 : : {
405 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
406 [ # # ][ # # ]: 0 : if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose )
[ # # ]
407 [ # # ]: 0 : throw DisposedException();
408 : :
409 [ # # ]: 0 : return m_pData->aImageSets.size();
410 : : }
411 : :
412 : : //------------------------------------------------------------------------------------------------------------------
413 : 0 : Sequence< ::rtl::OUString > SAL_CALL AnimatedImagesControlModel::getImageSet( ::sal_Int32 i_index ) throw (IndexOutOfBoundsException, RuntimeException)
414 : : {
415 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
416 [ # # ][ # # ]: 0 : if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose )
[ # # ]
417 [ # # ]: 0 : throw DisposedException();
418 : :
419 [ # # ][ # # ]: 0 : lcl_checkIndex( *m_pData, i_index, *this );
420 : :
421 [ # # ][ # # ]: 0 : return m_pData->aImageSets[ i_index ];
422 : : }
423 : :
424 : : //------------------------------------------------------------------------------------------------------------------
425 : 0 : void SAL_CALL AnimatedImagesControlModel::insertImageSet( ::sal_Int32 i_index, const Sequence< ::rtl::OUString >& i_imageURLs ) throw (IndexOutOfBoundsException, RuntimeException)
426 : : {
427 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard( GetMutex() );
428 : : // sanity checks
429 [ # # ][ # # ]: 0 : if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose )
[ # # ]
430 [ # # ]: 0 : throw DisposedException();
431 : :
432 [ # # ][ # # ]: 0 : lcl_checkIndex( *m_pData, i_index, *this, true );
433 : :
434 : : // actaul insertion
435 [ # # ][ # # ]: 0 : m_pData->aImageSets.insert( m_pData->aImageSets.begin() + i_index, i_imageURLs );
436 : :
437 : : // listener notification
438 [ # # ][ # # ]: 0 : lcl_notify( aGuard, BrdcstHelper, &XContainerListener::elementInserted, i_index, i_imageURLs, *this );
[ # # ]
439 : 0 : }
440 : :
441 : : //------------------------------------------------------------------------------------------------------------------
442 : 0 : void SAL_CALL AnimatedImagesControlModel::replaceImageSet( ::sal_Int32 i_index, const Sequence< ::rtl::OUString >& i_imageURLs ) throw (IndexOutOfBoundsException, RuntimeException)
443 : : {
444 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard( GetMutex() );
445 : : // sanity checks
446 [ # # ][ # # ]: 0 : if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose )
[ # # ]
447 [ # # ]: 0 : throw DisposedException();
448 : :
449 [ # # ][ # # ]: 0 : lcl_checkIndex( *m_pData, i_index, *this );
450 : :
451 : : // actaul insertion
452 [ # # ]: 0 : m_pData->aImageSets[ i_index ] = i_imageURLs;
453 : :
454 : : // listener notification
455 [ # # ][ # # ]: 0 : lcl_notify( aGuard, BrdcstHelper, &XContainerListener::elementReplaced, i_index, i_imageURLs, *this );
[ # # ]
456 : 0 : }
457 : :
458 : : //------------------------------------------------------------------------------------------------------------------
459 : 0 : void SAL_CALL AnimatedImagesControlModel::removeImageSet( ::sal_Int32 i_index ) throw (IndexOutOfBoundsException, RuntimeException)
460 : : {
461 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard( GetMutex() );
462 : : // sanity checks
463 [ # # ][ # # ]: 0 : if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose )
[ # # ]
464 [ # # ]: 0 : throw DisposedException();
465 : :
466 [ # # ][ # # ]: 0 : lcl_checkIndex( *m_pData, i_index, *this );
467 : :
468 : : // actual removal
469 [ # # ]: 0 : ::std::vector< Sequence< ::rtl::OUString > >::iterator removalPos = m_pData->aImageSets.begin() + i_index;
470 [ # # ]: 0 : Sequence< ::rtl::OUString > aRemovedElement( *removalPos );
471 [ # # ]: 0 : m_pData->aImageSets.erase( removalPos );
472 : :
473 : : // listener notification
474 [ # # ][ # # ]: 0 : lcl_notify( aGuard, BrdcstHelper, &XContainerListener::elementRemoved, i_index, aRemovedElement, *this );
[ # # ][ # # ]
475 : 0 : }
476 : :
477 : : //------------------------------------------------------------------------------------------------------------------
478 : 0 : void SAL_CALL AnimatedImagesControlModel::addContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException)
479 : : {
480 : 0 : BrdcstHelper.addListener( XContainerListener::static_type(), i_listener );
481 : 0 : }
482 : :
483 : : //------------------------------------------------------------------------------------------------------------------
484 : 0 : void SAL_CALL AnimatedImagesControlModel::removeContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException)
485 : : {
486 : 0 : BrdcstHelper.removeListener( XContainerListener::static_type(), i_listener );
487 : 0 : }
488 : :
489 : : //......................................................................................................................
490 : : } // namespace toolkit
491 : : //......................................................................................................................
492 : :
493 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|