Kaydet (Commit) dd1e686f authored tarafından Joseph Powers's avatar Joseph Powers

Replace List with std::vector< ImplAnimView* >

Ok, the list was a pointer to the list; however, the constructor always
created one and it was never replaced. Thus, I don't see a reason for the
member to be a pointer.
üst 7d1a41c1
...@@ -145,18 +145,20 @@ struct AInfo ...@@ -145,18 +145,20 @@ struct AInfo
// - AnimationBitmap - // - AnimationBitmap -
// ------------------- // -------------------
class ImplAnimView;
typedef ::std::vector< AnimationBitmap* > AnimationBitmapList_impl; typedef ::std::vector< AnimationBitmap* > AnimationBitmapList_impl;
typedef ::std::vector< ImplAnimView* > AnimViewList_impl;
class VCL_DLLPUBLIC Animation class VCL_DLLPUBLIC Animation
{ {
SAL_DLLPRIVATE static sal_uLong mnAnimCount; SAL_DLLPRIVATE static sal_uLong mnAnimCount;
AnimationBitmapList_impl maList; AnimationBitmapList_impl maList;
AnimViewList_impl maViewList;
Link maNotifyLink; Link maNotifyLink;
BitmapEx maBitmapEx; BitmapEx maBitmapEx;
Timer maTimer; Timer maTimer;
Size maGlobalSize; Size maGlobalSize;
List* mpViewList;
void* mpExtraData; void* mpExtraData;
long mnLoopCount; long mnLoopCount;
long mnLoops; long mnLoops;
......
...@@ -100,7 +100,6 @@ Animation::Animation() : ...@@ -100,7 +100,6 @@ Animation::Animation() :
{ {
DBG_CTOR( Animation, NULL ); DBG_CTOR( Animation, NULL );
maTimer.SetTimeoutHdl( LINK( this, Animation, ImplTimeoutHdl ) ); maTimer.SetTimeoutHdl( LINK( this, Animation, ImplTimeoutHdl ) );
mpViewList = new List;
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -121,7 +120,6 @@ Animation::Animation( const Animation& rAnimation ) : ...@@ -121,7 +120,6 @@ Animation::Animation( const Animation& rAnimation ) :
maList.push_back( new AnimationBitmap( *rAnimation.maList[ i ] ) ); maList.push_back( new AnimationBitmap( *rAnimation.maList[ i ] ) );
maTimer.SetTimeoutHdl( LINK( this, Animation, ImplTimeoutHdl ) ); maTimer.SetTimeoutHdl( LINK( this, Animation, ImplTimeoutHdl ) );
mpViewList = new List;
mnLoops = mbLoopTerminated ? 0 : mnLoopCount; mnLoops = mbLoopTerminated ? 0 : mnLoopCount;
} }
...@@ -137,10 +135,8 @@ Animation::~Animation() ...@@ -137,10 +135,8 @@ Animation::~Animation()
for( size_t i = 0, n = maList.size(); i < n; ++i ) for( size_t i = 0, n = maList.size(); i < n; ++i )
delete maList[ i ]; delete maList[ i ];
for( void* pView = mpViewList->First(); pView; pView = mpViewList->Next() ) for( size_t i = 0, n = maViewList.size(); i < n; ++i )
delete (ImplAnimView*) pView; delete maViewList[ i ];
delete mpViewList;
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -233,9 +229,9 @@ void Animation::SetEmpty() ...@@ -233,9 +229,9 @@ void Animation::SetEmpty()
delete maList[ i ]; delete maList[ i ];
maList.clear(); maList.clear();
for( void* pView = mpViewList->First(); pView; pView = mpViewList->Next() ) for( size_t i = 0, n = maViewList.size(); i < n; ++i )
delete (ImplAnimView*) pView; delete maViewList[ i ];
mpViewList->Clear(); maViewList.clear();
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -344,8 +340,9 @@ sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size& ...@@ -344,8 +340,9 @@ sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size&
ImplAnimView* pView; ImplAnimView* pView;
ImplAnimView* pMatch = NULL; ImplAnimView* pMatch = NULL;
for( pView = (ImplAnimView*) mpViewList->First(); pView; pView = (ImplAnimView*) mpViewList->Next() ) for( size_t i = 0; i < maViewList.size(); ++i )
{ {
pView = maViewList[ i ];
if( pView->ImplMatches( pOut, nExtraData ) ) if( pView->ImplMatches( pOut, nExtraData ) )
{ {
if( pView->ImplGetOutPos() == rDestPt && if( pView->ImplGetOutPos() == rDestPt &&
...@@ -356,7 +353,8 @@ sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size& ...@@ -356,7 +353,8 @@ sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size&
} }
else else
{ {
delete (ImplAnimView*) mpViewList->Remove( pView ); delete maViewList[ i ];
maViewList.erase( maViewList.begin() + i );
pView = NULL; pView = NULL;
} }
...@@ -364,7 +362,7 @@ sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size& ...@@ -364,7 +362,7 @@ sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size&
} }
} }
if( !mpViewList->Count() ) if( maViewList.empty() )
{ {
maTimer.Stop(); maTimer.Stop();
mbIsInAnimation = sal_False; mbIsInAnimation = sal_False;
...@@ -372,7 +370,7 @@ sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size& ...@@ -372,7 +370,7 @@ sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size&
} }
if( !pMatch ) if( !pMatch )
mpViewList->Insert( new ImplAnimView( this, pOut, rDestPt, rDestSz, nExtraData, pFirstFrameOutDev ), LIST_APPEND ); maViewList.push_back( new ImplAnimView( this, pOut, rDestPt, rDestSz, nExtraData, pFirstFrameOutDev ) );
if( !mbIsInAnimation ) if( !mbIsInAnimation )
{ {
...@@ -393,20 +391,21 @@ sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size& ...@@ -393,20 +391,21 @@ sal_Bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size&
void Animation::Stop( OutputDevice* pOut, long nExtraData ) void Animation::Stop( OutputDevice* pOut, long nExtraData )
{ {
ImplAnimView* pView = (ImplAnimView*) mpViewList->First(); for( size_t i = 0; i < maViewList.size(); )
while( pView )
{ {
ImplAnimView* pView = maViewList[ i ];
if( pView->ImplMatches( pOut, nExtraData ) ) if( pView->ImplMatches( pOut, nExtraData ) )
{ {
delete (ImplAnimView*) mpViewList->Remove( pView ); delete pView;
pView = (ImplAnimView*) mpViewList->GetCurObject(); maViewList.erase( maViewList.begin() + i );
} }
else else
pView = (ImplAnimView*) mpViewList->Next(); i++;
} }
if( !mpViewList->Count() ) if( maViewList.empty() )
{ {
maTimer.Stop(); maTimer.Stop();
mbIsInAnimation = sal_False; mbIsInAnimation = sal_False;
...@@ -472,8 +471,8 @@ IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG ) ...@@ -472,8 +471,8 @@ IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG )
AInfo* pAInfo; AInfo* pAInfo;
// create AInfo-List // create AInfo-List
for( pView = (ImplAnimView*) mpViewList->First(); pView; pView = (ImplAnimView*) mpViewList->Next() ) for( size_t i = 0, n = maViewList.size(); i < n; ++i )
aAInfoList.push_back( pView->ImplCreateAInfo() ); aAInfoList.push_back( maViewList[ i ]->ImplCreateAInfo() );
maNotifyLink.Call( this ); maNotifyLink.Call( this );
...@@ -486,7 +485,7 @@ IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG ) ...@@ -486,7 +485,7 @@ IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG )
pView = new ImplAnimView( this, pAInfo->pOutDev, pView = new ImplAnimView( this, pAInfo->pOutDev,
pAInfo->aStartOrg, pAInfo->aStartSize, pAInfo->nExtraData ); pAInfo->aStartOrg, pAInfo->aStartSize, pAInfo->nExtraData );
mpViewList->Insert( pView, LIST_APPEND ); maViewList.push_back( pView );
} }
else else
pView = (ImplAnimView*) pAInfo->pViewData; pView = (ImplAnimView*) pAInfo->pViewData;
...@@ -501,13 +500,13 @@ IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG ) ...@@ -501,13 +500,13 @@ IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG )
aAInfoList.clear(); aAInfoList.clear();
// delete all unmarked views and reset marked state // delete all unmarked views and reset marked state
pView = (ImplAnimView*) mpViewList->First(); for( size_t i = 0; i < maViewList.size(); )
while( pView )
{ {
pView = maViewList[ i ];
if( !pView->ImplIsMarked() ) if( !pView->ImplIsMarked() )
{ {
delete (ImplAnimView*) mpViewList->Remove( pView ); delete pView;
pView = (ImplAnimView*) mpViewList->GetCurObject(); maViewList.erase( maViewList.begin() + i );
} }
else else
{ {
...@@ -515,14 +514,14 @@ IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG ) ...@@ -515,14 +514,14 @@ IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG )
bGlobalPause = sal_False; bGlobalPause = sal_False;
pView->ImplSetMarked( sal_False ); pView->ImplSetMarked( sal_False );
pView = (ImplAnimView*) mpViewList->Next(); i++;
} }
} }
} }
else else
bGlobalPause = sal_False; bGlobalPause = sal_False;
if( !mpViewList->Count() ) if( maViewList.empty() )
Stop(); Stop();
else if( bGlobalPause ) else if( bGlobalPause )
ImplRestartTimer( 10 ); ImplRestartTimer( 10 );
...@@ -554,22 +553,22 @@ IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG ) ...@@ -554,22 +553,22 @@ IMPL_LINK( Animation, ImplTimeoutHdl, Timer*, EMPTYARG )
// marked; in this case remove view, because area of output // marked; in this case remove view, because area of output
// lies out of display area of window; mark state is // lies out of display area of window; mark state is
// set from view itself // set from view itself
pView = (ImplAnimView*) mpViewList->First(); for( size_t i = 0; i < maViewList.size(); )
while( pView )
{ {
pView = maViewList[ i ];
pView->ImplDraw( mnPos ); pView->ImplDraw( mnPos );
if( pView->ImplIsMarked() ) if( pView->ImplIsMarked() )
{ {
delete (ImplAnimView*) mpViewList->Remove( pView ); delete pView;
pView = (ImplAnimView*) mpViewList->GetCurObject(); maViewList.erase( maViewList.begin() + i );
} }
else else
pView = (ImplAnimView*) mpViewList->Next(); i++;
} }
// stop or restart timer // stop or restart timer
if( !mpViewList->Count() ) if( maViewList.empty() )
Stop(); Stop();
else else
ImplRestartTimer( pStepBmp->nWait ); ImplRestartTimer( pStepBmp->nWait );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment