include/vcl/toolkit/svlbitm.hxx     |    1 -
 include/vcl/toolkit/treelistbox.hxx |    3 +--
 vcl/source/app/salvtables.cxx       |    6 +++---
 vcl/source/treelist/svlbitm.cxx     |   24 ++++++++++++------------
 vcl/source/treelist/treelistbox.cxx |   19 ++++---------------
 5 files changed, 20 insertions(+), 33 deletions(-)

New commits:
commit 8d816d7a8f2ff35414b82dcc400626bc3a82a75b
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Feb 21 12:44:08 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Feb 21 16:49:56 2025 +0100

    vcl: Merge SvTreeListBox::{SetCheckButtonData,EnableCheckButton}
    
    Change-Id: I9b3be5d3c9b21e7178baa95fc71eb2e9904bb391
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182000
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/vcl/toolkit/treelistbox.hxx 
b/include/vcl/toolkit/treelistbox.hxx
index 2fb0eeb26210..91df0fc2e56d 100644
--- a/include/vcl/toolkit/treelistbox.hxx
+++ b/include/vcl/toolkit/treelistbox.hxx
@@ -536,7 +536,6 @@ public:
     void            SetNoAutoCurEntry( bool b );
 
     void            EnableCheckButton(SvLBoxButtonData&);
