LCOV - code coverage report
Current view: top level - libreoffice/toolkit/source/awt - animatedimagespeer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 227 0.0 %
Date: 2012-12-27 Functions: 0 29 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "toolkit/awt/animatedimagespeer.hxx"
      22             : #include "toolkit/helper/property.hxx"
      23             : 
      24             : #include <com/sun/star/awt/XAnimatedImages.hpp>
      25             : #include <com/sun/star/awt/Size.hpp>
      26             : #include <com/sun/star/graphic/GraphicProvider.hpp>
      27             : #include <com/sun/star/graphic/XGraphicProvider.hpp>
      28             : #include <com/sun/star/beans/XPropertySet.hpp>
      29             : #include <com/sun/star/graphic/XGraphic.hpp>
      30             : #include <com/sun/star/awt/ImageScaleMode.hpp>
      31             : 
      32             : #include <comphelper/componentcontext.hxx>
      33             : #include <comphelper/namedvaluecollection.hxx>
      34             : #include <comphelper/processfactory.hxx>
      35             : #include <rtl/ustrbuf.hxx>
      36             : #include <tools/diagnose_ex.h>
      37             : #include <tools/urlobj.hxx>
      38             : #include <vcl/throbber.hxx>
      39             : #include <vcl/svapp.hxx>
      40             : 
      41             : #include <limits>
      42             : 
      43             : //......................................................................................................................
      44             : namespace toolkit
      45             : {
      46             : //......................................................................................................................
      47             : 
      48             :     /** === begin UNO using === **/
      49             :     using ::com::sun::star::uno::XComponentContext;
      50             :     using ::com::sun::star::uno::Reference;
      51             :     using ::com::sun::star::uno::XInterface;
      52             :     using ::com::sun::star::uno::UNO_QUERY;
      53             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      54             :     using ::com::sun::star::uno::UNO_SET_THROW;
      55             :     using ::com::sun::star::uno::Exception;
      56             :     using ::com::sun::star::uno::RuntimeException;
      57             :     using ::com::sun::star::uno::Any;
      58             :     using ::com::sun::star::uno::makeAny;
      59             :     using ::com::sun::star::uno::Sequence;
      60             :     using ::com::sun::star::uno::Type;
      61             :     using ::com::sun::star::lang::EventObject;
      62             :     using ::com::sun::star::container::ContainerEvent;
      63             :     using ::com::sun::star::awt::XAnimatedImages;
      64             :     using ::com::sun::star::awt::Size;
      65             :     using ::com::sun::star::lang::XMultiServiceFactory;
      66             :     using ::com::sun::star::graphic::XGraphicProvider;
      67             :     using ::com::sun::star::beans::XPropertySet;
      68             :     using ::com::sun::star::graphic::XGraphic;
      69             :     /** === end UNO using === **/
      70             :     namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
      71             : 
      72             :     //==================================================================================================================
      73             :     //= AnimatedImagesPeer_Data
      74             :     //==================================================================================================================
      75           0 :     struct CachedImage
      76             :     {
      77             :         ::rtl::OUString                 sImageURL;
      78             :         mutable Reference< XGraphic >   xGraphic;
      79             : 
      80           0 :         CachedImage()
      81             :             :sImageURL()
      82           0 :             ,xGraphic()
      83             :         {
      84           0 :         }
      85             : 
      86           0 :         CachedImage( ::rtl::OUString const& i_imageURL )
      87             :             :sImageURL( i_imageURL )
      88           0 :             ,xGraphic()
      89             :         {
      90           0 :         }
      91             :     };
      92             : 
      93           0 :     struct AnimatedImagesPeer_Data
      94             :     {
      95             :         AnimatedImagesPeer&                             rAntiImpl;
      96             :         ::std::vector< ::std::vector< CachedImage > >   aCachedImageSets;
      97             : 
      98           0 :         AnimatedImagesPeer_Data( AnimatedImagesPeer& i_antiImpl )
      99             :             :rAntiImpl( i_antiImpl )
     100           0 :             ,aCachedImageSets()
     101             :         {
     102           0 :         }
     103             :     };
     104             : 
     105             :     //==================================================================================================================
     106             :     //= helper
     107             :     //==================================================================================================================
     108             :     namespace
     109             :     {
     110             :         //--------------------------------------------------------------------------------------------------------------
     111           0 :         ::rtl::OUString lcl_getHighContrastURL( ::rtl::OUString const& i_imageURL )
     112             :         {
     113           0 :             INetURLObject aURL( i_imageURL );
     114           0 :             if ( aURL.GetProtocol() != INET_PROT_PRIV_SOFFICE )
     115             :             {
     116           0 :                 OSL_VERIFY( aURL.insertName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "hicontrast" ) ), false, 0 ) );
     117           0 :                 return aURL.GetMainURL( INetURLObject::NO_DECODE );
     118             :             }
     119             :             // the private: scheme is not considered to be hierarchical by INetURLObject, so manually insert the
     120             :             // segment
     121           0 :             const sal_Int32 separatorPos = i_imageURL.indexOf( '/' );
     122           0 :             ENSURE_OR_RETURN( separatorPos != -1, "lcl_getHighContrastURL: unsipported URL scheme - cannot automatically determine HC version!", i_imageURL );
     123             : 
     124           0 :             ::rtl::OUStringBuffer composer;
     125           0 :             composer.append( i_imageURL.copy( 0, separatorPos ) );
     126           0 :             composer.appendAscii( "/hicontrast" );
     127           0 :             composer.append( i_imageURL.copy( separatorPos ) );
     128           0 :             return composer.makeStringAndClear();
     129             :         }
     130             : 
     131             :         //--------------------------------------------------------------------------------------------------------------
     132           0 :         bool lcl_ensureImage_throw( Reference< XGraphicProvider > const& i_graphicProvider, const bool i_isHighContrast, const CachedImage& i_cachedImage )
     133             :         {
     134           0 :             if ( !i_cachedImage.xGraphic.is() )
     135             :             {
     136           0 :                 ::comphelper::NamedValueCollection aMediaProperties;
     137           0 :                 if ( i_isHighContrast )
     138             :                 {
     139             :                     // try (to find) the high-contrast version of the graphic first
     140           0 :                     aMediaProperties.put( "URL", lcl_getHighContrastURL( i_cachedImage.sImageURL ) );
     141           0 :                     i_cachedImage.xGraphic.set( i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY );
     142             :                 }
     143           0 :                 if ( !i_cachedImage.xGraphic.is() )
     144             :                 {
     145           0 :                     aMediaProperties.put( "URL", i_cachedImage.sImageURL );
     146           0 :                     i_cachedImage.xGraphic.set( i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY );
     147           0 :                 }
     148             :             }
     149           0 :             return i_cachedImage.xGraphic.is();
     150             :         }
     151             : 
     152             :         //--------------------------------------------------------------------------------------------------------------
     153           0 :         Size lcl_getGraphicSizePixel( Reference< XGraphic > const& i_graphic )
     154             :         {
     155           0 :             Size aSizePixel;
     156             :             try
     157             :             {
     158           0 :                 if ( i_graphic.is() )
     159             :                 {
     160           0 :                     const Reference< XPropertySet > xGraphicProps( i_graphic, UNO_QUERY_THROW );
     161           0 :                     OSL_VERIFY( xGraphicProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SizePixel" ) ) ) >>= aSizePixel );
     162             :                 }
     163             :             }
     164           0 :             catch( const Exception& )
     165             :             {
     166             :                 DBG_UNHANDLED_EXCEPTION();
     167             :             }
     168           0 :             return aSizePixel;
     169             :         }
     170             : 
     171             :         //--------------------------------------------------------------------------------------------------------------
     172           0 :         void lcl_init( Sequence< ::rtl::OUString > const& i_imageURLs, ::std::vector< CachedImage >& o_images )
     173             :         {
     174           0 :             o_images.resize(0);
     175           0 :             size_t count = size_t( i_imageURLs.getLength() );
     176           0 :             o_images.reserve( count );
     177           0 :             for ( size_t i = 0; i < count; ++i )
     178             :             {
     179           0 :                 o_images.push_back( CachedImage( i_imageURLs[i] ) );
     180             :             }
     181           0 :         }
     182             : 
     183             :         //--------------------------------------------------------------------------------------------------------------
     184           0 :         void lcl_updateImageList_nothrow( AnimatedImagesPeer_Data& i_data )
     185             :         {
     186           0 :             Throbber* pThrobber = dynamic_cast< Throbber* >( i_data.rAntiImpl.GetWindow() );
     187           0 :             if ( pThrobber == NULL )
     188           0 :                 return;
     189             : 
     190             :             try
     191             :             {
     192             :                 // collect the image sizes of the different image sets
     193           0 :                 const Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     194           0 :                 const Reference< XGraphicProvider > xGraphicProvider( com::sun::star::graphic::GraphicProvider::create(xContext) );
     195             : 
     196           0 :                 const bool isHighContrast = pThrobber->GetSettings().GetStyleSettings().GetHighContrastMode();
     197             : 
     198           0 :                 sal_Int32 nPreferredSet = -1;
     199           0 :                 const size_t nImageSetCount = i_data.aCachedImageSets.size();
     200           0 :                 if ( nImageSetCount < 2 )
     201             :                 {
     202           0 :                     nPreferredSet = sal_Int32( nImageSetCount ) - 1;
     203             :                 }
     204             :                 else
     205             :                 {
     206           0 :                     ::std::vector< Size > aImageSizes( nImageSetCount );
     207           0 :                     for ( sal_Int32 nImageSet = 0; size_t( nImageSet ) < nImageSetCount; ++nImageSet )
     208             :                     {
     209           0 :                         ::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nImageSet ] );
     210           0 :                         if  (   ( rImageSet.empty() )
     211           0 :                             ||  ( !lcl_ensureImage_throw( xGraphicProvider, isHighContrast, rImageSet[0] ) )
     212             :                             )
     213             :                         {
     214           0 :                             aImageSizes[ nImageSet ] = Size( SAL_MAX_INT32, SAL_MAX_INT32 );
     215             :                         }
     216             :                         else
     217             :                         {
     218           0 :                             aImageSizes[ nImageSet ] = lcl_getGraphicSizePixel( rImageSet[0].xGraphic );
     219             :                         }
     220             :                     }
     221             : 
     222             :                     // find the set with the smallest difference between window size and image size
     223           0 :                     const ::Size aWindowSizePixel = pThrobber->GetSizePixel();
     224           0 :                     long nMinimalDistance = ::std::numeric_limits< long >::max();
     225           0 :                     for (   ::std::vector< Size >::const_iterator check = aImageSizes.begin();
     226           0 :                             check != aImageSizes.end();
     227             :                             ++check
     228             :                         )
     229             :                     {
     230           0 :                         if  (   ( check->Width > aWindowSizePixel.Width() )
     231           0 :                             ||  ( check->Height > aWindowSizePixel.Height() )
     232             :                             )
     233             :                             // do not use an image set which doesn't fit into the window
     234           0 :                             continue;
     235             : 
     236             :                         const sal_Int64 distance =
     237           0 :                                 ( aWindowSizePixel.Width() - check->Width ) * ( aWindowSizePixel.Width() - check->Width )
     238           0 :                             +   ( aWindowSizePixel.Height() - check->Height ) * ( aWindowSizePixel.Height() - check->Height );
     239           0 :                         if ( distance < nMinimalDistance )
     240             :                         {
     241           0 :                             nMinimalDistance = distance;
     242           0 :                             nPreferredSet = check - aImageSizes.begin();
     243             :                         }
     244           0 :                     }
     245             :                 }
     246             : 
     247             :                 // found a set?
     248           0 :                 Sequence< Reference< XGraphic > > aImages;
     249           0 :                 if ( ( nPreferredSet >= 0 ) && ( size_t( nPreferredSet ) < nImageSetCount ) )
     250             :                 {
     251             :                     // => set the images
     252           0 :                     ::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nPreferredSet ] );
     253           0 :                     aImages.realloc( rImageSet.size() );
     254           0 :                     sal_Int32 imageIndex = 0;
     255           0 :                     for (   ::std::vector< CachedImage >::const_iterator cachedImage = rImageSet.begin();
     256           0 :                             cachedImage != rImageSet.end();
     257             :                             ++cachedImage, ++imageIndex
     258             :                         )
     259             :                     {
     260           0 :                         lcl_ensureImage_throw( xGraphicProvider, isHighContrast, *cachedImage );
     261           0 :                         aImages[ imageIndex ] = cachedImage->xGraphic;
     262             :                     }
     263             :                 }
     264           0 :                 pThrobber->setImageList( aImages );
     265             :             }
     266           0 :             catch( const Exception& )
     267             :             {
     268             :                 DBG_UNHANDLED_EXCEPTION();
     269             :             }
     270             :         }
     271             : 
     272             :         //--------------------------------------------------------------------------------------------------------------
     273           0 :         void lcl_updateImageList_nothrow( AnimatedImagesPeer_Data& i_data, const Reference< XAnimatedImages >& i_images )
     274             :         {
     275             :             try
     276             :             {
     277           0 :                 const sal_Int32 nImageSetCount = i_images->getImageSetCount();
     278           0 :                 i_data.aCachedImageSets.resize(0);
     279           0 :                 for ( sal_Int32 set = 0;  set < nImageSetCount; ++set )
     280             :                 {
     281           0 :                     const Sequence< ::rtl::OUString > aImageURLs( i_images->getImageSet( set ) );
     282           0 :                     ::std::vector< CachedImage > aImages;
     283           0 :                     lcl_init( aImageURLs, aImages );
     284           0 :                     i_data.aCachedImageSets.push_back( aImages );
     285           0 :                 }
     286             : 
     287           0 :                 lcl_updateImageList_nothrow( i_data );
     288             :             }
     289           0 :             catch( const Exception& )
     290             :             {
     291             :                 DBG_UNHANDLED_EXCEPTION();
     292             :             }
     293           0 :         }
     294             :     }
     295             : 
     296             :     //==================================================================================================================
     297             :     //= AnimatedImagesPeer
     298             :     //==================================================================================================================
     299             :     //------------------------------------------------------------------------------------------------------------------
     300           0 :     AnimatedImagesPeer::AnimatedImagesPeer()
     301             :         :AnimatedImagesPeer_Base()
     302           0 :         ,m_pData( new AnimatedImagesPeer_Data( *this ) )
     303             :     {
     304           0 :     }
     305             : 
     306             :     //------------------------------------------------------------------------------------------------------------------
     307           0 :     AnimatedImagesPeer::~AnimatedImagesPeer()
     308             :     {
     309           0 :     }
     310             : 
     311             :     //------------------------------------------------------------------------------------------------------------------
     312           0 :     void SAL_CALL AnimatedImagesPeer::startAnimation(  ) throw (RuntimeException)
     313             :     {
     314           0 :         SolarMutexGuard aGuard;
     315           0 :         Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
     316           0 :         if ( pThrobber != NULL)
     317           0 :             pThrobber->start();
     318           0 :     }
     319             : 
     320             :     //------------------------------------------------------------------------------------------------------------------
     321           0 :     void SAL_CALL AnimatedImagesPeer::stopAnimation(  ) throw (RuntimeException)
     322             :     {
     323           0 :         SolarMutexGuard aGuard;
     324           0 :         Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
     325           0 :         if ( pThrobber != NULL)
     326           0 :             pThrobber->stop();
     327           0 :     }
     328             : 
     329             :     //------------------------------------------------------------------------------------------------------------------
     330           0 :     ::sal_Bool SAL_CALL AnimatedImagesPeer::isAnimationRunning(  ) throw (RuntimeException)
     331             :     {
     332           0 :         SolarMutexGuard aGuard;
     333           0 :         Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
     334           0 :         if ( pThrobber != NULL)
     335           0 :             return pThrobber->isRunning();
     336           0 :         return sal_False;
     337             :     }
     338             : 
     339             :     //------------------------------------------------------------------------------------------------------------------
     340           0 :     void SAL_CALL AnimatedImagesPeer::setProperty( const ::rtl::OUString& i_propertyName, const Any& i_value ) throw(RuntimeException)
     341             :     {
     342           0 :         SolarMutexGuard aGuard;
     343             : 
     344           0 :         Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
     345           0 :         if ( pThrobber == NULL )
     346             :         {
     347           0 :             VCLXWindow::setProperty( i_propertyName, i_value );
     348           0 :             return;
     349             :         }
     350             : 
     351           0 :         const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName );
     352           0 :         switch ( nPropertyId )
     353             :         {
     354             :             case BASEPROPERTY_STEP_TIME:
     355             :             {
     356           0 :                 sal_Int32 nStepTime( 0 );
     357           0 :                 if ( i_value >>= nStepTime )
     358           0 :                     pThrobber->setStepTime( nStepTime );
     359             :                 break;
     360             :             }
     361             :             case BASEPROPERTY_AUTO_REPEAT:
     362             :             {
     363           0 :                 sal_Bool bRepeat( sal_True );
     364           0 :                 if ( i_value >>= bRepeat )
     365           0 :                     pThrobber->setRepeat( bRepeat );
     366             :                 break;
     367             :             }
     368             : 
     369             :             case BASEPROPERTY_IMAGE_SCALE_MODE:
     370             :             {
     371           0 :                 sal_Int16 nScaleMode( ImageScaleMode::Anisotropic );
     372           0 :                 ImageControl* pImageControl = dynamic_cast< ImageControl* >( GetWindow() );
     373           0 :                 if ( pImageControl && ( i_value >>= nScaleMode ) )
     374             :                 {
     375           0 :                     pImageControl->SetScaleMode( nScaleMode );
     376             :                 }
     377             :             }
     378           0 :             break;
     379             : 
     380             :             default:
     381           0 :                 AnimatedImagesPeer_Base::setProperty( i_propertyName, i_value );
     382           0 :                 break;
     383           0 :         }
     384             :     }
     385             : 
     386             :     //------------------------------------------------------------------------------------------------------------------
     387           0 :     Any SAL_CALL AnimatedImagesPeer::getProperty( const ::rtl::OUString& i_propertyName ) throw(RuntimeException)
     388             :     {
     389           0 :         SolarMutexGuard aGuard;
     390             : 
     391           0 :         Any aReturn;
     392             : 
     393           0 :         Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
     394           0 :         if ( pThrobber == NULL )
     395           0 :             return VCLXWindow::getProperty( i_propertyName );
     396             : 
     397           0 :         const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName );
     398           0 :         switch ( nPropertyId )
     399             :         {
     400             :         case BASEPROPERTY_STEP_TIME:
     401           0 :             aReturn <<= pThrobber->getStepTime();
     402           0 :             break;
     403             : 
     404             :         case BASEPROPERTY_AUTO_REPEAT:
     405           0 :             aReturn <<= pThrobber->getRepeat();
     406           0 :             break;
     407             : 
     408             :         case BASEPROPERTY_IMAGE_SCALE_MODE:
     409             :             {
     410           0 :                 ImageControl const* pImageControl = dynamic_cast< ImageControl* >( GetWindow() );
     411           0 :                 aReturn <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::Anisotropic );
     412             :             }
     413           0 :             break;
     414             : 
     415             :         default:
     416           0 :             aReturn = AnimatedImagesPeer_Base::getProperty( i_propertyName );
     417           0 :             break;
     418             :         }
     419             : 
     420           0 :         return aReturn;
     421             :     }
     422             : 
     423             :     //------------------------------------------------------------------------------------------------------------------
     424           0 :     void AnimatedImagesPeer::ProcessWindowEvent( const VclWindowEvent& i_windowEvent )
     425             :     {
     426           0 :         switch ( i_windowEvent.GetId() )
     427             :         {
     428             :         case VCLEVENT_WINDOW_RESIZE:
     429           0 :             lcl_updateImageList_nothrow( *m_pData );
     430           0 :             break;
     431             :         }
     432             : 
     433           0 :         AnimatedImagesPeer_Base::ProcessWindowEvent( i_windowEvent );
     434           0 :     }
     435             : 
     436             :     //------------------------------------------------------------------------------------------------------------------
     437           0 :     void AnimatedImagesPeer::impl_updateImages_nolck( const Reference< XInterface >& i_animatedImages )
     438             :     {
     439           0 :         SolarMutexGuard aGuard;
     440             : 
     441           0 :         lcl_updateImageList_nothrow( *m_pData, Reference< XAnimatedImages >( i_animatedImages, UNO_QUERY_THROW ) );
     442           0 :     }
     443             : 
     444             :     //------------------------------------------------------------------------------------------------------------------
     445           0 :     void SAL_CALL AnimatedImagesPeer::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException)
     446             :     {
     447           0 :         SolarMutexGuard aGuard;
     448           0 :         Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW );
     449             : 
     450           0 :         sal_Int32 nPosition(0);
     451           0 :         OSL_VERIFY( i_event.Accessor >>= nPosition );
     452           0 :         size_t position = size_t( nPosition );
     453           0 :         if ( position > m_pData->aCachedImageSets.size() )
     454             :         {
     455             :             OSL_ENSURE( false, "AnimatedImagesPeer::elementInserted: illegal accessor/index!" );
     456           0 :             lcl_updateImageList_nothrow( *m_pData, xAnimatedImages );
     457             :         }
     458             : 
     459           0 :         Sequence< ::rtl::OUString > aImageURLs;
     460           0 :         OSL_VERIFY( i_event.Element >>= aImageURLs );
     461           0 :         ::std::vector< CachedImage > aImages;
     462           0 :         lcl_init( aImageURLs, aImages );
     463           0 :         m_pData->aCachedImageSets.insert( m_pData->aCachedImageSets.begin() + position, aImages );
     464           0 :         lcl_updateImageList_nothrow( *m_pData );
     465           0 :     }
     466             : 
     467             :     //------------------------------------------------------------------------------------------------------------------
     468           0 :     void SAL_CALL AnimatedImagesPeer::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException)
     469             :     {
     470           0 :         SolarMutexGuard aGuard;
     471           0 :         Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW );
     472             : 
     473           0 :         sal_Int32 nPosition(0);
     474           0 :         OSL_VERIFY( i_event.Accessor >>= nPosition );
     475           0 :         size_t position = size_t( nPosition );
     476           0 :         if ( position >= m_pData->aCachedImageSets.size() )
     477             :         {
     478             :             OSL_ENSURE( false, "AnimatedImagesPeer::elementRemoved: illegal accessor/index!" );
     479           0 :             lcl_updateImageList_nothrow( *m_pData, xAnimatedImages );
     480             :         }
     481             : 
     482           0 :         m_pData->aCachedImageSets.erase( m_pData->aCachedImageSets.begin() + position );
     483           0 :         lcl_updateImageList_nothrow( *m_pData );
     484           0 :     }
     485             : 
     486             :     //------------------------------------------------------------------------------------------------------------------
     487           0 :     void SAL_CALL AnimatedImagesPeer::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException)
     488             :     {
     489           0 :         SolarMutexGuard aGuard;
     490           0 :         Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW );
     491             : 
     492           0 :         sal_Int32 nPosition(0);
     493           0 :         OSL_VERIFY( i_event.Accessor >>= nPosition );
     494           0 :         size_t position = size_t( nPosition );
     495           0 :         if ( position >= m_pData->aCachedImageSets.size() )
     496             :         {
     497             :             OSL_ENSURE( false, "AnimatedImagesPeer::elementReplaced: illegal accessor/index!" );
     498           0 :             lcl_updateImageList_nothrow( *m_pData, xAnimatedImages );
     499             :         }
     500             : 
     501           0 :         Sequence< ::rtl::OUString > aImageURLs;
     502           0 :         OSL_VERIFY( i_event.Element >>= aImageURLs );
     503           0 :         ::std::vector< CachedImage > aImages;
     504           0 :         lcl_init( aImageURLs, aImages );
     505           0 :         m_pData->aCachedImageSets[ position ] = aImages;
     506           0 :         lcl_updateImageList_nothrow( *m_pData );
     507           0 :     }
     508             : 
     509             :     //------------------------------------------------------------------------------------------------------------------
     510           0 :     void SAL_CALL AnimatedImagesPeer::disposing( const EventObject& i_event ) throw (RuntimeException)
     511             :     {
     512           0 :         VCLXWindow::disposing( i_event );
     513           0 :     }
     514             : 
     515             :     //------------------------------------------------------------------------------------------------------------------
     516           0 :     void SAL_CALL AnimatedImagesPeer::modified( const EventObject& i_event ) throw (RuntimeException)
     517             :     {
     518           0 :         impl_updateImages_nolck( i_event.Source );
     519           0 :     }
     520             : 
     521             :     //------------------------------------------------------------------------------------------------------------------
     522           0 :     void SAL_CALL AnimatedImagesPeer::dispose(  ) throw(RuntimeException)
     523             :     {
     524           0 :         AnimatedImagesPeer_Base::dispose();
     525           0 :         SolarMutexGuard aGuard;
     526           0 :         m_pData->aCachedImageSets.resize(0);
     527           0 :     }
     528             : 
     529             : //......................................................................................................................
     530             : } // namespace toolkit
     531             : //......................................................................................................................
     532             : 
     533             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10