fdo#50632 IDE: update Object Catalog when closing a document

Change-Id: Ia635aee1611eaff663906e2238bf23a5013242a3
This commit is contained in:
Uray M. János
2012-07-24 19:27:25 +02:00
committed by Noel Power
parent 604b1bf89c
commit bb66a2c3ee
2 changed files with 29 additions and 7 deletions

View File

@@ -559,9 +559,12 @@ void BasicTreeListBox::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*
UpdateEntries();
}
void BasicTreeListBox::onDocumentClosed( const ScriptDocument& /*_rDocument*/ )
void BasicTreeListBox::onDocumentClosed( const ScriptDocument& rDocument )
{
UpdateEntries();
// The document is not yet actually deleted, so we need to remove its entry
// manually.
RemoveEntry(rDocument);
}
void BasicTreeListBox::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
@@ -578,7 +581,7 @@ void BasicTreeListBox::UpdateEntries()
{
BasicEntryDescriptor aCurDesc( GetEntryDescriptor( FirstSelected() ) );
// removing the invalid entries
SvLBoxEntry* pLastValid = 0;
SvLBoxEntry* pEntry = First();
while ( pEntry )
@@ -586,19 +589,36 @@ void BasicTreeListBox::UpdateEntries()
if ( IsValidEntry( pEntry ) )
pLastValid = pEntry;
else
{
delete (BasicEntry*)pEntry->GetUserData();
GetModel()->Remove( pEntry );
}
RemoveEntry(pEntry);
pEntry = pLastValid ? Next( pLastValid ) : First();
}
ScanAllEntries();
SetCurrentEntry( aCurDesc );
}
// Removes the entry from the tree.
void BasicTreeListBox::RemoveEntry (SvLBoxEntry* pEntry)
{
// removing the associated user data
delete (BasicEntry*)pEntry->GetUserData();
// removing the entry
GetModel()->Remove( pEntry );
}
// Removes the entry of rDocument.
void BasicTreeListBox::RemoveEntry (ScriptDocument const& rDocument)
{
// finding the entry of rDocument
for (SvLBoxEntry* pEntry = First(); pEntry; pEntry = Next(pEntry))
if (rDocument == GetEntryDescriptor(pEntry).GetDocument())
{
RemoveEntry(pEntry);
break;
}
}
SvLBoxEntry* BasicTreeListBox::CloneEntry( SvLBoxEntry* pSource )
{
SvLBoxEntry* pNew = SvTreeListBox::CloneEntry( pSource );

View File

@@ -195,6 +195,8 @@ public:
SvLBoxEntry* AddEntry( const ::rtl::OUString& rText, const Image& rImage,
SvLBoxEntry* pParent, bool bChildrenOnDemand,
std::auto_ptr< BasicEntry > aUserData );
void RemoveEntry (SvLBoxEntry*);
void RemoveEntry (ScriptDocument const&);
::rtl::OUString GetRootEntryName( const ScriptDocument& rDocument, LibraryLocation eLocation ) const;
void GetRootEntryBitmaps( const ScriptDocument& rDocument, Image& rImage );