diff options
author | Noel Grandin <noel@peralex.com> | 2012-06-14 11:39:42 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-06-20 19:46:39 +0200 |
commit | af50c7d9ce96de45d40e6c1462bf1682ce7572a5 (patch) | |
tree | db7854e15ede1bb4d5ce1fac83f4f2e94e814bd1 | |
parent | 20aa56cc713866255475aa7fbc4218bf0a58b581 (diff) |
Convert SV_DECL_PTRARR(SfxViewFrameArr_Impl) to std::vector
Change-Id: I3b6f41b97d1fc375985465ea9e5c0cca9e05ba10
-rw-r--r-- | sfx2/inc/arrdecl.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 29 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 12 |
3 files changed, 21 insertions, 22 deletions
diff --git a/sfx2/inc/arrdecl.hxx b/sfx2/inc/arrdecl.hxx index ad25bea7a413..9d1644640ae9 100644 --- a/sfx2/inc/arrdecl.hxx +++ b/sfx2/inc/arrdecl.hxx @@ -37,7 +37,7 @@ class SfxObjectShell; SV_DECL_PTRARR( SfxObjectShellArr_Impl, SfxObjectShell*, 4 ) class SfxViewFrame; -SV_DECL_PTRARR( SfxViewFrameArr_Impl, SfxViewFrame*, 4 ) +class SfxViewFrameArr_Impl : public std::vector<SfxViewFrame*> {}; class SfxViewShell; class SfxViewShellArr_Impl : public std::vector<SfxViewShell*> {}; diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index c4ccb6dbaee2..3719ac1c7149 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -252,7 +252,7 @@ public: void InsertViewFrame( SfxViewFrame* pFrame ) { StartListening( *pFrame ); - C40_INSERT( SfxViewFrame, pFrame, Count() ); + push_back( pFrame ); } void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); }; @@ -268,9 +268,9 @@ void SfxViewNotificatedFrameList_Impl::Notify( SfxBroadcaster& rBC, const SfxHin SfxViewFrame* pFrame = (SfxViewFrame*) &rBC; if( pFrame ) { - sal_uInt16 nPos = C40_GETPOS( SfxViewFrame, pFrame ); - if( nPos != USHRT_MAX ) - Remove( nPos ); + iterator it = std::find( begin(), end(), pFrame ); + if( it != end() ) + erase( it ); } break; } @@ -1432,9 +1432,8 @@ void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh ) pDispatcher->Flush(); } - SfxViewFrame *pThis = this; // this due to the sick Array syntax SfxViewFrameArr_Impl &rViewArr = SFX_APP()->GetViewFrames_Impl(); - rViewArr.C40_INSERT(SfxViewFrame, pThis, rViewArr.Count() ); + rViewArr.push_back( this ); } SfxViewFrame::SfxViewFrame @@ -1491,8 +1490,8 @@ SfxViewFrame::~SfxViewFrame() // Unregister from the Frame List. SfxApplication *pSfxApp = SFX_APP(); SfxViewFrameArr_Impl &rFrames = pSfxApp->GetViewFrames_Impl(); - const SfxViewFrame *pThis = this; - rFrames.Remove( rFrames.GetPos(pThis) ); + SfxViewFrameArr_Impl::iterator it = std::find( rFrames.begin(), rFrames.end(), this ); + rFrames.erase( it ); // Delete Member KillDispatcher_Impl(); @@ -1539,9 +1538,9 @@ SfxViewFrame* SfxViewFrame::GetFirst SfxViewFrameArr_Impl &rFrames = pSfxApp->GetViewFrames_Impl(); // search for a SfxDocument of the specified type - for ( sal_uInt16 nPos = 0; nPos < rFrames.Count(); ++nPos ) + for ( sal_uInt16 nPos = 0; nPos < rFrames.size(); ++nPos ) { - SfxViewFrame *pFrame = rFrames.GetObject(nPos); + SfxViewFrame *pFrame = rFrames[nPos]; if ( ( !pDoc || pDoc == pFrame->GetObjectShell() ) && ( !bOnlyIfVisible || pFrame->IsVisible() ) ) @@ -1565,14 +1564,14 @@ SfxViewFrame* SfxViewFrame::GetNext // refind the specified predecessor sal_uInt16 nPos; - for ( nPos = 0; nPos < rFrames.Count(); ++nPos ) - if ( rFrames.GetObject(nPos) == &rPrev ) + for ( nPos = 0; nPos < rFrames.size(); ++nPos ) + if ( rFrames[nPos] == &rPrev ) break; // search for a Frame of the specified type - for ( ++nPos; nPos < rFrames.Count(); ++nPos ) + for ( ++nPos; nPos < rFrames.size(); ++nPos ) { - SfxViewFrame *pFrame = rFrames.GetObject(nPos); + SfxViewFrame *pFrame = rFrames[nPos]; if ( ( !pDoc || pDoc == pFrame->GetObjectShell() ) && ( !bOnlyIfVisible || pFrame->IsVisible() ) ) @@ -2205,7 +2204,7 @@ sal_Bool SfxViewFrame::SwitchToViewShell_Impl return sal_False; } - DBG_ASSERT( SFX_APP()->GetViewFrames_Impl().Count() == SFX_APP()->GetViewShells_Impl().size(), "Inconsistent view arrays!" ); + DBG_ASSERT( SFX_APP()->GetViewFrames_Impl().size() == SFX_APP()->GetViewShells_Impl().size(), "Inconsistent view arrays!" ); return sal_True; } diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 3afdbef12b20..1f364c89907b 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1552,9 +1552,9 @@ SfxViewShell* SfxViewShell::GetFirst // sometimes dangling SfxViewShells exist that point to a dead SfxViewFrame // these ViewShells shouldn't be accessible anymore // a destroyed ViewFrame is not in the ViewFrame array anymore, so checking this array helps - for ( sal_uInt16 n=0; n<rFrames.Count(); ++n ) + for ( sal_uInt16 n=0; n<rFrames.size(); ++n ) { - SfxViewFrame *pFrame = rFrames.GetObject(n); + SfxViewFrame *pFrame = rFrames[n]; if ( pFrame == pShell->GetViewFrame() ) { // only ViewShells with a valid ViewFrame will be returned @@ -1594,9 +1594,9 @@ SfxViewShell* SfxViewShell::GetNext // sometimes dangling SfxViewShells exist that point to a dead SfxViewFrame // these ViewShells shouldn't be accessible anymore // a destroyed ViewFrame is not in the ViewFrame array anymore, so checking this array helps - for ( sal_uInt16 n=0; n<rFrames.Count(); ++n ) + for ( sal_uInt16 n=0; n<rFrames.size(); ++n ) { - SfxViewFrame *pFrame = rFrames.GetObject(n); + SfxViewFrame *pFrame = rFrames[n]; if ( pFrame == pShell->GetViewFrame() ) { // only ViewShells with a valid ViewFrame will be returned @@ -1626,9 +1626,9 @@ void SfxViewShell::Notify( SfxBroadcaster& rBC, { // avoid access to dangling ViewShells SfxViewFrameArr_Impl &rFrames = SFX_APP()->GetViewFrames_Impl(); - for ( sal_uInt16 n=0; n<rFrames.Count(); ++n ) + for ( sal_uInt16 n=0; n<rFrames.size(); ++n ) { - SfxViewFrame *frame = rFrames.GetObject(n); + SfxViewFrame *frame = rFrames[n]; if ( frame == GetViewFrame() && &rBC == GetObjectShell() ) { SfxItemSet* pSet = GetObjectShell()->GetMedium()->GetItemSet(); |