summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/AccessibilityIssue.hxx1
-rw-r--r--sw/inc/AccessibilityCheckStrings.hrc1
-rw-r--r--sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx11
-rw-r--r--sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odtbin0 -> 8263 bytes
-rw-r--r--sw/source/core/access/AccessibilityCheck.cxx42
5 files changed, 55 insertions, 0 deletions
diff --git a/include/sfx2/AccessibilityIssue.hxx b/include/sfx2/AccessibilityIssue.hxx
index 4cc9a72e7c19..085863cbd405 100644
--- a/include/sfx2/AccessibilityIssue.hxx
+++ b/include/sfx2/AccessibilityIssue.hxx
@@ -22,6 +22,7 @@ enum class AccessibilityIssueID
UNSPECIFIED, // TODO: remove - temporary
DOCUMENT_TITLE,
DOCUMENT_LANGUAGE,
+ DOCUMENT_BACKGROUND,
STYLE_LANGUAGE,
NO_ALT_OLE,
NO_ALT_GRAPHIC,
diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc
index 2c098e50edc8..858de1a47d93 100644
--- a/sw/inc/AccessibilityCheckStrings.hrc
+++ b/sw/inc/AccessibilityCheckStrings.hrc
@@ -21,6 +21,7 @@
#define STR_TEXT_BLINKING NC_("STR_TEXT_BLINKING", "Blinking text.")
#define STR_AVOID_FOOTNOTES NC_("STR_AVOID_FOOTNOTES", "Avoid footnotes.")
#define STR_AVOID_ENDNOTES NC_("STR_AVOID_ENDNOTES", "Avoid endnotes.")
+#define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", "Avoid background images.")
#define STR_HEADINGS_NOT_IN_ORDER NC_("STR_HEADINGS_NOT_IN_ORDER", "Headings not in order.")
#define STR_TEXT_FORMATTING_CONVEYS_MEANING NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys additional meaning.")
#define STR_NON_INTERACTIVE_FORMS NC_("STR_NON_INTERACTIVE_FORMS", "An input form is not interactive.")
diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
index d7ad7674c13b..2c36d2b5d4e7 100644
--- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
+++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
@@ -59,6 +59,17 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckParagraphIssues)
CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID);
}
+CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckBackgroundImage)
+{
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "BackgroundImageTest.odt");
+ CPPUNIT_ASSERT(pDoc);
+ sw::AccessibilityCheck aCheck(pDoc);
+ aCheck.check();
+ auto& aIssues = aCheck.getIssueCollection().getIssues();
+ CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size());
+ CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND, aIssues[0]->m_eIssueID);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt b/sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt
new file mode 100644
index 000000000000..eff6f178394b
--- /dev/null
+++ b/sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt
Binary files differ
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index f6c6ec7b43d5..de0a5bf63472 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <unoparagraph.hxx>
#include <tools/urlobj.hxx>
#include <editeng/langitem.hxx>
@@ -898,6 +899,46 @@ public:
}
};
+class BackgroundImageCheck : public DocumentCheck
+{
+public:
+ BackgroundImageCheck(sfx::AccessibilityIssueCollection& rIssueCollection)
+ : DocumentCheck(rIssueCollection)
+ {
+ }
+ void check(SwDoc* pDoc) override
+ {
+ uno::Reference<lang::XComponent> xDoc = pDoc->GetDocShell()->GetBaseModel();
+ uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xDoc, uno::UNO_QUERY);
+ if (!xStyleFamiliesSupplier.is())
+ return;
+ uno::Reference<container::XNameAccess> xStyleFamilies
+ = xStyleFamiliesSupplier->getStyleFamilies();
+ uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"),
+ uno::UNO_QUERY);
+ if (!xStyleFamily.is())
+ return;
+ const uno::Sequence<OUString>& xStyleFamilyNames = xStyleFamily->getElementNames();
+ for (const OUString& rStyleFamilyName : xStyleFamilyNames)
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(
+ xStyleFamily->getByName(rStyleFamilyName), uno::UNO_QUERY);
+ if (!xPropertySet.is())
+ continue;
+ auto aFillStyleContainer = xPropertySet->getPropertyValue("FillStyle");
+ if (aFillStyleContainer.has<drawing::FillStyle>())
+ {
+ drawing::FillStyle aFillStyle = aFillStyleContainer.get<drawing::FillStyle>();
+ if (aFillStyle == drawing::FillStyle_BITMAP)
+ {
+ lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_BACKGROUND_IMAGES),
+ sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND);
+ }
+ }
+ }
+ }
+};
+
} // end anonymous namespace
// Check Shapes, TextBox
@@ -945,6 +986,7 @@ void AccessibilityCheck::check()
aDocumentChecks.push_back(std::make_unique<DocumentDefaultLanguageCheck>(m_aIssueCollection));
aDocumentChecks.push_back(std::make_unique<DocumentTitleCheck>(m_aIssueCollection));
aDocumentChecks.push_back(std::make_unique<FootnoteEndnoteCheck>(m_aIssueCollection));
+ aDocumentChecks.push_back(std::make_unique<BackgroundImageCheck>(m_aIssueCollection));
for (std::unique_ptr<DocumentCheck>& rpDocumentCheck : aDocumentChecks)
{