basctl: Return std::unique_ptr in SbTreeListBox::ImpFindEntry

Instead of having an out param and a bool return value,
return a std::unique_ptr and create the weld::TreeIter
inside of the method implementation instead of having
to do so in the caller.

This is similar to

    commit 82edaf048b
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Sun Dec 21 01:36:30 2025 +0100

        weld: Return std::unique_ptr in weld::ItemView::get_selected

that simplified weld::ItemView API.

Change-Id: I7ede7f51f76b35fdeec45c3373a19a3808429b38
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196391
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn
2026-01-03 08:11:46 +01:00
parent 71e6e0f320
commit 4887919802
2 changed files with 9 additions and 12 deletions
+8 -11
View File
@@ -542,16 +542,17 @@ void SbTreeListBox::ReloadAllEntries()
}
}
bool SbTreeListBox::ImpFindEntry(weld::TreeIter& rIter, std::u16string_view rText)
std::unique_ptr<weld::TreeIter> SbTreeListBox::ImpFindEntry(std::u16string_view rText)
{
bool bValidIter = m_xControl->iter_children(rIter);
std::unique_ptr<weld::TreeIter> 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<weld::TreeIter> xSubLibIter = ImpFindEntry(aLibSubName))
m_xControl->copy_iterator(*xSubLibIter, *xCurIter);
}
}
const OUString& aName( aDesc.GetName() );
if ( !aName.isEmpty() )
+1 -1
View File
@@ -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<weld::TreeIter> ImpFindEntry(std::u16string_view rText);
// DocumentEventListener
virtual void onDocumentCreated( const ScriptDocument& _rDocument ) override;