diff options
author | Jim Raykowski <raykowj@gmail.com> | 2022-09-08 19:27:31 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2022-09-26 05:55:25 +0200 |
commit | 947fe0d89dee75ee43515ef7dfb43837d65a45bc (patch) | |
tree | 3fc8c819233f9c22abf7c8c896a6e08aa4fd90c0 | |
parent | a6abe4a33568d87904fd49c734af4726878af421 (diff) |
tdf#119788 tdf#117173 add accessibility NOTIFICATION role
and use it to make screen readers announce notifications from the
'Find and Replace' dialog
Change-Id: Ifcf9304883e2e824ea1b7998d7767e474b87c8b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139709
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r-- | offapi/com/sun/star/accessibility/AccessibleRole.idl | 7 | ||||
-rw-r--r-- | svx/source/dialog/srchdlg.cxx | 14 | ||||
-rw-r--r-- | svx/uiconfig/ui/findreplacedialog.ui | 3 | ||||
-rw-r--r-- | vcl/osx/a11yrolehelper.mm | 2 | ||||
-rw-r--r-- | vcl/qt5/QtAccessibleWidget.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/gtk3/a11y/atkwrapper.cxx | 2 | ||||
-rw-r--r-- | winaccessibility/source/service/AccComponentEventListener.cxx | 1 | ||||
-rw-r--r-- | winaccessibility/source/service/AccObject.cxx | 6 | ||||
-rw-r--r-- | winaccessibility/source/service/AccObjectWinManager.cxx | 1 |
10 files changed, 35 insertions, 9 deletions
diff --git a/offapi/com/sun/star/accessibility/AccessibleRole.idl b/offapi/com/sun/star/accessibility/AccessibleRole.idl index 6c7e9fbcf790..c8e8ccc03ec2 100644 --- a/offapi/com/sun/star/accessibility/AccessibleRole.idl +++ b/offapi/com/sun/star/accessibility/AccessibleRole.idl @@ -737,6 +737,13 @@ constants AccessibleRole */ const short STATIC = 86; + /** Notification text role. + + <p>An object that presents information to the user when the SHOWING state change event is + fired for the object.</p> + */ + const short NOTIFICATION = 87; + }; }; }; }; }; diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 4f2378881867..69483c124770 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -332,7 +332,6 @@ SvxSearchDialog::SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWi m_xSearchTmplLB->make_sorted(); m_xSearchAttrText->hide(); - m_xSearchLabel->show(); m_xReplaceTmplLB->make_sorted(); m_xReplaceAttrText->hide(); @@ -574,6 +573,13 @@ void SvxSearchDialog::SetSaveToModule(bool b) void SvxSearchDialog::SetSearchLabel(const OUString& rStr) { m_xSearchLabel->set_label(rStr); + if (!rStr.isEmpty()) + { + // hide/show to fire SHOWING state change event so search label text + // is announced by screen reader + m_xSearchLabel->hide(); + m_xSearchLabel->show(); + } if (rStr == SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND)) m_xSearchLB->set_entry_message_type(weld::EntryMessageType::Error); @@ -1360,9 +1366,6 @@ IMPL_LINK(SvxSearchDialog, CommandHdl_Impl, weld::Button&, rBtn, void) nModifyFlag = ModifyFlags::NONE; const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr }; rBindings.ExecuteSynchron( FID_SEARCH_NOW, ppArgs ); - - // grabbing focus to the search combo box makes the search label read by the screen reader - m_xSearchLB->grab_focus(); } else if ( &rBtn == m_xCloseBtn.get() ) { @@ -2208,7 +2211,8 @@ void SvxSearchDialog::SetModifyFlag_Impl( const weld::Widget* pCtrl ) { nModifyFlag |= ModifyFlags::Search; m_xSearchLB->set_entry_message_type(weld::EntryMessageType::Normal); - SvxSearchDialogWrapper::SetSearchLabel(""); + if (!SvxSearchDialogWrapper::GetSearchLabel().isEmpty()) + SvxSearchDialogWrapper::SetSearchLabel(""); } else if ( m_xReplaceLB.get() == pCtrl ) nModifyFlag |= ModifyFlags::Replace; diff --git a/svx/uiconfig/ui/findreplacedialog.ui b/svx/uiconfig/ui/findreplacedialog.ui index 4c1e9d2bc45f..a8401616d339 100644 --- a/svx/uiconfig/ui/findreplacedialog.ui +++ b/svx/uiconfig/ui/findreplacedialog.ui @@ -173,6 +173,7 @@ </child> <child> <object class="GtkLabel" id="searchlabel"> + <property name="visible">True</property> <property name="can-focus">False</property> <property name="no-show-all">True</property> <property name="hexpand">True</property> @@ -181,7 +182,7 @@ <property name="xalign">0</property> <child internal-child="accessible"> <object class="AtkObject" id="searchlabel-atkobject"> - <property name="AtkObject::accessible-role" translatable="no">static</property> + <property name="AtkObject::accessible-role" translatable="no">notification</property> </object> </child> </object> diff --git a/vcl/osx/a11yrolehelper.mm b/vcl/osx/a11yrolehelper.mm index 0ea7075277eb..5cb75c94a86f 100644 --- a/vcl/osx/a11yrolehelper.mm +++ b/vcl/osx/a11yrolehelper.mm @@ -126,6 +126,7 @@ using namespace ::com::sun::star::uno; MAP( AccessibleRole::DOCUMENT_SPREADSHEET, NSAccessibilityGroupRole ); MAP( AccessibleRole::DOCUMENT_TEXT, NSAccessibilityGroupRole ); MAP( AccessibleRole::STATIC, NSAccessibilityStaticTextRole ); + MAP( AccessibleRole::NOTIFICATION, NSAccessibilityStaticTextRole ); #undef MAP default: @@ -260,6 +261,7 @@ using namespace ::com::sun::star::uno; MAP( AccessibleRole::DOCUMENT_TEXT, @"" ); MAP( AccessibleRole::STATIC, @"" ); + MAP( AccessibleRole::NOTIFICATION, @"" ); #undef MAP default: diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index c097d8efd6ac..e2807dd6fecf 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -463,6 +463,12 @@ QAccessible::Role QtAccessibleWidget::role() const return QAccessible::MenuBar; case AccessibleRole::MENU_ITEM: return QAccessible::MenuItem; + case AccessibleRole::NOTIFICATION: +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 5) + return QAccessible::Notification; +#else + return QAccessible::StaticText; +#endif case AccessibleRole::OPTION_PANE: return QAccessible::Pane; case AccessibleRole::PAGE_TAB: diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 441680aec077..c71b19304813 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -2407,7 +2407,7 @@ namespace BuilderUtils { "list box", AccessibleRole::UNKNOWN }, { "grouping", AccessibleRole::GROUP_BOX }, { "image map", AccessibleRole::IMAGE_MAP }, - { "notification", AccessibleRole::UNKNOWN }, + { "notification", AccessibleRole::NOTIFICATION }, { "info bar", AccessibleRole::UNKNOWN }, { "level bar", AccessibleRole::UNKNOWN }, { "title bar", AccessibleRole::UNKNOWN }, diff --git a/vcl/unx/gtk3/a11y/atkwrapper.cxx b/vcl/unx/gtk3/a11y/atkwrapper.cxx index 8159bb119e5f..9f0c6e4bbdc0 100644 --- a/vcl/unx/gtk3/a11y/atkwrapper.cxx +++ b/vcl/unx/gtk3/a11y/atkwrapper.cxx @@ -343,6 +343,8 @@ static AtkRole mapToAtkRole( sal_Int16 nRole ) return ATK_ROLE_DOCUMENT_TEXT; case accessibility::AccessibleRole::STATIC: return ATK_ROLE_STATIC; + case accessibility::AccessibleRole::NOTIFICATION: + return ATK_ROLE_NOTIFICATION; default: SAL_WARN("vcl.gtk", "Unmapped accessible role: " << nRole); return ATK_ROLE_UNKNOWN; diff --git a/winaccessibility/source/service/AccComponentEventListener.cxx b/winaccessibility/source/service/AccComponentEventListener.cxx index 83c29aad3d9e..ca0dec0fa311 100644 --- a/winaccessibility/source/service/AccComponentEventListener.cxx +++ b/winaccessibility/source/service/AccComponentEventListener.cxx @@ -177,6 +177,7 @@ void AccComponentEventListener::SetComponentState(sal_Int64 state, bool enable) // 8. label should have no FOCUSABLE state, Firefox has READONLY state, we can also have. if ( GetRole() != AccessibleRole::LABEL && GetRole() != AccessibleRole::STATIC + && GetRole() != AccessibleRole::NOTIFICATION && GetRole() != AccessibleRole::SCROLL_BAR) { pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::FOCUSABLE); diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx index 1f7dc5df224d..d1e805ce2428 100644 --- a/winaccessibility/source/service/AccObject.cxx +++ b/winaccessibility/source/service/AccObject.cxx @@ -145,7 +145,8 @@ const short ROLE_TABLE[][2] = {DOCUMENT_PRESENTATION, ROLE_SYSTEM_DOCUMENT }, {DOCUMENT_SPREADSHEET, ROLE_SYSTEM_DOCUMENT }, {DOCUMENT_TEXT, ROLE_SYSTEM_DOCUMENT }, - {STATIC, ROLE_SYSTEM_STATICTEXT } + {STATIC, ROLE_SYSTEM_STATICTEXT }, + {NOTIFICATION, ROLE_SYSTEM_ALERT} }; @@ -821,6 +822,7 @@ void AccObject::UpdateState() { case LABEL: case STATIC: + case NOTIFICATION: m_pIMAcc->IncreaseState( STATE_SYSTEM_READONLY ); break; case TEXT: @@ -859,7 +861,7 @@ void AccObject::UpdateState() if(!(Role == FILLER || Role == END_NOTE || Role == FOOTER || Role == FOOTNOTE || Role == GROUP_BOX || Role == RULER || Role == HEADER || Role == ICON || Role == INTERNAL_FRAME || Role == LABEL || Role == LAYERED_PANE || Role == SCROLL_BAR || Role == SCROLL_PANE || Role == SPLIT_PANE || Role == STATIC || Role == STATUS_BAR - || Role == TOOL_TIP)) + || Role == TOOL_TIP || Role == NOTIFICATION)) { if( SEPARATOR == Role ) { diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx index 4967ecb4ee4e..44dbcb98ac3a 100644 --- a/winaccessibility/source/service/AccObjectWinManager.cxx +++ b/winaccessibility/source/service/AccObjectWinManager.cxx @@ -732,6 +732,7 @@ AccObjectWinManager::CreateAccEventListener(XAccessible* pXAcc) case AccessibleRole::ICON: case AccessibleRole::LABEL: case AccessibleRole::STATIC: + case AccessibleRole::NOTIFICATION: case AccessibleRole::MENU_ITEM: case AccessibleRole::CHECK_MENU_ITEM: case AccessibleRole::RADIO_MENU_ITEM: |