[Libreoffice-commits] core.git: vcl/inc vcl/qt5

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Oct 2 13:05:36 UTC 2018


 vcl/inc/qt5/Qt5AccessibleWidget.hxx |    9 ++---
 vcl/qt5/Qt5AccessibleWidget.cxx     |   61 +++++++++++++++++++++++-------------
 2 files changed, 45 insertions(+), 25 deletions(-)

New commits:
commit 570d99b7776ccbee031737a9c32c5c9af11649ed
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Mon Oct 1 09:55:19 2018 +0200
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Tue Oct 2 15:05:13 2018 +0200

    Qt5AccessibleWidget: Implement QAccessibleActionInterface
    
    shows available action and allows to execute them
    
    Change-Id: I944e4eccaac7c458af77b471c1d6e10650b1e798
    Reviewed-on: https://gerrit.libreoffice.org/61183
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/vcl/inc/qt5/Qt5AccessibleWidget.hxx b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
index c77104931eb6..d1008f992ab9 100644
--- a/vcl/inc/qt5/Qt5AccessibleWidget.hxx
+++ b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
@@ -27,8 +27,9 @@
 class Qt5Frame;
 class Qt5Widget;
 
-class VCLPLUG_QT5_PUBLIC Qt5AccessibleWidget : public QObject, public QAccessibleInterface
-//public QAccessibleActionInterface
+class VCLPLUG_QT5_PUBLIC Qt5AccessibleWidget : public QObject,
+                                               public QAccessibleInterface,
+                                               public QAccessibleActionInterface
 {
     Q_OBJECT
 
@@ -61,9 +62,9 @@ public:
     void* interface_cast(QAccessible::InterfaceType t) override;
 
     // QAccessibleActionInterface
-    /*  QStringList actionNames() const override;
+    QStringList actionNames() const override;
     void doAction(const QString& actionName) override;
-    QStringList keyBindingsForAction(const QString& actionName) const override; */
+    QStringList keyBindingsForAction(const QString& actionName) const override;
 
     // Factory
     static QAccessibleInterface* customFactory(const QString& classname, QObject* object);
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index 4025ed223a7f..2d691a2d112c 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -24,13 +24,15 @@
 
 #include <Qt5Frame.hxx>
 #include <Qt5Tools.hxx>
-#include <Qt5XAccessible.hxx>
 #include <Qt5Widget.hxx>
+#include <Qt5XAccessible.hxx>
 
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
 #include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleAction.hpp>
 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
+#include <com/sun/star/accessibility/XAccessibleKeyBinding.hpp>
 #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
 
 #include <sal/log.hxx>
@@ -512,30 +514,13 @@ QColor Qt5AccessibleWidget::backgroundColor() const
     return toQColor(xAccessibleComponent->getBackground());
 }
 
-void* Qt5AccessibleWidget::interface_cast(QAccessible::InterfaceType /* t */)
+void* Qt5AccessibleWidget::interface_cast(QAccessible::InterfaceType t)
 {
-    /* if (t == QAccessible::ActionInterface)
-        return static_cast<QAccessibleActionInterface*>(this); */
+    if (t == QAccessible::ActionInterface)
+        return static_cast<QAccessibleActionInterface*>(this);
     return nullptr;
 }
 
-// QAccessibleActionInterface
-/* QStringList Qt5AccessibleWidget::actionNames() const
-{
-    qDebug("Qt5AccessibleWidget::actionNames");
-    QStringList actionNames;
-    return actionNames;
-}
-void Qt5AccessibleWidget::doAction(const QString& actionName)
-{
-    qDebug("Qt5AccessibleWidget::doAction");
-}
-QStringList Qt5AccessibleWidget::keyBindingsForAction(const QString& actionName) const
-{
-    qDebug("Qt5AccessibleWidget::keyBindingsForAction");
-    return QStringList();
-} */
-
 bool Qt5AccessibleWidget::isValid() const
 {
     return m_xAccessible.is() && m_xAccessible->getAccessibleContext().is();
@@ -570,4 +555,38 @@ QAccessibleInterface* Qt5AccessibleWidget::customFactory(const QString& classnam
     return nullptr;
 }
 
+// QAccessibleActionInterface
+QStringList Qt5AccessibleWidget::actionNames() const
+{
+    QStringList actionNames;
+    Reference<XAccessibleAction> xAccessibleAction(m_xAccessible, UNO_QUERY);
+    if (!xAccessibleAction.is())
+        return actionNames;
+
+    int count = xAccessibleAction->getAccessibleActionCount();
+    for (int i = 0; i < count; i++)
+    {
+        OUString desc = xAccessibleAction->getAccessibleActionDescription(i);
+        actionNames.append(toQString(desc));
+    }
+    return actionNames;
+}
+
+void Qt5AccessibleWidget::doAction(const QString& actionName)
+{
+    Reference<XAccessibleAction> xAccessibleAction(m_xAccessible, UNO_QUERY);
+    if (!xAccessibleAction.is())
+        return;
+
+    int index = actionNames().indexOf(actionName);
+    if (index == -1)
+        return;
+    xAccessibleAction->doAccessibleAction(index);
+}
+
+QStringList Qt5AccessibleWidget::keyBindingsForAction(const QString& /* actionName */) const
+{
+    return QStringList();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list