basctl/source/basicide/bastype2.cxx |   19 ++++++++-----------
 basctl/source/basicide/macrodlg.cxx |   10 +++++-----
 basctl/source/basicide/macrodlg.hxx |    1 -
 basctl/source/inc/bastype2.hxx      |    2 +-
 4 files changed, 14 insertions(+), 18 deletions(-)

New commits:
commit 4887919802c24bd4bca8ff7a98bf3591b8a917c0
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Jan 1 13:02:42 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Jan 3 08:11:46 2026 +0100

    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 82edaf048b53168c74357a51dab3377ed5c779e0
        Author: Michael Weghorn <[email protected]>
        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 <[email protected]>

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<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() )
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<weld::TreeIter> ImpFindEntry(std::u16string_view rText);
 
     // DocumentEventListener
     virtual void onDocumentCreated( const ScriptDocument& _rDocument ) 
override;
commit 71e6e0f320e60de2beb392ba80a96f9243e32c05
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Jan 1 12:16:59 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Jan 3 08:11:38 2026 +0100

    basctl: Replace MacroChooser::m_xBasicBoxIter with local var
    
    By now, this class member is only used in one method.
    Use a local variable instead.
    
    Change-Id: Ic2f096aaef9c34d7f697b6ca0a204780db69a28d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196390
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/basctl/source/basicide/macrodlg.cxx 
b/basctl/source/basicide/macrodlg.cxx
index aa319ceec733..0bdadf0da00c 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -63,7 +63,6 @@ MacroChooser::MacroChooser(weld::Window* pParnt, const 
Reference< frame::XFrame
     , m_xMacroNameEdit(m_xBuilder->weld_entry(u"macronameedit"_ustr))
     , m_xMacroLibsFrame(m_xBuilder->weld_frame(u"librariesframe"_ustr))
     , m_xBasicBox(new 
SbTreeListBox(m_xBuilder->weld_tree_view(u"libraries"_ustr), m_xDialog.get()))
-    , m_xBasicBoxIter(m_xBasicBox->make_iterator())
     , m_xMacrosInTxt(m_xBuilder->weld_label(u"existingmacrosft"_ustr))
     , m_xMacroBox(m_xBuilder->weld_tree_view(u"macros"_ustr))
     , m_xMacroBoxIter(m_xMacroBox->make_iterator())
@@ -192,15 +191,16 @@ short MacroChooser::run()
     if( rSelectedDoc.isDocument() && !rSelectedDoc.isActive() )
     {
         // Search for the right entry
-        bool bValidIter = m_xBasicBox->get_iter_first(*m_xBasicBoxIter);
+        std::unique_ptr<weld::TreeIter> pIter = m_xBasicBox->make_iterator();
+        bool bValidIter = m_xBasicBox->get_iter_first(*pIter);
         while (bValidIter)
         {
-            EntryDescriptor 
aCmpDesc(m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()));
+            EntryDescriptor 
aCmpDesc(m_xBasicBox->GetEntryDescriptor(pIter.get()));
             const ScriptDocument& rCmpDoc( aCmpDesc.GetDocument() );
             if (rCmpDoc.isDocument() && rCmpDoc.isActive())
             {
                 std::unique_ptr<weld::TreeIter> 
xEntry(m_xBasicBox->make_iterator());
-                m_xBasicBox->copy_iterator(*m_xBasicBoxIter, *xEntry);
+                m_xBasicBox->copy_iterator(*pIter, *xEntry);
                 std::unique_ptr<weld::TreeIter> 
xLastValid(m_xBasicBox->make_iterator());
                 bool bValidEntryIter = true;
                 do
@@ -211,7 +211,7 @@ short MacroChooser::run()
                 while (bValidEntryIter);
                 m_xBasicBox->set_cursor(*xLastValid);
             }
-            bValidIter = m_xBasicBox->iter_next_sibling(*m_xBasicBoxIter);
+            bValidIter = m_xBasicBox->iter_next_sibling(*pIter);
         }
     }
 
diff --git a/basctl/source/basicide/macrodlg.hxx 
b/basctl/source/basicide/macrodlg.hxx
index f1c7a5ffbbc2..3b0684c343f0 100644
--- a/basctl/source/basicide/macrodlg.hxx
+++ b/basctl/source/basicide/macrodlg.hxx
@@ -76,7 +76,6 @@ private:
     std::unique_ptr<weld::Entry> m_xMacroNameEdit;
     std::unique_ptr<weld::Frame> m_xMacroLibsFrame;
     std::unique_ptr<SbTreeListBox> m_xBasicBox;
-    std::unique_ptr<weld::TreeIter> m_xBasicBoxIter;
     std::unique_ptr<weld::Label> m_xMacrosInTxt;
     std::unique_ptr<weld::TreeView> m_xMacroBox;
     std::unique_ptr<weld::TreeIter> m_xMacroBoxIter;

Reply via email to