[Libreoffice-commits] core.git: comphelper/source include/comphelper include/toolkit offapi/com offapi/UnoApi_offapi.mk toolkit/source vcl/unx

Samuel Thibault (via logerrit) logerrit at kemper.freedesktop.org
Thu May 9 11:40:53 UTC 2019


 comphelper/source/misc/accessiblecontexthelper.cxx        |    6 +
 include/comphelper/accessiblecontexthelper.hxx            |    7 +
 include/toolkit/awt/vclxaccessiblecomponent.hxx           |    2 
 offapi/UnoApi_offapi.mk                                   |    1 
 offapi/com/sun/star/accessibility/XAccessibleContext2.idl |   56 ++++++++++++++
 toolkit/source/awt/vclxaccessiblecomponent.cxx            |   13 +++
 vcl/unx/gtk/a11y/atkwrapper.cxx                           |   12 +++
 7 files changed, 95 insertions(+), 2 deletions(-)

New commits:
commit b4009daccd11e416865efd5fd3c205c46691bb12
Author:     Samuel Thibault <sthibault at hypra.fr>
AuthorDate: Thu May 2 17:24:30 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu May 9 13:39:33 2019 +0200

    tdf#124400 a11y: add accessible ID
    
    Such ID is not meant to be presented to the user, but to be an ID
    which is stable over application development. Typically, this is
    the gtkbuilder ID. Such an ID can then be used to identify a given
    well-known accessible object independently from the current locale,
    user-visible labelling, or dialog structure. This can then be used
    for tailored screen reading (e.g. automatically announcing the
    content of a well-known object), or for automatic regression testing
    (to check the behavior of well-known objects). Uniqueness within
    the window is thus desirable when returning a non-empty string.
    
    This adds XAccessibleXContext2 to augment XAccessibleXContext with
    getAccessibleId().  The VCL implementation just takes Window::get_id(),
    i.e. the gtkbuilder id, which is enough for most use cases for now.
    
    atk_object_wrapper_new then passes it to
    atk_object_set_accessible_id() for AT-SPI technologies to pick it up.
    
    Change-Id: Iea0ad08d036e539dbcfec1a9be026c8da8d17357
    Reviewed-on: https://gerrit.libreoffice.org/71743
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    Tested-by: Jenkins

diff --git a/comphelper/source/misc/accessiblecontexthelper.cxx b/comphelper/source/misc/accessiblecontexthelper.cxx
index 1b6d7f59f547..463c9735f228 100644
--- a/comphelper/source/misc/accessiblecontexthelper.cxx
+++ b/comphelper/source/misc/accessiblecontexthelper.cxx
@@ -196,6 +196,12 @@ namespace comphelper
     }
 
 
+    OUString SAL_CALL OAccessibleContextHelper::getAccessibleId(  )
+    {
+        return OUString();
+    }
+
+
     sal_Int32 SAL_CALL OAccessibleContextHelper::getAccessibleIndexInParent(  )
     {
         OExternalLockGuard aGuard( this );
diff --git a/include/comphelper/accessiblecontexthelper.hxx b/include/comphelper/accessiblecontexthelper.hxx
index 7af467872faa..f8182526b280 100644
--- a/include/comphelper/accessiblecontexthelper.hxx
+++ b/include/comphelper/accessiblecontexthelper.hxx
@@ -22,7 +22,7 @@
 
 #include <cppuhelper/compbase2.hxx>
 #include <cppuhelper/basemutex.hxx>
-#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext2.hpp>
 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
 #include <comphelper/comphelperdllapi.h>
 #include <comphelper/solarmutex.hxx>
@@ -37,7 +37,7 @@ namespace comphelper
 
 
     class OContextHelper_Impl;
-    typedef ::cppu::WeakAggComponentImplHelper2 <   css::accessibility::XAccessibleContext,
+    typedef ::cppu::WeakAggComponentImplHelper2 <   css::accessibility::XAccessibleContext2,
                                                     css::accessibility::XAccessibleEventBroadcaster
                                                 >   OAccessibleContextHelper_Base;
 
@@ -91,6 +91,9 @@ namespace comphelper
         virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) override = 0;
         virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) override = 0;
 
