summaryrefslogtreecommitdiff
path: root/sw/source/core/access
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-12-05 22:04:35 +0100
committerTomaž Vajngerl <quikee@gmail.com>2019-12-26 00:15:00 +0100
commit53d20484f4c9d5dc152e35a871b03d097d6ad41f (patch)
tree317b46afcb522f9f5c255a36325921afc6e7b676 /sw/source/core/access
parentef6e2b50376ada302958bc982e3dd73d2e0821ca (diff)
Accessibility check base functionality
This adds AccessibilityCheck class to writer, which perfors the accessibility check of the current document to make the document conform to PDF/UA requirements. The first check this adds is check for the "alt" (sometimes also called "title") to be present for graphics, OLE objects (charts) and shapes. Change-Id: I98dcca787099bdb17cab9291546074cdde2ae5a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85820 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw/source/core/access')
-rw-r--r--sw/source/core/access/AccessibilityCheck.cxx75
1 files changed, 75 insertions, 0 deletions
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
new file mode 100644
index 000000000000..64c51e131d45
--- /dev/null
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <AccessibilityCheck.hxx>
+#include <ndgrf.hxx>
+#include <ndole.hxx>
+#include <IDocumentDrawModelAccess.hxx>
+#include <drawdoc.hxx>
+#include <svx/svdpage.hxx>
+
+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)
+ {
+ SwNode* pNode = pNodes[n];
+ if (pNode)
+ {
+ if (pNode->GetNodeType() & SwNodeType::NoTextMask)
+ {
+ SwNoTextNode* pNoTextNode = pNode->GetNoTextNode();
+ if (pNoTextNode)
+ {
+ OUString sAlternative = pNoTextNode->GetTitle();
+ if (sAlternative.isEmpty())
+ {
+ OUString sName = pNoTextNode->GetFlyFormat()->GetName();
+ AccessibilityIssue aIssue;
+ aIssue.m_aIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName);
+ m_aAccessibilityIssueCollection.push_back(aIssue);
+ }
+ }
+ }
+ }
+ }
+
+ // Check Shapes, TextBox
+ IDocumentDrawModelAccess& rDrawModelAccess = m_pDoc->getIDocumentDrawModelAccess();
+ auto* pModel = rDrawModelAccess.GetDrawModel();
+ for (sal_uInt16 nPage = 0; nPage < pModel->GetPageCount(); ++nPage)
+ {
+ SdrPage* pPage = pModel->GetPage(nPage);
+ 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();
+ AccessibilityIssue aIssue;
+ aIssue.m_aIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName);
+ m_aAccessibilityIssueCollection.push_back(aIssue);
+ }
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */