summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx11
-rw-r--r--sw/qa/core/accessibilitycheck/data/HighlightTest.odtbin0 -> 8599 bytes
-rw-r--r--sw/source/core/access/AccessibilityCheck.cxx29
3 files changed, 34 insertions, 6 deletions
diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
index 75cf071c1e69..ead35acfb4ca 100644
--- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
+++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
@@ -105,6 +105,17 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testHyperlinks)
CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::HYPERLINK_IS_TEXT, aIssues[1]->m_eIssueID);
}
+CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckHighlightedText)
+{
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "HighlightTest.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/HighlightTest.odt b/sw/qa/core/accessibilitycheck/data/HighlightTest.odt
new file mode 100644
index 000000000000..da4821681502
--- /dev/null
+++ b/sw/qa/core/accessibilitycheck/data/HighlightTest.odt
Binary files differ
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index 9195fcfcbd52..6d229fa40a16 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -356,8 +356,8 @@ class TextContrastCheck : public NodeCheck
{
private:
void checkTextRange(uno::Reference<text::XTextRange> const& xTextRange,
- uno::Reference<text::XTextContent> const& xParagraph,
- const SwTextNode* pTextNode)
+ uno::Reference<text::XTextContent> const& xParagraph, SwTextNode* pTextNode,
+ sal_Int32 nTextStart)
{
Color nParaBackColor(COL_AUTO);
uno::Reference<beans::XPropertySet> xParagraphProperties(xParagraph, uno::UNO_QUERY);
@@ -378,9 +378,6 @@ private:
SAL_WARN("sw.a11y", "CharColor void");
return;
}
- Color aForegroundColor(ColorTransparency, nCharColor);
- if (aForegroundColor == COL_AUTO)
- return;
const SwPageDesc* pPageDescription = pTextNode->FindPageDesc();
const SwFrameFormat& rPageFormat = pPageDescription->GetMaster();
@@ -411,6 +408,22 @@ private:
// If not character background color, try paragraph background color
if (aBackgroundColor == COL_AUTO)
aBackgroundColor = nParaBackColor;
+ else
+ {
+ 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->setStart(nTextStart);
+ pIssue->setEnd(nTextStart + xTextRange->getString().getLength());
+ }
+
+ Color aForegroundColor(ColorTransparency, nCharColor);
+ if (aForegroundColor == COL_AUTO)
+ return;
// If not paragraph background color, try page color
if (aBackgroundColor == COL_AUTO)
@@ -446,11 +459,15 @@ public:
uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+ sal_Int32 nStart = 0;
while (xRunEnum->hasMoreElements())
{
uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
if (xRun.is())
- checkTextRange(xRun, xParagraph, pTextNode);
+ {
+ checkTextRange(xRun, xParagraph, pTextNode, nStart);
+ nStart += xRun->getString().getLength();
+ }
}
}
};