[Libreoffice-commits] core.git: include/vcl svx/source vcl/inc vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu May 21 11:26:14 UTC 2020


 include/vcl/weld.hxx           |   10 -
 svx/source/fmcomp/gridcell.cxx |  255 -----------------------------------------
 svx/source/inc/gridcell.hxx    |   32 -----
 vcl/inc/salvtables.hxx         |   20 ---
 vcl/source/app/salvtables.cxx  |   82 -------------
 vcl/unx/gtk3/gtk3gtkinst.cxx   |  150 ++++++------------------
 6 files changed, 42 insertions(+), 507 deletions(-)

New commits:
commit 0677d46bcc56c1f6c27b9331662990b38fd452d6
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed May 20 15:22:56 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu May 21 13:25:38 2020 +0200

    FmXListBoxCell doesn't need to implement css::awt::XListBox
    
    FmXListBoxCell implements css::awt::XListBox but none of that functionality is
    needed locally where it is used to pick a value in a cell when edited
    interactively.
    
    As an XInterface a FmXListBoxCell does fall into the
    script::XEventAttacherManager attach/detach sink-hole so its very difficult to
    determine if it (and any of its siblings) really need to implement the amount
    of uno interfaces they actually implement, so this is a little speculative.
    
    See https://ask.libreoffice.org/en/question/152691/how-to-populate-combo-box-within-table-control-in-form/
    for an example of the ComboBox interaction case which is similar to this ListBox case.
    
    The exotic "multiselection" option definitely isn't shown as an option in the property browser
    for a listbox column in the table control.
    
    Change-Id: I7bdc351e615c9df708a30e4396f6f352fabaed36
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94584
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index d7a9ec278731..fd734309d6a9 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -749,16 +749,6 @@ public:
     virtual void set_max_mru_count(int nCount) = 0;
     virtual OUString get_mru_entries() const = 0;
     virtual void set_mru_entries(const OUString& rEntries) = 0;
-
-    // Form Controls List Box related multi-selection support
-    // Only SelectionMode::Single or SelectionMode::Multiple are supported.
-    // SelectionMode::Multiple mode is basically bizarre but in use in
-    // the Form Controls List Box which we seem stuck with
-    virtual void set_selection_mode(SelectionMode eMode) = 0;
-    virtual void scroll_to_row(int pos) = 0;
-    virtual void select(int pos) = 0;
-    virtual void unselect(int pos) = 0;
-    virtual std::vector<int> get_selected_rows() const = 0;
 };
 
 class VCL_DLLPUBLIC TreeIter
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 2eef5e666941..0700e03e435c 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -3967,8 +3967,6 @@ FmXListBoxCell::FmXListBoxCell(DbGridColumn* pColumn, std::unique_ptr<DbCellCont
   , m_aItemListeners(m_aMutex)
   , m_aActionListeners(m_aMutex)
   , m_pBox(&static_cast<svt::ListBoxControl&>(m_pCellControl->GetWindow()).get_widget())
-  , m_nLines(Application::GetSettings().GetStyleSettings().GetListBoxMaximumLineCount())
-  , m_bMulti(false)
 {
     m_pBox->connect_changed(LINK(this, FmXListBoxCell, ChangedHdl));
 }
@@ -3995,257 +3993,8 @@ void FmXListBoxCell::disposing()
     FmXTextCell::disposing();
 }
 
-Any SAL_CALL FmXListBoxCell::queryAggregation( const css::uno::Type& _rType )
-{
-    Any aReturn = FmXTextCell::queryAggregation(_rType);
-
-    if ( !aReturn.hasValue() )
-        aReturn = FmXListBoxCell_Base::queryInterface( _rType );
-
-    return aReturn;
-}
-
-Sequence< css::uno::Type > SAL_CALL FmXListBoxCell::getTypes(  )
-{
-    return ::comphelper::concatSequences(
-        FmXTextCell::getTypes(),
-        FmXListBoxCell_Base::getTypes()
-    );
-}
-
 IMPLEMENT_GET_IMPLEMENTATION_ID( FmXListBoxCell )
 
