1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #define ENABLE_BYTESTRING_STREAM_OPERATORS 28cdf0e10cSrcweir #include <vcl/animate.hxx> 29cdf0e10cSrcweir #include <tools/debug.hxx> 30cdf0e10cSrcweir #include <tools/stream.hxx> 31cdf0e10cSrcweir #include <rtl/crc.h> 32cdf0e10cSrcweir #include <vcl/virdev.hxx> 33cdf0e10cSrcweir #include <vcl/window.hxx> 34cdf0e10cSrcweir #include <impanmvw.hxx> 35cdf0e10cSrcweir DBG_NAME( Animation ) 36cdf0e10cSrcweir 37cdf0e10cSrcweir // ----------- 38cdf0e10cSrcweir // - Defines - 39cdf0e10cSrcweir // ----------- 40cdf0e10cSrcweir 41cdf0e10cSrcweir #define MIN_TIMEOUT 2L 42cdf0e10cSrcweir #define INC_TIMEOUT 0L 43cdf0e10cSrcweir 44cdf0e10cSrcweir // ----------- 45cdf0e10cSrcweir // - statics - 46cdf0e10cSrcweir // ----------- 47cdf0e10cSrcweir 48cdf0e10cSrcweir sal_uLong Animation::mnAnimCount = 0UL; 49cdf0e10cSrcweir 50cdf0e10cSrcweir // ------------------- 51cdf0e10cSrcweir // - AnimationBitmap - 52cdf0e10cSrcweir // ------------------- 53cdf0e10cSrcweir 54cdf0e10cSrcweir sal_uLong AnimationBitmap::GetChecksum() const 55cdf0e10cSrcweir { 56cdf0e10cSrcweir sal_uInt32 nCrc = aBmpEx.GetChecksum(); 57cdf0e10cSrcweir SVBT32 aBT32; 58cdf0e10cSrcweir 59cdf0e10cSrcweir UInt32ToSVBT32( aPosPix.X(), aBT32 ); 60cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 61cdf0e10cSrcweir 62cdf0e10cSrcweir UInt32ToSVBT32( aPosPix.Y(), aBT32 ); 63cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 64cdf0e10cSrcweir 65cdf0e10cSrcweir UInt32ToSVBT32( aSizePix.Width(), aBT32 ); 66cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 67cdf0e10cSrcweir 68cdf0e10cSrcweir UInt32ToSVBT32( aSizePix.Height(), aBT32 ); 69cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 70cdf0e10cSrcweir 71cdf0e10cSrcweir UInt32ToSVBT32( (long) nWait, aBT32 ); 72cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir UInt32ToSVBT32( (long) eDisposal, aBT32 ); 75cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir UInt32ToSVBT32( (long) bUserInput, aBT32 ); 78cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 79cdf0e10cSrcweir 80cdf0e10cSrcweir return nCrc; 81cdf0e10cSrcweir } 82cdf0e10cSrcweir 83cdf0e10cSrcweir // ------------- 84cdf0e10cSrcweir // - Animation - 85cdf0e10cSrcweir // ------------- 86cdf0e10cSrcweir 87cdf0e10cSrcweir Animation::Animation() : 88cdf0e10cSrcweir mnLoopCount ( 0 ), 89cdf0e10cSrcweir mnLoops ( 0 ), 90cdf0e10cSrcweir mnPos ( 0 ), 91cdf0e10cSrcweir meCycleMode ( CYCLE_NORMAL ), 92cdf0e10cSrcweir mbIsInAnimation ( sal_False ), 93cdf0e10cSrcweir mbLoopTerminated ( sal_False ), 94cdf0e10cSrcweir mbIsWaiting ( sal_False ) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir DBG_CTOR( Animation, NULL ); 97cdf0e10cSrcweir maTimer.SetTimeoutHdl( LINK( this, Animation, ImplTimeoutHdl ) ); 98cdf0e10cSrcweir mpViewList = new List; 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir // ----------------------------------------------------------------------- 102cdf0e10cSrcweir 103cdf0e10cSrcweir Animation::Animation( const Animation& rAnimation ) : 104cdf0e10cSrcweir maBitmapEx ( rAnimation.maBitmapEx ), 105cdf0e10cSrcweir maGlobalSize ( rAnimation.maGlobalSize ), 106cdf0e10cSrcweir mnLoopCount ( rAnimation.mnLoopCount ), 107cdf0e10cSrcweir mnPos ( rAnimation.mnPos ), 108cdf0e10cSrcweir meCycleMode ( rAnimation.meCycleMode ), 109cdf0e10cSrcweir mbIsInAnimation ( sal_False ), 110cdf0e10cSrcweir mbLoopTerminated ( rAnimation.mbLoopTerminated ), 111cdf0e10cSrcweir mbIsWaiting ( rAnimation.mbIsWaiting ) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir DBG_CTOR( Animation, NULL ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir for( long i = 0, nCount = rAnimation.maList.Count(); i < nCount; i++ ) 116cdf0e10cSrcweir maList.Insert( new AnimationBitmap( *(AnimationBitmap*) rAnimation.maList.GetObject( i ) ), LIST_APPEND ); 117cdf0e10cSrcweir 118cdf0e10cSrcweir maTimer.SetTimeoutHdl( LINK( this, Animation, ImplTimeoutHdl ) ); 119cdf0e10cSrcweir mpViewList = new List; 120cdf0e10cSrcweir mnLoops = mbLoopTerminated ? 0 : mnLoopCount; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir // ----------------------------------------------------------------------- 124cdf0e10cSrcweir 125cdf0e10cSrcweir Animation::~Animation() 126cdf0e10cSrcweir { 127cdf0e10cSrcweir DBG_DTOR( Animation, NULL ); 128cdf0e10cSrcweir 129cdf0e10cSrcweir if( mbIsInAnimation ) 130cdf0e10cSrcweir Stop(); 131cdf0e10cSrcweir 132cdf0e10cSrcweir for( void* pStepBmp = maList.First(); pStepBmp; pStepBmp = maList.Next() ) 133cdf0e10cSrcweir delete (AnimationBitmap*) pStepBmp; 134cdf0e10cSrcweir 135cdf0e10cSrcweir for( void* pView = mpViewList->First(); pView; pView = mpViewList->Next() ) 136cdf0e10cSrcweir delete (ImplAnimView*) pView; 137cdf0e10cSrcweir 138cdf0e10cSrcweir delete mpViewList; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir // ----------------------------------------------------------------------- 142cdf0e10cSrcweir 143cdf0e10cSrcweir Animation& Animation::operator=( const Animation& rAnimation ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir Clear(); 146cdf0e10cSrcweir 147cdf0e10cSrcweir for( long i = 0, nCount = rAnimation.maList.Count(); i < nCount; i++ ) 148cdf0e10cSrcweir maList.Insert( new AnimationBitmap( *(AnimationBitmap*) rAnimation.maList.GetObject( i ) ), LIST_APPEND ); 149cdf0e10cSrcweir 150cdf0e10cSrcweir maGlobalSize = rAnimation.maGlobalSize; 151cdf0e10cSrcweir maBitmapEx = rAnimation.maBitmapEx; 152cdf0e10cSrcweir meCycleMode = rAnimation.meCycleMode; 153cdf0e10cSrcweir mnLoopCount = rAnimation.mnLoopCount; 154cdf0e10cSrcweir mnPos = rAnimation.mnPos; 155cdf0e10cSrcweir mbLoopTerminated = rAnimation.mbLoopTerminated; 156cdf0e10cSrcweir mbIsWaiting = rAnimation.mbIsWaiting; 157cdf0e10cSrcweir mnLoops = mbLoopTerminated ? 0 : mnLoopCount; 158cdf0e10cSrcweir 159cdf0e10cSrcweir return *this; 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir // ----------------------------------------------------------------------- 163cdf0e10cSrcweir 164cdf0e10cSrcweir sal_Bool Animation::operator==( const Animation& rAnimation ) const 165cdf0e10cSrcweir { 166cdf0e10cSrcweir const sal_uLong nCount = maList.Count(); 167cdf0e10cSrcweir sal_Bool bRet = sal_False; 168cdf0e10cSrcweir 169cdf0e10cSrcweir if( rAnimation.maList.Count() == nCount && 170cdf0e10cSrcweir rAnimation.maBitmapEx == maBitmapEx && 171cdf0e10cSrcweir rAnimation.maGlobalSize == maGlobalSize && 172cdf0e10cSrcweir rAnimation.meCycleMode == meCycleMode ) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir bRet = sal_True; 175cdf0e10cSrcweir 176cdf0e10cSrcweir for( sal_uLong n = 0; n < nCount; n++ ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir if( ( *(AnimationBitmap*) maList.GetObject( n ) ) != 179cdf0e10cSrcweir ( *(AnimationBitmap*) rAnimation.maList.GetObject( n ) ) ) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir bRet = sal_False; 182cdf0e10cSrcweir break; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir } 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir return bRet; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir // ------------------------------------------------------------------ 191cdf0e10cSrcweir 192cdf0e10cSrcweir sal_Bool Animation::IsEqual( const Animation& rAnimation ) const 193cdf0e10cSrcweir { 194cdf0e10cSrcweir const sal_uLong nCount = maList.Count(); 195cdf0e10cSrcweir sal_Bool bRet = sal_False; 196cdf0e10cSrcweir 197cdf0e10cSrcweir if( rAnimation.maList.Count() == nCount && 198cdf0e10cSrcweir rAnimation.maBitmapEx.IsEqual( maBitmapEx ) && 199cdf0e10cSrcweir rAnimation.maGlobalSize == maGlobalSize && 200cdf0e10cSrcweir rAnimation.meCycleMode == meCycleMode ) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir for( sal_uLong n = 0; ( n < nCount ) && !bRet; n++ ) 203cdf0e10cSrcweir if( ( (AnimationBitmap*) maList.GetObject( n ) )->IsEqual( *(AnimationBitmap*) rAnimation.maList.GetObject( n ) ) ) 204cdf0e10cSrcweir bRet = sal_True; 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir return bRet; 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir // ------------------------------------------------------------------ 211cdf0e10cSrcweir 212cdf0e10cSrcweir sal_Bool Animation::IsEmpty() const 213cdf0e10cSrcweir { 214cdf0e10cSrcweir return( maBitmapEx.IsEmpty() && !maList.Count() ); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir // ------------------------------------------------------------------ 218cdf0e10cSrcweir 219cdf0e10cSrcweir void Animation::SetEmpty() 220cdf0e10cSrcweir { 221cdf0e10cSrcweir maTimer.Stop(); 222cdf0e10cSrcweir mbIsInAnimation = sal_False; 223cdf0e10cSrcweir maGlobalSize = Size(); 224cdf0e10cSrcweir maBitmapEx.SetEmpty(); 225cdf0e10cSrcweir 226cdf0e10cSrcweir for( void* pStepBmp = maList.First(); pStepBmp; pStepBmp = maList.Next() ) 227cdf0e10cSrcweir delete (AnimationBitmap*) pStepBmp; 228cdf0e10cSrcweir maList.Clear(); 229cdf0e10cSrcweir 230cdf0e10cSrcweir for( void* pView = mpViewList->First(); pView; pView = mpViewList->Next() ) 231cdf0e10cSrcweir delete (ImplAnimView*) pView; 232cdf0e10cSrcweir mpViewList->Clear(); 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir // ----------------------------------------------------------------------- 236cdf0e10cSrcweir 237cdf0e10cSrcweir void Animation::Clear() 238cdf0e10cSrcweir { 239cdf0e10cSrcweir SetEmpty(); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir 242cdf0e10cSrcweir // ----------------------------------------------------------------------- 243cdf0e10cSrcweir 244cdf0e10cSrcweir sal_Bool Animation::IsTransparent() const 245cdf0e10cSrcweir { 246cdf0e10cSrcweir Point aPoint; 247cdf0e10cSrcweir Rectangle aRect( aPoint, maGlobalSize ); 248cdf0e10cSrcweir sal_Bool bRet = sal_False; 249cdf0e10cSrcweir 250cdf0e10cSrcweir // Falls irgendein 'kleines' Bildchen durch den Hintergrund 251cdf0e10cSrcweir // ersetzt werden soll, muessen wir 'transparent' sein, um 252cdf0e10cSrcweir // richtig dargestellt zu werden, da die Appl. aus Optimierungsgruenden 253cdf0e10cSrcweir // kein Invalidate auf nicht-transp. Grafiken ausfuehren 254cdf0e10cSrcweir for( long i = 0, nCount = maList.Count(); i < nCount; i++ ) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir const AnimationBitmap* pAnimBmp = (AnimationBitmap*) maList.GetObject( i ); 257cdf0e10cSrcweir 258cdf0e10cSrcweir if( DISPOSE_BACK == pAnimBmp->eDisposal && Rectangle( pAnimBmp->aPosPix, pAnimBmp->aSizePix ) != aRect ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir bRet = sal_True; 261cdf0e10cSrcweir break; 262cdf0e10cSrcweir } 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir if( !bRet ) 266cdf0e10cSrcweir bRet = maBitmapEx.IsTransparent(); 267cdf0e10cSrcweir 268cdf0e10cSrcweir return bRet; 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir // ----------------------------------------------------------------------- 272cdf0e10cSrcweir 273cdf0e10cSrcweir sal_uLong Animation::GetSizeBytes() const 274cdf0e10cSrcweir { 275cdf0e10cSrcweir sal_uLong nSizeBytes = GetBitmapEx().GetSizeBytes(); 276cdf0e10cSrcweir 277cdf0e10cSrcweir for( long i = 0, nCount = maList.Count(); i < nCount; i++ ) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir const AnimationBitmap* pAnimBmp = (AnimationBitmap*) maList.GetObject( i ); 280cdf0e10cSrcweir nSizeBytes += pAnimBmp->aBmpEx.GetSizeBytes(); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir return nSizeBytes; 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir // ----------------------------------------------------------------------- 287cdf0e10cSrcweir 288cdf0e10cSrcweir sal_uLong Animation::GetChecksum() const 289cdf0e10cSrcweir { 290cdf0e10cSrcweir SVBT32 aBT32; 291cdf0e10cSrcweir sal_uInt32 nCrc = GetBitmapEx().GetChecksum(); 292cdf0e10cSrcweir 293cdf0e10cSrcweir UInt32ToSVBT32( maList.Count(), aBT32 ); 294cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 295cdf0e10cSrcweir 296cdf0e10cSrcweir UInt32ToSVBT32( maGlobalSize.Width(), aBT32 ); 297cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 298cdf0e10cSrcweir 299cdf0e10cSrcweir UInt32ToSVBT32( maGlobalSize.Height(), aBT32 ); 300cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 301cdf0e10cSrcweir 302cdf0e10cSrcweir UInt32ToSVBT32( (long) meCycleMode, aBT32 ); 303cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 304cdf0e10cSrcweir 305cdf0e10cSrcweir for( long i = 0, nCount = maList.Count(); i < nCount; i++ ) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir UInt32ToSVBT32( ( (AnimationBitmap*) maList.GetObject( i ) )->GetChecksum(), aBT32 ); 308cdf0e10cSrcweir nCrc = rtl_crc32( nCrc, aBT32, 4 ); 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir return nCrc; 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir // ----------------------------------------------------------------------- 315cdf0e10cSrcweir 316cdf0e10cSrcweir sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, long nExtraData, 317cdf0e10cSrcweir OutputDevice* pFirstFrameOutDev ) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir return Start( pOut, rDestPt, pOut->PixelToLogic( maGlobalSize ), nExtraData, pFirstFrameOutDev ); 320cdf0e10cSrcweir } 321cdf0e10cSrcweir 322cdf0e10cSrcweir // ----------------------------------------------------------------------- 323cdf0e10cSrcweir 324cdf0e10cSrcweir sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size& rDestSz, long nExtraData, 325cdf0e10cSrcweir OutputDevice* pFirstFrameOutDev ) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir sal_Bool bRet = sal_False; 328cdf0e10cSrcweir 329cdf0e10cSrcweir if( maList.Count() ) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir if( ( pOut->GetOutDevType() == OUTDEV_WINDOW ) && !mbLoopTerminated && 332cdf0e10cSrcweir ( ANIMATION_TIMEOUT_ON_CLICK != ( (AnimationBitmap*) maList.GetObject( mnPos ) )->nWait ) ) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir ImplAnimView* pView; 335cdf0e10cSrcweir ImplAnimView* pMatch = NULL; 336cdf0e10cSrcweir 337cdf0e10cSrcweir for( pView = (ImplAnimView*) mpViewList->First(); pView; pView = (ImplAnimView*) mpViewList->Next() ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir if( pView->ImplMatches( pOut, nExtraData ) ) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir if( pView->ImplGetOutPos() == rDestPt && 342cdf0e10cSrcweir pView->ImplGetOutSizePix() == pOut->LogicToPixel( rDestSz ) ) 343cdf0e10cSrcweir { 344cdf0e10cSrcweir pView->ImplRepaint(); 345cdf0e10cSrcweir pMatch = pView; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir else 348cdf0e10cSrcweir { 349cdf0e10cSrcweir delete (ImplAnimView*) mpViewList->Remove( pView ); 350cdf0e10cSrcweir pView = NULL; 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir break; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir if( !mpViewList->Count() ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir maTimer.Stop(); 360cdf0e10cSrcweir mbIsInAnimation = sal_False; 361cdf0e10cSrcweir mnPos = 0UL; 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir if( !pMatch ) 365cdf0e10cSrcweir mpViewList->Insert( new ImplAnimView( this, pOut, rDestPt, rDestSz, nExtraData, pFirstFrameOutDev ), LIST_APPEND ); 366cdf0e10cSrcweir 367cdf0e10cSrcweir if( !mbIsInAnimation ) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir ImplRestartTimer( ( (AnimationBitmap*) maList.GetObject( mnPos ) )->nWait ); 370cdf0e10cSrcweir mbIsInAnimation = sal_True; 371cdf0e10cSrcweir } 372cdf0e10cSrcweir } 373cdf0e10cSrcweir else 374cdf0e10cSrcweir Draw( pOut, rDestPt, rDestSz ); 375cdf0e10cSrcweir 376cdf0e10cSrcweir bRet = sal_True; 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir return bRet; 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir // ----------------------------------------------------------------------- 383cdf0e10cSrcweir 384cdf0e10cSrcweir void Animation::Stop( OutputDevice* pOut, long nExtraData ) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir ImplAnimView* pView = (ImplAnimView*) mpViewList->First(); 387cdf0e10cSrcweir 388cdf0e10cSrcweir while( pView ) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir if( pView->ImplMatches( pOut, nExtraData ) ) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir delete (ImplAnimView*) mpViewList->Remove( pView ); 393cdf0e10cSrcweir pView = (ImplAnimView*) mpViewList->GetCurObject(); 394cdf0e10cSrcweir } 395cdf0e10cSrcweir else 396cdf0e10cSrcweir pView = (ImplAnimView*) mpViewList->Next(); 397cdf0e10cSrcweir } 398cdf0e10cSrcweir 399cdf0e10cSrcweir if( !mpViewList->Count() ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir maTimer.Stop(); 402cdf0e10cSrcweir mbIsInAnimation = sal_False; 403cdf0e10cSrcweir } 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir // ----------------------------------------------------------------------- 407cdf0e10cSrcweir 408cdf0e10cSrcweir void Animation::Draw( OutputDevice* pOut, const Point& rDestPt ) const 409cdf0e10cSrcweir { 410cdf0e10cSrcweir Draw( pOut, rDestPt, pOut->PixelToLogic( maGlobalSize ) ); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir // ----------------------------------------------------------------------- 414cdf0e10cSrcweir 415cdf0e10cSrcweir void Animation::Draw( OutputDevice* pOut, const Point& rDestPt, const Size& rDestSz ) const 416cdf0e10cSrcweir { 417cdf0e10cSrcweir const sal_uLong nCount = maList.Count(); 418cdf0e10cSrcweir 419cdf0e10cSrcweir if( nCount ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir AnimationBitmap* pObj = (AnimationBitmap*) maList.GetObject( Min( mnPos, (long) nCount - 1L ) ); 422cdf0e10cSrcweir 423cdf0e10cSrcweir if( pOut->GetConnectMetaFile() || ( pOut->GetOutDevType() == OUTDEV_PRINTER ) ) 424cdf0e10cSrcweir ( (AnimationBitmap*) maList.GetObject( 0 ) )->aBmpEx.Draw( pOut, rDestPt, rDestSz ); 425cdf0e10cSrcweir else if( ANIMATION_TIMEOUT_ON_CLICK == pObj->nWait ) 426cdf0e10cSrcweir pObj->aBmpEx.Draw( pOut, rDestPt, rDestSz ); 427cdf0e10cSrcweir else 428cdf0e10cSrcweir { 429cdf0e10cSrcweir const sal_uLong nOldPos = mnPos; 430cdf0e10cSrcweir ( (Animation*) this )->mnPos = mbLoopTerminated ? ( nCount - 1UL ) : mnPos; 431cdf0e10cSrcweir delete new ImplAnimView( (Animation*) this, pOut, rDestPt, rDestSz, 0 ); 432cdf0e10cSrcweir ( (Animation*) this )->mnPos = nOldPos; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir } 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir // ----------------------------------------------------------------------- 438cdf0e10cSrcweir 439cdf0e10cSrcweir void Animation::ImplRestartTimer( sal_uLong nTimeout ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir maTimer.SetTimeout( Max( nTimeout, (sal_uLong)(MIN_TIMEOUT + ( mnAnimCount - 1 ) * INC_TIMEOUT) ) * 10L ); 442cdf0e10cSrcweir maTimer.Start(); 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir // ----------------------------------------------------------------------- 446cdf0e10cSrcweir 447cdf0e10cSrcweir IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG ) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir const sal_uLong nAnimCount = maList.Count(); 450cdf0e10cSrcweir 451cdf0e10cSrcweir if( nAnimCount ) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir ImplAnimView* pView; 454cdf0e10cSrcweir sal_Bool bGlobalPause = sal_True; 455cdf0e10cSrcweir 456cdf0e10cSrcweir if( maNotifyLink.IsSet() ) 457cdf0e10cSrcweir { 458cdf0e10cSrcweir AInfo* pAInfo; 459cdf0e10cSrcweir 460cdf0e10cSrcweir // create AInfo-List 461cdf0e10cSrcweir for( pView = (ImplAnimView*) mpViewList->First(); pView; pView = (ImplAnimView*) mpViewList->Next() ) 462cdf0e10cSrcweir maAInfoList.Insert( pView->ImplCreateAInfo() ); 463cdf0e10cSrcweir 464cdf0e10cSrcweir maNotifyLink.Call( this ); 465cdf0e10cSrcweir 466cdf0e10cSrcweir // set view state from AInfo structure 467cdf0e10cSrcweir for( pAInfo = (AInfo*) maAInfoList.First(); pAInfo; pAInfo = (AInfo*) maAInfoList.Next() ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir if( !pAInfo->pViewData ) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir pView = new ImplAnimView( this, pAInfo->pOutDev, 472cdf0e10cSrcweir pAInfo->aStartOrg, pAInfo->aStartSize, pAInfo->nExtraData ); 473cdf0e10cSrcweir 474cdf0e10cSrcweir mpViewList->Insert( pView, LIST_APPEND ); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir else 477cdf0e10cSrcweir pView = (ImplAnimView*) pAInfo->pViewData; 478cdf0e10cSrcweir 479cdf0e10cSrcweir pView->ImplPause( pAInfo->bPause ); 480cdf0e10cSrcweir pView->ImplSetMarked( sal_True ); 481cdf0e10cSrcweir } 482cdf0e10cSrcweir 483cdf0e10cSrcweir // delete AInfo structures 484cdf0e10cSrcweir for( pAInfo = (AInfo*) maAInfoList.First(); pAInfo; pAInfo = (AInfo*) maAInfoList.Next() ) 485cdf0e10cSrcweir delete (AInfo*) pAInfo; 486cdf0e10cSrcweir maAInfoList.Clear(); 487cdf0e10cSrcweir 488cdf0e10cSrcweir // delete all unmarked views and reset marked state 489cdf0e10cSrcweir pView = (ImplAnimView*) mpViewList->First(); 490cdf0e10cSrcweir while( pView ) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir if( !pView->ImplIsMarked() ) 493cdf0e10cSrcweir { 494cdf0e10cSrcweir delete (ImplAnimView*) mpViewList->Remove( pView ); 495cdf0e10cSrcweir pView = (ImplAnimView*) mpViewList->GetCurObject(); 496cdf0e10cSrcweir } 497cdf0e10cSrcweir else 498cdf0e10cSrcweir { 499cdf0e10cSrcweir if( !pView->ImplIsPause() ) 500cdf0e10cSrcweir bGlobalPause = sal_False; 501cdf0e10cSrcweir 502cdf0e10cSrcweir pView->ImplSetMarked( sal_False ); 503cdf0e10cSrcweir pView = (ImplAnimView*) mpViewList->Next(); 504cdf0e10cSrcweir } 505cdf0e10cSrcweir } 506cdf0e10cSrcweir } 507cdf0e10cSrcweir else 508cdf0e10cSrcweir bGlobalPause = sal_False; 509cdf0e10cSrcweir 510cdf0e10cSrcweir if( !mpViewList->Count() ) 511cdf0e10cSrcweir Stop(); 512cdf0e10cSrcweir else if( bGlobalPause ) 513cdf0e10cSrcweir ImplRestartTimer( 10 ); 514cdf0e10cSrcweir else 515cdf0e10cSrcweir { 516cdf0e10cSrcweir AnimationBitmap* pStepBmp = (AnimationBitmap*) maList.GetObject( ++mnPos ); 517cdf0e10cSrcweir 518cdf0e10cSrcweir if( !pStepBmp ) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir if( mnLoops == 1 ) 521cdf0e10cSrcweir { 522cdf0e10cSrcweir Stop(); 523cdf0e10cSrcweir mbLoopTerminated = sal_True; 524cdf0e10cSrcweir mnPos = nAnimCount - 1UL; 525cdf0e10cSrcweir maBitmapEx = ( (AnimationBitmap*) maList.GetObject( mnPos ) )->aBmpEx; 526cdf0e10cSrcweir return 0L; 527cdf0e10cSrcweir } 528cdf0e10cSrcweir else 529cdf0e10cSrcweir { 530cdf0e10cSrcweir if( mnLoops ) 531cdf0e10cSrcweir mnLoops--; 532cdf0e10cSrcweir 533cdf0e10cSrcweir mnPos = 0; 534cdf0e10cSrcweir pStepBmp = (AnimationBitmap*) maList.GetObject( mnPos ); 535cdf0e10cSrcweir } 536cdf0e10cSrcweir } 537cdf0e10cSrcweir 538cdf0e10cSrcweir // Paint all views; after painting check, if view is 539cdf0e10cSrcweir // marked; in this case remove view, because area of output 540cdf0e10cSrcweir // lies out of display area of window; mark state is 541cdf0e10cSrcweir // set from view itself 542cdf0e10cSrcweir pView = (ImplAnimView*) mpViewList->First(); 543cdf0e10cSrcweir while( pView ) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir pView->ImplDraw( mnPos ); 546cdf0e10cSrcweir 547cdf0e10cSrcweir if( pView->ImplIsMarked() ) 548cdf0e10cSrcweir { 549cdf0e10cSrcweir delete (ImplAnimView*) mpViewList->Remove( pView ); 550cdf0e10cSrcweir pView = (ImplAnimView*) mpViewList->GetCurObject(); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir else 553cdf0e10cSrcweir pView = (ImplAnimView*) mpViewList->Next(); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir // stop or restart timer 557cdf0e10cSrcweir if( !mpViewList->Count() ) 558cdf0e10cSrcweir Stop(); 559cdf0e10cSrcweir else 560cdf0e10cSrcweir ImplRestartTimer( pStepBmp->nWait ); 561cdf0e10cSrcweir } 562cdf0e10cSrcweir } 563cdf0e10cSrcweir else 564cdf0e10cSrcweir Stop(); 565cdf0e10cSrcweir 566cdf0e10cSrcweir return 0L; 567cdf0e10cSrcweir } 568cdf0e10cSrcweir 569cdf0e10cSrcweir // ----------------------------------------------------------------------- 570cdf0e10cSrcweir 571cdf0e10cSrcweir sal_Bool Animation::Insert( const AnimationBitmap& rStepBmp ) 572cdf0e10cSrcweir { 573cdf0e10cSrcweir sal_Bool bRet = sal_False; 574cdf0e10cSrcweir 575cdf0e10cSrcweir if( !IsInAnimation() ) 576cdf0e10cSrcweir { 577cdf0e10cSrcweir Point aPoint; 578cdf0e10cSrcweir Rectangle aGlobalRect( aPoint, maGlobalSize ); 579cdf0e10cSrcweir 580cdf0e10cSrcweir maGlobalSize = aGlobalRect.Union( Rectangle( rStepBmp.aPosPix, rStepBmp.aSizePix ) ).GetSize(); 581cdf0e10cSrcweir maList.Insert( new AnimationBitmap( rStepBmp ), LIST_APPEND ); 582cdf0e10cSrcweir 583cdf0e10cSrcweir // zunaechst nehmen wir die erste BitmapEx als Ersatz-BitmapEx 584cdf0e10cSrcweir if( maList.Count() == 1 ) 585cdf0e10cSrcweir maBitmapEx = rStepBmp.aBmpEx; 586cdf0e10cSrcweir 587cdf0e10cSrcweir bRet = sal_True; 588cdf0e10cSrcweir } 589cdf0e10cSrcweir 590cdf0e10cSrcweir return bRet; 591cdf0e10cSrcweir } 592cdf0e10cSrcweir 593cdf0e10cSrcweir // ----------------------------------------------------------------------- 594cdf0e10cSrcweir 595cdf0e10cSrcweir const AnimationBitmap& Animation::Get( sal_uInt16 nAnimation ) const 596cdf0e10cSrcweir { 597cdf0e10cSrcweir DBG_ASSERT( ( nAnimation < maList.Count() ), "No object at this position" ); 598cdf0e10cSrcweir return *(AnimationBitmap*) maList.GetObject( nAnimation ); 599cdf0e10cSrcweir } 600cdf0e10cSrcweir 601cdf0e10cSrcweir // ----------------------------------------------------------------------- 602cdf0e10cSrcweir 603cdf0e10cSrcweir void Animation::Replace( const AnimationBitmap& rNewAnimationBitmap, sal_uInt16 nAnimation ) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir DBG_ASSERT( ( nAnimation < maList.Count() ), "No object at this position" ); 606cdf0e10cSrcweir 607cdf0e10cSrcweir delete (AnimationBitmap*) maList.Replace( new AnimationBitmap( rNewAnimationBitmap ), nAnimation ); 608cdf0e10cSrcweir 609cdf0e10cSrcweir // Falls wir an erster Stelle einfuegen, 610cdf0e10cSrcweir // muessen wir natuerlich auch, 611cdf0e10cSrcweir // auch die Ersatzdarstellungs-BitmapEx 612cdf0e10cSrcweir // aktualisieren; 613cdf0e10cSrcweir if ( ( !nAnimation && ( !mbLoopTerminated || ( maList.Count() == 1 ) ) ) || 614cdf0e10cSrcweir ( ( nAnimation == maList.Count() - 1 ) && mbLoopTerminated ) ) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir maBitmapEx = rNewAnimationBitmap.aBmpEx; 617cdf0e10cSrcweir } 618cdf0e10cSrcweir } 619cdf0e10cSrcweir 620cdf0e10cSrcweir // ----------------------------------------------------------------------- 621cdf0e10cSrcweir 622cdf0e10cSrcweir void Animation::SetLoopCount( const sal_uLong nLoopCount ) 623cdf0e10cSrcweir { 624cdf0e10cSrcweir mnLoopCount = nLoopCount; 625cdf0e10cSrcweir ResetLoopCount(); 626cdf0e10cSrcweir } 627cdf0e10cSrcweir 628cdf0e10cSrcweir // ----------------------------------------------------------------------- 629cdf0e10cSrcweir 630cdf0e10cSrcweir void Animation::ResetLoopCount() 631cdf0e10cSrcweir { 632cdf0e10cSrcweir mnLoops = mnLoopCount; 633cdf0e10cSrcweir mbLoopTerminated = sal_False; 634cdf0e10cSrcweir } 635cdf0e10cSrcweir 636cdf0e10cSrcweir // ----------------------------------------------------------------------- 637cdf0e10cSrcweir 638cdf0e10cSrcweir sal_Bool Animation::Convert( BmpConversion eConversion ) 639cdf0e10cSrcweir { 640cdf0e10cSrcweir DBG_ASSERT( !IsInAnimation(), "Animation modified while it is animated" ); 641cdf0e10cSrcweir 642cdf0e10cSrcweir sal_Bool bRet; 643cdf0e10cSrcweir 644cdf0e10cSrcweir if( !IsInAnimation() && maList.Count() ) 645cdf0e10cSrcweir { 646cdf0e10cSrcweir bRet = sal_True; 647cdf0e10cSrcweir 648cdf0e10cSrcweir for( void* pStepBmp = maList.First(); pStepBmp && bRet; pStepBmp = maList.Next() ) 649cdf0e10cSrcweir bRet = ( ( AnimationBitmap*) pStepBmp )->aBmpEx.Convert( eConversion ); 650cdf0e10cSrcweir 651cdf0e10cSrcweir maBitmapEx.Convert( eConversion ); 652cdf0e10cSrcweir } 653cdf0e10cSrcweir else 654cdf0e10cSrcweir bRet = sal_False; 655cdf0e10cSrcweir 656cdf0e10cSrcweir return bRet; 657cdf0e10cSrcweir } 658cdf0e10cSrcweir 659cdf0e10cSrcweir // ----------------------------------------------------------------------- 660cdf0e10cSrcweir 661cdf0e10cSrcweir sal_Bool Animation::ReduceColors( sal_uInt16 nNewColorCount, BmpReduce eReduce ) 662cdf0e10cSrcweir { 663cdf0e10cSrcweir DBG_ASSERT( !IsInAnimation(), "Animation modified while it is animated" ); 664cdf0e10cSrcweir 665cdf0e10cSrcweir sal_Bool bRet; 666cdf0e10cSrcweir 667cdf0e10cSrcweir if( !IsInAnimation() && maList.Count() ) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir bRet = sal_True; 670cdf0e10cSrcweir 671cdf0e10cSrcweir for( void* pStepBmp = maList.First(); pStepBmp && bRet; pStepBmp = maList.Next() ) 672cdf0e10cSrcweir bRet = ( ( AnimationBitmap*) pStepBmp )->aBmpEx.ReduceColors( nNewColorCount, eReduce ); 673cdf0e10cSrcweir 674cdf0e10cSrcweir maBitmapEx.ReduceColors( nNewColorCount, eReduce ); 675cdf0e10cSrcweir } 676cdf0e10cSrcweir else 677cdf0e10cSrcweir bRet = sal_False; 678cdf0e10cSrcweir 679cdf0e10cSrcweir return bRet; 680cdf0e10cSrcweir } 681cdf0e10cSrcweir 682cdf0e10cSrcweir // ----------------------------------------------------------------------- 683cdf0e10cSrcweir 684cdf0e10cSrcweir sal_Bool Animation::Invert() 685cdf0e10cSrcweir { 686cdf0e10cSrcweir DBG_ASSERT( !IsInAnimation(), "Animation modified while it is animated" ); 687cdf0e10cSrcweir 688cdf0e10cSrcweir sal_Bool bRet; 689cdf0e10cSrcweir 690cdf0e10cSrcweir if( !IsInAnimation() && maList.Count() ) 691cdf0e10cSrcweir { 692cdf0e10cSrcweir bRet = sal_True; 693cdf0e10cSrcweir 694cdf0e10cSrcweir for( void* pStepBmp = maList.First(); pStepBmp && bRet; pStepBmp = maList.Next() ) 695cdf0e10cSrcweir bRet = ( ( AnimationBitmap*) pStepBmp )->aBmpEx.Invert(); 696cdf0e10cSrcweir 697cdf0e10cSrcweir maBitmapEx.Invert(); 698cdf0e10cSrcweir } 699cdf0e10cSrcweir else 700cdf0e10cSrcweir bRet = sal_False; 701cdf0e10cSrcweir 702cdf0e10cSrcweir return bRet; 703cdf0e10cSrcweir } 704cdf0e10cSrcweir 705cdf0e10cSrcweir // ----------------------------------------------------------------------- 706cdf0e10cSrcweir 707cdf0e10cSrcweir sal_Bool Animation::Mirror( sal_uLong nMirrorFlags ) 708cdf0e10cSrcweir { 709cdf0e10cSrcweir DBG_ASSERT( !IsInAnimation(), "Animation modified while it is animated" ); 710cdf0e10cSrcweir 711cdf0e10cSrcweir sal_Bool bRet; 712cdf0e10cSrcweir 713cdf0e10cSrcweir if( !IsInAnimation() && maList.Count() ) 714cdf0e10cSrcweir { 715cdf0e10cSrcweir bRet = sal_True; 716cdf0e10cSrcweir 717cdf0e10cSrcweir if( nMirrorFlags ) 718cdf0e10cSrcweir { 719cdf0e10cSrcweir for( AnimationBitmap* pStepBmp = (AnimationBitmap*) maList.First(); 720cdf0e10cSrcweir pStepBmp && bRet; 721cdf0e10cSrcweir pStepBmp = (AnimationBitmap*) maList.Next() ) 722cdf0e10cSrcweir { 723cdf0e10cSrcweir if( ( bRet = pStepBmp->aBmpEx.Mirror( nMirrorFlags ) ) == sal_True ) 724cdf0e10cSrcweir { 725cdf0e10cSrcweir if( nMirrorFlags & BMP_MIRROR_HORZ ) 726cdf0e10cSrcweir pStepBmp->aPosPix.X() = maGlobalSize.Width() - pStepBmp->aPosPix.X() - pStepBmp->aSizePix.Width(); 727cdf0e10cSrcweir 728cdf0e10cSrcweir if( nMirrorFlags & BMP_MIRROR_VERT ) 729cdf0e10cSrcweir pStepBmp->aPosPix.Y() = maGlobalSize.Height() - pStepBmp->aPosPix.Y() - pStepBmp->aSizePix.Height(); 730cdf0e10cSrcweir } 731cdf0e10cSrcweir } 732cdf0e10cSrcweir 733cdf0e10cSrcweir maBitmapEx.Mirror( nMirrorFlags ); 734cdf0e10cSrcweir } 735cdf0e10cSrcweir } 736cdf0e10cSrcweir else 737cdf0e10cSrcweir bRet = sal_False; 738cdf0e10cSrcweir 739cdf0e10cSrcweir return bRet; 740cdf0e10cSrcweir } 741cdf0e10cSrcweir 742cdf0e10cSrcweir // ----------------------------------------------------------------------- 743cdf0e10cSrcweir 744cdf0e10cSrcweir sal_Bool Animation::Dither( sal_uLong nDitherFlags ) 745cdf0e10cSrcweir { 746cdf0e10cSrcweir DBG_ASSERT( !IsInAnimation(), "Animation modified while it is animated" ); 747cdf0e10cSrcweir 748cdf0e10cSrcweir sal_Bool bRet; 749cdf0e10cSrcweir 750cdf0e10cSrcweir if( !IsInAnimation() && maList.Count() ) 751cdf0e10cSrcweir { 752cdf0e10cSrcweir bRet = sal_True; 753cdf0e10cSrcweir 754cdf0e10cSrcweir for( void* pStepBmp = maList.First(); pStepBmp && bRet; pStepBmp = maList.Next() ) 755cdf0e10cSrcweir bRet = ( ( AnimationBitmap*) pStepBmp )->aBmpEx.Dither( nDitherFlags ); 756cdf0e10cSrcweir 757cdf0e10cSrcweir maBitmapEx.Dither( nDitherFlags ); 758cdf0e10cSrcweir } 759cdf0e10cSrcweir else 760cdf0e10cSrcweir bRet = sal_False; 761cdf0e10cSrcweir 762cdf0e10cSrcweir return bRet; 763cdf0e10cSrcweir } 764cdf0e10cSrcweir 765cdf0e10cSrcweir // ----------------------------------------------------------------------- 766cdf0e10cSrcweir 767cdf0e10cSrcweir sal_Bool Animation::Adjust( short nLuminancePercent, short nContrastPercent, 768cdf0e10cSrcweir short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, 769cdf0e10cSrcweir double fGamma, sal_Bool bInvert ) 770cdf0e10cSrcweir { 771cdf0e10cSrcweir DBG_ASSERT( !IsInAnimation(), "Animation modified while it is animated" ); 772cdf0e10cSrcweir 773cdf0e10cSrcweir sal_Bool bRet; 774cdf0e10cSrcweir 775cdf0e10cSrcweir if( !IsInAnimation() && maList.Count() ) 776cdf0e10cSrcweir { 777cdf0e10cSrcweir bRet = sal_True; 778cdf0e10cSrcweir 779cdf0e10cSrcweir for( void* pStepBmp = maList.First(); pStepBmp && bRet; pStepBmp = maList.Next() ) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir bRet = ( ( AnimationBitmap*) pStepBmp )->aBmpEx.Adjust( nLuminancePercent, nContrastPercent, 782cdf0e10cSrcweir nChannelRPercent, nChannelGPercent, nChannelBPercent, 783cdf0e10cSrcweir fGamma, bInvert ); 784cdf0e10cSrcweir } 785cdf0e10cSrcweir 786cdf0e10cSrcweir maBitmapEx.Adjust( nLuminancePercent, nContrastPercent, 787cdf0e10cSrcweir nChannelRPercent, nChannelGPercent, nChannelBPercent, 788cdf0e10cSrcweir fGamma, bInvert ); 789cdf0e10cSrcweir } 790cdf0e10cSrcweir else 791cdf0e10cSrcweir bRet = sal_False; 792cdf0e10cSrcweir 793cdf0e10cSrcweir return bRet; 794cdf0e10cSrcweir } 795cdf0e10cSrcweir 796cdf0e10cSrcweir // ----------------------------------------------------------------------- 797cdf0e10cSrcweir 798cdf0e10cSrcweir sal_Bool Animation::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam, const Link* pProgress ) 799cdf0e10cSrcweir { 800cdf0e10cSrcweir DBG_ASSERT( !IsInAnimation(), "Animation modified while it is animated" ); 801cdf0e10cSrcweir 802cdf0e10cSrcweir sal_Bool bRet; 803cdf0e10cSrcweir 804cdf0e10cSrcweir if( !IsInAnimation() && maList.Count() ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir bRet = sal_True; 807cdf0e10cSrcweir 808cdf0e10cSrcweir for( void* pStepBmp = maList.First(); pStepBmp && bRet; pStepBmp = maList.Next() ) 809cdf0e10cSrcweir bRet = ( ( AnimationBitmap*) pStepBmp )->aBmpEx.Filter( eFilter, pFilterParam, pProgress ); 810cdf0e10cSrcweir 811cdf0e10cSrcweir maBitmapEx.Filter( eFilter, pFilterParam, pProgress ); 812cdf0e10cSrcweir } 813cdf0e10cSrcweir else 814cdf0e10cSrcweir bRet = sal_False; 815cdf0e10cSrcweir 816cdf0e10cSrcweir return bRet; 817cdf0e10cSrcweir } 818cdf0e10cSrcweir 819cdf0e10cSrcweir // ----------------------------------------------------------------------- 820cdf0e10cSrcweir 821cdf0e10cSrcweir SvStream& operator<<( SvStream& rOStm, const Animation& rAnimation ) 822cdf0e10cSrcweir { 823cdf0e10cSrcweir const sal_uInt16 nCount = rAnimation.Count(); 824cdf0e10cSrcweir 825cdf0e10cSrcweir if( nCount ) 826cdf0e10cSrcweir { 827cdf0e10cSrcweir const ByteString aDummyStr; 828cdf0e10cSrcweir const sal_uInt32 nDummy32 = 0UL; 829cdf0e10cSrcweir 830cdf0e10cSrcweir // Falls keine BitmapEx gesetzt wurde, schreiben wir 831cdf0e10cSrcweir // einfach die erste Bitmap der Animation 832cdf0e10cSrcweir if( !rAnimation.GetBitmapEx().GetBitmap() ) 833cdf0e10cSrcweir rOStm << rAnimation.Get( 0 ).aBmpEx; 834cdf0e10cSrcweir else 835cdf0e10cSrcweir rOStm << rAnimation.GetBitmapEx(); 836cdf0e10cSrcweir 837cdf0e10cSrcweir // Kennung schreiben ( SDANIMA1 ) 838cdf0e10cSrcweir rOStm << (sal_uInt32) 0x5344414e << (sal_uInt32) 0x494d4931; 839cdf0e10cSrcweir 840cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nCount; i++ ) 841cdf0e10cSrcweir { 842cdf0e10cSrcweir const AnimationBitmap& rAnimBmp = rAnimation.Get( i ); 843cdf0e10cSrcweir const sal_uInt16 nRest = nCount - i - 1; 844cdf0e10cSrcweir 845cdf0e10cSrcweir // AnimationBitmap schreiben 846cdf0e10cSrcweir rOStm << rAnimBmp.aBmpEx; 847cdf0e10cSrcweir rOStm << rAnimBmp.aPosPix; 848cdf0e10cSrcweir rOStm << rAnimBmp.aSizePix; 849cdf0e10cSrcweir rOStm << rAnimation.maGlobalSize; 850cdf0e10cSrcweir rOStm << (sal_uInt16) ( ( ANIMATION_TIMEOUT_ON_CLICK == rAnimBmp.nWait ) ? 65535 : rAnimBmp.nWait ); 851cdf0e10cSrcweir rOStm << (sal_uInt16) rAnimBmp.eDisposal; 852cdf0e10cSrcweir rOStm << (sal_uInt8) rAnimBmp.bUserInput; 853cdf0e10cSrcweir rOStm << (sal_uInt32) rAnimation.mnLoopCount; 854cdf0e10cSrcweir rOStm << nDummy32; // unbenutzt 855cdf0e10cSrcweir rOStm << nDummy32; // unbenutzt 856cdf0e10cSrcweir rOStm << nDummy32; // unbenutzt 857cdf0e10cSrcweir rOStm << aDummyStr; // unbenutzt 858cdf0e10cSrcweir rOStm << nRest; // Anzahl der Strukturen, die noch _folgen_ 859cdf0e10cSrcweir } 860cdf0e10cSrcweir } 861cdf0e10cSrcweir 862cdf0e10cSrcweir return rOStm; 863cdf0e10cSrcweir } 864cdf0e10cSrcweir 865cdf0e10cSrcweir // ----------------------------------------------------------------------- 866cdf0e10cSrcweir 867cdf0e10cSrcweir SvStream& operator>>( SvStream& rIStm, Animation& rAnimation ) 868cdf0e10cSrcweir { 869cdf0e10cSrcweir Bitmap aBmp; 870cdf0e10cSrcweir sal_uLong nStmPos = rIStm.Tell(); 871cdf0e10cSrcweir sal_uInt32 nAnimMagic1, nAnimMagic2; 872cdf0e10cSrcweir sal_uInt16 nOldFormat = rIStm.GetNumberFormatInt(); 873cdf0e10cSrcweir sal_Bool bReadAnimations = sal_False; 874cdf0e10cSrcweir 875cdf0e10cSrcweir rIStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); 876cdf0e10cSrcweir nStmPos = rIStm.Tell(); 877cdf0e10cSrcweir rIStm >> nAnimMagic1 >> nAnimMagic2; 878cdf0e10cSrcweir 879cdf0e10cSrcweir rAnimation.Clear(); 880cdf0e10cSrcweir 881cdf0e10cSrcweir // Wenn die BitmapEx am Anfang schon gelesen 882cdf0e10cSrcweir // wurde ( von Graphic ), koennen wir direkt die Animationsbitmaps einlesen 883cdf0e10cSrcweir if( ( nAnimMagic1 == 0x5344414e ) && ( nAnimMagic2 == 0x494d4931 ) && !rIStm.GetError() ) 884cdf0e10cSrcweir bReadAnimations = sal_True; 885cdf0e10cSrcweir // ansonsten versuchen wir erstmal die Bitmap(-Ex) zu lesen 886cdf0e10cSrcweir else 887cdf0e10cSrcweir { 888cdf0e10cSrcweir rIStm.Seek( nStmPos ); 889cdf0e10cSrcweir rIStm >> rAnimation.maBitmapEx; 890cdf0e10cSrcweir nStmPos = rIStm.Tell(); 891cdf0e10cSrcweir rIStm >> nAnimMagic1 >> nAnimMagic2; 892cdf0e10cSrcweir 893cdf0e10cSrcweir if( ( nAnimMagic1 == 0x5344414e ) && ( nAnimMagic2 == 0x494d4931 ) && !rIStm.GetError() ) 894cdf0e10cSrcweir bReadAnimations = sal_True; 895cdf0e10cSrcweir else 896cdf0e10cSrcweir rIStm.Seek( nStmPos ); 897cdf0e10cSrcweir } 898cdf0e10cSrcweir 899cdf0e10cSrcweir // ggf. Animationsbitmaps lesen 900cdf0e10cSrcweir if( bReadAnimations ) 901cdf0e10cSrcweir { 902cdf0e10cSrcweir AnimationBitmap aAnimBmp; 903cdf0e10cSrcweir BitmapEx aBmpEx; 904cdf0e10cSrcweir ByteString aDummyStr; 905cdf0e10cSrcweir sal_uInt32 nTmp32; 906cdf0e10cSrcweir sal_uInt16 nTmp16; 907cdf0e10cSrcweir sal_uInt8 cTmp; 908cdf0e10cSrcweir 909cdf0e10cSrcweir do 910cdf0e10cSrcweir { 911cdf0e10cSrcweir rIStm >> aAnimBmp.aBmpEx; 912cdf0e10cSrcweir rIStm >> aAnimBmp.aPosPix; 913cdf0e10cSrcweir rIStm >> aAnimBmp.aSizePix; 914cdf0e10cSrcweir rIStm >> rAnimation.maGlobalSize; 915cdf0e10cSrcweir rIStm >> nTmp16; aAnimBmp.nWait = ( ( 65535 == nTmp16 ) ? ANIMATION_TIMEOUT_ON_CLICK : nTmp16 ); 916cdf0e10cSrcweir rIStm >> nTmp16; aAnimBmp.eDisposal = ( Disposal) nTmp16; 917cdf0e10cSrcweir rIStm >> cTmp; aAnimBmp.bUserInput = (sal_Bool) cTmp; 918cdf0e10cSrcweir rIStm >> nTmp32; rAnimation.mnLoopCount = (sal_uInt16) nTmp32; 919cdf0e10cSrcweir rIStm >> nTmp32; // unbenutzt 920cdf0e10cSrcweir rIStm >> nTmp32; // unbenutzt 921cdf0e10cSrcweir rIStm >> nTmp32; // unbenutzt 922cdf0e10cSrcweir rIStm >> aDummyStr; // unbenutzt 923cdf0e10cSrcweir rIStm >> nTmp16; // Rest zu lesen 924cdf0e10cSrcweir 925cdf0e10cSrcweir rAnimation.Insert( aAnimBmp ); 926cdf0e10cSrcweir } 927cdf0e10cSrcweir while( nTmp16 && !rIStm.GetError() ); 928cdf0e10cSrcweir 929cdf0e10cSrcweir rAnimation.ResetLoopCount(); 930cdf0e10cSrcweir } 931cdf0e10cSrcweir 932cdf0e10cSrcweir rIStm.SetNumberFormatInt( nOldFormat ); 933cdf0e10cSrcweir 934cdf0e10cSrcweir return rIStm; 935cdf0e10cSrcweir } 936