sw/source/core/access/AccessibilityCheck.cxx | 46 +++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-)
New commits: commit 47ca3f1f762352b488d58b3bf23d5776576f1cca Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Mon Jul 31 15:11:44 2023 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Wed Aug 2 01:15:51 2023 +0200 tdf#156545 - a11y - fix warns about background character style formattings Do not add warn to a11y sidebar if we use charstyle for character background format. Change-Id: Ide558b590cae2bc20c71c5c44909cd2cdeb89985 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155095 Tested-by: Jenkins Tested-by: Gabor Kelemen <kelem...@ubuntu.com> Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index ac0f442a5041..501799a2a2ff 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -480,15 +480,43 @@ private: 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()); + OUString sCharStyleName; + Color nCharStyleBackColor(COL_AUTO); + if (xProperties->getPropertyValue("CharStyleName") >>= sCharStyleName) + { + try + { + uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier( + pTextNode->GetDoc().GetDocShell()->GetModel(), uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xCont + = xStyleFamiliesSupplier->getStyleFamilies(); + uno::Reference<container::XNameAccess> xStyleFamily( + xCont->getByName("CharacterStyles"), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xInfo( + xStyleFamily->getByName(sCharStyleName), uno::UNO_QUERY); + xInfo->getPropertyValue("CharBackColor") >>= nCharStyleBackColor; + } + catch (const uno::Exception&) + { + } + } + else + { + SAL_WARN("sw.a11y", "CharStyleName void"); + } + + if (aBackgroundColor != nCharStyleBackColor) + { + 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);