From 053365d29e28af88b173ed8594649ca70c17ce6b Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Wed, 2 Apr 2025 11:56:55 +0200 Subject: [PATCH] editeng a11y: Drop paragraph's a11y description So far, "paragraph " and the (start of) the paragraph text were reported as the accessible description of the paragraph. This resulted e.g. in Orca saying something like "Paragraph 0: Hello world Hello world" when moving cursor to a paragraph containing the text "Hello world" in Impress, because both, a11y description and the text reported via the AtspiText interface were reported. Drop the a11y description, which is also consistent with Writer where no description is reported. The // (writer takes first sentence here, but that's not supported // from EditEngine) comment dropped along with this commit looks outdated. The fact that this is a paragraph is already reported via the a11y role and the text is reported via the XAccessibleText interface. (The information which paragraph this is could be retrieved by checking the children of the paragraph's parent, so if an AT wanted to report that, it could implement corresponding logic on the client side.) Adjust the Impress a11y test originally added in commit 6185a27db46bf5cba404e669eaf3a1c78f4a8607 Author: Colomban Wendling Date: Sun Jul 31 17:20:03 2022 +0200 tdf#150064 Add tests for a11y tree order Check the tree order is stable across loads and page switches. accordingly, which included the description in the expected output, but that's not the purpose of the test. Also adjust the sw a11y test (test::AccessibleTestBase::BasicTestFontworkDialog) accordingly. Change-Id: Ifbc1a15a976d7488396630c6bc3c9e42ba26ccc1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183625 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- .../AccessibleEditableTextPara.cxx | 41 +------- include/editeng/editrids.hrc | 1 - sd/qa/unit/a11y/layout.cxx | 93 +++++++++---------- sw/qa/extras/accessibility/dialogs.cxx | 6 +- 4 files changed, 50 insertions(+), 91 deletions(-) diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index 3185342d16e4..b8a00af82f7c 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -675,46 +675,7 @@ namespace accessibility OUString SAL_CALL AccessibleEditableTextPara::getAccessibleDescription() { - SolarMutexGuard aGuard; - - // append first 40 characters from text, or first line, if shorter - // (writer takes first sentence here, but that's not supported - // from EditEngine) - // throws if defunc - OUString aLine; - - if( getCharacterCount() ) - aLine = getTextAtIndex(0, AccessibleTextType::LINE).SegmentText; - - // Get the string from the resource for the specified id. - OUString sStr(EditResId(RID_SVXSTR_A11Y_PARAGRAPH_DESCRIPTION)); - OUString sParaIndex = OUString::number(GetParagraphIndex()); - sStr = sStr.replaceFirst("$(ARG)", sParaIndex); - - if( aLine.getLength() > MaxDescriptionLen ) - { - OUString aCurrWord; - sal_Int32 i; - - // search backward from MaxDescriptionLen for previous word start - for( aCurrWord=getTextAtIndex(MaxDescriptionLen, AccessibleTextType::WORD).SegmentText, - i=MaxDescriptionLen, - aLine=OUString(); - i>=0; - --i ) - { - if( getTextAtIndex(i, AccessibleTextType::WORD).SegmentText != aCurrWord ) - { - if( i == 0 ) - // prevent completely empty string - aLine = getTextAtIndex(0, AccessibleTextType::WORD).SegmentText; - else - aLine = getTextRange(0, i); - } - } - } - - return sStr + aLine; + return OUString(); } OUString SAL_CALL AccessibleEditableTextPara::getAccessibleName() diff --git a/include/editeng/editrids.hrc b/include/editeng/editrids.hrc index d0872f0a88a7..46d87cc9556b 100644 --- a/include/editeng/editrids.hrc +++ b/include/editeng/editrids.hrc @@ -313,7 +313,6 @@ #define RID_SVXSTR_A11Y_IMAGEBULLET_DESCRIPTION NC_("RID_SVXSTR_A11Y_IMAGEBULLET_DESCRIPTION", "Image bullet in paragraph") #define RID_SVXSTR_A11Y_IMAGEBULLET_NAME NC_("RID_SVXSTR_A11Y_IMAGEBULLET_NAME", "Image bullet") -#define RID_SVXSTR_A11Y_PARAGRAPH_DESCRIPTION NC_("RID_SVXSTR_A11Y_PARAGRAPH_DESCRIPTION", "Paragraph: $(ARG) ") #define RID_SVXSTR_QUERY_CONTINUE NC_("RID_SVXSTR_QUERY_CONTINUE", "Continue checking at beginning of document?") #define RID_SVXSTR_QUERY_BW_CONTINUE NC_("RID_SVXSTR_QUERY_BW_CONTINUE", "Continue checking at end of document?") diff --git a/sd/qa/unit/a11y/layout.cxx b/sd/qa/unit/a11y/layout.cxx index 9fd2abf07aca..803c9c17cb3e 100644 --- a/sd/qa/unit/a11y/layout.cxx +++ b/sd/qa/unit/a11y/layout.cxx @@ -24,12 +24,12 @@ CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, TestImpressDefaultStructure) CPPUNIT_ASSERT_EQUAL(u"" "" - "" + "" "Click to add Title" "" "" "" - "" + "" "Click to add Text" "" ""_ustr, @@ -86,47 +86,46 @@ CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, tdf150064) xDrawView->setCurrentPage(xDrawPage); Scheduler::ProcessEventsToIdle(); - CPPUNIT_ASSERT_EQUAL( - u"" - "" - "P1 title" - "" - "" - "Some text" - "" - "" - "" - "1" - "" - "" - "2" - "" - "" - "3" - "" - "" - "4" - "" - "" - "5" - "" - "" - "6" - "" - "" - "7" - "" - "" - "8" - "" - "" - "9" - "" - "" - "10" - "" - "
"_ustr, - collectText()); + CPPUNIT_ASSERT_EQUAL(u"" + "" + "P1 title" + "" + "" + "Some text" + "" + "" + "" + "1" + "" + "" + "2" + "" + "" + "3" + "" + "" + "4" + "" + "" + "5" + "" + "" + "6" + "" + "" + "7" + "" + "" + "8" + "" + "" + "9" + "" + "" + "10" + "" + "
"_ustr, + collectText()); CPPUNIT_ASSERT(xDrawPages->getByIndex(1) >>= xDrawPage); xDrawView->setCurrentPage(xDrawPage); @@ -134,16 +133,16 @@ CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, tdf150064) CPPUNIT_ASSERT_EQUAL(u"" "" - "P2 title" + "P2 title" "" "" - "1" + "1" "" "" - "2" + "2" "" "" - "3" + "3" ""_ustr, collectText()); } diff --git a/sw/qa/extras/accessibility/dialogs.cxx b/sw/qa/extras/accessibility/dialogs.cxx index 1072a2c47b1f..c56434807593 100644 --- a/sw/qa/extras/accessibility/dialogs.cxx +++ b/sw/qa/extras/accessibility/dialogs.cxx @@ -173,9 +173,9 @@ CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, BasicTestFontworkDialog) CPPUNIT_ASSERT(activateMenuItem(u"Insert", u"Fontwork...")); CPPUNIT_ASSERT(dialogWaiter->waitEndDialog()); - CPPUNIT_ASSERT_EQUAL(u"Simple"_ustr, - collectText()); + CPPUNIT_ASSERT_EQUAL( + u"Simple"_ustr, + collectText()); } CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, BasicTestFrameDialog)