-void SAL_CALL FmXListBoxCell::addItemListener(const Reference< css::awt::XItemListener >& l)
-{
-    m_aItemListeners.addInterface( l );
-}
-
-
-void SAL_CALL FmXListBoxCell::removeItemListener(const Reference< css::awt::XItemListener >& l)
-{
-    m_aItemListeners.removeInterface( l );
-}
-
-
-void SAL_CALL FmXListBoxCell::addActionListener(const Reference< css::awt::XActionListener >& l)
-{
-    m_aActionListeners.addInterface( l );
-}
-
-
-void SAL_CALL FmXListBoxCell::removeActionListener(const Reference< css::awt::XActionListener >& l)
-{
-    m_aActionListeners.removeInterface( l );
-}
-
-void SAL_CALL FmXListBoxCell::addItem(const OUString& aItem, sal_Int16 nPos)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    if (m_pBox)
-        m_pBox->insert_text(nPos, aItem);
-}
-
-void SAL_CALL FmXListBoxCell::addItems(const css::uno::Sequence<OUString>& aItems, sal_Int16 nPos)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    if (m_pBox)
-    {
-        sal_uInt16 nP = nPos;
-        for ( const auto& rItem : aItems )
-        {
-            m_pBox->insert_text(nP, rItem);
-            if ( nPos != -1 )    // Not if 0xFFFF, because LIST_APPEND
-                nP++;
-        }
-    }
-}
-
-void SAL_CALL FmXListBoxCell::removeItems(sal_Int16 nPos, sal_Int16 nCount)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    if ( m_pBox )
-    {
-        for ( sal_uInt16 n = nCount; n; )
-            m_pBox->remove( nPos + (--n) );
-    }
-}
-
-sal_Int16 SAL_CALL FmXListBoxCell::getItemCount()
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    return m_pBox ? m_pBox->get_count() : 0;
-}
-
-OUString SAL_CALL FmXListBoxCell::getItem(sal_Int16 nPos)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    return m_pBox ? m_pBox->get_text(nPos) : OUString();
-}
-
-css::uno::Sequence<OUString> SAL_CALL FmXListBoxCell::getItems()
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-
-    css::uno::Sequence<OUString> aSeq;
-    if (m_pBox)
-    {
-        const sal_Int32 nEntries = m_pBox->get_count();
-        aSeq = css::uno::Sequence<OUString>( nEntries );
-        for ( sal_Int32 n = nEntries; n; )
-        {
-            --n;
-            aSeq.getArray()[n] = m_pBox->get_text( n );
-        }
-    }
-    return aSeq;
-}
-
-sal_Int16 SAL_CALL FmXListBoxCell::getSelectedItemPos()
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    if (m_pBox)
-    {
-        UpdateFromColumn();
-        sal_Int32 nPos = m_pBox->get_active();
-        if (nPos > SHRT_MAX || nPos < SHRT_MIN)
-            throw std::out_of_range("awt::XListBox::getSelectedItemPos can only return a short");
-        return nPos;
-    }
-    return 0;
-}
-
-Sequence< sal_Int16 > SAL_CALL FmXListBoxCell::getSelectedItemsPos()
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    Sequence<sal_Int16> aSeq;
-
-    if (m_pBox)
-    {
-        UpdateFromColumn();
-        auto aSelected = m_pBox->get_selected_rows();
-        size_t nSelEntries = aSelected.size();
-        aSeq = Sequence<sal_Int16>( nSelEntries );
-        for (size_t n = 0; n < nSelEntries; ++n)
-            aSeq.getArray()[n] = aSelected[n];
-    }
-    return aSeq;
-}
-
-OUString SAL_CALL FmXListBoxCell::getSelectedItem()
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-
-    OUString aItem;
-
-    if (m_pBox)
-    {
-        UpdateFromColumn();
-        aItem = m_pBox->get_active_text();
-    }
-
-    return aItem;
-}
-
-css::uno::Sequence<OUString> SAL_CALL FmXListBoxCell::getSelectedItems()
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-
-    css::uno::Sequence<OUString> aSeq;
-
-    if (m_pBox)
-    {
-        UpdateFromColumn();
-        auto aSelected = m_pBox->get_selected_rows();
-        const size_t nSelEntries = aSelected.size();
-        aSeq = css::uno::Sequence<OUString>( nSelEntries );
-        for (size_t n = 0; n < nSelEntries; ++n)
-            aSeq.getArray()[n] = m_pBox->get_text(aSelected[n]);
-    }
-    return aSeq;
-}
-
-void SAL_CALL FmXListBoxCell::selectItemPos(sal_Int16 nPos, sal_Bool bSelect)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-
-    if (m_pBox)
-    {
-        if (bSelect)
-            m_pBox->select(nPos);
-        else
-            m_pBox->unselect(nPos);
-    }
-}
-
-void SAL_CALL FmXListBoxCell::selectItemsPos(const Sequence< sal_Int16 >& aPositions, sal_Bool bSelect)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-
-    if (m_pBox)
-    {
-        for ( sal_uInt16 n = static_cast<sal_uInt16>(aPositions.getLength()); n; )
-        {
-            auto nPos = static_cast<sal_uInt16>(aPositions.getConstArray()[--n]);
-            if (bSelect)
-                m_pBox->select(nPos);
-            else
-                m_pBox->unselect(nPos);
-        }
-    }
-}
-
-void SAL_CALL FmXListBoxCell::selectItem(const OUString& aItem, sal_Bool bSelect)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-
-    if (m_pBox)
-    {
-        auto nPos = m_pBox->find_text(aItem);
-        if (bSelect)
-            m_pBox->select(nPos);
-        else
-            m_pBox->unselect(nPos);
-    }
-}
-
-sal_Bool SAL_CALL FmXListBoxCell::isMutipleMode()
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-
-    return m_bMulti;
-}
-
-void SAL_CALL FmXListBoxCell::setMultipleMode(sal_Bool bMulti)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-
-    m_bMulti = bMulti;
-
-    if (m_pBox)
-        m_pBox->set_selection_mode(bMulti ? SelectionMode::Multiple : SelectionMode::Single);
-}
-
-sal_Int16 SAL_CALL FmXListBoxCell::getDropDownLineCount()
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-    return m_nLines;
-}
-
-void SAL_CALL FmXListBoxCell::setDropDownLineCount(sal_Int16 nLines)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-
-    m_nLines = nLines; // just store it to return it
-}
-
-void SAL_CALL FmXListBoxCell::makeVisible(sal_Int16 nEntry)
-{
-    ::osl::MutexGuard aGuard( m_aMutex );
-
-    if (m_pBox)
-        m_pBox->scroll_to_row(nEntry);
-}
-
 IMPL_LINK_NOARG(FmXListBoxCell, ChangedHdl, weld::ComboBox&, void)
 {
     if (!m_pBox || !m_pBox->changed_by_direct_pick())
@@ -4258,8 +4007,8 @@ IMPL_LINK_NOARG(FmXListBoxCell, ChangedHdl, weld::ComboBox&, void)
     aEvent.Highlighted = 0;
 
     // with multiple selection 0xFFFF, otherwise the ID
-    aEvent.Selected = (m_pBox->get_selected_rows().size() == 1 )
-        ? m_pBox->get_active() : 0xFFFF;
+    aEvent.Selected = (m_pBox->get_active() != -1 )
+                    ? m_pBox->get_active() : 0xFFFF;
 
     m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
     return;
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index 360e6d83da8a..2e43144fcb1d 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -952,46 +952,16 @@ protected:
 };
 
 
