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

Michael Weghorn (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 22 16:51:10 UTC 2021


 vcl/qt5/Qt5AccessibleWidget.cxx |   29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

New commits:
commit 0f15f1ec7c7b9ed7abf4a40b9b9c2f3876ce3e5f
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Thu Jul 22 11:26:41 2021 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Thu Jul 22 18:50:28 2021 +0200

    qt5 a11y: Always query the XAccessibleContext for a11y interfaces
    
    The accessibility interfaces are implemented by the object
    implementing 'XAccessibilityContext' which is often the same
    as the 'XAccessible' (in which case the corresponding
    'XAccessible::getAccessibleContext()' call just returns a
    reference to self), but it doesn't have to be that way.
    
    From offapi/com/sun/star/modules.idl:
    
    >     /** UNO Accessibility API
    >
    >         <p>This modules contains the basic interfaces of the UAA (UNO
    >         Accessibility API).  Services that describe how these interfaces are
    >         implemented can be found in other modules.  The services in this module
    >         describe only what every accessible object has to support.</p>
    >
    >         <p>Making a class accessible starts by supporting the
    >         ::com::sun::star::accessibility::XAccessible interface.
    >         This interface's only method returns the actual accessibility object, an
    >         instance of ::com::sun::star::accessibility::XAccessibleContext.
    >         These two interfaces may be implemented by the same class in which case
    >         a call to ::com::sun::star::accessibility::XAccessible getAccessible()
    >         returns the same object that is
    >         called.  Alternatively the implementation of the
    >         ::com::sun::star::accessibility::XAccessibleContext
    >         interface can be done by another class.  This makes it possible to put
    >         all accessibility implementations into their own library which has only
    >         to be loaded when necessary.</p>
    >
    >         <p>Note that all other interfaces have to be implemented by the same
    >         class that implements the
    >         ::com::sun::star::accessibility::XAccessibleContext
    >         interface.  Note also that there is no way back from an accessibility
    >         object to the object from which it has been obtained by means of the
    >         UAA.  If you need such a back-link you have to provide one on your
    >         own.</p>
    >     */
    >     module accessibility {};
    
    This e.g. makes Accerciser show the correct values of the "URL" and
    "Text" controls in Writer's "Insert" -> "Hyperlink" dialog.
    
    Change-Id: I909b1fdf5e1e7ca50db5d5191ae69cb558a49dc8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119364
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index c68368085332..c7008f36d26a 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -556,8 +556,7 @@ QAccessible::Role Qt5AccessibleWidget::role() const
         }
     }
 
-    SAL_WARN("vcl.qt5",
-             "Unmapped role: " << m_xAccessible->getAccessibleContext()->getAccessibleRole());
+    SAL_WARN("vcl.qt5", "Unmapped role: " << getAccessibleContextImpl()->getAccessibleRole());
     return QAccessible::NoRole;
 }
 
