summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-12-25 13:27:32 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-12-25 13:39:19 +0100
commitf3465f3f024ddd3d8406c0cf6a74fda8266ab339 (patch)
treec9138c28af137b81913b2775c62d0567e7e72348
parentpdf: Add option for PDF/UA to the PDF export dialog (diff)
downloadcore-feature/accessibilitycheck.tar.gz
core-feature/accessibilitycheck.zip
acc. check: implement goto for OLE/Graphic objects feature/accessibilitycheck
This implements goto function for Graphic/OLE objects that are reported in a AccessibilityCheckResult. So this enables to go to the object inside a document for which we have reported an accessibility issue. Change-Id: I699966b116a76ea032cb1acc9a431687fa204e07
-rw-r--r--include/svx/AccessibilityCheck.hxx1
-rw-r--r--svx/source/dialog/AccessibilityCheckDialog.cxx1
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/source/core/access/AccessibilityCheck.cxx21
-rw-r--r--sw/source/core/access/AccessibilityCheckResult.cxx58
-rw-r--r--sw/source/core/inc/AccessibilityCheck.hxx13
-rw-r--r--sw/source/core/inc/AccessibilityCheckResult.hxx49
7 files changed, 129 insertions, 15 deletions
diff --git a/include/svx/AccessibilityCheck.hxx b/include/svx/AccessibilityCheck.hxx
index ba4b01d9d6a5..23fdd31c6e8a 100644
--- a/include/svx/AccessibilityCheck.hxx
+++ b/include/svx/AccessibilityCheck.hxx
@@ -37,6 +37,7 @@ public:
{
}
virtual ~AccessibilityCheckResult() {}
+ virtual bool canGotoIssue() const = 0;
virtual void gotoIssue() const = 0;
};
diff --git a/svx/source/dialog/AccessibilityCheckDialog.cxx b/svx/source/dialog/AccessibilityCheckDialog.cxx
index e88ca36ebb89..8189f5e9ba65 100644
--- a/svx/source/dialog/AccessibilityCheckDialog.cxx
+++ b/svx/source/dialog/AccessibilityCheckDialog.cxx
@@ -24,6 +24,7 @@ AccessibilityCheckEntry::AccessibilityCheckEntry(
, m_rAccessibilityCheckResult(rAccessibilityCheckResult)
{
m_xLabel->set_label(m_rAccessibilityCheckResult->m_aIssueText);
+ m_xGotoButton->set_visible(rAccessibilityCheckResult->canGotoIssue());
m_xGotoButton->connect_clicked(LINK(this, AccessibilityCheckEntry, GotoButtonClicked));
m_xContainer->show();
}
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index acab4210994b..8fa7132da457 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -96,6 +96,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/SwNumberTree/SwNodeNum \
sw/source/core/SwNumberTree/SwNumberTree \
sw/source/core/access/AccessibilityCheck \
+ sw/source/core/access/AccessibilityCheckResult \
sw/source/core/access/acccell \
sw/source/core/access/acccontext \
sw/source/core/access/accdoc \
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index b06f9012f738..78571c50f786 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -45,12 +45,14 @@ OUString sTextBlinking("Blinking text.");
OUString sAvoidFootnotes("Avoid footnotes.");
OUString sAvoidEndnotes("Avoid endnotes.");
-void lclAddIssue(svx::AccessibilityCheckResultCollection& rResultCollection, OUString const& rText,
- svx::AccessibilityIssueID eIssue = svx::AccessibilityIssueID::UNSPECIFIED)
+std::shared_ptr<sw::AccessibilityCheckResult>
+lclAddIssue(svx::AccessibilityCheckResultCollection& rResultCollection, OUString const& rText,
+ svx::AccessibilityIssueID eIssue = svx::AccessibilityIssueID::UNSPECIFIED)
{
auto pResult = std::make_shared<sw::AccessibilityCheckResult>(eIssue);
pResult->m_aIssueText = rText;
rResultCollection.getResults().push_back(pResult);
+ return pResult;
}
}
@@ -91,7 +93,20 @@ class NoTextNodeAltTextCheck : public NodeCheck
{
OUString sName = pNoTextNode->GetFlyFormat()->GetName();
OUString sIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName);
- lclAddIssue(m_rResultCollection, sIssueText);
+ auto pResult = lclAddIssue(m_rResultCollection, sIssueText);
+
+ if (pNoTextNode->IsOLENode())
+ {
+ pResult->setDoc(pNoTextNode->GetDoc());
+ pResult->setIssueObject(IssueObject::OLE);
+ pResult->setObjectID(pNoTextNode->GetFlyFormat()->GetName());
+ }
+ else if (pNoTextNode->IsGrfNode())
+ {
+ pResult->setDoc(pNoTextNode->GetDoc());
+ pResult->setIssueObject(IssueObject::GRAPHIC);
+ pResult->setObjectID(pNoTextNode->GetFlyFormat()->GetName());
+ }
}
}
diff --git a/sw/source/core/access/AccessibilityCheckResult.cxx b/sw/source/core/access/AccessibilityCheckResult.cxx
new file mode 100644
index 000000000000..6d85cb040f0c
--- /dev/null
+++ b/sw/source/core/access/AccessibilityCheckResult.cxx
@@ -0,0 +1,58 @@
+/* -*- 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 <AccessibilityCheckResult.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+
+namespace sw
+{
+AccessibilityCheckResult::AccessibilityCheckResult(svx::AccessibilityIssueID eIssueID)
+ : svx::AccessibilityCheckResult(eIssueID)
+ , m_eIssueObject(IssueObject::UNKNOWN)
+ , m_pDoc(nullptr)
+{
+}
+
+void AccessibilityCheckResult::setIssueObject(IssueObject eIssueObject)
+{
+ m_eIssueObject = eIssueObject;
+}
+
+void AccessibilityCheckResult::setDoc(SwDoc* pDoc) { m_pDoc = pDoc; }
+
+void AccessibilityCheckResult::setObjectID(OUString const& rID) { m_sObjectID = rID; }
+
+bool AccessibilityCheckResult::canGotoIssue() const
+{
+ if (m_eIssueObject != IssueObject::UNKNOWN)
+ return true;
+ return false;
+}
+
+void AccessibilityCheckResult::gotoIssue() const
+{
+ switch (m_eIssueObject)
+ {
+ case IssueObject::GRAPHIC:
+ case IssueObject::OLE:
+ {
+ SwWrtShell* pWrtShell = m_pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->GotoFly(m_sObjectID, FLYCNTTYPE_ALL, true);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+} // end sw namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/AccessibilityCheck.hxx b/sw/source/core/inc/AccessibilityCheck.hxx
index 05a88a3a4975..741d3159d484 100644
--- a/sw/source/core/inc/AccessibilityCheck.hxx
+++ b/sw/source/core/inc/AccessibilityCheck.hxx
@@ -12,22 +12,11 @@
#define INCLUDED_SW_SOURCE_CORE_ACCESSIBILITYCHECK_HXX
#include <svx/AccessibilityCheck.hxx>
+#include <AccessibilityCheckResult.hxx>
#include <doc.hxx>
namespace sw
{
-class SW_DLLPUBLIC AccessibilityCheckResult final : public svx::AccessibilityCheckResult
-{
-public:
- AccessibilityCheckResult(svx::AccessibilityIssueID eIssueID
- = svx::AccessibilityIssueID::UNSPECIFIED)
- : svx::AccessibilityCheckResult(eIssueID)
- {
- }
-
- void gotoIssue() const override {}
-};
-
class SW_DLLPUBLIC AccessibilityCheck final : public svx::AccessibilityCheck
{
private:
diff --git a/sw/source/core/inc/AccessibilityCheckResult.hxx b/sw/source/core/inc/AccessibilityCheckResult.hxx
new file mode 100644
index 000000000000..ffc46a86412f
--- /dev/null
+++ b/sw/source/core/inc/AccessibilityCheckResult.hxx
@@ -0,0 +1,49 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef INCLUDED_SW_SOURCE_CORE_ACCESSIBILITYCHECKRESULT_HXX
+#define INCLUDED_SW_SOURCE_CORE_ACCESSIBILITYCHECKRESULT_HXX
+
+#include <svx/AccessibilityCheck.hxx>
+#include <doc.hxx>
+
+namespace sw
+{
+enum class IssueObject
+{
+ UNKNOWN,
+ GRAPHIC,
+ OLE,
+};
+
+class SW_DLLPUBLIC AccessibilityCheckResult final : public svx::AccessibilityCheckResult
+{
+private:
+ IssueObject m_eIssueObject;
+ SwDoc* m_pDoc;
+ OUString m_sObjectID;
+
+public:
+ AccessibilityCheckResult(svx::AccessibilityIssueID eIssueID
+ = svx::AccessibilityIssueID::UNSPECIFIED);
+
+ void setIssueObject(IssueObject eIssueObject);
+ void setDoc(SwDoc* pDoc);
+ void setObjectID(OUString const& rID);
+
+ bool canGotoIssue() const override;
+ void gotoIssue() const override;
+};
+
+} // end sw namespace
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */