diff options
author | Uray M. János <uray.janos@gmail.com> | 2012-07-24 19:27:25 +0200 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2012-07-26 10:10:41 +0100 |
commit | bb66a2c3ee9807e79ba437c770559787abe61b9b (patch) | |
tree | 38be570e23d5223ecbbbd30f330382df03e513a1 | |
parent | 604b1bf89ced64b509122eaa8cc99dbf033438ab (diff) |
fdo#50632 IDE: update Object Catalog when closing a document
Change-Id: Ia635aee1611eaff663906e2238bf23a5013242a3
-rw-r--r-- | basctl/source/basicide/bastype2.cxx | 34 | ||||
-rw-r--r-- | 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 ce4d0a388290..d8ccb8b07d54 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 e8acb2b51a9c..efcaa4f23460 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 ); |