offapi/com/sun/star/accessibility/AccessibleRole.idl | 8 +++++ offapi/com/sun/star/text/AccessibleParagraphView.idl | 5 +-- sw/source/core/access/accmap.cxx | 12 +++++-- sw/source/core/access/accpara.cxx | 25 ++++++++++++---- sw/source/core/access/accpara.hxx | 2 + sw/source/core/access/acctextframe.cxx | 3 + test/source/a11y/AccessibilityTools.cxx | 2 + vcl/osx/a11yrolehelper.mm | 2 + vcl/qa/cppunit/a11y/atspi2/atspi2.cxx | 1 vcl/qt5/QtAccessibleWidget.cxx | 1 vcl/source/window/builder.cxx | 2 - vcl/unx/gtk3/a11y/atkwrapper.cxx | 2 + vcl/unx/gtk4/a11y.cxx | 1 winaccessibility/inc/AccParagraphEventListener.hxx | 4 +- winaccessibility/source/service/AccObject.cxx | 6 +++ winaccessibility/source/service/AccObjectWinManager.cxx | 1 16 files changed, 60 insertions(+), 17 deletions(-)
New commits: commit b7d2a9c824aca1a4dfd1b857a3620e73ade6bc0d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Oct 27 17:55:59 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Oct 28 05:45:25 2023 +0200 tdf#135586 sw a11y: Use BLOCK_QUOTE role for "Block Quotation" para If a paragraph is using the "Block Quotation" paragraph style, report the newly introduced BLOCK_QUOTE a11y role for it instead of the PARAGRAPH role. This is similar to how the HEADING role is reported when one of the paragraph styles for headings is used (s. `SwAccessibleParagraph::GetRealHeadingLevel`). This is also in line with what is documented for mapping LO elements to tagged PDF elements in sw/inc/EnhancedPDFExportHelper.hxx: > * Mapping of OOo elements to tagged pdf elements: > * > * OOo element tagged pdf element > * ----------- ------------------ > * [...] > * SwFormat Quotations BlockQuote This makes the Orca screen reader with the gtk3 VCL plugin on Linux and the NVDA screen reader on Windows explicitly announce a paragraph as block quote when moving there with the cursor. Adapt some places that have specific handling for the PARAGRAPH role to take into account the BLOCK_QUOTE role as well. Change-Id: I4a89625c2a3f07d37df09e68cb7045a59cfff633 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158574 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/offapi/com/sun/star/text/AccessibleParagraphView.idl b/offapi/com/sun/star/text/AccessibleParagraphView.idl index 4b5a9d23e457..108faedd0fd2 100644 --- a/offapi/com/sun/star/text/AccessibleParagraphView.idl +++ b/offapi/com/sun/star/text/AccessibleParagraphView.idl @@ -49,9 +49,10 @@ service AccessibleParagraphView children of the paragraph fragment but of the document view itself.</li> <li>The role is either - ::com::sun::star::accessibility::AccessibleRole::PARAGRAPH or + ::com::sun::star::accessibility::AccessibleRole::PARAGRAPH, + ::com::sun::star::accessibility::AccessibleRole::BLOCK_QUOTE or ::com::sun::star::accessibility::AccessibleRole::HEADING. - The later one is returned + The latter is returned if the paragraph's style is contained in the chapter numbering of a text document. <li>The name is "paragraph" or "heading" (or the equivalent term diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index 9b3ac84876eb..0df41e3a2814 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -899,7 +899,8 @@ void SwAccessibleMap::FireEvent( const SwAccessibleEvent_Impl& rEvent ) if( aIter != mpFrameMap->end() ) { rtl::Reference < SwAccessibleContext > xContext( (*aIter).second.get() ); - if (xContext.is() && xContext->getAccessibleRole() == AccessibleRole::PARAGRAPH) + if (xContext.is() && (xContext->getAccessibleRole() == AccessibleRole::PARAGRAPH + || xContext->getAccessibleRole() == AccessibleRole::BLOCK_QUOTE)) { xAccImpl = xContext.get(); } @@ -1333,7 +1334,8 @@ void SwAccessibleMap::InvalidateShapeInParaSelection() if (xAccParent.is()) { uno::Reference< XAccessibleContext > xAccContext = xAccParent->getAccessibleContext(); - if(xAccContext.is() && xAccContext->getAccessibleRole() == AccessibleRole::PARAGRAPH) + if(xAccContext.is() && (xAccContext->getAccessibleRole() == AccessibleRole::PARAGRAPH || + xAccContext->getAccessibleRole() == AccessibleRole::BLOCK_QUOTE)) { SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xAccContext.get()); if(pAccFrame->IsSelectedInDoc()) @@ -1597,7 +1599,8 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa if (xPara.is()) { uno::Reference< XAccessibleContext > xParaContext = xPara->getAccessibleContext(); - if (xParaContext.is() && xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH) + if (xParaContext.is() && (xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH + || xParaContext->getAccessibleRole() == AccessibleRole::BLOCK_QUOTE)) { SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xPara.get()); if (pAccPara) @@ -1617,7 +1620,8 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa { uno::Reference< XAccessible > xPara = pAccShape->getAccessibleParent(); uno::Reference< XAccessibleContext > xParaContext = xPara->getAccessibleContext(); - if (xParaContext.is() && xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH) + if (xParaContext.is() && (xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH + || xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)) { SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xPara.get()); if (m_setParaAdd.count(pAccPara) == 0 ) diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 96e58f35f1c3..7fb728f68fbc 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -281,18 +281,22 @@ void SwAccessibleParagraph::InvalidateContent_( bool bVisibleDataFired ) FireVisibleDataEvent(); } + bool bNewIsBlockQuote = IsBlockQuote(); bool bNewIsHeading = IsHeading(); //Get the real heading level, Heading1 ~ Heading10 m_nHeadingLevel = GetRealHeadingLevel(); + bool bOldIsBlockQuote; bool bOldIsHeading; { std::scoped_lock aGuard( m_Mutex ); + bOldIsBlockQuote = m_bIsBlockQuote; bOldIsHeading = m_bIsHeading; + m_bIsBlockQuote = bNewIsBlockQuote; if( m_bIsHeading != bNewIsHeading ) m_bIsHeading = bNewIsHeading; } - if( bNewIsHeading != bOldIsHeading ) + if (bNewIsBlockQuote != bOldIsBlockQuote || bNewIsHeading != bOldIsHeading) { // The role has changed AccessibleEventObject aEvent; @@ -397,6 +401,7 @@ SwAccessibleParagraph::SwAccessibleParagraph( const SwTextFrame& rTextFrame ) : SwAccessibleContext( pInitMap, AccessibleRole::PARAGRAPH, &rTextFrame ) , m_nOldCaretPos( -1 ) + , m_bIsBlockQuote(false) , m_bIsHeading( false ) //Get the real heading level, Heading1 ~ Heading10 , m_nHeadingLevel (-1) @@ -405,6 +410,7 @@ SwAccessibleParagraph::SwAccessibleParagraph( , m_bLastHasSelection(false) //To add TEXT_SELECTION_CHANGED event { StartListening(const_cast<SwTextFrame&>(rTextFrame)); + m_bIsBlockQuote = IsBlockQuote(); m_bIsHeading = IsHeading(); //Get the real heading level, Heading1 ~ Heading10 m_nHeadingLevel = GetRealHeadingLevel(); @@ -3504,16 +3510,13 @@ bool SwAccessibleParagraph::GetSelectionAtIndex( sal_Int16 SAL_CALL SwAccessibleParagraph::getAccessibleRole() { SolarMutexGuard g; - //Get the real heading level, Heading1 ~ Heading10 if (m_nHeadingLevel > 0) - { return AccessibleRole::HEADING; - } + if (m_bIsBlockQuote) + return AccessibleRole::BLOCK_QUOTE; else - { return AccessibleRole::PARAGRAPH; - } } //Get the real heading level, Heading1 ~ Heading10 @@ -3538,6 +3541,16 @@ sal_Int32 SwAccessibleParagraph::GetRealHeadingLevel() return -1; } +bool SwAccessibleParagraph::IsBlockQuote() +{ + uno::Reference<css::beans::XPropertySet> xPortion = CreateUnoPortion(0, 0); + uno::Any aStyleAny = xPortion->getPropertyValue("ParaStyleName"); + OUString sValue; + if (aStyleAny >>= sValue) + return sValue == "Quotations"; + return false; +} + uno::Any SAL_CALL SwAccessibleParagraph::getExtendedAttributes() { SolarMutexGuard g; diff --git a/sw/source/core/access/accpara.hxx b/sw/source/core/access/accpara.hxx index 3f6c57231d49..890604a50e95 100644 --- a/sw/source/core/access/accpara.hxx +++ b/sw/source/core/access/accpara.hxx @@ -78,6 +78,7 @@ class SwAccessibleParagraph : // as the cursor is inside this object (protected by // mutex) + bool m_bIsBlockQuote; bool m_bIsHeading; // protected by base classes mutex sal_Int32 m_nHeadingLevel; @@ -369,6 +370,7 @@ public: // XAccessibleExtendedAttributes virtual css::uno::Any SAL_CALL getExtendedAttributes() override ; sal_Int32 GetRealHeadingLevel(); + bool IsBlockQuote(); // #i89175# // XAccessibleMultiLineText diff --git a/sw/source/core/access/acctextframe.cxx b/sw/source/core/access/acctextframe.cxx index 6b5340ce6f34..e1b5cd029ceb 100644 --- a/sw/source/core/access/acctextframe.cxx +++ b/sw/source/core/access/acctextframe.cxx @@ -151,7 +151,8 @@ sal_Bool SAL_CALL SwAccessibleTextFrame::isAccessibleChildSelected( sal_Int64 nC if( xContext.is() ) { - if( xContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) + const sal_Int16 nRole = xContext->getAccessibleRole(); + if (nRole == AccessibleRole::PARAGRAPH || nRole == AccessibleRole::BLOCK_QUOTE) { uno::Reference< css::accessibility::XAccessibleText > xText(xAcc, uno::UNO_QUERY); commit f44eae4912e8f2ba34d93a71a609473df976a2cb Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Oct 27 14:53:59 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Oct 28 05:45:15 2023 +0200 tdf#135586 a11y: Add a new BLOCK_QUOTE a11y role A block quote role exists in all of WAI-ARIA 1.3 (role "blockquote", [1]), IAccessible2 (`IA2_ROLE_BLOCK_QUOTE`, [2]) and AT-SPI (`ROLE_BLOCK_QUOTE`, [3]). Take over the definition that is the same in WAI-ARIA and IAccessible2: > A section of content that is quoted from another source. The intended use for now is for a Writer paragraph using the "Block Quotation" paragraph style, similar to how the HEADING role is used for paragraphs using a corresponding paragraph style. For gtk3 (ATK) and winaccessibility (IAccessible2), map the new role to the equivalant roles. For macOS and the gtk4 as well as the Qt-based VCL plugins on Linux which currently don't have an equivalent role, fall back to the same role that the PARAGRAPH role is mapped to. This way, the behavior there will remain unchanged once the BLOCK_QUOTE role is used for Writer paragraphs with the corresponding style. In general, treat BLOCK_QUOTE like PARAGRAPH in code applying special handling for the PARAGRAPH role. [1] https://w3c.github.io/aria/#blockquote [2] https://github.com/LinuxA11y/IAccessible2/blob/3d8c7f0b833453f761ded6b12d8be431507bfe0b/api/AccessibleRole.idl#L318 [3] https://gitlab.gnome.org/GNOME/at-spi2-core/-/blob/7cc4cee53ddbd22631fd110f0e5ce045dec2e411/xml/Accessible.xml#L615-616 Change-Id: I248c183a2e7ec5d6f0a89bf3cb4829bbd8588c77 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158573 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/offapi/com/sun/star/accessibility/AccessibleRole.idl b/offapi/com/sun/star/accessibility/AccessibleRole.idl index f5e269d3a423..09fac50df7de 100644 --- a/offapi/com/sun/star/accessibility/AccessibleRole.idl +++ b/offapi/com/sun/star/accessibility/AccessibleRole.idl @@ -744,6 +744,14 @@ constants AccessibleRole */ const short NOTIFICATION = 87; + /** Block quote role. + + <p>A section of content that is quoted from another source.</p> + + @since LibreOffice 24.2 + */ + const short BLOCK_QUOTE = 88; + }; }; }; }; }; diff --git a/test/source/a11y/AccessibilityTools.cxx b/test/source/a11y/AccessibilityTools.cxx index d19c42b388e0..150a1cdf836a 100644 --- a/test/source/a11y/AccessibilityTools.cxx +++ b/test/source/a11y/AccessibilityTools.cxx @@ -220,6 +220,8 @@ OUString AccessibilityTools::getRoleName(const sal_Int16 role) return "UNKNOWN"; case accessibility::AccessibleRole::ALERT: return "ALERT"; + case accessibility::AccessibleRole::BLOCK_QUOTE: + return "BLOCK_QUOTE"; case accessibility::AccessibleRole::BUTTON_DROPDOWN: return "BUTTON_DROPDOWN"; case accessibility::AccessibleRole::BUTTON_MENU: diff --git a/vcl/osx/a11yrolehelper.mm b/vcl/osx/a11yrolehelper.mm index e95036dbebd9..a1cf62f327cc 100644 --- a/vcl/osx/a11yrolehelper.mm +++ b/vcl/osx/a11yrolehelper.mm @@ -46,6 +46,7 @@ using namespace ::com::sun::star::uno; MAP( AccessibleRole::UNKNOWN, NSAccessibilityUnknownRole ); MAP( AccessibleRole::ALERT, NSAccessibilityUnknownRole ); // FIXME + MAP( AccessibleRole::BLOCK_QUOTE, NSAccessibilityTextAreaRole ); MAP( AccessibleRole::COLUMN_HEADER, NSAccessibilityColumnRole ); MAP( AccessibleRole::CANVAS, NSAccessibilityUnknownRole ); // FIXME MAP( AccessibleRole::CHECK_BOX, NSAccessibilityCheckBoxRole ); @@ -186,6 +187,7 @@ using namespace ::com::sun::star::uno; MAP( AccessibleRole::UNKNOWN, NSAccessibilityUnknownSubrole ); MAP( AccessibleRole::ALERT, NSAccessibilitySystemDialogSubrole ); + MAP( AccessibleRole::BLOCK_QUOTE, @"" ); MAP( AccessibleRole::COLUMN_HEADER, @"" ); MAP( AccessibleRole::CANVAS, @"" ); MAP( AccessibleRole::CHECK_BOX, @"" ); diff --git a/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx b/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx index d51ceeaaee81..85110eeddecb 100644 --- a/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx +++ b/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx @@ -36,6 +36,7 @@ static AtspiRole mapToAtspiRole(sal_Int16 nRole) MAP_DIRECT(UNKNOWN); MAP_DIRECT(ALERT); + MAP_DIRECT(BLOCK_QUOTE); MAP_DIRECT(COLUMN_HEADER); MAP_DIRECT(CANVAS); MAP_DIRECT(CHECK_BOX); diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index cec049340f07..cba67bc60cc8 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -462,6 +462,7 @@ QAccessible::Role QtAccessibleWidget::role() const case AccessibleRole::PANEL: return QAccessible::Pane; case AccessibleRole::PARAGRAPH: + case AccessibleRole::BLOCK_QUOTE: return QAccessible::Paragraph; case AccessibleRole::PASSWORD_TEXT: return QAccessible::EditableText; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 229296a275c9..3d9456432164 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -2438,7 +2438,7 @@ namespace BuilderUtils { "info bar", AccessibleRole::UNKNOWN }, { "level bar", AccessibleRole::UNKNOWN }, { "title bar", AccessibleRole::UNKNOWN }, - { "block quote", AccessibleRole::UNKNOWN }, + { "block quote", AccessibleRole::BLOCK_QUOTE }, { "audio", AccessibleRole::UNKNOWN }, { "video", AccessibleRole::UNKNOWN }, { "definition", AccessibleRole::UNKNOWN }, diff --git a/vcl/unx/gtk3/a11y/atkwrapper.cxx b/vcl/unx/gtk3/a11y/atkwrapper.cxx index 904358a2d229..729da012e067 100644 --- a/vcl/unx/gtk3/a11y/atkwrapper.cxx +++ b/vcl/unx/gtk3/a11y/atkwrapper.cxx @@ -174,6 +174,8 @@ static AtkRole mapToAtkRole( sal_Int16 nRole ) return ATK_ROLE_UNKNOWN; case accessibility::AccessibleRole::ALERT: return ATK_ROLE_ALERT; + case accessibility::AccessibleRole::BLOCK_QUOTE: + return ATK_ROLE_BLOCK_QUOTE; case accessibility::AccessibleRole::COLUMN_HEADER: return ATK_ROLE_COLUMN_HEADER; case accessibility::AccessibleRole::CANVAS: diff --git a/vcl/unx/gtk4/a11y.cxx b/vcl/unx/gtk4/a11y.cxx index 51c055bca186..fcd9cb6fb949 100644 --- a/vcl/unx/gtk4/a11y.cxx +++ b/vcl/unx/gtk4/a11y.cxx @@ -138,6 +138,7 @@ map_accessible_role(const css::uno::Reference<css::accessibility::XAccessible>& eRole = GTK_ACCESSIBLE_ROLE_WIDGET; break; case css::accessibility::AccessibleRole::PARAGRAPH: + case css::accessibility::AccessibleRole::BLOCK_QUOTE: #if GTK_CHECK_VERSION(4, 13, 1) eRole = GTK_ACCESSIBLE_ROLE_PARAGRAPH; #else diff --git a/winaccessibility/inc/AccParagraphEventListener.hxx b/winaccessibility/inc/AccParagraphEventListener.hxx index daa07603bc19..d2f5457e1b0c 100644 --- a/winaccessibility/inc/AccParagraphEventListener.hxx +++ b/winaccessibility/inc/AccParagraphEventListener.hxx @@ -26,8 +26,8 @@ /** * AccParagraphEventListener is inherited from AccContainerEventListener. It handles the events - * generated by container controls. The accessible roles are: PARAGRAPH and HEADING. - * It defines the procedure of specific event handling related with text containsers and provides + * generated by container controls. The accessible roles are: PARAGRAPH, HEADING and BLOCK_QUOTE. + * It defines the procedure of specific event handling related with text containers and provides * the detailed support for some related methods. */ class AccParagraphEventListener : public AccContainerEventListener diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx index ad0f65d8cc09..96e8cfa37b5e 100644 --- a/winaccessibility/source/service/AccObject.cxx +++ b/winaccessibility/source/service/AccObject.cxx @@ -67,6 +67,8 @@ short lcl_mapToIAccessible2Role(sal_Int16 nUnoRole) return IA2_ROLE_UNKNOWN; case css::accessibility::AccessibleRole::ALERT: return ROLE_SYSTEM_DIALOG; + case css::accessibility::AccessibleRole::BLOCK_QUOTE: + return IA2_ROLE_BLOCK_QUOTE; case css::accessibility::AccessibleRole::COLUMN_HEADER: return ROLE_SYSTEM_COLUMNHEADER; case css::accessibility::AccessibleRole::CANVAS: @@ -369,7 +371,7 @@ void AccObject::UpdateName( ) if( ( TEXT_FRAME == m_accRole ) && ( m_pParentObj !=nullptr )&& ( SCROLL_PANE == m_pParentObj -> m_accRole ) ) m_pIMAcc->Put_XAccName( o3tl::toW(m_pParentObj->m_xAccContextRef->getAccessibleName().getStr()) ); //IAccessibility2 Implementation 2009----- - if ( PARAGRAPH == m_accRole) + if (m_accRole == AccessibleRole::PARAGRAPH || m_accRole == AccessibleRole::BLOCK_QUOTE) { m_pIMAcc->Put_XAccName(L""); } @@ -470,6 +472,7 @@ void AccObject::SetValue( Any pAny ) // 3. date editor's msaa value should be the same as spinbox case DATE_EDITOR: case TEXT: + case BLOCK_QUOTE: case PARAGRAPH: case HEADING: case TABLE_CELL: @@ -924,6 +927,7 @@ void AccObject::UpdateState() case HEADING: //Image Map + case BLOCK_QUOTE: case PARAGRAPH: case PASSWORD_TEXT: case SHAPE: diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx index 04f81875cd88..24deb8150c51 100644 --- a/winaccessibility/source/service/AccObjectWinManager.cxx +++ b/winaccessibility/source/service/AccObjectWinManager.cxx @@ -749,6 +749,7 @@ AccObjectWinManager::CreateAccEventListener(XAccessible* pXAcc) case AccessibleRole::VIEW_PORT: pRet = new AccContainerEventListener(pXAcc, this); break; + case AccessibleRole::BLOCK_QUOTE: case AccessibleRole::PARAGRAPH: case AccessibleRole::HEADING: pRet = new AccParagraphEventListener(pXAcc, this);