@@ -776,7 +775,7 @@ QAccessibleInterface* Qt5AccessibleWidget::customFactory(const QString& classnam
 QStringList Qt5AccessibleWidget::actionNames() const
 {
     QStringList actionNames;
-    Reference<XAccessibleAction> xAccessibleAction(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleAction> xAccessibleAction(getAccessibleContextImpl(), UNO_QUERY);
     if (!xAccessibleAction.is())
         return actionNames;
 
@@ -791,7 +790,7 @@ QStringList Qt5AccessibleWidget::actionNames() const
 
 void Qt5AccessibleWidget::doAction(const QString& actionName)
 {
-    Reference<XAccessibleAction> xAccessibleAction(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleAction> xAccessibleAction(getAccessibleContextImpl(), UNO_QUERY);
     if (!xAccessibleAction.is())
         return;
 
@@ -804,7 +803,7 @@ void Qt5AccessibleWidget::doAction(const QString& actionName)
 QStringList Qt5AccessibleWidget::keyBindingsForAction(const QString& actionName) const
 {
     QStringList keyBindings;
-    Reference<XAccessibleAction> xAccessibleAction(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleAction> xAccessibleAction(getAccessibleContextImpl(), UNO_QUERY);
     if (!xAccessibleAction.is())
         return keyBindings;
 
@@ -871,7 +870,7 @@ QString Qt5AccessibleWidget::attributes(int offset, int* startOffset, int* endOf
     *startOffset = -1;
     *endOffset = -1;
 
-    Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleText> xText(getAccessibleContextImpl(), UNO_QUERY);
     if (!xText.is())
         return QString();
 
@@ -920,7 +919,7 @@ QString Qt5AccessibleWidget::attributes(int offset, int* startOffset, int* endOf
 
 int Qt5AccessibleWidget::characterCount() const
 {
-    Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleText> xText(getAccessibleContextImpl(), UNO_QUERY);
     if (xText.is())
         return xText->getCharacterCount();
     return 0;
@@ -933,7 +932,7 @@ QRect Qt5AccessibleWidget::characterRect(int /* offset */) const
 
 int Qt5AccessibleWidget::cursorPosition() const
 {
-    Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleText> xText(getAccessibleContextImpl(), UNO_QUERY);
     if (xText.is())
         return xText->getCaretPosition();
     return 0;
@@ -950,7 +949,7 @@ void Qt5AccessibleWidget::removeSelection(int /* selectionIndex */)
 }
 void Qt5AccessibleWidget::scrollToSubstring(int startIndex, int endIndex)
 {
-    Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleText> xText(getAccessibleContextImpl(), UNO_QUERY);
     if (xText.is())
         xText->scrollSubstringTo(startIndex, endIndex, AccessibleScrollType_SCROLL_ANYWHERE);
 }
@@ -962,7 +961,7 @@ void Qt5AccessibleWidget::selection(int selectionIndex, int* startOffset, int* e
 
     Reference<XAccessibleText> xText;
     if (selectionIndex == 0)
-        xText = Reference<XAccessibleText>(m_xAccessible, UNO_QUERY);
+        xText = Reference<XAccessibleText>(getAccessibleContextImpl(), UNO_QUERY);
 
     if (startOffset)
         *startOffset = xText.is() ? xText->getSelectionStart() : 0;
@@ -972,26 +971,26 @@ void Qt5AccessibleWidget::selection(int selectionIndex, int* startOffset, int* e
 
 int Qt5AccessibleWidget::selectionCount() const
 {
-    Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleText> xText(getAccessibleContextImpl(), UNO_QUERY);
     if (xText.is() && !xText->getSelectedText().isEmpty())
         return 1; // Only 1 selection supported atm
     return 0;
 }
 void Qt5AccessibleWidget::setCursorPosition(int position)
 {
-    Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleText> xText(getAccessibleContextImpl(), UNO_QUERY);
     if (xText.is())
         xText->setCaretPosition(position);
 }
 void Qt5AccessibleWidget::setSelection(int /* selectionIndex */, int startOffset, int endOffset)
 {
-    Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleText> xText(getAccessibleContextImpl(), UNO_QUERY);
     if (xText.is())
         xText->setSelection(startOffset, endOffset);
 }
 QString Qt5AccessibleWidget::text(int startOffset, int endOffset) const
 {
-    Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleText> xText(getAccessibleContextImpl(), UNO_QUERY);
     if (xText.is())
         return toQString(xText->getTextRange(startOffset, endOffset));
     return QString();
@@ -1018,7 +1017,7 @@ QString Qt5AccessibleWidget::textAtOffset(int offset, QAccessible::TextBoundaryT
         return text(0, nCharCount);
     }
 
-    Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY);
+    Reference<XAccessibleText> xText(getAccessibleContextImpl(), UNO_QUERY);
     if (!xText.is())
         return QString();
 


More information about the Libreoffice-commits mailing list