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