[Libreoffice-commits] core.git: Branch 'feature/accessibilitycheck' - 2 commits - sw/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sun Dec 15 18:04:25 UTC 2019


 sw/source/core/access/AccessibilityCheck.cxx |   87 +++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)

New commits:
commit 071dd016424fce45e3c38172d92716e052dde1ff
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Dec 15 19:02:16 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sun Dec 15 19:02:16 2019 +0100

    acc. check: check for endnotes and footnotes
    
    Endnotes and footnotes cause problems for accessibility and should
    be avoided.
    
    Change-Id: Ibbce4d246f76feb8d389a7ba588836e2fef8f5d5

diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index 90e1a6eb658c..c37f5975a04b 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -25,6 +25,8 @@
 #include <charatr.hxx>
 #include <svx/xfillit0.hxx>
 #include <svx/xflclit.hxx>
+#include <ftnidx.hxx>
+#include <txtftn.hxx>
 
 namespace sw
 {
@@ -40,6 +42,8 @@ OUString sStyleNoLanguage("Style '%STYLE_NAME%' has no language set");
 OUString sDocumentTitle("Document title is not set");
 OUString sTextContrast("Text contrast is too low.");
 OUString sTextBlinking("Blinking text.");
+OUString sAvoidFootnotes("Avoid footnotes.");
+OUString sAvoidEndnotes("Avoid endnotes.");
 }
 
 class BaseCheck
@@ -529,6 +533,35 @@ public:
     }
 };
 
+class FootnoteEndnoteCheck : public DocumentCheck
+{
+public:
+    FootnoteEndnoteCheck(std::vector<svx::AccessibilityCheckResult>& rResultCollection)
+        : DocumentCheck(rResultCollection)
+    {
+    }
+
+    void check(SwDoc* pDoc) override
+    {
+        for (SwTextFootnote const* pTextFootnote : pDoc->GetFootnoteIdxs())
+        {
+            SwFormatFootnote const& rFootnote = pTextFootnote->GetFootnote();
+            if (rFootnote.IsEndNote())
+            {
+                svx::AccessibilityCheckResult aResult;
+                aResult.m_aIssueText = sAvoidEndnotes;
+                m_rResultCollection.push_back(aResult);
+            }
+            else
+            {
+                svx::AccessibilityCheckResult aResult;
+                aResult.m_aIssueText = sAvoidFootnotes;
+                m_rResultCollection.push_back(aResult);
+            }
+        }
+    }
+};
+
 // Check Shapes, TextBox
 void AccessibilityCheck::checkObject(SdrObject* pObject)
 {
@@ -556,6 +589,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));
+    aDocumentChecks.push_back(std::make_unique<FootnoteEndnoteCheck>(m_aResultCollection));
 
     for (std::unique_ptr<DocumentCheck>& rpDocumentCheck : aDocumentChecks)
     {
commit ff3efe7b148eb2b50beb379221f8f919275fcaf3
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Dec 15 17:36:24 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sun Dec 15 17:36:24 2019 +0100

    acc. check: check for blinking text
    
    Change-Id: If023c9b6c6225a3889f2fd68b8ed62abb4365d48

diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index 062bea8f18fb..90e1a6eb658c 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -39,6 +39,7 @@ OUString sDocumentDefaultLanguage("Document default language is not set");
 OUString sStyleNoLanguage("Style '%STYLE_NAME%' has no language set");
 OUString sDocumentTitle("Document title is not set");
 OUString sTextContrast("Text contrast is too low.");
+OUString sTextBlinking("Blinking text.");
 }
 
 class BaseCheck
@@ -399,6 +400,57 @@ public:
     }
 };
 
+class BlinkingTextCheck : public NodeCheck
+{
+private:
+    void checkTextRange(uno::Reference<text::XTextRange> const& xTextRange)
+    {
+        uno::Reference<beans::XPropertySet> xProperties(xTextRange, uno::UNO_QUERY);
+        if (xProperties.is() && xProperties->getPropertySetInfo()->hasPropertyByName("CharFlash"))
+        {
+            bool bBlinking = false;
+            xProperties->getPropertyValue("CharFlash") >>= bBlinking;
+
+            if (bBlinking)
+            {
+                svx::AccessibilityCheckResult aResult;
+                aResult.m_aIssueText = sTextBlinking;
+                m_rResultCollection.push_back(aResult);
+            }
+        }
+    }
+
+public:
+    BlinkingTextCheck(
+        std::vector<svx::AccessibilityCheckResult>& rAccessibilityCheckResultCollection)
+        : NodeCheck(rAccessibilityCheckResultCollection)
+    {
+    }
+
+    void check(SwNode* pCurrent) override
+    {
+        if (pCurrent->IsTextNode())
+        {
+            SwTextNode* pTextNode = pCurrent->GetTextNode();
+            uno::Reference<text::XTextContent> xParagraph;
+            xParagraph = SwXParagraph::CreateXParagraph(*pTextNode->GetDoc(), pTextNode);
+            if (xParagraph.is())
+            {
+                uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph,
+                                                                             uno::UNO_QUERY);
+                uno::Reference<container::XEnumeration> xRunEnum
+                    = xRunEnumAccess->createEnumeration();
+                while (xRunEnum->hasMoreElements())
+                {
+                    uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+                    if (xRun.is())
+                        checkTextRange(xRun);
+                }
+            }
+        }
+    }
+};
+
 class DocumentCheck : public BaseCheck
 {
 public:
@@ -516,6 +568,7 @@ void AccessibilityCheck::check()
     aNodeChecks.push_back(std::make_unique<NumberingCheck>(m_aResultCollection));
     aNodeChecks.push_back(std::make_unique<HyperlinkCheck>(m_aResultCollection));
     aNodeChecks.push_back(std::make_unique<TextContrastCheck>(m_aResultCollection));
+    aNodeChecks.push_back(std::make_unique<BlinkingTextCheck>(m_aResultCollection));
 
     auto const& pNodes = m_pDoc->GetNodes();
     SwNode* pNode = nullptr;


More information about the Libreoffice-commits mailing list