editeng a11y: Drop paragraph's a11y description

So far, "paragraph <number>" 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 6185a27db4
    Author: Colomban Wendling <cwendling@hypra.fr>
    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 <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn
2025-04-02 11:56:55 +02:00
parent 64ab001207
commit 053365d29e
4 changed files with 50 additions and 91 deletions

View File

@@ -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()

View File

@@ -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?")

View File

@@ -24,12 +24,12 @@ CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, TestImpressDefaultStructure)
CPPUNIT_ASSERT_EQUAL(u"<SHAPE name=\"PageShape: Slide 1\" description=\" \"/>"
"<SHAPE name=\"PresentationTitle \" description=\" \">"
"<PARAGRAPH description=\"Paragraph: 0 Click to add Title\">"
"<PARAGRAPH>"
"Click to add Title"
"</PARAGRAPH>"
"</SHAPE>"
"<SHAPE name=\"PresentationSubtitle \" description=\" \">"
"<PARAGRAPH description=\"Paragraph: 0 Click to add Text\">"
"<PARAGRAPH>"
"Click to add Text"
"</PARAGRAPH>"
"</SHAPE>"_ustr,
@@ -86,47 +86,46 @@ CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, tdf150064)
xDrawView->setCurrentPage(xDrawPage);
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(
u"<SHAPE name=\"PageShape: Slide 1\" description=\" \"/>"
"<SHAPE name=\"PresentationTitle \" description=\" \">"
"<PARAGRAPH description=\"Paragraph: 0 P1 title\">P1 title</PARAGRAPH>"
"</SHAPE>"
"<SHAPE name=\"PresentationSubtitle \" description=\" \">"
"<PARAGRAPH description=\"Paragraph: 0 Some text\">Some text</PARAGRAPH>"
"</SHAPE>"
"<TABLE name=\"TableShape \" description=\" \">"
"<TABLE_CELL name=\"A1\">"
"<PARAGRAPH description=\"Paragraph: 0 1\">1</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"B1\">"
"<PARAGRAPH description=\"Paragraph: 0 2\">2</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"C1\">"
"<PARAGRAPH description=\"Paragraph: 0 3\">3</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"D1\">"
"<PARAGRAPH description=\"Paragraph: 0 4\">4</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"E1\">"
"<PARAGRAPH description=\"Paragraph: 0 5\">5</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"A2\">"
"<PARAGRAPH description=\"Paragraph: 0 6\">6</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"B2\">"
"<PARAGRAPH description=\"Paragraph: 0 7\">7</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"C2\">"
"<PARAGRAPH description=\"Paragraph: 0 8\">8</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"D2\">"
"<PARAGRAPH description=\"Paragraph: 0 9\">9</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"E2\">"
"<PARAGRAPH description=\"Paragraph: 0 10\">10</PARAGRAPH>"
"</TABLE_CELL>"
"</TABLE>"_ustr,
collectText());
CPPUNIT_ASSERT_EQUAL(u"<SHAPE name=\"PageShape: Slide 1\" description=\" \"/>"
"<SHAPE name=\"PresentationTitle \" description=\" \">"
"<PARAGRAPH>P1 title</PARAGRAPH>"
"</SHAPE>"
"<SHAPE name=\"PresentationSubtitle \" description=\" \">"
"<PARAGRAPH>Some text</PARAGRAPH>"
"</SHAPE>"
"<TABLE name=\"TableShape \" description=\" \">"
"<TABLE_CELL name=\"A1\">"
"<PARAGRAPH>1</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"B1\">"
"<PARAGRAPH>2</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"C1\">"
"<PARAGRAPH>3</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"D1\">"
"<PARAGRAPH>4</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"E1\">"
"<PARAGRAPH>5</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"A2\">"
"<PARAGRAPH>6</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"B2\">"
"<PARAGRAPH>7</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"C2\">"
"<PARAGRAPH>8</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"D2\">"
"<PARAGRAPH>9</PARAGRAPH>"
"</TABLE_CELL>"
"<TABLE_CELL name=\"E2\">"
"<PARAGRAPH>10</PARAGRAPH>"
"</TABLE_CELL>"
"</TABLE>"_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"<SHAPE name=\"PageShape: Slide 2\" description=\" \"/>"
"<SHAPE name=\"PresentationTitle \" description=\" \">"
"<PARAGRAPH description=\"Paragraph: 0 P2 title\">P2 title</PARAGRAPH>"
"<PARAGRAPH>P2 title</PARAGRAPH>"
"</SHAPE>"
"<SHAPE name=\"PresentationOutliner \" description=\" \">"
"<PARAGRAPH description=\"Paragraph: 0 1\">1</PARAGRAPH>"
"<PARAGRAPH>1</PARAGRAPH>"
"</SHAPE>"
"<SHAPE name=\"PresentationOutliner \" description=\" \">"
"<PARAGRAPH description=\"Paragraph: 0 2\">2</PARAGRAPH>"
"<PARAGRAPH>2</PARAGRAPH>"
"</SHAPE>"
"<SHAPE name=\"PresentationOutliner \" description=\" \">"
"<PARAGRAPH description=\"Paragraph: 0 3\">3</PARAGRAPH>"
"<PARAGRAPH>3</PARAGRAPH>"
"</SHAPE>"_ustr,
collectText());
}

View File

@@ -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"<PARAGRAPH/><SHAPE name=\"Fontwork 1\" description=\" \"><PARAGRAPH "
"description=\"Paragraph: 0 Simple\">Simple</PARAGRAPH></SHAPE>"_ustr,
collectText());
CPPUNIT_ASSERT_EQUAL(
u"<PARAGRAPH/><SHAPE name=\"Fontwork 1\" description=\" \"><PARAGRAPH>Simple</PARAGRAPH></SHAPE>"_ustr,
collectText());
}
CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, BasicTestFrameDialog)