diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-12-15 10:26:22 +0100 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-12-25 13:39:17 +0100 |
commit | 4c559d38ad43bd345b9432ee24ee2661dc05f069 (patch) | |
tree | 42322a486c19c564109f8aaa8b6d3058c584f4ed | |
parent | c173cce99f0226cd0f0d7a8be672110926972d85 (diff) |
acc. check: check document contains a document title (metadata)
Change-Id: I09dd2143153e787730d1528de030d8777edcb05f
-rw-r--r-- | sw/source/core/access/AccessibilityCheck.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index e342df2e5bd2..498b4d968d9d 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -12,11 +12,13 @@ #include <ndgrf.hxx> #include <ndole.hxx> #include <ndtxt.hxx> +#include <docsh.hxx> #include <IDocumentDrawModelAccess.hxx> #include <drawdoc.hxx> #include <svx/svdpage.hxx> #include <swtable.hxx> #include <com/sun/star/text/XTextContent.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <unoparagraph.hxx> #include <tools/urlobj.hxx> #include <editeng/langitem.hxx> @@ -33,6 +35,7 @@ OUString sFakeNumbering("Fake numbering '%NUMBERING%'"); OUString sHyperlinkTextIsLink("Hyperlink text is the same as the link address '%LINK%'"); OUString sDocumentDefaultLanguage("Document default language is not set"); OUString sStyleNoLanguage("Style '%STYLE_NAME%' has no language set"); +OUString sDocumentTitle("Document title is not set"); } class BaseCheck @@ -308,6 +311,34 @@ public: } }; +class DocumentTitleCheck : public DocumentCheck +{ +public: + DocumentTitleCheck(std::vector<svx::AccessibilityCheckResult>& rResultCollection) + : DocumentCheck(rResultCollection) + { + } + + void check(SwDoc* pDoc) override + { + SwDocShell* pShell = pDoc->GetDocShell(); + if (pShell) + { + const uno::Reference<document::XDocumentPropertiesSupplier> xDPS(pShell->GetModel(), + uno::UNO_QUERY_THROW); + const uno::Reference<document::XDocumentProperties> xDocumentProperties( + xDPS->getDocumentProperties()); + OUString sTitle = xDocumentProperties->getTitle(); + if (sTitle.isEmpty()) + { + svx::AccessibilityCheckResult aResult; + aResult.m_aIssueText = sDocumentTitle; + m_rResultCollection.push_back(aResult); + } + } + } +}; + // Check Shapes, TextBox void AccessibilityCheck::checkObject(SdrObject* pObject) { @@ -334,6 +365,7 @@ void AccessibilityCheck::check() std::vector<std::unique_ptr<DocumentCheck>> aDocumentChecks; aDocumentChecks.push_back(std::make_unique<DocumentDefaultLanguageCheck>(m_aResultCollection)); + aDocumentChecks.push_back(std::make_unique<DocumentTitleCheck>(m_aResultCollection)); for (std::unique_ptr<DocumentCheck>& rpDocumentCheck : aDocumentChecks) { |