diff options
-rw-r--r-- | include/svx/AccessibilityIssue.hxx | 14 | ||||
-rw-r--r-- | sw/CppunitTest_sw_core_accessibilitycheck.mk | 69 | ||||
-rw-r--r-- | sw/Module_sw.mk | 1 | ||||
-rw-r--r-- | sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 40 | ||||
-rw-r--r-- | sw/qa/core/accessibilitycheck/data/DocumentTest.odt | bin | 0 -> 9338 bytes | |||
-rw-r--r-- | sw/source/core/access/AccessibilityCheck.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/inc/AccessibilityCheck.hxx | 2 |
7 files changed, 128 insertions, 4 deletions
diff --git a/include/svx/AccessibilityIssue.hxx b/include/svx/AccessibilityIssue.hxx index 894439c54fec..9d9143aef683 100644 --- a/include/svx/AccessibilityIssue.hxx +++ b/include/svx/AccessibilityIssue.hxx @@ -15,9 +15,23 @@ namespace svx { +enum class AccessibilityIssueID +{ + UNSPECIFIED, // TODO: remove - temporary + DOCUMENT_TITLE, + DOCUMENT_LANGUAGE, + STYLE_LANGUAGE +}; + class SVX_DLLPUBLIC AccessibilityIssue { public: + AccessibilityIssue(AccessibilityIssueID eIssueID = AccessibilityIssueID::UNSPECIFIED) + : m_eIssueID(eIssueID) + { + } + + AccessibilityIssueID m_eIssueID; OUString m_aIssueText; }; } diff --git a/sw/CppunitTest_sw_core_accessibilitycheck.mk b/sw/CppunitTest_sw_core_accessibilitycheck.mk new file mode 100644 index 000000000000..3927603c400b --- /dev/null +++ b/sw/CppunitTest_sw_core_accessibilitycheck.mk @@ -0,0 +1,69 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sw_core_accessibilitycheck)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_accessibilitycheck)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_accessibilitycheck, \ + sw/qa/core/accessibilitycheck/AccessibilityCheckTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_core_accessibilitycheck, \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + svx \ + sfx \ + sw \ + test \ + unotest \ + utl \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_core_accessibilitycheck,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_core_accessibilitycheck,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/source/uibase/inc \ + -I$(SRCDIR)/sw/qa/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_core_accessibilitycheck,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_core_accessibilitycheck)) +$(eval $(call gb_CppunitTest_use_vcl,sw_core_accessibilitycheck)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_core_accessibilitycheck,services)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_accessibilitycheck,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_core_accessibilitycheck)) + +$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_accessibilitycheck, \ + modules/swriter \ +)) + +$(eval $(call gb_CppunitTest_use_more_fonts,sw_core_accessibilitycheck)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 101d3b73921b..17b60a0eec14 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -105,6 +105,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_apitests \ CppunitTest_sw_unowriter \ CppunitTest_sw_core_text \ + CppunitTest_sw_core_accessibilitycheck \ )) ifneq ($(DISABLE_GUI),TRUE) diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx new file mode 100644 index 000000000000..1f114c004a6c --- /dev/null +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -0,0 +1,40 @@ +/* -*- 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 <swmodeltestbase.hxx> +#include <wrtsh.hxx> +#include <AccessibilityCheck.hxx> + +class AccessibilityCheckTest : public SwModelTestBase +{ +public: + SwDoc* createDoc(const char* pName = nullptr) + { + load("/sw/qa/core/accessibilitycheck/data/", pName); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + return pTextDoc->GetDocShell()->GetDoc(); + } +}; + +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheck) +{ + SwDoc* pDoc = createDoc("DocumentTest.odt"); + CPPUNIT_ASSERT(pDoc); + sw::AccessibilityCheck aCheck(pDoc); + aCheck.check(); + auto& aIssues = aCheck.getIssueCollecton(); + CPPUNIT_ASSERT_EQUAL(size_t(2), aIssues.size()); + CPPUNIT_ASSERT_EQUAL(svx::AccessibilityIssueID::DOCUMENT_LANGUAGE, aIssues[0].m_eIssueID); + CPPUNIT_ASSERT_EQUAL(svx::AccessibilityIssueID::DOCUMENT_TITLE, aIssues[1].m_eIssueID); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/DocumentTest.odt b/sw/qa/core/accessibilitycheck/data/DocumentTest.odt Binary files differnew file mode 100644 index 000000000000..65b9a7c2fd46 --- /dev/null +++ b/sw/qa/core/accessibilitycheck/data/DocumentTest.odt diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index cce19f896e47..5608e29dff47 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -287,7 +287,7 @@ public: LanguageType eLanguage = rLang.GetLanguage(); if (eLanguage == LANGUAGE_NONE) { - svx::AccessibilityIssue aIssue; + svx::AccessibilityIssue aIssue(svx::AccessibilityIssueID::DOCUMENT_LANGUAGE); aIssue.m_aIssueText = sDocumentDefaultLanguage; m_rIssueCollection.push_back(aIssue); } @@ -298,7 +298,7 @@ public: const SwAttrSet& rAttrSet = pTextFormatCollection->GetAttrSet(); if (rAttrSet.GetLanguage(false).GetLanguage() == LANGUAGE_NONE) { - svx::AccessibilityIssue aIssue; + svx::AccessibilityIssue aIssue(svx::AccessibilityIssueID::STYLE_LANGUAGE); OUString sName = pTextFormatCollection->GetName(); aIssue.m_aIssueText = sStyleNoLanguage.replaceAll("%STYLE_NAME%", sName); m_rIssueCollection.push_back(aIssue); @@ -328,7 +328,7 @@ public: OUString sTitle = xDocumentProperties->getTitle(); if (sTitle.isEmpty()) { - svx::AccessibilityIssue aIssue; + svx::AccessibilityIssue aIssue(svx::AccessibilityIssueID::DOCUMENT_TITLE); aIssue.m_aIssueText = sDocumentTitle; m_rIssueCollection.push_back(aIssue); } diff --git a/sw/source/core/inc/AccessibilityCheck.hxx b/sw/source/core/inc/AccessibilityCheck.hxx index 9e77ca15e125..30bcb90e00a1 100644 --- a/sw/source/core/inc/AccessibilityCheck.hxx +++ b/sw/source/core/inc/AccessibilityCheck.hxx @@ -16,7 +16,7 @@ namespace sw { -class AccessibilityCheck final : public svx::AccessibilityCheck +class SW_DLLPUBLIC AccessibilityCheck final : public svx::AccessibilityCheck { private: SwDoc* m_pDoc; |