tdf#104833 a11y: Use VCLXAccessibleEdit for VCLXMultiLineEdit

Instead of the generic `VCLXAccessibleComponent`,
use `VCLXAccessibleEdit` as a11y class for
`VCLXMultiLineEdit` (the component interface
class for MultiLineEdit) as well, not just for `VCLXEdit`.

With the preparatory changes from

    Change-Id I8218db61feb07605f6ea5309f26eebd38312458a
    tdf#104833 a11y: Don't use VCLXEdit in VCLXAccessibleEdit

in place, it behaves as expected when interacting
with the multi line edit from the sample dialog in
attachment 189287 in tdf#104833 using Accerciser and
the qt6 or gtk3 VCL plugin (and the text can also be
edited when removing the readonly flag from the control)
or the update dialog (which uses UNO controls,
`UnoControlEditModel` for the panes that were not
announced, s. extensions/source/update/check/updatehdl.cxx ).

In particular, the a11y text interface is supported by
the multi line edit on the a11y layer, which makes
Orca with the gtk3 VCL plugin announce the text content
when the control gets focused.

NVDA on Windows still announces "Checking..." instead
of using the actual text that would be retrievable via
the IAccessibleText interface now. This is probably
because "Checking..." is the (outdated) accessible name,
as can be seen by interacting with the object in NVDA's
Python console:

    >>> focus.name
    'Checking...'
    >>> txt = focus.IAccessibleTextObject
    >>> txt.text(0, txt.nCharacters)
    'LibreOfficeDev 24.2 is up to date.'

For both, gtk3 and qt6, the a11y object does have the
new text as a11y name as well, as can be verified in
Accerciser:

    In [10]: acc.name
    Out[10]: 'LibreOfficeDev 24.2 is up to date.'
    In [11]: txt = acc.queryText()
    In [12]: txt.getTextAtOffset(0,3)
    Out[12]: ('LibreOfficeDev 24.2 is up to date.', 0, 34)

Change-Id: Id80e191cdd5342b3215fdb9d2ad3847470366337
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156402
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2023-09-01 10:59:31 +02:00
parent 847df831b1
commit a766f7555c
5 changed files with 26 additions and 0 deletions

View file

@ -102,6 +102,8 @@ public:
createAccessibleContext( VCLXScrollBar* _pXWindow ) override; createAccessibleContext( VCLXScrollBar* _pXWindow ) override;
virtual css::uno::Reference< css::accessibility::XAccessibleContext > virtual css::uno::Reference< css::accessibility::XAccessibleContext >
createAccessibleContext( VCLXEdit* _pXWindow ) override; createAccessibleContext( VCLXEdit* _pXWindow ) override;
virtual css::uno::Reference< css::accessibility::XAccessibleContext >
createAccessibleContext( VCLXMultiLineEdit* _pXWindow ) override;
virtual css::uno::Reference< css::accessibility::XAccessibleContext > virtual css::uno::Reference< css::accessibility::XAccessibleContext >
createAccessibleContext( VCLXComboBox* _pXWindow ) override; createAccessibleContext( VCLXComboBox* _pXWindow ) override;
virtual css::uno::Reference< css::accessibility::XAccessibleContext > virtual css::uno::Reference< css::accessibility::XAccessibleContext >
@ -280,6 +282,11 @@ Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLX
return new VCLXAccessibleEdit( _pXWindow ); return new VCLXAccessibleEdit( _pXWindow );
} }
Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXMultiLineEdit* _pXWindow )
{
return new VCLXAccessibleEdit( _pXWindow );
}
Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXComboBox* _pXWindow ) Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXComboBox* _pXWindow )
{ {
bool bIsDropDownBox = false; bool bIsDropDownBox = false;

View file

@ -461,6 +461,9 @@ public:
static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds );
virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); }
protected:
virtual css::uno::Reference<css::accessibility::XAccessibleContext> CreateAccessibleContext() override;
}; };
// class VCLXSpinField // class VCLXSpinField

View file

@ -37,6 +37,7 @@ class VCLXFixedText;
class VCLXScrollBar; class VCLXScrollBar;
class VCLXEdit; class VCLXEdit;
class VCLXComboBox; class VCLXComboBox;
class VCLXMultiLineEdit;
class VCLXToolBox; class VCLXToolBox;
class VCLXHeaderBar; class VCLXHeaderBar;
class VCLXWindow; class VCLXWindow;
@ -102,6 +103,11 @@ namespace toolkit
virtual css::uno::Reference< css::accessibility::XAccessibleContext > virtual css::uno::Reference< css::accessibility::XAccessibleContext >
createAccessibleContext( VCLXEdit* _pXWindow ) = 0; createAccessibleContext( VCLXEdit* _pXWindow ) = 0;
/** creates an accessible context for a multiline edit window
*/
virtual css::uno::Reference< css::accessibility::XAccessibleContext >
createAccessibleContext( VCLXMultiLineEdit* _pXWindow ) = 0;
/** creates an accessible context for a combo box window /** creates an accessible context for a combo box window
*/ */
virtual css::uno::Reference< css::accessibility::XAccessibleContext > virtual css::uno::Reference< css::accessibility::XAccessibleContext >

View file

@ -7869,4 +7869,9 @@ void VCLXMultiLineEdit::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
VCLXWindow::ImplGetPropertyIds( rIds, true ); VCLXWindow::ImplGetPropertyIds( rIds, true );
} }
css::uno::Reference<css::accessibility::XAccessibleContext> VCLXMultiLineEdit::CreateAccessibleContext()
{
return getAccessibleFactory().createAccessibleContext(this);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -107,6 +107,11 @@ namespace toolkit
{ {
return nullptr; return nullptr;
} }
css::uno::Reference< css::accessibility::XAccessibleContext >
createAccessibleContext( VCLXMultiLineEdit* /*_pXWindow*/ ) override
{
return nullptr;
}
css::uno::Reference< css::accessibility::XAccessibleContext > css::uno::Reference< css::accessibility::XAccessibleContext >
createAccessibleContext( VCLXComboBox* /*_pXWindow*/ ) override createAccessibleContext( VCLXComboBox* /*_pXWindow*/ ) override
{ {