tdf#127935 Make double click expand/collapse entry in option tree

Also makes keyboard use to expand/collapse work

Change-Id: I5b9d065ebe4a612ebe9658feb9ff71c504de7982
Reviewed-on: https://gerrit.libreoffice.org/80173
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx
index aa6f7f5..1042b68 100644
--- a/cui/source/inc/treeopt.hxx
+++ b/cui/source/inc/treeopt.hxx
@@ -159,6 +159,7 @@ private:

    void            ApplyOptions( bool deactivate );

    DECL_STATIC_LINK(OfaTreeOptionsDialog, ExpandCollapseHdl_Impl, weld::TreeView&, void);
    DECL_LINK(ShowPageHdl_Impl, weld::TreeView&, void);
    DECL_LINK(BackHdl_Impl, weld::Button&, void);
    DECL_LINK(ApplyHdl_Impl, weld::Button&, void);
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 845e765..ab802ec 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -608,6 +608,14 @@ sal_uInt16  OfaTreeOptionsDialog::AddGroup(const OUString& rGroupName,
    return nRet - 1;
}

IMPL_STATIC_LINK(OfaTreeOptionsDialog, ExpandCollapseHdl_Impl, weld::TreeView&, xTreeView, void)
{
    std::unique_ptr<weld::TreeIter> xEntry(xTreeView.make_iterator());
    xTreeView.get_selected(xEntry.get());
    if (xTreeView.iter_has_child(*xEntry))
        xTreeView.get_row_expanded(*xEntry) ? xTreeView.collapse_row(*xEntry) : xTreeView.expand_row(*xEntry);
}

IMPL_LINK_NOARG(OfaTreeOptionsDialog, ShowPageHdl_Impl, weld::TreeView&, void)
{
    SelectHdl_Impl();
@@ -741,6 +749,7 @@ void OfaTreeOptionsDialog::ApplyItemSets()
void OfaTreeOptionsDialog::InitTreeAndHandler()
{
    xTreeLB->set_help_id(HID_OFADLG_TREELISTBOX);
    xTreeLB->connect_row_activated( LINK( this, OfaTreeOptionsDialog, ExpandCollapseHdl_Impl ) );
    xTreeLB->connect_changed( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) );
    xBackPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) );
    xApplyPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, ApplyHdl_Impl ) );