sw/source/core/access/AccessibilityCheck.cxx | 70 ++++++++++++++++----------- sw/source/core/inc/AccessibilityCheck.hxx | 3 + 2 files changed, 47 insertions(+), 26 deletions(-)
New commits: commit b9973ff6a17ff4c5b66be1835e5820bf6db3d507 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat Dec 7 13:08:16 2019 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Thu Dec 26 11:33:55 2019 +0100 Extract accessibility checks to it's own function Change-Id: I986b863d152b515927c62785bfed39354559a743 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85822 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index 4460bb9a28ca..870f67169e11 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -14,15 +14,53 @@ #include <IDocumentDrawModelAccess.hxx> #include <drawdoc.hxx> #include <svx/svdpage.hxx> +#include <swtable.hxx> + +namespace +{ +OUString sNoAlt("No alt text for graphic '%OBJECT_NAME%'"); +} + +// Check NoTextNodes: Graphic, OLE +void AccessibilityCheck::checkNoTextNode(SwNoTextNode* pNoTextNode) +{ + if (!pNoTextNode) + return; + + OUString sAlternative = pNoTextNode->GetTitle(); + if (sAlternative.isEmpty()) + { + OUString sName = pNoTextNode->GetFlyFormat()->GetName(); + svx::AccessibilityIssue aIssue; + aIssue.m_aIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName); + m_aAccessibilityIssueCollection.push_back(aIssue); + } +} + +// Check Shapes, TextBox +void AccessibilityCheck::checkObject(SdrObject* pObject) +{ + if (!pObject) + return; + + if (pObject->GetObjIdentifier() == OBJ_CUSTOMSHAPE || pObject->GetObjIdentifier() == OBJ_TEXT) + { + OUString sAlternative = pObject->GetTitle(); + if (sAlternative.isEmpty()) + { + OUString sName = pObject->GetName(); + svx::AccessibilityIssue aIssue; + aIssue.m_aIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName); + m_aAccessibilityIssueCollection.push_back(aIssue); + } + } +} void AccessibilityCheck::check() { if (m_pDoc == nullptr) return; - OUString sNoAlt("No alt text for graphic '%OBJECT_NAME%'"); - - // Check NoTextNodes: Graphic, OLE auto const& pNodes = m_pDoc->GetNodes(); for (sal_uLong n = 0; n < pNodes.Count(); ++n) { @@ -33,21 +71,11 @@ void AccessibilityCheck::check() { SwNoTextNode* pNoTextNode = pNode->GetNoTextNode(); if (pNoTextNode) - { - OUString sAlternative = pNoTextNode->GetTitle(); - if (sAlternative.isEmpty()) - { - OUString sName = pNoTextNode->GetFlyFormat()->GetName(); - svx::AccessibilityIssue aIssue; - aIssue.m_aIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName); - m_aAccessibilityIssueCollection.push_back(aIssue); - } - } + checkNoTextNode(pNoTextNode); } } } - // Check Shapes, TextBox IDocumentDrawModelAccess& rDrawModelAccess = m_pDoc->getIDocumentDrawModelAccess(); auto* pModel = rDrawModelAccess.GetDrawModel(); for (sal_uInt16 nPage = 0; nPage < pModel->GetPageCount(); ++nPage) @@ -56,18 +84,8 @@ void AccessibilityCheck::check() for (size_t nObject = 0; nObject < pPage->GetObjCount(); ++nObject) { SdrObject* pObject = pPage->GetObj(nObject); - if (pObject->GetObjIdentifier() == OBJ_CUSTOMSHAPE - || pObject->GetObjIdentifier() == OBJ_TEXT) - { - OUString sAlternative = pObject->GetTitle(); - if (sAlternative.isEmpty()) - { - OUString sName = pObject->GetName(); - svx::AccessibilityIssue aIssue; - aIssue.m_aIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName); - m_aAccessibilityIssueCollection.push_back(aIssue); - } - } + if (pObject) + checkObject(pObject); } } } diff --git a/sw/source/core/inc/AccessibilityCheck.hxx b/sw/source/core/inc/AccessibilityCheck.hxx index 670ed0416225..4648b06dce70 100644 --- a/sw/source/core/inc/AccessibilityCheck.hxx +++ b/sw/source/core/inc/AccessibilityCheck.hxx @@ -13,6 +13,7 @@ #include <doc.hxx> #include <svx/AccessibilityIssue.hxx> +#include <node.hxx> class AccessibilityCheck { @@ -31,6 +32,8 @@ public: } void check(); + void checkNoTextNode(SwNoTextNode* pNoTextNode); + void checkObject(SdrObject* pObject); }; #endif _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits