diff options
author | László Németh <nemeth@numbertext.org> | 2023-11-08 11:04:40 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2023-11-08 21:16:59 +0100 |
commit | 0156cba6e34026f8fa0f2912e503378a5ec2208d (patch) | |
tree | aa284af7253aafab16d2d2afb1a78c69e4916935 /sw/source/core/access | |
parent | e87937d1fab87fa3225f5bcc0d2f5182d5fcef39 (diff) |
tdf#43784 tdf#158114 sw accessibility: check missing linked graphic
Show missing linked graphics and their abbreviated paths,
(and as tooltips, full paths) in the accessibility checker.
Change-Id: Ia378f4ea3260251d1b2530fadc48aea6e0323a08
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159150
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/core/access')
-rw-r--r-- | sw/source/core/access/AccessibilityCheck.cxx | 42 | ||||
-rw-r--r-- | sw/source/core/access/AccessibilityIssue.cxx | 1 |
2 files changed, 40 insertions, 3 deletions
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index 63443bcb89bd..2e3219765e22 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -44,6 +44,9 @@ #include <unotext.hxx> #include <svx/svdoashp.hxx> #include <svx/sdasitm.hxx> +#include <ndgrf.hxx> +#include <svl/fstathelper.hxx> +#include <osl/file.h> namespace sw { @@ -98,13 +101,46 @@ class NoTextNodeAltTextCheck : public NodeCheck if (!pNoTextNode) return; - if (!pNoTextNode->GetTitle().isEmpty() || !pNoTextNode->GetDescription().isEmpty()) - return; - const SwFrameFormat* pFrameFormat = pNoTextNode->GetFlyFormat(); if (!pFrameFormat) return; + // linked graphic with broken link + if (pNoTextNode->IsGrfNode() && pNoTextNode->GetGrfNode()->IsLinkedFile()) + { + OUString sURL(pNoTextNode->GetGrfNode()->GetGraphic().getOriginURL()); + if (!FStatHelper::IsDocument(sURL)) + { + INetURLObject aURL(sURL); + OUString aSystemPath = sURL; + + // abbreviate URL + if (aURL.GetProtocol() == INetProtocol::File) + { + OUString aAbbreviatedPath; + aSystemPath = aURL.getFSysPath(FSysStyle::Detect); + osl_abbreviateSystemPath(aSystemPath.pData, &aAbbreviatedPath.pData, 46, + nullptr); + sURL = aAbbreviatedPath; + } + + OUString sIssueText = SwResId(STR_LINKED_GRAPHIC) + .replaceAll("%OBJECT_NAME%", pFrameFormat->GetName()) + .replaceFirst("%LINK%", sURL); + + auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText, + sfx::AccessibilityIssueID::LINKED_GRAPHIC); + pIssue->setDoc(pNoTextNode->GetDoc()); + pIssue->setIssueObject(IssueObject::LINKED); + pIssue->setObjectID(pNoTextNode->GetFlyFormat()->GetName()); + pIssue->setNode(pNoTextNode); + pIssue->setAdditionalInfo({ aSystemPath }); + } + } + + if (!pNoTextNode->GetTitle().isEmpty() || !pNoTextNode->GetDescription().isEmpty()) + return; + OUString sIssueText = SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", pFrameFormat->GetName()); diff --git a/sw/source/core/access/AccessibilityIssue.cxx b/sw/source/core/access/AccessibilityIssue.cxx index d3a4a1754240..075fa15ceb51 100644 --- a/sw/source/core/access/AccessibilityIssue.cxx +++ b/sw/source/core/access/AccessibilityIssue.cxx @@ -78,6 +78,7 @@ void AccessibilityIssue::gotoIssue() const switch (TempIssueObject.m_eIssueObject) { + case IssueObject::LINKED: case IssueObject::GRAPHIC: case IssueObject::OLE: case IssueObject::TEXTFRAME: |