include/vcl/toolkit/treelistentry.hxx               |    3 ++
 include/vcl/weld.hxx                                |    1 
 vcl/inc/qt5/QtInstanceIconView.hxx                  |    1 
 vcl/inc/salvtables.hxx                              |    1 
 vcl/qt5/QtInstanceIconView.cxx                      |   10 ++++++
 vcl/source/accessibility/accessiblelistboxentry.cxx |    9 ++++++
 vcl/source/app/salvtables.cxx                       |    7 ++++
 vcl/unx/gtk3/gtkinst.cxx                            |   29 ++++++++++++++++++++
 8 files changed, 61 insertions(+)

New commits:
commit e58074800eb9d5cb08427e295cc039ac8f644fb4
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Feb 25 13:07:31 2026 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Wed Feb 25 17:16:42 2026 +0100

    add accessible description support to an iconview entry
    
    Change-Id: Ia0bad19e572bdd51e035b35540176a6559152afb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200328
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/include/vcl/toolkit/treelistentry.hxx 
b/include/vcl/toolkit/treelistentry.hxx
index 599a4e6a21e1..0310e5de9b1b 100644
--- a/include/vcl/toolkit/treelistentry.hxx
+++ b/include/vcl/toolkit/treelistentry.hxx
@@ -71,6 +71,7 @@ class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvTreeListEntry
     SvTLEntryFlags      nEntryFlags;
     std::optional<Color> mxTextColor;
     OUString m_sAccessibleName;
+    OUString m_sAccessibleDescription;
 
 private:
     void ClearChildren();
@@ -120,6 +121,8 @@ public:
     void SetTextColor( std::optional<Color> xColor ) { mxTextColor = xColor; }
     OUString GetAccessibleName() { return m_sAccessibleName; }
     void SetAccessibleName(const OUString& rName) { m_sAccessibleName = rName; 
};
+    OUString GetAccessibleDescription() { return m_sAccessibleDescription; }
+    void SetAccessibleDescription(const OUString& rDesc) { 
m_sAccessibleDescription = rDesc; };
     std::optional<Color> const & GetTextColor() const { return mxTextColor; }
 
     void SetExtraIndent(sal_uInt32 nExtraIndent) { mnExtraIndent = 
nExtraIndent; }
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 1aa0ebf9e55a..9d5f2257bf2a 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1790,6 +1790,7 @@ public:
     virtual void set_text(int pos, const OUString& rText) = 0;
     virtual void set_id(int pos, const OUString& rId) = 0;
     virtual void set_item_accessible_name(int pos, const OUString& rName) = 0;
+    virtual void set_item_accessible_description(int pos, const OUString& 
rDescription) = 0;
 
     void remove(int pos)
     {
diff --git a/vcl/inc/qt5/QtInstanceIconView.hxx 
b/vcl/inc/qt5/QtInstanceIconView.hxx
index e5db98f36e1f..ccced3b1d666 100644
--- a/vcl/inc/qt5/QtInstanceIconView.hxx
+++ b/vcl/inc/qt5/QtInstanceIconView.hxx
@@ -51,6 +51,7 @@ public:
     virtual void set_text(int nPos, const OUString& rText) override;
     virtual void set_id(int nPos, const OUString& rId) override;
     virtual void set_item_accessible_name(int nPos, const OUString& rName) 
override;
+    virtual void set_item_accessible_description(int nPos, const OUString& 
rDescription) override;
     virtual void do_remove(int pos) override;
     virtual tools::Rectangle get_rect(int pos) const override;
 
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 875eb912c9da..17f29f3d6132 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1970,6 +1970,7 @@ public:
     virtual void set_id(int pos, const OUString& rId) override;
 
     virtual void set_item_accessible_name(int pos, const OUString& rName) 
override;
+    virtual void set_item_accessible_description(int pos, const OUString& 
rDescription) override;
 
     virtual OUString get_text(const weld::TreeIter& rIter) const override;
 
diff --git a/vcl/qt5/QtInstanceIconView.cxx b/vcl/qt5/QtInstanceIconView.cxx
index ed0382439180..0f50d44f26fc 100644
--- a/vcl/qt5/QtInstanceIconView.cxx
+++ b/vcl/qt5/QtInstanceIconView.cxx
@@ -209,6 +209,16 @@ void QtInstanceIconView::set_item_accessible_name(int 
nPos, const OUString& rNam
     });
 }
 