-typedef ::cppu::ImplHelper1 <   css::awt::XListBox
-                            >   FmXListBoxCell_Base;
 class FmXListBoxCell final :public FmXTextCell
-                        ,public FmXListBoxCell_Base
 {
 public:
     FmXListBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl );
 
-    DECLARE_UNO3_AGG_DEFAULTS(FmXListBoxCell, FmXTextCell)
-    virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override;
-    virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes(  ) override;
     virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
 
 // OComponentHelper
     virtual void SAL_CALL disposing() override;
 
-// css::awt::XListBox
-    virtual void SAL_CALL addItemListener(const css::uno::Reference< css::awt::XItemListener >& l) override;
-    virtual void SAL_CALL removeItemListener(const css::uno::Reference< css::awt::XItemListener >& l) override;
-    virtual void SAL_CALL addActionListener(const css::uno::Reference< css::awt::XActionListener >& l) override;
-    virtual void SAL_CALL removeActionListener(const css::uno::Reference< css::awt::XActionListener >& l) override;
-    virtual void SAL_CALL addItem(const OUString& aItem, sal_Int16 nPos) override;
-    virtual void SAL_CALL addItems(const css::uno::Sequence< OUString >& aItems, sal_Int16 nPos) override;
-    virtual void SAL_CALL removeItems(sal_Int16 nPos, sal_Int16 nCount) override;
-    virtual sal_Int16 SAL_CALL getItemCount() override;
-    virtual OUString SAL_CALL getItem(sal_Int16 nPos) override;
-    virtual css::uno::Sequence< OUString > SAL_CALL getItems() override;
-    virtual sal_Int16 SAL_CALL getSelectedItemPos() override;
-    virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSelectedItemsPos() override;
-    virtual OUString SAL_CALL getSelectedItem() override;
-    virtual css::uno::Sequence< OUString > SAL_CALL getSelectedItems() override;
-    virtual void SAL_CALL selectItemPos(sal_Int16 nPos, sal_Bool bSelect) override;
-    virtual void SAL_CALL selectItemsPos(const css::uno::Sequence< sal_Int16 >& aPositions, sal_Bool bSelect) override;
-    virtual void SAL_CALL selectItem(const OUString& aItem, sal_Bool bSelect) override;
-    virtual sal_Bool SAL_CALL isMutipleMode() override;
-    virtual void SAL_CALL setMultipleMode(sal_Bool bMulti) override;
-    virtual sal_Int16 SAL_CALL getDropDownLineCount() override;
-    virtual void SAL_CALL setDropDownLineCount(sal_Int16 nLines) override;
-    virtual void SAL_CALL makeVisible(sal_Int16 nEntry) override;
-
 private:
     virtual ~FmXListBoxCell() override;
 
@@ -1002,8 +972,6 @@ private:
     ::comphelper::OInterfaceContainerHelper2   m_aItemListeners,
                                         m_aActionListeners;
     weld::ComboBox* m_pBox;
-    sal_uInt16 m_nLines;
-    bool m_bMulti;
 };
 
 
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 006ad1f36bd1..6cc85731952e 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -923,16 +923,6 @@ public:
 
     virtual void set_mru_entries(const OUString&) override;
 
-    virtual void set_selection_mode(SelectionMode eMode) override;
-
-    virtual void scroll_to_row(int nRow) override;
-
-    virtual void select(int pos) override;
-
-    virtual void unselect(int pos) override;
-
-    virtual std::vector<int> get_selected_rows() const override;
-
     virtual void HandleEventListener(VclWindowEvent& rEvent) override;
 
     virtual ~SalInstanceComboBoxWithoutEdit() override;
@@ -1003,16 +993,6 @@ public:
 
     virtual void set_mru_entries(const OUString& rEntries) override;
 
-    virtual void set_selection_mode(SelectionMode eMode) override;
-
-    virtual void scroll_to_row(int nRow) override;
-
-    virtual void select(int pos) override;
-
-    virtual void unselect(int pos) override;
-
-    virtual std::vector<int> get_selected_rows() const override;
-
     virtual void HandleEventListener(VclWindowEvent& rEvent) override;
 
     virtual ~SalInstanceComboBoxWithEdit() override;
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index b256caac3702..b3c9d2cfb77d 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -5770,35 +5770,6 @@ void SalInstanceComboBoxWithoutEdit::set_mru_entries(const OUString&)
     assert(false && "not implemented");
 }
 
-void SalInstanceComboBoxWithoutEdit::set_selection_mode(SelectionMode eMode)
-{
-    m_xComboBox->EnableMultiSelection(eMode == SelectionMode::Multiple);
-}
-
-std::vector<int> SalInstanceComboBoxWithoutEdit::get_selected_rows() const
-{
-    std::vector<int> aRet;
-    const sal_Int32 nSelEntries = m_xComboBox->GetSelectedEntryCount();
-    for (sal_Int32 n = 0; n < nSelEntries; ++n)
-        aRet.push_back(m_xComboBox->GetSelectedEntryPos(n));
-    return aRet;
-}
-
-void SalInstanceComboBoxWithoutEdit::scroll_to_row(int nRow)
-{
-    m_xComboBox->SetTopEntry(nRow);
-}
-
-void SalInstanceComboBoxWithoutEdit::select(int nRow)
-{
-    m_xComboBox->SelectEntryPos(nRow, true);
-}
-
-void SalInstanceComboBoxWithoutEdit::unselect(int nRow)
-{
-    m_xComboBox->SelectEntryPos(nRow, false);
-}
-
 void SalInstanceComboBoxWithoutEdit::HandleEventListener(VclWindowEvent& rEvent)
 {
     CallHandleEventListener(rEvent);
@@ -5975,34 +5946,6 @@ void SalInstanceComboBoxWithEdit::set_mru_entries(const OUString& rEntries)
     m_xComboBox->SetMRUEntries(rEntries);
 }
 
