diff options
author | offtkp <parisoplop@gmail.com> | 2022-10-07 17:13:53 +0300 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2022-10-13 09:20:17 +0200 |
commit | b45867766184ad1200df4183dab537fac9e83ea2 (patch) | |
tree | c25885891475bcb772e68aa38b65893042f2c3a2 | |
parent | 51500b21784792d13a7102dd2485787bac3ddf3e (diff) |
a11y: Add char attr a11y check for entire paragraph
Accessibility check would not work if the entire paragraph had
character attributes, because then it wouldn't have individual text
hints
Now check if there's a SwAttrSet and if it has the a11y char attributes
that an issue should be generated for
Also add test for this specific case
Change-Id: Iee035eecd25ed130e78ed27041c3e56ea988ecc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141078
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 13 | ||||
-rw-r--r-- | sw/qa/core/accessibilitycheck/data/ParagraphTest.odt | bin | 0 -> 8330 bytes | |||
-rw-r--r-- | sw/source/core/access/AccessibilityCheck.cxx | 29 |
3 files changed, 42 insertions, 0 deletions
diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index 169a3fa03191..d7ad7674c13b 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -46,6 +46,19 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testTableSplitMergeAndAltText) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::NO_ALT_SHAPE, aIssues[6]->m_eIssueID); } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckParagraphIssues) +{ + // Tests whether formatting issues are detected when the whole paragraph has them instead of + // some text inside the paragraph + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "ParagraphTest.odt"); + CPPUNIT_ASSERT(pDoc); + sw::AccessibilityCheck aCheck(pDoc); + aCheck.check(); + auto& aIssues = aCheck.getIssueCollection().getIssues(); + CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size()); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/ParagraphTest.odt b/sw/qa/core/accessibilitycheck/data/ParagraphTest.odt Binary files differnew file mode 100644 index 000000000000..766ecd0b4e2e --- /dev/null +++ b/sw/qa/core/accessibilitycheck/data/ParagraphTest.odt diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index 50a37dc00bef..f6c6ec7b43d5 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -551,6 +551,35 @@ public: } } } + else if (pTextNode->HasSwAttrSet()) + { + // Paragraph doesn't have hints but the entire paragraph might have char attributes + auto& aSwAttrSet = pTextNode->GetSwAttrSet(); + auto nParagraphLength = pTextNode->GetText().getLength(); + if (nParagraphLength == 0) + return; + if (aSwAttrSet.HasItem(RES_CHRATR_WEIGHT) || aSwAttrSet.HasItem(RES_CHRATR_CJK_WEIGHT) + || aSwAttrSet.HasItem(RES_CHRATR_CTL_WEIGHT) + || aSwAttrSet.HasItem(RES_CHRATR_POSTURE) + || aSwAttrSet.HasItem(RES_CHRATR_CJK_POSTURE) + || aSwAttrSet.HasItem(RES_CHRATR_CTL_POSTURE) + || aSwAttrSet.HasItem(RES_CHRATR_SHADOWED) || aSwAttrSet.HasItem(RES_CHRATR_COLOR) + || aSwAttrSet.HasItem(RES_CHRATR_EMPHASIS_MARK) + || aSwAttrSet.HasItem(RES_CHRATR_UNDERLINE) + || aSwAttrSet.HasItem(RES_CHRATR_OVERLINE) + || aSwAttrSet.HasItem(RES_CHRATR_CROSSEDOUT) + || aSwAttrSet.HasItem(RES_CHRATR_RELIEF) || aSwAttrSet.HasItem(RES_CHRATR_CONTOUR)) + { + auto pIssue + = lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_FORMATTING_CONVEYS_MEANING), + sfx::AccessibilityIssueID::TEXT_FORMATTING); + pIssue->setIssueObject(IssueObject::TEXT); + pIssue->setNode(pTextNode); + SwDoc& rDocument = pTextNode->GetDoc(); + pIssue->setDoc(rDocument); + pIssue->setEnd(nParagraphLength); + } + } } }; |