diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2021-07-28 09:39:07 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2021-07-28 15:44:58 +0200 |
commit | 349a8801b9ee98f4f9ee1d35f7d28e17baedf7cc (patch) | |
tree | 2bd6dd20f7618a812f550867515f4bfa9a2cc553 /toolkit | |
parent | 9ceb47ce712157019ca06ee11c66515ea7cc16ec (diff) |
a11y: Expose FormattedField as spinbox
This adds a new accessibility class 'SVTXAccessibleNumericField'
that implements 'XAccessibleValue' and reports having an a11y
role of 'AccessibleRole::SPIN_BOX'. An object of that class
is returned by 'SVTXNumericField::CreateAccessibleContext'.
Create an 'SVTXNumericField' XWindow peer for windows
of type 'WindowType::FORMATTEDFIELD'
(instead of a 'VCLXNumericField' one), so the
newly introduced accessibility class gets used for
'FormattedField'.
This way, FormattedFields are now exposed to a11y tools
as spinboxes.
Previously, since no specific accessibility class
had been implemented for VCLXNumericField (then used as
XWindow peer class for FormattedField), the
one for VCLXEdit, i.e. VCLXAccessibleEdit, was used.
While VCLXNumericField implements XNumericField
and thus in general offers the relevant methods to implement
an accessible class that implements XAccessibleValue as well,
it uses the Formatter from the VCLXFormattedSpinField base class
to get/set values. However, that doesn't work for the FormattedField
case, since FormattedField has its own formatter of a different
type and the 'mpFormatter' member in the VCLXFormattedSpinField
base class is a nullptr, resulting in the corresponding
getter methods always returning 0 and the setters doing nothing.
With this commit in place, Accerciser now reports role
"spin box" instead of just "text" for FormattedFields
and displays the current value as well as allows to change
it via the "Value" interface when using the qt5/kf5 VCL plugin.
Note: For non-integer values, Accerciser doesn't show the actual
decimal value, but an integer, e.g. when the value for "Height"
spinbox in Writer's "Page Style" -> "Page" dialog (section "Paper
format") is set to "29.70cm", Accerciser shows "30" instead of
"29.70", despite 'Qt5AccessibleWidget::currentValue' returning
the exact value. This is because Accerciser appears to rely
on the value for the minimum increment being reported (as a
corresponding decimal value) by a call
to 'atspi_value_get_minimum_increment', s.[1].
However, there is currently no corresponding method in the
'XAccesibleValue' interface for that at-spi method which
'Qt5AccessibleWidget::currentValue' could call to retrieve
the value.
The NVDA screen reader on Windows now also says e.g.
"Width: (Type = 344) spin button editable Alt+W selected 8.50″"
instead of "Width: (Type = 344) edit Alt+W selected 8.50″".
[1] https://developer.gnome.org/libatspi/stable/libatspi-atspi-value.html#atspi-value-get-minimum-increment
Change-Id: I8af326c2d24c1801147a56ea2e2a886ab42ac634
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119590
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/awt/vclxwindows.cxx | 7 | ||||
-rw-r--r-- | toolkit/source/helper/accessibilityclient.cxx | 5 | ||||
-rw-r--r-- | toolkit/source/helper/unowrapper.cxx | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index caf63ba3b5d0..02bd6b8799e8 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -7665,6 +7665,13 @@ css::uno::Sequence< css::uno::Type > SVTXNumericField::getTypes() return aTypeList.getTypes(); } + +css::uno::Reference<accessibility::XAccessibleContext> SVTXNumericField::CreateAccessibleContext() +{ + return getAccessibleFactory().createAccessibleContext(this); +} + + void SVTXNumericField::setValue( double Value ) { SolarMutexGuard aGuard; diff --git a/toolkit/source/helper/accessibilityclient.cxx b/toolkit/source/helper/accessibilityclient.cxx index 9d795ac620e4..7136dc5a3a8d 100644 --- a/toolkit/source/helper/accessibilityclient.cxx +++ b/toolkit/source/helper/accessibilityclient.cxx @@ -120,6 +120,11 @@ namespace toolkit return nullptr; } css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( SVTXNumericField* /*_pXWindow*/ ) override + { + return nullptr; + } + css::uno::Reference< css::accessibility::XAccessibleContext > createAccessibleContext( VCLXWindow* /*_pXWindow*/ ) override { return nullptr; diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx index aa32d1b86aa6..4f3f3b22b604 100644 --- a/toolkit/source/helper/unowrapper.cxx +++ b/toolkit/source/helper/unowrapper.cxx @@ -55,8 +55,8 @@ static rtl::Reference<VCLXWindow> CreateXWindow( vcl::Window const * pWindow ) // corresponding accessibility API. case WindowType::METRICBOX: case WindowType::COMBOBOX: return new VCLXComboBox; + case WindowType::FORMATTEDFIELD: return new SVTXNumericField; case WindowType::SPINFIELD: - case WindowType::FORMATTEDFIELD: case WindowType::CURRENCYFIELD: return new VCLXNumericField; case WindowType::DATEFIELD: return new VCLXDateField; case WindowType::MULTILINEEDIT: |