From 133c979a15bbba5bc784cccc00edb9e1dc1cbff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?"Uray=20M.=20J=C3=A1nos"?= Date: Tue, 24 Jul 2012 19:27:25 +0200 Subject: [PATCH] fdo#50632 IDE: update Object Catalog when closing a document Change-Id: Ia635aee1611eaff663906e2238bf23a5013242a3 --- basctl/source/basicide/bastype2.cxx | 34 +++++++++++++++++++++++++++------- basctl/source/basicide/bastype2.hxx | 2 ++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index 087651e..4c72181 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -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 ); diff --git a/basctl/source/basicide/bastype2.hxx b/basctl/source/basicide/bastype2.hxx index 5a3374d..66b031e 100644 --- a/basctl/source/basicide/bastype2.hxx +++ b/basctl/source/basicide/bastype2.hxx @@ -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 ); -- 1.7.7