+        // XAccessibleContext2 - default implementation
+        virtual OUString SAL_CALL getAccessibleId(  ) override;
+
         // XAccessibleContext - default implementations
         /** default implementation for retrieving the index of this object within the parent
             <p>This basic implementation here returns the index <code>i</code> of the child for which
diff --git a/include/toolkit/awt/vclxaccessiblecomponent.hxx b/include/toolkit/awt/vclxaccessiblecomponent.hxx
index 8779f0e14237..377dcbc57ce1 100644
--- a/include/toolkit/awt/vclxaccessiblecomponent.hxx
+++ b/include/toolkit/awt/vclxaccessiblecomponent.hxx
@@ -99,6 +99,7 @@ public:
     sal_Int16 SAL_CALL getAccessibleRole(  ) override;
     OUString SAL_CALL getAccessibleDescription(  ) override;
     OUString SAL_CALL getAccessibleName(  ) override;
+    OUString SAL_CALL getAccessibleId(  ) override;
     css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) override;
     css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) override;
     css::lang::Locale SAL_CALL getLocale(  ) override;
@@ -138,6 +139,7 @@ private:
     sal_Int16 getAccessibleRole() => VCL Window::GetAccessibleRole()
     OUString getAccessibleDescription() => VCL Window::GetAccessibleDescription
     OUString getAccessibleName() => VCL Window::GetAccessibleText() => Most windows return Window::GetText()
+    OUString getAccessibleId() => VCL Window::get_id()
     Reference< XAccessibleRelationSet > getAccessibleRelationSet()
     Reference< XAccessibleStateSet > getAccessibleStateSet() => override FillAccessibleStateSet( ... )
 
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index a1ffab05d2e8..4c79c9d04328 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -1634,6 +1634,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/accessibility,\
 	XAccessibleAction \
 	XAccessibleComponent \
 	XAccessibleContext \
+	XAccessibleContext2 \
 	XAccessibleEditableText \
 	XAccessibleEventBroadcaster \
 	XAccessibleEventListener \
diff --git a/offapi/com/sun/star/accessibility/XAccessibleContext2.idl b/offapi/com/sun/star/accessibility/XAccessibleContext2.idl
new file mode 100644
index 000000000000..e9d4feae1021
--- /dev/null
+++ b/offapi/com/sun/star/accessibility/XAccessibleContext2.idl
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef __com_sun_star_accessibility_XAccessibleContext2_idl__
+#define __com_sun_star_accessibility_XAccessibleContext2_idl__
+
+module com { module sun { module star { module accessibility {
+
+/** Implement this interface for exposing more aspects of a class's
+    content.
+
+    <p>This is an extension of XAccessibleContext to add getAccessibleId().</p>
+
+    @since LibreOffice 6.3
+*/
+interface XAccessibleContext2 : ::com::sun::star::accessibility::XAccessibleContext
+{
+    /** Return the object's identifier.
+
+        <p>This is not meant to be presented to the user, but to be an ID
+        which is stable over application development. Typically, this is
+        the gtkbuilder ID. Such an ID can then be used to identify a given
+        well-known accessible object independently from the current locale,
+        user-visible labelling, or dialog structure. This can then be used for
+        tailored screen reading (e.g. automatically announcing the content of a
+        well-known object), or for automatic regression testing (to check the
+        behavior of well-known objects). Uniqueness within the window is thus
+        desirable when returning a non-empty string.</p>
+
+        @return
+            The returned string is the object's identifier.
+    */
+    string  getAccessibleId ();
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx
index 8bd78e5d9c1b..f9b55d278655 100644
--- a/toolkit/source/awt/vclxaccessiblecomponent.cxx
+++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx
@@ -620,6 +620,19 @@ OUString VCLXAccessibleComponent::getAccessibleName(  )
     return aName;
 }
 
+OUString VCLXAccessibleComponent::getAccessibleId(  )
+{
+    OExternalLockGuard aGuard( this );
+
+    OUString aId;
+    if ( GetWindow() )
+    {
+        const OUString &aWindowId = GetWindow()->get_id();
+        aId = aWindowId;
+    }
+    return aId;
+}
+
 uno::Reference< accessibility::XAccessibleRelationSet > VCLXAccessibleComponent::getAccessibleRelationSet(  )
 {
     OExternalLockGuard aGuard( this );
diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx
index a6382c8b2ef6..63b4cfa04430 100644
--- a/vcl/unx/gtk/a11y/atkwrapper.cxx
+++ b/vcl/unx/gtk/a11y/atkwrapper.cxx
@@ -31,6 +31,7 @@
 #include <com/sun/star/accessibility/XAccessibleValue.hpp>
 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext2.hpp>
 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
 #include <com/sun/star/accessibility/XAccessibleMultiLineText.hpp>
@@ -880,6 +881,17 @@ atk_object_wrapper_new( const css::uno::Reference< css::accessibility::XAccessib
                 OSL_ASSERT( false );
         }
 
+#if ATK_CHECK_VERSION(2,33,1)
+        {
+            css::uno::Reference<css::accessibility::XAccessibleContext2> xContext2(xContext, css::uno::UNO_QUERY);
+            if( xContext2.is() )
+            {
+                OString aId = OUStringToOString( xContext2->getAccessibleId(), RTL_TEXTENCODING_UTF8);
+                atk_object_set_accessible_id(atk_obj, aId.getStr());
+            }
+        }
+#endif
+
         return ATK_OBJECT( pWrap );
     }
     catch (const uno::Exception &)


More information about the Libreoffice-commits mailing list