-    void            SetCheckButtonData(SvLBoxButtonData&);
 
     /** Returns the default image which clients should use for expanded nodes, 
to have a consistent user
         interface experience in the whole product.
diff --git a/vcl/source/treelist/treelistbox.cxx 
b/vcl/source/treelist/treelistbox.cxx
index dec5259ef84b..40db47113318 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -1796,7 +1796,7 @@ void SvTreeListBox::SetDefaultCollapsedEntryBmp( const 
Image& aBmp )
 
 void SvTreeListBox::EnableCheckButton(SvLBoxButtonData& rData)
 {
-    SetCheckButtonData(rData);
+    pCheckButtonData = &rData;
     nTreeFlags |= SvTreeFlags::CHKBTN;
     rData.SetLink( LINK(this, SvTreeListBox, CheckButtonClick));
 
@@ -1805,11 +1805,6 @@ void SvTreeListBox::EnableCheckButton(SvLBoxButtonData& 
rData)
         Invalidate();
 }
 
-void SvTreeListBox::SetCheckButtonData(SvLBoxButtonData& rData)
-{
-    pCheckButtonData = &rData;
-}
-
 const Image& SvTreeListBox::GetDefaultExpandedNodeImage( )
 {
     return SvImpLBox::GetDefaultExpandedNodeImage( );
commit a19f35090f571fdafe8147b2584bba8c666daafa
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Feb 21 12:42:16 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Feb 21 16:49:50 2025 +0100

    vcl treeview: Pass SvLBoxButtonData by ref instead of pointer
    
    This allows dropping the (unused) special handling for nullptr.
    
    Change-Id: I547b0804f11106afaf4d053e4a20ce3e5e7d9119
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181999
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/include/vcl/toolkit/treelistbox.hxx 
b/include/vcl/toolkit/treelistbox.hxx
index 43882465aaa5..2fb0eeb26210 100644
--- a/include/vcl/toolkit/treelistbox.hxx
+++ b/include/vcl/toolkit/treelistbox.hxx
@@ -535,8 +535,8 @@ public:
 
     void            SetNoAutoCurEntry( bool b );
 
-    void            EnableCheckButton( SvLBoxButtonData* );
-    void            SetCheckButtonData( SvLBoxButtonData* );
+    void            EnableCheckButton(SvLBoxButtonData&);
+    void            SetCheckButtonData(SvLBoxButtonData&);
 
     /** Returns the default image which clients should use for expanded nodes, 
to have a consistent user
         interface experience in the whole product.
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 4d6647c9bce0..0b24c467a368 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4407,10 +4407,10 @@ void 
SalInstanceTreeView::enable_toggle_buttons(weld::ColumnToggleType eType)
     assert(n_children() == 0 && "tree must be empty");
     m_bTogglesAsRadio = eType == weld::ColumnToggleType::Radio;
 
-    SvLBoxButtonData* pData = m_bTogglesAsRadio ? &m_aRadioButtonData : 
&m_aCheckButtonData;
-    m_xTreeView->EnableCheckButton(pData);
+    SvLBoxButtonData& rData = m_bTogglesAsRadio ? m_aRadioButtonData : 
m_aCheckButtonData;
+    m_xTreeView->EnableCheckButton(rData);
     // EnableCheckButton clobbered this, restore it
-    pData->SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
+    rData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
 }
 
 void SalInstanceTreeView::set_toggle(int pos, TriState eState, int col)
diff --git a/vcl/source/treelist/treelistbox.cxx 
b/vcl/source/treelist/treelistbox.cxx
index 7b81eb7c82fe..dec5259ef84b 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -1794,26 +1794,20 @@ void SvTreeListBox::SetDefaultCollapsedEntryBmp( const 
Image& aBmp )
     pImpl->SetDefaultEntryColBmp( aBmp );
 }
 
-void SvTreeListBox::EnableCheckButton( SvLBoxButtonData* pData )
+void SvTreeListBox::EnableCheckButton(SvLBoxButtonData& rData)
 {
-    if( !pData )
-        nTreeFlags &= ~SvTreeFlags::CHKBTN;
-    else
-    {
-        SetCheckButtonData( pData );
-        nTreeFlags |= SvTreeFlags::CHKBTN;
-        pData->SetLink( LINK(this, SvTreeListBox, CheckButtonClick));
-    }
+    SetCheckButtonData(rData);
+    nTreeFlags |= SvTreeFlags::CHKBTN;
+    rData.SetLink( LINK(this, SvTreeListBox, CheckButtonClick));
 
     SetTabs();
     if( IsUpdateMode() )
         Invalidate();
 }
 
-void SvTreeListBox::SetCheckButtonData( SvLBoxButtonData* pData )
+void SvTreeListBox::SetCheckButtonData(SvLBoxButtonData& rData)
 {
-    if ( pData )
-        pCheckButtonData = pData;
+    pCheckButtonData = &rData;
 }
 
 const Image& SvTreeListBox::GetDefaultExpandedNodeImage( )
commit 3d0547f3002eca287c17b8bea2c46c454d487a06
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Feb 21 12:29:34 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Feb 21 16:49:43 2025 +0100

    vcl: Drop SvLBoxButtonData::SetImage
    
    This is never called from outside, so
    move the logic to the only caller instead of
    having a public method.
    
    Change-Id: I24de9da32c9e65d328174b251dbf3f80f3e9e0a8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181998
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/vcl/toolkit/svlbitm.hxx b/include/vcl/toolkit/svlbitm.hxx
index 5e2dd4794da4..6e2bc7788f73 100644
--- a/include/vcl/toolkit/svlbitm.hxx
+++ b/include/vcl/toolkit/svlbitm.hxx
@@ -90,7 +90,6 @@ public:
     SvTreeListEntry*        GetActEntry() const;
     SvLBoxButton*           GetActBox() const;
 
-    void                    SetImage(SvBmp eIndex, const Image& aImage) { 
aBmps[eIndex] = aImage; }
     Image&                  GetImage(SvBmp eIndex) { return aBmps.at(eIndex); }
 
     void                    SetDefaultImages(const Control& 
rControlForSettings);
diff --git a/vcl/source/treelist/svlbitm.cxx b/vcl/source/treelist/svlbitm.cxx
index 2cbc35b04613..48731fd1d7fe 100644
--- a/vcl/source/treelist/svlbitm.cxx
+++ b/vcl/source/treelist/svlbitm.cxx
@@ -122,21 +122,21 @@ void SvLBoxButtonData::SetDefaultImages(const Control& 
rCtrl)
 
     if (m_bShowRadioButton)
     {
-        SetImage(SvBmp::UNCHECKED,   RadioButton::GetRadioImage( rSettings, 
DrawButtonFlags::Default ) );
-        SetImage(SvBmp::CHECKED,     RadioButton::GetRadioImage( rSettings, 
DrawButtonFlags::Checked ) );
-        SetImage(SvBmp::HICHECKED,   RadioButton::GetRadioImage( rSettings, 
DrawButtonFlags::Checked | DrawButtonFlags::Pressed ) );
-        SetImage(SvBmp::HIUNCHECKED, RadioButton::GetRadioImage( rSettings, 
DrawButtonFlags::Default | DrawButtonFlags::Pressed ) );
-        SetImage(SvBmp::TRISTATE,    RadioButton::GetRadioImage( rSettings, 
DrawButtonFlags::DontKnow ) );
-        SetImage(SvBmp::HITRISTATE,  RadioButton::GetRadioImage( rSettings, 
DrawButtonFlags::DontKnow | DrawButtonFlags::Pressed ) );
+        aBmps[SvBmp::UNCHECKED] = RadioButton::GetRadioImage(rSettings, 
DrawButtonFlags::Default);
+        aBmps[SvBmp::CHECKED] = RadioButton::GetRadioImage(rSettings, 
DrawButtonFlags::Checked);
+        aBmps[SvBmp::HICHECKED] = RadioButton::GetRadioImage(rSettings, 
DrawButtonFlags::Checked | DrawButtonFlags::Pressed);
+        aBmps[SvBmp::HIUNCHECKED] = RadioButton::GetRadioImage(rSettings, 
DrawButtonFlags::Default | DrawButtonFlags::Pressed);
+        aBmps[SvBmp::TRISTATE] = RadioButton::GetRadioImage(rSettings, 
DrawButtonFlags::DontKnow);
+        aBmps[SvBmp::HITRISTATE] = RadioButton::GetRadioImage(rSettings, 
DrawButtonFlags::DontKnow | DrawButtonFlags::Pressed);
     }
     else
     {
-        SetImage(SvBmp::UNCHECKED,   CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::Default ) );
-        SetImage(SvBmp::CHECKED,     CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::Checked ) );
-        SetImage(SvBmp::HICHECKED,   CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::Checked | DrawButtonFlags::Pressed ) );
-        SetImage(SvBmp::HIUNCHECKED, CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::Default | DrawButtonFlags::Pressed ) );
-        SetImage(SvBmp::TRISTATE,    CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::DontKnow ) );
-        SetImage(SvBmp::HITRISTATE,  CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::DontKnow | DrawButtonFlags::Pressed ) );
+        aBmps[SvBmp::UNCHECKED] = CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::Default);
+        aBmps[SvBmp::CHECKED] = CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::Checked);
+        aBmps[SvBmp::HICHECKED] = CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::Checked | DrawButtonFlags::Pressed);
+        aBmps[SvBmp::HIUNCHECKED] = CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::Default | DrawButtonFlags::Pressed);
+        aBmps[SvBmp::TRISTATE] = CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::DontKnow);
+        aBmps[SvBmp::HITRISTATE] = CheckBox::GetCheckImage( rSettings, 
DrawButtonFlags::DontKnow | DrawButtonFlags::Pressed);
     }
 }
 

Reply via email to