-void SalInstanceComboBoxWithEdit::set_selection_mode(SelectionMode /*eMode*/)
-{
-}
-
-std::vector<int> SalInstanceComboBoxWithEdit::get_selected_rows() const
-{
-    std::vector<int> aRet;
-    int nActive = get_active();
-    if (nActive != -1)
-        aRet.push_back(nActive);
-    return aRet;
-}
-
-void SalInstanceComboBoxWithEdit::scroll_to_row(int /*nRow*/)
-{
-    assert(false && "not implemented");
-}
-
-void SalInstanceComboBoxWithEdit::select(int /*nRow*/)
-{
-    assert(false && "not implemented");
-}
-
-void SalInstanceComboBoxWithEdit::unselect(int /*nRow*/)
-{
-    assert(false && "not implemented");
-}
-
 void SalInstanceComboBoxWithEdit::HandleEventListener(VclWindowEvent& rEvent)
 {
     if (rEvent.GetId() == VclEventId::DropdownPreOpen)
@@ -6170,31 +6113,6 @@ public:
         assert(false && "not implemented");
     }
 
-    virtual void set_selection_mode(SelectionMode eMode) override
-    {
-        m_pTreeView->set_selection_mode(eMode);
-    }
-
-    virtual std::vector<int> get_selected_rows() const override
-    {
-        return m_pTreeView->get_selected_rows();
-    }
-
-    void scroll_to_row(int nRow) override
-    {
-        m_pTreeView->scroll_to_row(nRow);
-    }
-
-    virtual void select(int pos) override
-    {
-        m_pTreeView->select(pos);
-    }
-
-    virtual void unselect(int pos) override
-    {
-        m_pTreeView->unselect(pos);
-    }
-
     virtual void set_item_menu(const OString&, weld::Menu*) override
     {
         assert(false && "not implemented");
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 4ca590393fad..530a115bd96b 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -9033,62 +9033,6 @@ tools::Rectangle get_row_area(GtkTreeView* pTreeView, GList* pColumns, GtkTreePa
     return aRet;
 }
 
-std::vector<int> get_selected_rows(GtkTreeView* pTreeView)
-{
-    std::vector<int> aRows;
-
-    GList* pList = gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(pTreeView), nullptr);
-    for (GList* pItem = g_list_first(pList); pItem; pItem = g_list_next(pItem))
-    {
-        GtkTreePath* path = static_cast<GtkTreePath*>(pItem->data);
-
-        gint depth;
-        gint* indices = gtk_tree_path_get_indices_with_depth(path, &depth);
-        int nRow = indices[depth-1];
-
-        aRows.push_back(nRow);
-    }
-    g_list_free_full(pList, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
-
-    return aRows;
-}
-
-void scroll_to_row(GtkTreeView* pTreeView, int pos)
-{
-    GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
-    gtk_tree_view_scroll_to_cell(pTreeView, path, nullptr, false, 0, 0);
-    gtk_tree_path_free(path);
-}
-
-void select_tree(GtkTreeView* pTreeView, GtkTreeModel* pTreeModel, int pos)
-{
-    if (pos == -1 || (pos == 0 && gtk_tree_model_iter_n_children(pTreeModel, nullptr) == 0))
-    {
-        gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(pTreeView));
-    }
-    else
-    {
-        GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
-        gtk_tree_selection_select_path(gtk_tree_view_get_selection(pTreeView), path);
-        gtk_tree_view_scroll_to_cell(pTreeView, path, nullptr, false, 0, 0);
-        gtk_tree_path_free(path);
-    }
-}
-
-void unselect_tree(GtkTreeView* pTreeView, GtkTreeModel* pTreeModel, int pos)
-{
-    if (pos == -1 || (pos == 0 && gtk_tree_model_iter_n_children(pTreeModel, nullptr) == 0))
-    {
-        gtk_tree_selection_select_all(gtk_tree_view_get_selection(pTreeView));
-    }
-    else
-    {
-        GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
-        gtk_tree_selection_unselect_path(gtk_tree_view_get_selection(pTreeView), path);
-        gtk_tree_path_free(path);
-    }
-}
-
 class GtkInstanceTreeView : public GtkInstanceContainer, public virtual weld::TreeView
 {
 private:
@@ -10181,7 +10125,17 @@ public:
     {
         assert(gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze");
         disable_notify_events();
-        select_tree(m_pTreeView, GTK_TREE_MODEL(m_pTreeStore), pos);
+        if (pos == -1 || (pos == 0 && n_children() == 0))
+        {
+            gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(m_pTreeView));
+        }
+        else
+        {
+            GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
+            gtk_tree_selection_select_path(gtk_tree_view_get_selection(m_pTreeView), path);
+            gtk_tree_view_scroll_to_cell(m_pTreeView, path, nullptr, false, 0, 0);
+            gtk_tree_path_free(path);
+        }
         enable_notify_events();
     }
 
@@ -10199,7 +10153,9 @@ public:
     {
         assert(gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze");
         disable_notify_events();
-        ::scroll_to_row(m_pTreeView, pos);
+        GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
+        gtk_tree_view_scroll_to_cell(m_pTreeView, path, nullptr, false, 0, 0);
+        gtk_tree_path_free(path);
         enable_notify_events();
     }
 
@@ -10214,13 +10170,37 @@ public:
     {
         assert(gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen, select after thaw. Note selection doesn't survive a freeze");
         disable_notify_events();
-        unselect_tree(m_pTreeView, GTK_TREE_MODEL(m_pTreeStore), pos);
+        if (pos == -1 || (pos == 0 && n_children() == 0))
+        {
+            gtk_tree_selection_select_all(gtk_tree_view_get_selection(m_pTreeView));
+        }
+        else
+        {
+            GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
+            gtk_tree_selection_unselect_path(gtk_tree_view_get_selection(m_pTreeView), path);
+            gtk_tree_path_free(path);
+        }
         enable_notify_events();
     }
 
     virtual std::vector<int> get_selected_rows() const override
     {
-        return ::get_selected_rows(m_pTreeView);
+        std::vector<int> aRows;
+
+        GList* pList = gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(m_pTreeView), nullptr);
+        for (GList* pItem = g_list_first(pList); pItem; pItem = g_list_next(pItem))
+        {
+            GtkTreePath* path = static_cast<GtkTreePath*>(pItem->data);
+
+            gint depth;
+            gint* indices = gtk_tree_path_get_indices_with_depth(path, &depth);
+            int nRow = indices[depth-1];
+
+            aRows.push_back(nRow);
+        }
+        g_list_free_full(pList, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
+
+        return aRows;
     }
 
     virtual void all_foreach(const std::function<bool(weld::TreeIter&)>& func) override
@@ -14364,31 +14344,6 @@ public:
         return nWidth;
     }
 
-    virtual void set_selection_mode(SelectionMode eMode) override
-    {
-        gtk_tree_selection_set_mode(gtk_tree_view_get_selection(m_pTreeView), VclToGtk(eMode));
-    }
-
-    void scroll_to_row(int nRow) override
-    {
-        ::scroll_to_row(m_pTreeView, nRow);
-    }
-
-    virtual std::vector<int> get_selected_rows() const override
-    {
-        return ::get_selected_rows(m_pTreeView);
-    }
-
-    void select(int nRow) override
-    {
-        select_tree(m_pTreeView, m_pTreeModel, nRow);
-    }
-
-    void unselect(int nRow) override
-    {
-        unselect_tree(m_pTreeView, m_pTreeModel, nRow);
-    }
-
     virtual ~GtkInstanceComboBox() override
     {
         m_xCustomMenuButtonHelper.reset();
@@ -14816,31 +14771,6 @@ public:
         return 0;
     }
 
-    virtual void set_selection_mode(SelectionMode eMode) override
-    {
-        m_pTreeView->set_selection_mode(eMode);
-    }
-
-    virtual std::vector<int> get_selected_rows() const override
-    {
-        return m_pTreeView->get_selected_rows();
-    }
-
-    void scroll_to_row(int nRow) override
-    {
-        m_pTreeView->scroll_to_row(nRow);
-    }
-
-    void select(int nRow) override
-    {
-        m_pTreeView->select(nRow);
-    }
-
-    void unselect(int nRow) override
-    {
-        m_pTreeView->unselect(nRow);
-    }
-
     virtual ~GtkInstanceEntryTreeView() override
     {
         if (m_nAutoCompleteIdleId)


More information about the Libreoffice-commits mailing list