diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-10-29 16:43:30 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-10-30 13:10:54 +0100 |
commit | 4d33df9087bad92bca7ad570779445befc633f17 (patch) | |
tree | f0618d5d741b4da6f24a4d38e22225de43d061ee /vcl | |
parent | a15c38aa4e4ec66c5d74c026c7583188bff98ca9 (diff) |
qt5 a11y: Implement most of QAccessibleTextInterface
Change-Id: I184bad8a6915048d425f8baa56d2e5675d4b97d1
Reviewed-on: https://gerrit.libreoffice.org/62512
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/Library_vclplug_qt5.mk | 1 | ||||
-rw-r--r-- | vcl/inc/qt5/Qt5AccessibleText.hxx | 62 | ||||
-rw-r--r-- | vcl/inc/qt5/Qt5AccessibleWidget.hxx | 24 | ||||
-rw-r--r-- | vcl/qt5/Qt5AccessibleText.cxx | 104 | ||||
-rw-r--r-- | vcl/qt5/Qt5AccessibleWidget.cxx | 114 |
5 files changed, 130 insertions, 175 deletions
diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk index c835b748696b..ba7e41cefa3b 100644 --- a/vcl/Library_vclplug_qt5.mk +++ b/vcl/Library_vclplug_qt5.mk @@ -81,7 +81,6 @@ endif $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\ vcl/qt5/Qt5AccessibleEventListener \ - vcl/qt5/Qt5AccessibleText \ vcl/qt5/Qt5AccessibleValue \ vcl/qt5/Qt5AccessibleWidget \ vcl/qt5/Qt5Bitmap \ diff --git a/vcl/inc/qt5/Qt5AccessibleText.hxx b/vcl/inc/qt5/Qt5AccessibleText.hxx deleted file mode 100644 index 2f9e50381009..000000000000 --- a/vcl/inc/qt5/Qt5AccessibleText.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- 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/. - */ - -#pragma once - -#include <vclpluginapi.h> - -#include "Qt5AccessibleWidget.hxx" - -#include <QtCore/QObject> -#include <QtCore/QPair> -#include <QtCore/QString> -#include <QtCore/QStringList> -#include <QtCore/QVector> -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleActionInterface> -#include <QtGui/QAccessibleInterface> -#include <QtGui/QAccessibleValueInterface> -#include <QtGui/QColor> -#include <QtGui/QWindow> - -#include <com/sun/star/accessibility/XAccessible.hpp> - -class Qt5Frame; -class Qt5Widget; - -class VCLPLUG_QT5_PUBLIC Qt5AccessibleText : public QAccessibleTextInterface -{ -public: - Qt5AccessibleText(const css::uno::Reference<css::accessibility::XAccessible> xAccessible); - - void addSelection(int startOffset, int endOffset) override; - QString attributes(int offset, int* startOffset, int* endOffset) const override; - int characterCount() const override; - QRect characterRect(int offset) const override; - int cursorPosition() const override; - int offsetAtPoint(const QPoint& point) const override; - void removeSelection(int selectionIndex) override; - void scrollToSubstring(int startIndex, int endIndex) override; - void selection(int selectionIndex, int* startOffset, int* endOffset) const override; - int selectionCount() const override; - void setCursorPosition(int position) override; - void setSelection(int selectionIndex, int startOffset, int endOffset) override; - QString text(int startOffset, int endOffset) const override; - QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int* startOffset, int* endOffset) const override; - QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, int* startOffset, - int* endOffset) const override; - QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int* startOffset, int* endOffset) const override; - -private: - css::uno::Reference<css::accessibility::XAccessible> m_xAccessible; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/Qt5AccessibleWidget.hxx b/vcl/inc/qt5/Qt5AccessibleWidget.hxx index 1e372479e479..338bc7b5c36a 100644 --- a/vcl/inc/qt5/Qt5AccessibleWidget.hxx +++ b/vcl/inc/qt5/Qt5AccessibleWidget.hxx @@ -31,7 +31,8 @@ class Qt5Widget; class VCLPLUG_QT5_PUBLIC Qt5AccessibleWidget : public QObject, public QAccessibleInterface, - public QAccessibleActionInterface + public QAccessibleActionInterface, + public QAccessibleTextInterface { Q_OBJECT @@ -71,6 +72,27 @@ public: QAccessibleValueInterface* valueInterface(); QAccessibleTextInterface* textInterface(); + // QAccessibleTextInterface + void addSelection(int startOffset, int endOffset) override; + QString attributes(int offset, int* startOffset, int* endOffset) const override; + int characterCount() const override; + QRect characterRect(int offset) const override; + int cursorPosition() const override; + int offsetAtPoint(const QPoint& point) const override; + void removeSelection(int selectionIndex) override; + void scrollToSubstring(int startIndex, int endIndex) override; + void selection(int selectionIndex, int* startOffset, int* endOffset) const override; + int selectionCount() const override; + void setCursorPosition(int position) override; + void setSelection(int selectionIndex, int startOffset, int endOffset) override; + QString text(int startOffset, int endOffset) const override; + QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, + int* startOffset, int* endOffset) const override; + QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, int* startOffset, + int* endOffset) const override; + QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, + int* startOffset, int* endOffset) const override; + // Factory static QAccessibleInterface* customFactory(const QString& classname, QObject* object); diff --git a/vcl/qt5/Qt5AccessibleText.cxx b/vcl/qt5/Qt5AccessibleText.cxx deleted file mode 100644 index 2649096b1a2e..000000000000 --- a/vcl/qt5/Qt5AccessibleText.cxx +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- 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 . - */ - -#include <Qt5AccessibleText.hxx> - -#include <QtGui/QAccessibleInterface> - -#include <Qt5Frame.hxx> -#include <Qt5Tools.hxx> -#include <Qt5Widget.hxx> -#include <Qt5XAccessible.hxx> - -#include <com/sun/star/accessibility/AccessibleRelationType.hpp> -#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/XAccessibleRelationSet.hpp> -#include <com/sun/star/accessibility/XAccessibleStateSet.hpp> -#include <com/sun/star/accessibility/XAccessibleText.hpp> -#include <com/sun/star/accessibility/XAccessibleValue.hpp> -#include <com/sun/star/uno/Sequence.hxx> - -#include <comphelper/AccessibleImplementationHelper.hxx> -#include <sal/log.hxx> -#include <vcl/popupmenuwindow.hxx> - -using namespace css; -using namespace css::accessibility; -using namespace css::uno; - -Qt5AccessibleText::Qt5AccessibleText(const Reference<XAccessible> xAccessible) - : m_xAccessible(xAccessible) -{ -} - -void Qt5AccessibleText::addSelection(int /* startOffset */, int /* endOffset */) {} -QString Qt5AccessibleText::attributes(int /* offset */, int* /* startOffset */, - int* /* endOffset */) const -{ - return QString(); -} -int Qt5AccessibleText::characterCount() const -{ - Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY); - return xText->getCharacterCount(); -} -QRect Qt5AccessibleText::characterRect(int /* offset */) const { return QRect(); } -int Qt5AccessibleText::cursorPosition() const { return 0; } -int Qt5AccessibleText::offsetAtPoint(const QPoint& /* point */) const { return 0; } -void Qt5AccessibleText::removeSelection(int /* selectionIndex */) {} -void Qt5AccessibleText::scrollToSubstring(int /* startIndex */, int /* endIndex */) {} -void Qt5AccessibleText::selection(int /* selectionIndex */, int* /* startOffset */, - int* /* endOffset */) const -{ -} -int Qt5AccessibleText::selectionCount() const { return 0; } -void Qt5AccessibleText::setCursorPosition(int /* position */) {} -void Qt5AccessibleText::setSelection(int /* selectionIndex */, int /* startOffset */, - int /* endOffset */) -{ -} -QString Qt5AccessibleText::text(int /* startOffset */, int /* endOffset */) const -{ - return QString(); -} -QString Qt5AccessibleText::textAfterOffset(int /* offset */, - QAccessible::TextBoundaryType /* boundaryType */, - int* /* startOffset */, int* /* endOffset */) const -{ - return QString(); -} -QString Qt5AccessibleText::textAtOffset(int /* offset */, - QAccessible::TextBoundaryType /* boundaryType */, - int* /* startOffset */, int* /* endOffset */) const -{ - return QString(); -} -QString Qt5AccessibleText::textBeforeOffset(int /* offset */, - QAccessible::TextBoundaryType /* boundaryType */, - int* /* startOffset */, int* /* endOffset */) const -{ - return QString(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx index 6b6832745b07..06712281c2a0 100644 --- a/vcl/qt5/Qt5AccessibleWidget.cxx +++ b/vcl/qt5/Qt5AccessibleWidget.cxx @@ -22,13 +22,12 @@ #include <QtGui/QAccessibleInterface> +#include <Qt5AccessibleEventListener.hxx> +#include <Qt5AccessibleValue.hxx> #include <Qt5Frame.hxx> #include <Qt5Tools.hxx> #include <Qt5Widget.hxx> #include <Qt5XAccessible.hxx> -#include <Qt5AccessibleText.hxx> -#include <Qt5AccessibleValue.hxx> -#include <Qt5AccessibleEventListener.hxx> #include <com/sun/star/accessibility/AccessibleRelationType.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> @@ -36,11 +35,12 @@ #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/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/accessibility/XAccessibleEventListener.hpp> #include <com/sun/star/accessibility/XAccessibleKeyBinding.hpp> #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> #include <com/sun/star/accessibility/XAccessibleStateSet.hpp> -#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> -#include <com/sun/star/accessibility/XAccessibleEventListener.hpp> +#include <com/sun/star/accessibility/XAccessibleText.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <comphelper/AccessibleImplementationHelper.hxx> @@ -617,6 +617,8 @@ void* Qt5AccessibleWidget::interface_cast(QAccessible::InterfaceType t) { if (t == QAccessible::ActionInterface) return static_cast<QAccessibleActionInterface*>(this); + if (t == QAccessible::TextInterface) + return static_cast<QAccessibleTextInterface*>(this); return nullptr; } @@ -717,9 +719,107 @@ QAccessibleValueInterface* Qt5AccessibleWidget::valueInterface() return new Qt5AccessibleValue(m_xAccessible); } -QAccessibleTextInterface* Qt5AccessibleWidget::textInterface() +QAccessibleTextInterface* Qt5AccessibleWidget::textInterface() { return nullptr; } + +// QAccessibleTextInterface +void Qt5AccessibleWidget::addSelection(int /* startOffset */, int /* endOffset */) +{ + SAL_INFO("vcl.qt5", "Unsupported QAccessibleTextInterface::addSelection"); +} +QString Qt5AccessibleWidget::attributes(int /* offset */, int* /* startOffset */, + int* /* endOffset */) const +{ + SAL_INFO("vcl.qt5", "Unsupported QAccessibleTextInterface::attributes"); + return QString(); +} +int Qt5AccessibleWidget::characterCount() const +{ + Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY); + if (xText.is()) + return xText->getCharacterCount(); + return 0; +} +QRect Qt5AccessibleWidget::characterRect(int /* offset */) const +{ + SAL_INFO("vcl.qt5", "Unsupported QAccessibleTextInterface::characterRect"); + return QRect(); +} +int Qt5AccessibleWidget::cursorPosition() const +{ + SAL_INFO("vcl.qt5", "Unsupported QAccessibleTextInterface::cursorPosition"); + return 0; +} +int Qt5AccessibleWidget::offsetAtPoint(const QPoint& /* point */) const +{ + SAL_INFO("vcl.qt5", "Unsupported QAccessibleTextInterface::offsetAtPoint"); + return 0; +} +void Qt5AccessibleWidget::removeSelection(int /* selectionIndex */) +{ + SAL_INFO("vcl.qt5", "Unsupported QAccessibleTextInterface::removeSelection"); +} +void Qt5AccessibleWidget::scrollToSubstring(int /* startIndex */, int /* endIndex */) +{ + SAL_INFO("vcl.qt5", "Unsupported QAccessibleTextInterface::scrollToSubstring"); +} +void Qt5AccessibleWidget::selection(int /* selectionIndex */, int* startOffset, + int* endOffset) const +{ + Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY); + if (!xText.is()) + return; + + sal_Int32 nStart = xText->getSelectionStart(); + startOffset = &nStart; + sal_Int32 nEnd = xText->getSelectionEnd(); + endOffset = &nEnd; +} +int Qt5AccessibleWidget::selectionCount() const +{ + Reference<XAccessibleText> xText(m_xAccessible, 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); + if (xText.is()) + xText->setCaretPosition(position); +} +void Qt5AccessibleWidget::setSelection(int /* selectionIndex */, int startOffset, int endOffset) +{ + Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY); + if (xText.is()) + xText->setSelection(startOffset, endOffset); +} +QString Qt5AccessibleWidget::text(int startOffset, int endOffset) const +{ + Reference<XAccessibleText> xText(m_xAccessible, UNO_QUERY); + if (xText.is()) + return toQString(xText->getTextRange(startOffset, endOffset)); + return QString(); +} +QString Qt5AccessibleWidget::textAfterOffset(int /* offset */, + QAccessible::TextBoundaryType /* boundaryType */, + int* /* startOffset */, int* /* endOffset */) const +{ + SAL_INFO("vcl.qt5", "Unsupported QAccessibleTextInterface::textAfterOffset"); + return QString(); +} +QString Qt5AccessibleWidget::textAtOffset(int /* offset */, + QAccessible::TextBoundaryType /* boundaryType */, + int* /* startOffset */, int* /* endOffset */) const +{ + SAL_INFO("vcl.qt5", "Unsupported QAccessibleTextInterface::textAtOffset"); + return QString(); +} +QString Qt5AccessibleWidget::textBeforeOffset(int /* offset */, + QAccessible::TextBoundaryType /* boundaryType */, + int* /* startOffset */, int* /* endOffset */) const { - return new Qt5AccessibleText(m_xAccessible); + SAL_INFO("vcl.qt5", "Unsupported QAccessibleTextInterface::textBeforeOffset"); + return QString(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |