vcl/unx/gtk4/convert3to4.cxx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
New commits: commit 0482f156a0ade16d55787ea2ca1c08404f9961e5 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Jul 29 12:18:33 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sat Jul 30 13:11:16 2022 +0200 gtk4: convert AtkObject::accessible-role to something else we only use AtkObject::accessible-role for "static", but there doesn't seem to be a good match to anything I can see in gtk4. convert it to accessible-role of "alert" for lack of a better idea. Change-Id: Ic0795fed006b827914f1319150a915187188a4db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137617 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/unx/gtk4/convert3to4.cxx b/vcl/unx/gtk4/convert3to4.cxx index 9032ac4692a7..3dc2eae08a11 100644 --- a/vcl/unx/gtk4/convert3to4.cxx +++ b/vcl/unx/gtk4/convert3to4.cxx @@ -762,6 +762,9 @@ ConvertResult Convert3To4(const css::uno::Reference<css::xml::dom::XNode>& xNode if (sName == "AtkObject::accessible-name") xName->setNodeValue("label"); + + if (sName == "AtkObject::accessible-role") + xName->setNodeValue("accessible-role"); } else if (xChild->getNodeName() == "child") { @@ -1357,11 +1360,41 @@ ConvertResult Convert3To4(const css::uno::Reference<css::xml::dom::XNode>& xNode xParentObject->insertBefore(xAccessibility, xNode); // move the converted old AtkObject:: properties into a new accessibility parent + css::uno::Reference<css::xml::dom::XNode> xRole; for (css::uno::Reference<css::xml::dom::XNode> xCurrent = xChild->getFirstChild(); xCurrent.is(); xCurrent = xChild->getFirstChild()) { + if (css::uno::Reference<css::xml::dom::XNamedNodeMap> xCurrentMap + = xCurrent->getAttributes()) + { + css::uno::Reference<css::xml::dom::XNode> xName + = xCurrentMap->getNamedItem("name"); + OUString sName(xName->getNodeValue()); + if (sName == "accessible-role") + { + xRole = xCurrent; + } + } + xAccessibility->appendChild(xChild->removeChild(xCurrent)); } + + if (xRole) + { + auto xRoleText = xRole->getFirstChild(); + if (xRoleText.is()) + { + OUString sText = xRoleText->getNodeValue(); + // don't really know what the right solution here should be, but "static" isn't + // a role that exists in gtk4, nothing seems to match exactly, but maybe "alert" + // is a useful place to land for now + if (sText == "static") + xRoleText->setNodeValue("alert"); + } + // move out of accessibility section to property section + xParentObject->insertBefore(xRole->getParentNode()->removeChild(xRole), + xAccessibility); + } } // only create the child box for GtkButton/GtkToggleButton