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