Kaydet (Commit) 000bb6af authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Fridrich Štrba

Convert tools/table.hxx usage to std::map in Basic IDE module

üst e55595d0
...@@ -146,6 +146,7 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq ) ...@@ -146,6 +146,7 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
DBG_ASSERT( nWhich, "Wich fuer SearchItem ?" ); DBG_ASSERT( nWhich, "Wich fuer SearchItem ?" );
const SfxPoolItem& rItem = pArgs->Get( nWhich ); const SfxPoolItem& rItem = pArgs->Get( nWhich );
DBG_ASSERT( rItem.ISA( SvxSearchItem ), "Kein Searchitem!" ); DBG_ASSERT( rItem.ISA( SvxSearchItem ), "Kein Searchitem!" );
IDEWindowTable::const_iterator it;
if ( rItem.ISA( SvxSearchItem ) ) if ( rItem.ISA( SvxSearchItem ) )
{ {
// memorize item because of the adjustments... // memorize item because of the adjustments...
...@@ -155,22 +156,20 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq ) ...@@ -155,22 +156,20 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
if ( ((const SvxSearchItem&)rItem).GetCommand() == SVX_SEARCHCMD_REPLACE_ALL ) if ( ((const SvxSearchItem&)rItem).GetCommand() == SVX_SEARCHCMD_REPLACE_ALL )
{ {
sal_uInt16 nActModWindows = 0; sal_uInt16 nActModWindows = 0;
IDEBaseWindow* pWin = aIDEWindowTable.First(); for( it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
while ( pWin )
{ {
IDEBaseWindow* pWin = it->second;
if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) ) if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) )
nActModWindows++; nActModWindows++;
pWin = aIDEWindowTable.Next();
} }
if ( ( nActModWindows <= 1 ) || ( !((const SvxSearchItem&)rItem).GetSelection() && QueryBox( pCurWin, WB_YES_NO|WB_DEF_YES, String( IDEResId( RID_STR_SEARCHALLMODULES ) ) ).Execute() == RET_YES ) ) if ( ( nActModWindows <= 1 ) || ( !((const SvxSearchItem&)rItem).GetSelection() && QueryBox( pCurWin, WB_YES_NO|WB_DEF_YES, String( IDEResId( RID_STR_SEARCHALLMODULES ) ) ).Execute() == RET_YES ) )
{ {
pWin = aIDEWindowTable.First(); for( it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
while ( pWin )
{ {
IDEBaseWindow* pWin = it->second;
if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) ) if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) )
nFound = nFound + ((ModulWindow*)pWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem ); nFound = nFound + ((ModulWindow*)pWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem );
pWin = aIDEWindowTable.Next();
} }
} }
else else
...@@ -187,8 +186,15 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq ) ...@@ -187,8 +186,15 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
{ {
// search other modules... // search other modules...
sal_Bool bChangeCurWindow = sal_False; sal_Bool bChangeCurWindow = sal_False;
aIDEWindowTable.Seek( pCurWin ); for( it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
IDEBaseWindow* pWin = aIDEWindowTable.Next(); if ( it->second == pCurWin)
break;
if ( it != aIDEWindowTable.end() )
++it;
IDEBaseWindow* pWin = NULL;
if ( it != aIDEWindowTable.end() )
pWin = it->second;
sal_Bool bSearchedFromStart = sal_False; sal_Bool bSearchedFromStart = sal_False;
while ( !nFound && !bCanceled && ( pWin || !bSearchedFromStart ) ) while ( !nFound && !bCanceled && ( pWin || !bSearchedFromStart ) )
{ {
...@@ -200,7 +206,9 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq ) ...@@ -200,7 +206,9 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
QueryBox aQuery(pParent, WB_YES_NO|WB_DEF_YES, ResId::toString(IDEResId(RID_STR_SEARCHFROMSTART))); QueryBox aQuery(pParent, WB_YES_NO|WB_DEF_YES, ResId::toString(IDEResId(RID_STR_SEARCHFROMSTART)));
if ( aQuery.Execute() == RET_YES ) if ( aQuery.Execute() == RET_YES )
{ {
pWin = aIDEWindowTable.First(); it = aIDEWindowTable.begin();
if ( it != aIDEWindowTable.end() )
pWin = it->second;
bSearchedFromStart = sal_True; bSearchedFromStart = sal_True;
} }
else else
...@@ -222,7 +230,11 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq ) ...@@ -222,7 +230,11 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
} }
} }
if ( pWin && ( pWin != pCurWin ) ) if ( pWin && ( pWin != pCurWin ) )
pWin = aIDEWindowTable.Next(); {
++it;
if ( it != aIDEWindowTable.end() )
pWin = it->second;
}
else else
pWin = 0; pWin = 0;
} }
...@@ -453,10 +465,10 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq ) ...@@ -453,10 +465,10 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
DBG_ASSERT( rReq.GetArgs(), "arguments expected" ); DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
const SfxUInt16Item &rTabId = (const SfxUInt16Item&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_TABID ); const SfxUInt16Item &rTabId = (const SfxUInt16Item&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_TABID );
const SfxStringItem &rModName = (const SfxStringItem&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_MODULENAME ); const SfxStringItem &rModName = (const SfxStringItem&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_MODULENAME );
IDEBaseWindow* pWin = aIDEWindowTable.Get( rTabId.GetValue() );
DBG_ASSERT( pWin, "Window nicht im Liste, aber in TabBar ?" ); DBG_ASSERT( pWin, "Window nicht im Liste, aber in TabBar ?" );
if ( pWin ) if ( aIDEWindowTable.find( rTabId.GetValue() ) != aIDEWindowTable.end() )
{ {
IDEBaseWindow* pWin = aIDEWindowTable[ rTabId.GetValue() ];
::rtl::OUString aNewName( rModName.GetValue() ); ::rtl::OUString aNewName( rModName.GetValue() );
::rtl::OUString aOldName( pWin->GetName() ); ::rtl::OUString aOldName( pWin->GetName() );
if ( aNewName != aOldName ) if ( aNewName != aOldName )
...@@ -490,7 +502,7 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq ) ...@@ -490,7 +502,7 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
else else
{ {
// set old name in TabWriter // set old name in TabWriter
sal_uInt16 nId = (sal_uInt16)aIDEWindowTable.GetKey( pWin ); sal_uInt16 nId = GetIDEWindowId( pWin );
DBG_ASSERT( nId, "No entry in Tabbar!" ); DBG_ASSERT( nId, "No entry in Tabbar!" );
if ( nId ) if ( nId )
pTabBar->SetPageText( nId, aOldName ); pTabBar->SetPageText( nId, aOldName );
...@@ -523,9 +535,9 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq ) ...@@ -523,9 +535,9 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
case SID_BASICIDE_STOREALLMODULESOURCES: case SID_BASICIDE_STOREALLMODULESOURCES:
case SID_BASICIDE_UPDATEALLMODULESOURCES: case SID_BASICIDE_UPDATEALLMODULESOURCES:
{ {
IDEBaseWindow* pWin = aIDEWindowTable.First(); for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
while ( pWin )
{ {
IDEBaseWindow* pWin = it->second;
if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) ) if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) )
{ {
if ( rReq.GetSlot() == SID_BASICIDE_STOREALLMODULESOURCES ) if ( rReq.GetSlot() == SID_BASICIDE_STOREALLMODULESOURCES )
...@@ -533,7 +545,6 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq ) ...@@ -533,7 +545,6 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
else else
pWin->UpdateData(); pWin->UpdateData();
} }
pWin = aIDEWindowTable.Next();
} }
} }
break; break;
...@@ -1192,7 +1203,7 @@ void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, sal_Bool bUpdateTabBar ...@@ -1192,7 +1203,7 @@ void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, sal_Bool bUpdateTabBar
} }
if ( bUpdateTabBar ) if ( bUpdateTabBar )
{ {
sal_uLong nKey = aIDEWindowTable.GetKey( pCurWin ); sal_uLong nKey = GetIDEWindowId( pCurWin );
if ( pCurWin && ( pTabBar->GetPagePos( (sal_uInt16)nKey ) == TAB_PAGE_NOTFOUND ) ) if ( pCurWin && ( pTabBar->GetPagePos( (sal_uInt16)nKey ) == TAB_PAGE_NOTFOUND ) )
pTabBar->InsertPage( (sal_uInt16)nKey, pCurWin->GetTitle() ); // has just been faded in pTabBar->InsertPage( (sal_uInt16)nKey, pCurWin->GetTitle() ); // has just been faded in
pTabBar->SetCurPageId( (sal_uInt16)nKey ); pTabBar->SetCurPageId( (sal_uInt16)nKey );
...@@ -1275,9 +1286,9 @@ IDEBaseWindow* BasicIDEShell::FindApplicationWindow() ...@@ -1275,9 +1286,9 @@ IDEBaseWindow* BasicIDEShell::FindApplicationWindow()
IDEBaseWindow* BasicIDEShell::FindWindow( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rName, BasicIDEType nType, sal_Bool bFindSuspended ) IDEBaseWindow* BasicIDEShell::FindWindow( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rName, BasicIDEType nType, sal_Bool bFindSuspended )
{ {
IDEBaseWindow* pWin = aIDEWindowTable.First(); for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
while ( pWin )
{ {
IDEBaseWindow* pWin = it->second;
if ( !pWin->IsSuspended() || bFindSuspended ) if ( !pWin->IsSuspended() || bFindSuspended )
{ {
if ( rLibName.isEmpty() || rName.isEmpty() || nType == BASICIDE_TYPE_UNKNOWN ) if ( rLibName.isEmpty() || rName.isEmpty() || nType == BASICIDE_TYPE_UNKNOWN )
...@@ -1292,7 +1303,6 @@ IDEBaseWindow* BasicIDEShell::FindWindow( const ScriptDocument& rDocument, const ...@@ -1292,7 +1303,6 @@ IDEBaseWindow* BasicIDEShell::FindWindow( const ScriptDocument& rDocument, const
return pWin; return pWin;
} }
} }
pWin = aIDEWindowTable.Next();
} }
return 0; return 0;
} }
...@@ -1451,9 +1461,9 @@ void BasicIDEShell::Deactivate( sal_Bool bMDI ) ...@@ -1451,9 +1461,9 @@ void BasicIDEShell::Deactivate( sal_Bool bMDI )
// test CanClose to also test during deactivating the BasicIDE whether // test CanClose to also test during deactivating the BasicIDE whether
// the sourcecode is too large in one of the modules... // the sourcecode is too large in one of the modules...
for ( sal_uLong nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ ) for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin ); IDEBaseWindow* pWin = it->second;
if ( /* !pWin->IsSuspended() && */ !pWin->CanClose() ) if ( /* !pWin->IsSuspended() && */ !pWin->CanClose() )
{ {
if ( !m_aCurLibName.isEmpty() && ( pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName ) ) if ( !m_aCurLibName.isEmpty() && ( pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName ) )
......
...@@ -231,13 +231,7 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const ...@@ -231,13 +231,7 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const
else else
{ {
pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED ); pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED );
IDEBaseWindow* pTmp = aIDEWindowTable.First(); nKey = GetIDEWindowId( pWin );
while ( pTmp && !nKey )
{
if ( pTmp == pWin )
nKey = aIDEWindowTable.GetCurKey();
pTmp = aIDEWindowTable.Next();
}
DBG_ASSERT( nKey, "CreateBasWin: Kein Key- Fenster nicht gefunden!" ); DBG_ASSERT( nKey, "CreateBasWin: Kein Key- Fenster nicht gefunden!" );
} }
if( nKey && xLib.is() && rDocument.isInVBAMode() ) if( nKey && xLib.is() && rDocument.isInVBAMode() )
...@@ -269,17 +263,23 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const ...@@ -269,17 +263,23 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const
ModulWindow* BasicIDEShell::FindBasWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rModName, sal_Bool bCreateIfNotExist, sal_Bool bFindSuspended ) ModulWindow* BasicIDEShell::FindBasWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rModName, sal_Bool bCreateIfNotExist, sal_Bool bFindSuspended )
{ {
ModulWindow* pModWin = 0; ModulWindow* pModWin = 0;
IDEBaseWindow* pWin = aIDEWindowTable.First(); for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin();
while ( pWin && !pModWin ) it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = it->second;
if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( ModulWindow ) ) ) if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( ModulWindow ) ) )
{ {
if ( rLibName.isEmpty() ) if ( rLibName.isEmpty() )
{
pModWin = (ModulWindow*)pWin; pModWin = (ModulWindow*)pWin;
break;
}
else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rModName ) else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rModName )
{
pModWin = (ModulWindow*)pWin; pModWin = (ModulWindow*)pWin;
break;
}
} }
pWin = aIDEWindowTable.Next();
} }
if ( !pModWin && bCreateIfNotExist ) if ( !pModWin && bCreateIfNotExist )
pModWin = CreateBasWin( rDocument, rLibName, rModName ); pModWin = CreateBasWin( rDocument, rLibName, rModName );
......
...@@ -110,13 +110,7 @@ DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, cons ...@@ -110,13 +110,7 @@ DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, cons
else else
{ {
pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED ); pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED );
IDEBaseWindow* pTmp = aIDEWindowTable.First(); nKey = GetIDEWindowId( pWin );
while ( pTmp && !nKey )
{
if ( pTmp == pWin )
nKey = aIDEWindowTable.GetCurKey();
pTmp = aIDEWindowTable.Next();
}
DBG_ASSERT( nKey, "CreateDlgWin: Kein Key - Fenster nicht gefunden!" ); DBG_ASSERT( nKey, "CreateDlgWin: Kein Key - Fenster nicht gefunden!" );
} }
...@@ -136,17 +130,22 @@ DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, cons ...@@ -136,17 +130,22 @@ DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, cons
DialogWindow* BasicIDEShell::FindDlgWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName, sal_Bool bCreateIfNotExist, sal_Bool bFindSuspended ) DialogWindow* BasicIDEShell::FindDlgWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName, sal_Bool bCreateIfNotExist, sal_Bool bFindSuspended )
{ {
DialogWindow* pDlgWin = 0; DialogWindow* pDlgWin = 0;
IDEBaseWindow* pWin = aIDEWindowTable.First(); for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
while ( pWin && !pDlgWin )
{ {
IDEBaseWindow* pWin = it->second;
if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( DialogWindow ) ) ) if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( DialogWindow ) ) )
{ {
if ( rLibName.isEmpty() ) if ( rLibName.isEmpty() )
{
pDlgWin = (DialogWindow*)pWin; pDlgWin = (DialogWindow*)pWin;
break;
}
else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rDlgName ) else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rDlgName )
{
pDlgWin = (DialogWindow*)pWin; pDlgWin = (DialogWindow*)pWin;
break;
}
} }
pWin = aIDEWindowTable.Next();
} }
if ( !pDlgWin && bCreateIfNotExist ) if ( !pDlgWin && bCreateIfNotExist )
pDlgWin = CreateDlgWin( rDocument, rLibName, rDlgName ); pDlgWin = CreateDlgWin( rDocument, rLibName, rDlgName );
...@@ -154,6 +153,14 @@ DialogWindow* BasicIDEShell::FindDlgWin( const ScriptDocument& rDocument, const ...@@ -154,6 +153,14 @@ DialogWindow* BasicIDEShell::FindDlgWin( const ScriptDocument& rDocument, const
return pDlgWin; return pDlgWin;
} }
sal_uInt16 BasicIDEShell::GetIDEWindowId(const IDEBaseWindow* pWin) const
{
for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
if ( it->second == pWin )
return it->first;
return 0;
}
SdrView* BasicIDEShell::GetCurDlgView() const SdrView* BasicIDEShell::GetCurDlgView() const
{ {
if ( !pCurWin || !pCurWin->IsA( TYPE( DialogWindow ) ) ) if ( !pCurWin || !pCurWin->IsA( TYPE( DialogWindow ) ) )
......
...@@ -245,15 +245,13 @@ BasicIDEShell::~BasicIDEShell() ...@@ -245,15 +245,13 @@ BasicIDEShell::~BasicIDEShell()
SetWindow( 0 ); SetWindow( 0 );
SetCurWindow( 0 ); SetCurWindow( 0 );
IDEBaseWindow* pWin = aIDEWindowTable.First(); for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
while ( pWin )
{ {
// no store; does already happen when the BasicManagers are destroyed // no store; does already happen when the BasicManagers are destroyed
delete pWin; delete it->second;
pWin = aIDEWindowTable.Next();
} }
aIDEWindowTable.Clear(); aIDEWindowTable.clear();
delete pTabBar; delete pTabBar;
delete pObjectCatalog; delete pObjectCatalog;
DestroyModulWindowLayout(); DestroyModulWindowLayout();
...@@ -316,11 +314,12 @@ void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument ) ...@@ -316,11 +314,12 @@ void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument )
bool bSetCurWindow = false; bool bSetCurWindow = false;
bool bSetCurLib = ( _rDocument == m_aCurDocument ); bool bSetCurLib = ( _rDocument == m_aCurDocument );
std::vector<IDEBaseWindow*> aDeleteVec;
// remove all windows which belong to this document // remove all windows which belong to this document
for ( sal_uLong nWin = aIDEWindowTable.Count(); nWin; ) for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = aIDEWindowTable.GetObject( --nWin ); IDEBaseWindow* pWin = it->second;
if ( pWin->IsDocument( _rDocument ) ) if ( pWin->IsDocument( _rDocument ) )
{ {
if ( pWin->GetStatus() & (BASWIN_RUNNINGBASIC|BASWIN_INRESCHEDULE) ) if ( pWin->GetStatus() & (BASWIN_RUNNINGBASIC|BASWIN_INRESCHEDULE) )
...@@ -332,14 +331,18 @@ void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument ) ...@@ -332,14 +331,18 @@ void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument )
pWin->BasicStopped(); pWin->BasicStopped();
} }
else else
{ aDeleteVec.push_back( pWin );
pWin->StoreData();
if ( pWin == pCurWin )
bSetCurWindow = true;
RemoveWindow( pWin, sal_True, sal_False );
}
} }
} }
// delete windows outside main loop so we don't invalidate the original iterator
for( std::vector<IDEBaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it )
{
IDEBaseWindow* pWin = *it;
pWin->StoreData();
if ( pWin == pCurWin )
bSetCurWindow = true;
RemoveWindow( pWin, sal_True, sal_False );
}
// remove lib info // remove lib info
BasicIDEData* pData = BasicIDEGlobals::GetExtraData(); BasicIDEData* pData = BasicIDEGlobals::GetExtraData();
...@@ -362,9 +365,9 @@ void BasicIDEShell::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ ...@@ -362,9 +365,9 @@ void BasicIDEShell::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/
void BasicIDEShell::onDocumentModeChanged( const ScriptDocument& _rDocument ) void BasicIDEShell::onDocumentModeChanged( const ScriptDocument& _rDocument )
{ {
for ( sal_uLong nWin = aIDEWindowTable.Count(); nWin; ) for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = aIDEWindowTable.GetObject( --nWin ); IDEBaseWindow* pWin = it->second;
if ( pWin->IsDocument( _rDocument ) && _rDocument.isDocument() ) if ( pWin->IsDocument( _rDocument ) && _rDocument.isDocument() )
pWin->SetReadOnly( _rDocument.isReadOnly() ); pWin->SetReadOnly( _rDocument.isReadOnly() );
} }
...@@ -372,9 +375,9 @@ void BasicIDEShell::onDocumentModeChanged( const ScriptDocument& _rDocument ) ...@@ -372,9 +375,9 @@ void BasicIDEShell::onDocumentModeChanged( const ScriptDocument& _rDocument )
void BasicIDEShell::StoreAllWindowData( sal_Bool bPersistent ) void BasicIDEShell::StoreAllWindowData( sal_Bool bPersistent )
{ {
for ( sal_uLong nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ ) for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin ); IDEBaseWindow* pWin = it->second;
DBG_ASSERT( pWin, "PrepareClose: NULL-Pointer in Table?" ); DBG_ASSERT( pWin, "PrepareClose: NULL-Pointer in Table?" );
if ( !pWin->IsSuspended() ) if ( !pWin->IsSuspended() )
pWin->StoreData(); pWin->StoreData();
...@@ -414,9 +417,9 @@ sal_uInt16 BasicIDEShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing ) ...@@ -414,9 +417,9 @@ sal_uInt16 BasicIDEShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
else else
{ {
sal_Bool bCanClose = sal_True; sal_Bool bCanClose = sal_True;
for ( sal_uLong nWin = 0; bCanClose && ( nWin < aIDEWindowTable.Count() ); nWin++ ) for ( sal_uLong nWin = 0; bCanClose && ( nWin < aIDEWindowTable.size() ); nWin++ )
{ {
IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin ); IDEBaseWindow* pWin = aIDEWindowTable[ nWin ];
if ( !pWin->CanClose() ) if ( !pWin->CanClose() )
{ {
if ( !m_aCurLibName.isEmpty() && ( pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName ) ) if ( !m_aCurLibName.isEmpty() && ( pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName ) )
...@@ -484,7 +487,7 @@ IMPL_LINK_INLINE_END( BasicIDEShell, TabBarSplitHdl, TabBar *, pTBar ) ...@@ -484,7 +487,7 @@ IMPL_LINK_INLINE_END( BasicIDEShell, TabBarSplitHdl, TabBar *, pTBar )
IMPL_LINK( BasicIDEShell, TabBarHdl, TabBar *, pCurTabBar ) IMPL_LINK( BasicIDEShell, TabBarHdl, TabBar *, pCurTabBar )
{ {
sal_uInt16 nCurId = pCurTabBar->GetCurPageId(); sal_uInt16 nCurId = pCurTabBar->GetCurPageId();
IDEBaseWindow* pWin = aIDEWindowTable.Get( nCurId ); IDEBaseWindow* pWin = aIDEWindowTable[ nCurId ];
DBG_ASSERT( pWin, "Eintrag in TabBar passt zu keinem Fenster!" ); DBG_ASSERT( pWin, "Eintrag in TabBar passt zu keinem Fenster!" );
SetCurWindow( pWin ); SetCurWindow( pWin );
...@@ -505,7 +508,7 @@ sal_Bool BasicIDEShell::NextPage( sal_Bool bPrev ) ...@@ -505,7 +508,7 @@ sal_Bool BasicIDEShell::NextPage( sal_Bool bPrev )
if ( nPos < pTabBar->GetPageCount() ) if ( nPos < pTabBar->GetPageCount() )
{ {
IDEBaseWindow* pWin = aIDEWindowTable.Get( pTabBar->GetPageId( nPos ) ); IDEBaseWindow* pWin = aIDEWindowTable[ pTabBar->GetPageId( nPos ) ];
SetCurWindow( pWin, sal_True ); SetCurWindow( pWin, sal_True );
bRet = sal_True; bRet = sal_True;
} }
...@@ -652,14 +655,14 @@ void BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&, ...@@ -652,14 +655,14 @@ void BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
m_pCurLocalizationMgr->handleBasicStarted(); m_pCurLocalizationMgr->handleBasicStarted();
} }
IDEBaseWindow* pWin = aIDEWindowTable.First(); for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin();
while ( pWin ) it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = it->second;
if ( nHintId == SBX_HINT_BASICSTART ) if ( nHintId == SBX_HINT_BASICSTART )
pWin->BasicStarted(); pWin->BasicStarted();
else else
pWin->BasicStopped(); pWin->BasicStopped();
pWin = aIDEWindowTable.Next();
} }
} }
} }
...@@ -672,17 +675,20 @@ void BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&, ...@@ -672,17 +675,20 @@ void BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
void BasicIDEShell::CheckWindows() void BasicIDEShell::CheckWindows()
{ {
sal_Bool bSetCurWindow = sal_False; sal_Bool bSetCurWindow = sal_False;
for ( sal_uLong nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ ) std::vector<IDEBaseWindow*> aDeleteVec;
for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin ); IDEBaseWindow* pWin = it->second;
if ( pWin->GetStatus() & BASWIN_TOBEKILLED ) if ( pWin->GetStatus() & BASWIN_TOBEKILLED )
{ aDeleteVec.push_back( pWin );
pWin->StoreData(); }
if ( pWin == pCurWin ) for ( std::vector<IDEBaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it )
bSetCurWindow = sal_True; {
RemoveWindow( pWin, sal_True, sal_False ); IDEBaseWindow* pWin = *it;
nWin--; pWin->StoreData();
} if ( pWin == pCurWin )
bSetCurWindow = sal_True;
RemoveWindow( pWin, sal_True, sal_False );
} }
if ( bSetCurWindow ) if ( bSetCurWindow )
SetCurWindow( FindApplicationWindow(), sal_True ); SetCurWindow( FindApplicationWindow(), sal_True );
...@@ -693,17 +699,20 @@ void BasicIDEShell::CheckWindows() ...@@ -693,17 +699,20 @@ void BasicIDEShell::CheckWindows()
void BasicIDEShell::RemoveWindows( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, sal_Bool bDestroy ) void BasicIDEShell::RemoveWindows( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, sal_Bool bDestroy )
{ {
sal_Bool bChangeCurWindow = pCurWin ? sal_False : sal_True; sal_Bool bChangeCurWindow = pCurWin ? sal_False : sal_True;
for ( sal_uLong nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ ) std::vector<IDEBaseWindow*> aDeleteVec;
for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin ); IDEBaseWindow* pWin = it->second;
if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName ) if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName )
{ aDeleteVec.push_back( pWin );
if ( pWin == pCurWin ) }
bChangeCurWindow = sal_True; for ( std::vector<IDEBaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it )
pWin->StoreData(); {
RemoveWindow( pWin, bDestroy, sal_False ); IDEBaseWindow* pWin = *it;
nWin--; if ( pWin == pCurWin )
} bChangeCurWindow = sal_True;
pWin->StoreData();
RemoveWindow( pWin, bDestroy, sal_False );
} }
if ( bChangeCurWindow ) if ( bChangeCurWindow )
SetCurWindow( FindApplicationWindow(), sal_True ); SetCurWindow( FindApplicationWindow(), sal_True );
...@@ -717,9 +726,10 @@ void BasicIDEShell::UpdateWindows() ...@@ -717,9 +726,10 @@ void BasicIDEShell::UpdateWindows()
sal_Bool bChangeCurWindow = pCurWin ? sal_False : sal_True; sal_Bool bChangeCurWindow = pCurWin ? sal_False : sal_True;
if ( !m_aCurLibName.isEmpty() ) if ( !m_aCurLibName.isEmpty() )
{ {
for ( sal_uLong nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ ) std::vector<IDEBaseWindow*> aDeleteVec;
for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin ); IDEBaseWindow* pWin = it->second;
if ( !pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName ) if ( !pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName )
{ {
if ( pWin == pCurWin ) if ( pWin == pCurWin )
...@@ -729,12 +739,13 @@ void BasicIDEShell::UpdateWindows() ...@@ -729,12 +739,13 @@ void BasicIDEShell::UpdateWindows()
// Window is frozen at first, later the windows should be changed // Window is frozen at first, later the windows should be changed
// anyway to be marked as hidden instead of being deleted. // anyway to be marked as hidden instead of being deleted.
if ( !(pWin->GetStatus() & ( BASWIN_TOBEKILLED | BASWIN_RUNNINGBASIC | BASWIN_SUSPENDED ) ) ) if ( !(pWin->GetStatus() & ( BASWIN_TOBEKILLED | BASWIN_RUNNINGBASIC | BASWIN_SUSPENDED ) ) )
{ aDeleteVec.push_back( pWin );
RemoveWindow( pWin, sal_False, sal_False );
nWin--;
}
} }
} }
for ( std::vector<IDEBaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it )
{
RemoveWindow( *it, sal_False, sal_False );
}
} }
if ( bCreatingWindow ) if ( bCreatingWindow )
...@@ -859,9 +870,9 @@ void BasicIDEShell::UpdateWindows() ...@@ -859,9 +870,9 @@ void BasicIDEShell::UpdateWindows()
void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, sal_Bool bDestroy, sal_Bool bAllowChangeCurWindow ) void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, sal_Bool bDestroy, sal_Bool bAllowChangeCurWindow )
{ {
DBG_ASSERT( pWindow_, "Kann keinen NULL-Pointer loeschen!" ); DBG_ASSERT( pWindow_, "Kann keinen NULL-Pointer loeschen!" );
sal_uLong nKey = aIDEWindowTable.GetKey( pWindow_ ); sal_uLong nKey = GetIDEWindowId( pWindow_ );
pTabBar->RemovePage( (sal_uInt16)nKey ); pTabBar->RemovePage( (sal_uInt16)nKey );
aIDEWindowTable.Remove( nKey ); aIDEWindowTable.erase( nKey );
if ( pWindow_ == pCurWin ) if ( pWindow_ == pCurWin )
{ {
if ( bAllowChangeCurWindow ) if ( bAllowChangeCurWindow )
...@@ -895,7 +906,7 @@ void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, sal_Bool bDestroy, sa ...@@ -895,7 +906,7 @@ void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, sal_Bool bDestroy, sa
// there will be no notify... // there will be no notify...
pWindow_->BasicStopped(); pWindow_->BasicStopped();
} }
aIDEWindowTable.Insert( nKey, pWindow_ ); // jump in again aIDEWindowTable[ nKey ] = pWindow_; // jump in again
} }
} }
else else
...@@ -903,7 +914,7 @@ void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, sal_Bool bDestroy, sa ...@@ -903,7 +914,7 @@ void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, sal_Bool bDestroy, sa
pWindow_->Hide(); pWindow_->Hide();
pWindow_->AddStatus( BASWIN_SUSPENDED ); pWindow_->AddStatus( BASWIN_SUSPENDED );
pWindow_->Deactivating(); pWindow_->Deactivating();
aIDEWindowTable.Insert( nKey, pWindow_ ); // jump in again aIDEWindowTable[ nKey ] = pWindow_; // jump in again
} }
} }
...@@ -913,7 +924,7 @@ void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, sal_Bool bDestroy, sa ...@@ -913,7 +924,7 @@ void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, sal_Bool bDestroy, sa
sal_uInt16 BasicIDEShell::InsertWindowInTable( IDEBaseWindow* pNewWin ) sal_uInt16 BasicIDEShell::InsertWindowInTable( IDEBaseWindow* pNewWin )
{ {
nCurKey++; nCurKey++;
aIDEWindowTable.Insert( nCurKey, pNewWin ); aIDEWindowTable[ nCurKey ] = pNewWin;
return nCurKey; return nCurKey;
} }
......
...@@ -208,7 +208,7 @@ bool RenameModule( Window* pErrorParent, const ScriptDocument& rDocument, const ...@@ -208,7 +208,7 @@ bool RenameModule( Window* pErrorParent, const ScriptDocument& rDocument, const
pModWin->SetSbModule( (SbModule*)pModWin->GetBasic()->FindModule( rNewName ) ); pModWin->SetSbModule( (SbModule*)pModWin->GetBasic()->FindModule( rNewName ) );
// update tabwriter // update tabwriter
sal_uInt16 nId = (sal_uInt16)(pIDEShell->GetIDEWindowTable()).GetKey( pWin ); sal_uInt16 nId = pIDEShell->GetIDEWindowId( pWin );
DBG_ASSERT( nId, "No entry in Tabbar!" ); DBG_ASSERT( nId, "No entry in Tabbar!" );
if ( nId ) if ( nId )
{ {
......
...@@ -217,7 +217,7 @@ bool RenameDialog( Window* pErrorParent, const ScriptDocument& rDocument, const ...@@ -217,7 +217,7 @@ bool RenameDialog( Window* pErrorParent, const ScriptDocument& rDocument, const
((DialogWindow*)pWin)->UpdateBrowser(); ((DialogWindow*)pWin)->UpdateBrowser();
// update tabwriter // update tabwriter
sal_uInt16 nId = (sal_uInt16)(pIDEShell->GetIDEWindowTable()).GetKey( pWin ); sal_uInt16 nId = pIDEShell->GetIDEWindowId( pWin );
DBG_ASSERT( nId, "No entry in Tabbar!" ); DBG_ASSERT( nId, "No entry in Tabbar!" );
if ( nId ) if ( nId )
{ {
...@@ -338,13 +338,12 @@ void StopBasic() ...@@ -338,13 +338,12 @@ void StopBasic()
if ( pShell ) if ( pShell )
{ {
IDEWindowTable& rWindows = pShell->GetIDEWindowTable(); IDEWindowTable& rWindows = pShell->GetIDEWindowTable();
IDEBaseWindow* pWin = rWindows.First(); for( IDEWindowTable::const_iterator it = rWindows.begin(); it != rWindows.end(); ++it )
while ( pWin )
{ {
IDEBaseWindow* pWin = it->second;
// call BasicStopped manually because the Stop-Notify // call BasicStopped manually because the Stop-Notify
// might not get through otherwise // might not get through otherwise
pWin->BasicStopped(); pWin->BasicStopped();
pWin = rWindows.Next();
} }
} }
BasicIDE::BasicStopped(); BasicIDE::BasicStopped();
......
...@@ -462,10 +462,10 @@ void BasicIDETabBar::Command( const CommandEvent& rCEvt ) ...@@ -462,10 +462,10 @@ void BasicIDETabBar::Command( const CommandEvent& rCEvt )
if( pBasic ) if( pBasic )
{ {
IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable(); IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable();
IDEBaseWindow* pWin = aIDEWindowTable.Get( GetCurPageId() ); IDEWindowTable::const_iterator it = aIDEWindowTable.find( GetCurPageId() );
if( pWin && pWin->ISA( ModulWindow ) ) if( it != aIDEWindowTable.end() && it->second->ISA( ModulWindow ) )
{ {
SbModule* pActiveModule = (SbModule*)pBasic->FindModule( pWin->GetName() ); SbModule* pActiveModule = (SbModule*)pBasic->FindModule( it->second->GetName() );
if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::DOCUMENT ) ) if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::DOCUMENT ) )
{ {
aPopup.EnableItem( SID_BASICIDE_DELETECURRENT, sal_False ); aPopup.EnableItem( SID_BASICIDE_DELETECURRENT, sal_False );
...@@ -532,7 +532,7 @@ void BasicIDETabBar::Sort() ...@@ -532,7 +532,7 @@ void BasicIDETabBar::Sort()
sal_uInt16 nId = GetPageId( i ); sal_uInt16 nId = GetPageId( i );
aTabBarSortHelper.nPageId = nId; aTabBarSortHelper.nPageId = nId;
aTabBarSortHelper.aPageText = GetPageText( nId ); aTabBarSortHelper.aPageText = GetPageText( nId );
IDEBaseWindow* pWin = aIDEWindowTable.Get( nId ); IDEBaseWindow* pWin = aIDEWindowTable[ nId ];
if ( pWin->IsA( TYPE( ModulWindow ) ) ) if ( pWin->IsA( TYPE( ModulWindow ) ) )
{ {
......
...@@ -823,10 +823,10 @@ DialogWindow* FindDialogWindowForEditor( DlgEditor* pEditor ) ...@@ -823,10 +823,10 @@ DialogWindow* FindDialogWindowForEditor( DlgEditor* pEditor )
{ {
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell(); BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable(); IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable();
IDEBaseWindow* pWin = aIDEWindowTable.First();
DialogWindow* pFoundDlgWin = NULL; DialogWindow* pFoundDlgWin = NULL;
while( pWin ) for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = it->second;
if ( !pWin->IsSuspended() && pWin->IsA( TYPE( DialogWindow ) ) ) if ( !pWin->IsSuspended() && pWin->IsA( TYPE( DialogWindow ) ) )
{ {
DialogWindow* pDlgWin = (DialogWindow*)pWin; DialogWindow* pDlgWin = (DialogWindow*)pWin;
...@@ -837,7 +837,6 @@ DialogWindow* FindDialogWindowForEditor( DlgEditor* pEditor ) ...@@ -837,7 +837,6 @@ DialogWindow* FindDialogWindowForEditor( DlgEditor* pEditor )
break; break;
} }
} }
pWin = aIDEWindowTable.Next();
} }
return pFoundDlgWin; return pFoundDlgWin;
} }
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
#include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/container/XContainerListener.hpp>
#include <sfx2/viewsh.hxx> #include <sfx2/viewsh.hxx>
#include <svx/ifaceids.hxx> #include <svx/ifaceids.hxx>
#include <tools/table.hxx>
#include <vcl/scrbar.hxx> #include <vcl/scrbar.hxx>
#include <map>
class SfxViewFactory; class SfxViewFactory;
...@@ -60,9 +60,9 @@ class LocalizationMgr; ...@@ -60,9 +60,9 @@ class LocalizationMgr;
struct BasicIDEShell_Impl; struct BasicIDEShell_Impl;
#if _SOLAR__PRIVATE #if _SOLAR__PRIVATE
DECLARE_TABLE( IDEWindowTable, IDEBaseWindow* ) typedef std::map<sal_uInt16, IDEBaseWindow*> IDEWindowTable;
#else #else
typedef Table IDEWindowTable; typedef std::map<sal_uInt16, void*> IDEWindowTable;
#endif #endif
namespace BasicIDE namespace BasicIDE
...@@ -186,6 +186,7 @@ public: ...@@ -186,6 +186,7 @@ public:
ScrollBarBox& GetScrollBarBox() { return aScrollBarBox; } ScrollBarBox& GetScrollBarBox() { return aScrollBarBox; }
TabBar* GetTabBar() { return (TabBar*)pTabBar; } TabBar* GetTabBar() { return (TabBar*)pTabBar; }
IDEWindowTable& GetIDEWindowTable() { return aIDEWindowTable; } IDEWindowTable& GetIDEWindowTable() { return aIDEWindowTable; }
sal_uInt16 GetIDEWindowId(const IDEBaseWindow* pWin) const;
SdrView* GetCurDlgView() const; SdrView* GetCurDlgView() const;
......
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