diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index 3f2a029017e7..c39bc363cfbd 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -542,16 +542,17 @@ void SbTreeListBox::ReloadAllEntries() } } -bool SbTreeListBox::ImpFindEntry(weld::TreeIter& rIter, std::u16string_view rText) +std::unique_ptr SbTreeListBox::ImpFindEntry(std::u16string_view rText) { - bool bValidIter = m_xControl->iter_children(rIter); + std::unique_ptr pIter = m_xControl->make_iterator(); + bool bValidIter = m_xControl->iter_children(*pIter); while (bValidIter) { - if (rText == m_xControl->get_text(rIter)) - return true; - bValidIter = m_xControl->iter_next_sibling(rIter); + if (rText == m_xControl->get_text(*pIter)) + return pIter; + bValidIter = m_xControl->iter_next_sibling(*pIter); } - return false; + return {}; } void SbTreeListBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ ) @@ -823,12 +824,8 @@ void SbTreeListBox::SetCurrentEntry (EntryDescriptor const & rDesc) if( !aLibSubName.isEmpty() ) { m_xControl->expand_row(*xLibIter); - auto xSubLibIter = m_xControl->make_iterator(xLibIter.get()); - bool bSubLibEntry = ImpFindEntry(*xSubLibIter, aLibSubName); - if (bSubLibEntry) - { + if (std::unique_ptr xSubLibIter = ImpFindEntry(aLibSubName)) m_xControl->copy_iterator(*xSubLibIter, *xCurIter); - } } const OUString& aName( aDesc.GetName() ); if ( !aName.isEmpty() ) diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx index c031b82b6a95..632a4ac94407 100644 --- a/basctl/source/inc/bastype2.hxx +++ b/basctl/source/inc/bastype2.hxx @@ -195,7 +195,7 @@ protected: void ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName); void ImpCreateLibSubEntriesInVBAMode(const weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName ); void ImpCreateLibSubSubEntriesInVBAMode(const weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName); - bool ImpFindEntry(weld::TreeIter& rIter, std::u16string_view rText); + std::unique_ptr ImpFindEntry(std::u16string_view rText); // DocumentEventListener virtual void onDocumentCreated( const ScriptDocument& _rDocument ) override;