+void QtInstanceIconView::set_item_accessible_description(int nPos, const 
OUString& rDescription)
+{
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] {
+        QModelIndex aIndex = modelIndex(nPos);
+        m_pModel->setData(aIndex, toQString(rDescription), 
Qt::AccessibleDescriptionRole);
+    });
+}
+
 void QtInstanceIconView::do_remove(int) { assert(false && "Not implemented 
yet"); }
 
 tools::Rectangle QtInstanceIconView::get_rect(int) const
diff --git a/vcl/source/accessibility/accessiblelistboxentry.cxx 
b/vcl/source/accessibility/accessiblelistboxentry.cxx
index f0cf6ec79622..5af1988385c2 100644
--- a/vcl/source/accessibility/accessiblelistboxentry.cxx
+++ b/vcl/source/accessibility/accessiblelistboxentry.cxx
@@ -354,6 +354,15 @@ OUString SAL_CALL 
AccessibleListBoxEntry::getAccessibleDescription(  )
     SolarMutexGuard aSolarGuard;
     ::osl::MutexGuard aGuard( m_aMutex );
 
+    ensureAlive();
+
+    if (SvTreeListEntry* pEntry = 
m_pTreeListBox->GetEntryFromPath(m_aEntryPath))
+    {
+        OUString sDesc = pEntry->GetAccessibleDescription();
+        if (!sDesc.isEmpty())
+            return sDesc;
+    }
+
     return OUString();
 }
 
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index af023f86845e..9bd614688618 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -5591,6 +5591,13 @@ void SalInstanceIconView::set_item_accessible_name(int 
pos, const OUString& rNam
     pEntry->SetAccessibleName(rName);
 }
 
+void SalInstanceIconView::set_item_accessible_description(int pos, const 
OUString& rDescription)
+{
+    SvTreeListEntry* pEntry = m_xIconView->GetEntry(pos);
+    assert(pEntry);
+    pEntry->SetAccessibleDescription(rDescription);
+}
+
 tools::Rectangle SalInstanceIconView::get_rect(int pos) const
 {
     SvTreeListEntry* aEntry = m_xIconView->GetEntry(nullptr, pos);
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 0d1e1ee28b52..66d9e7b66457 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -16933,6 +16933,35 @@ private:
 #endif
     }
 
+    virtual void set_item_accessible_description(int pos, const OUString& 
rDescription) override
+    {
+#if GTK_CHECK_VERSION(4, 0, 0)
+        (void)pos;
+        (void)rDescription;
+#else
+        AtkObject* pAtkObject = 
gtk_widget_get_accessible(GTK_WIDGET(m_pIconView));
+        if (!pAtkObject)
+            return;
+
+        GtkTreeModel* pModel = GTK_TREE_MODEL(m_pTreeStore);
+        GtkTreeIter iter;
+        if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos))
+        {
+            GtkTreePath* pPath = 
gtk_tree_model_get_path(GTK_TREE_MODEL(m_pTreeStore), &iter);
+            assert(gtk_tree_path_get_depth(pPath) == 1);
+            int* indices = gtk_tree_path_get_indices(pPath);
+            const int nIndex = indices[0];
+            assert(nIndex < atk_object_get_n_accessible_children(pAtkObject)
+                   && "item index too high for ItemView's accessible child 
count");
+
+            AtkObject* pChild = atk_object_ref_accessible_child(pAtkObject, 
nIndex);
+            atk_object_set_description(pChild, rDescription.toUtf8().getStr());
+            g_object_unref(pChild);
+            gtk_tree_path_free(pPath);
+        }
+#endif
+    }
+
     virtual void do_remove(int pos) override
     {
         disable_notify_events();

Reply via email to