LCOV - code coverage report
Current view: top level - toolkit/source/awt - animatedimagespeer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 227 0.0 %
Date: 2012-08-25 Functions: 0 29 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 350 0.0 %

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

Generated by: LCOV version 1.10