sw/inc/OnlineAccessibilityCheck.hxx                 |    4 ++
 sw/source/core/txtnode/OnlineAccessibilityCheck.cxx |   30 ++++++++++++++++++--
 2 files changed, 30 insertions(+), 4 deletions(-)

New commits:
commit ef0858071faf93ce48237ea3948f50e288eb702b
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Oct 24 22:38:56 2022 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Thu Nov 17 05:47:28 2022 +0100

    sw: initial a11y check - first run when the document is opened
    
    When the document is opened we first need to run the a11y check
    on the whole document so we can report the a11y state in the
    statusbar and set the a11y issues to the nodes.
    
    Change-Id: I0573e8fd695e3b0560fa0554f4702c88e7980a13
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141786
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sw/inc/OnlineAccessibilityCheck.hxx 
b/sw/inc/OnlineAccessibilityCheck.hxx
index 9ec6f28ba6b1..47e42a27de29 100644
--- a/sw/inc/OnlineAccessibilityCheck.hxx
+++ b/sw/inc/OnlineAccessibilityCheck.hxx
@@ -51,10 +51,12 @@ private:
     SwContentNode* m_pPreviousNode;
     SwNodeOffset m_nPreviousNodeIndex;
     sal_Int32 m_nAccessibilityIssues;
+    bool m_bInitialCheck;
 
-    void runCheck(SwContentNode* pNode);
+    void runAccessibilityCheck(SwContentNode* pNode);
     void updateStatusbar();
     void updateNodeStatus(SwContentNode* pContentNode);
+    void initialCheck();
 
 public:
     OnlineAccessibilityCheck(SwDoc& rDocument);
diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx 
b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
index a2a9783c3fd1..7fb93c070f0f 100644
--- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
+++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
@@ -61,6 +61,7 @@ OnlineAccessibilityCheck::OnlineAccessibilityCheck(SwDoc& 
rDocument)
     , m_pPreviousNode(nullptr)
     , m_nPreviousNodeIndex(-1)
     , m_nAccessibilityIssues(0)
+    , m_bInitialCheck(false)
 {
 }
 
@@ -106,7 +107,7 @@ void OnlineAccessibilityCheck::updateStatusbar()
         pBindings->Invalidate(FN_STAT_ACCESSIBILITY_CHECK);
 }
 
-void OnlineAccessibilityCheck::runCheck(SwContentNode* pContentNode)
+void OnlineAccessibilityCheck::runAccessibilityCheck(SwContentNode* 
pContentNode)
 {
     m_aAccessibilityCheck.getIssueCollection().clear();
 
@@ -123,9 +124,28 @@ void OnlineAccessibilityCheck::runCheck(SwContentNode* 
pContentNode)
 
     pContentNode->getAccessibilityCheckStatus().pCollection
         = std::make_unique<sfx::AccessibilityIssueCollection>(aCollection);
+}
+
+void OnlineAccessibilityCheck::initialCheck()
+{
+    if (m_bInitialCheck)
+        return;
+
+    auto const& pNodes = m_rDocument.GetNodes();
+    for (SwNodeOffset n(0); n < pNodes.Count(); ++n)
+    {
+        SwNode* pNode = pNodes[n];
+        if (pNode && pNode->IsContentNode())
+        {
+            auto* pCurrent = pNode->GetContentNode();
+            runAccessibilityCheck(pCurrent);
+            updateNodeStatus(pCurrent);
+        }
+    }
 
-    updateNodeStatus(pContentNode);
     updateStatusbar();
+
+    m_bInitialCheck = true;
 }
 
 void OnlineAccessibilityCheck::update(const SwPosition& rNewPos)
@@ -174,7 +194,9 @@ void OnlineAccessibilityCheck::update(const SwPosition& 
rNewPos)
     {
         auto* pContentNode = pNode->GetContentNode();
 
-        runCheck(pContentNode);
+        runAccessibilityCheck(pContentNode);
+        updateNodeStatus(pContentNode);
+        updateStatusbar();
 
         // Assign previous node and index
         EndListeningAll();
@@ -187,6 +209,8 @@ void OnlineAccessibilityCheck::update(const SwPosition& 
rNewPos)
         m_pPreviousNode = nullptr;
         m_nPreviousNodeIndex = SwNodeOffset(-1);
     }
+
+    initialCheck();
 }
 
 } // end sw

Reply via email to