sw/inc/OnlineAccessibilityCheck.hxx                 |    3 ++
 sw/inc/node.hxx                                     |    3 ++
 sw/source/core/access/AccessibilityCheck.cxx        |   12 +++++++-
 sw/source/core/docnode/node.cxx                     |   16 +++++++++++
 sw/source/core/inc/AccessibilityCheck.hxx           |    1 
 sw/source/core/txtnode/OnlineAccessibilityCheck.cxx |   28 ++++++++++++++++++--
 sw/source/core/txtnode/ndtxt.cxx                    |    9 ++++++
 7 files changed, 69 insertions(+), 3 deletions(-)

New commits:
commit fd56017db598ae7a9a955414cfed07e11014b56c
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sun Nov 13 22:21:29 2022 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sat Dec 24 12:16:57 2022 +0000

    sw: handle joining and splitting nodes for online a11y check
    
    Change-Id: I706bf56209beebbe2987bce436536c3d9ade51f1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142655
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 5e9ba2e6bc08493b10268abdec0c22c1d7c307f6)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144497
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/inc/OnlineAccessibilityCheck.hxx 
b/sw/inc/OnlineAccessibilityCheck.hxx
index 3d68a71f11db..5e1da9b77c99 100644
--- a/sw/inc/OnlineAccessibilityCheck.hxx
+++ b/sw/inc/OnlineAccessibilityCheck.hxx
@@ -66,6 +66,7 @@ private:
 public:
     OnlineAccessibilityCheck(SwDoc& rDocument);
     void update(SwPosition const& rNewPos);
+    void resetAndQueue(SwNode* pNode);
     sal_Int32 getNumberOfAccessibilityIssues() { return 
m_nAccessibilityIssues; }
 };
 
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 8099178c1eaf..a3b9e13ad52d 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -86,6 +86,7 @@ namespace sw
 struct AccessibilityCheckStatus
 {
     std::unique_ptr<sfx::AccessibilityIssueCollection> pCollection;
+    void reset();
 };
 
 }
@@ -324,6 +325,8 @@ public:
         return m_aAccessibilityCheckStatus;
     }
 
+    void resetAndQueueAccessibilityCheck();
+
 private:
     SwNode( const SwNode & rNodes ) = delete;
     SwNode & operator= ( const SwNode & rNodes ) = delete;
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 8a319c03e7aa..a1a549d25069 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -69,12 +69,22 @@
 #include <swcrsr.hxx>
 #include <hints.hxx>
 #include <frameformats.hxx>
+#include <OnlineAccessibilityCheck.hxx>
 #ifdef DBG_UTIL
 #include <sal/backtrace.hxx>
 #endif
 
 using namespace ::com::sun::star::i18n;
 
+namespace sw
+{
+
+void AccessibilityCheckStatus::reset()
+{
+    pCollection.reset();
+}
+
+}
 
 /*
  * Some local helper functions for the attribute set handle of a content node.
@@ -2142,4 +2152,10 @@ void SwNode::RemoveAnchoredFly(SwFrameFormat *const 
pFlyFormat)
     m_aAnchoredFlys.erase(it);
 }
 
+void SwNode::resetAndQueueAccessibilityCheck()
+{
+    GetDoc().getOnlineAccessibilityCheck()->resetAndQueue(this);
+}
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx 
b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
index 1188bc7d06c5..d162e1a661ba 100644
--- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
+++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
@@ -263,8 +263,7 @@ void 
OnlineAccessibilityCheck::clearAccessibilityIssuesFromAllNodes()
         SwNode* pNode = pNodes[n];
         if (pNode)
         {
-            auto& rStatus = pNode->getAccessibilityCheckStatus();
-            rStatus.pCollection.reset();
+            pNode->getAccessibilityCheckStatus().reset();
         }
     }
 
@@ -272,6 +271,20 @@ void 
OnlineAccessibilityCheck::clearAccessibilityIssuesFromAllNodes()
     updateStatusbar();
 }
 
+void OnlineAccessibilityCheck::resetAndQueue(SwNode* pNode)
+{
+    bool bOnlineCheckStatus
+        = 
officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get();
+    if (!bOnlineCheckStatus)
+        return;
+
+    pNode->getAccessibilityCheckStatus().reset();
+    m_aNodes.erase(pNode);
+    runAccessibilityCheck(pNode);
+    updateNodeStatus(pNode);
+    updateStatusbar();
+}
+
 } // end sw
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 8eeb9b6cdf59..b3880c24fcc2 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -481,6 +481,9 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & 
rPos,
         }
         SetSmartTagDirty( true );
 
+        resetAndQueueAccessibilityCheck();
+        pNode->resetAndQueueAccessibilityCheck();
+
         if ( pNode->HasHints() )
         {
             if ( pNode->m_pSwpHints->CanBeDeleted() )
@@ -618,6 +621,9 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & 
rPos,
             SetSmartTags( std::move(pList2) );
         }
 
+        resetAndQueueAccessibilityCheck();
+        pNode->resetAndQueueAccessibilityCheck();
+
         if (pContentIndexRestore)
         {   // call before making frames and before RegisterToNode
             (*pContentIndexRestore)(pNode, sw::mark::RestoreMode::NonFlys, 
false);
@@ -1076,6 +1082,8 @@ SwContentNode *SwTextNode::JoinNext()
         SetGrammarCheck( std::move(pList3) );
         SetSmartTags( std::move(pList2) );
 
+        resetAndQueueAccessibilityCheck();
+
         if (bOldHasNumberingWhichNeedsLayoutUpdate || 
HasNumberingWhichNeedsLayoutUpdate(*this))
         {
             // Repaint all text frames that belong to this numbering to avoid 
outdated generated
@@ -1177,6 +1185,7 @@ void SwTextNode::JoinPrev()
         SetWrong( std::move(pList) );
         SetGrammarCheck( std::move(pList3) );
         SetSmartTags( std::move(pList2) );
+        resetAndQueueAccessibilityCheck();
         InvalidateNumRule();
         sw::CheckResetRedlineMergeFlag(*this,
                 eOldMergeFlag == SwNode::Merge::NonFirst
commit 7c9594b9a4a60348eddf7daeffd440c708dfe89d
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Oct 31 11:09:46 2022 +0100
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sat Dec 24 12:16:52 2022 +0000

    sw: run document properties a11y checks on a loaded document
    
    Change-Id: Iba98a91a61955af52651348409f88244d1eed2c1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142216
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 45d1fca81991f0d6837c98d6be6fe0d21d566fa5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144496
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sw/inc/OnlineAccessibilityCheck.hxx 
b/sw/inc/OnlineAccessibilityCheck.hxx
index fe4652949d64..3d68a71f11db 100644
--- a/sw/inc/OnlineAccessibilityCheck.hxx
+++ b/sw/inc/OnlineAccessibilityCheck.hxx
@@ -53,6 +53,7 @@ private:
     sal_Int32 m_nAccessibilityIssues;
     bool m_bInitialCheck;
     bool m_bOnlineCheckStatus;
+    std::unique_ptr<sfx::AccessibilityIssueCollection> 
m_pDocumentAccessibilityIssues;
 
     void runAccessibilityCheck(SwNode* pNode);
     void updateStatusbar();
@@ -60,6 +61,7 @@ private:
     void initialCheck();
     void lookForPreviousNodeAndUpdate(SwPosition const& rNewPos);
     void clearAccessibilityIssuesFromAllNodes();
+    void runDocumentLevelAccessibilityCheck();
 
 public:
     OnlineAccessibilityCheck(SwDoc& rDocument);
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index d984fef8336a..ea3cf4edaaa5 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -1410,7 +1410,7 @@ void AccessibilityCheck::checkNode(SwNode* pNode)
     }
 }
 
-void AccessibilityCheck::check()
+void AccessibilityCheck::checkDocumentProperties()
 {
     if (m_pDoc == nullptr)
         return;
@@ -1423,6 +1423,16 @@ void AccessibilityCheck::check()
         if (pDocumentCheck)
             pDocumentCheck->check(m_pDoc);
     }
+}
+
+void AccessibilityCheck::check()
+{
+    if (m_pDoc == nullptr)
+        return;
+
+    init();
+
+    checkDocumentProperties();
 
     auto const& pNodes = m_pDoc->GetNodes();
     SwNode* pNode = nullptr;
diff --git a/sw/source/core/inc/AccessibilityCheck.hxx 
b/sw/source/core/inc/AccessibilityCheck.hxx
index 1ff4cf5b16f7..c7613e8829a4 100644
--- a/sw/source/core/inc/AccessibilityCheck.hxx
+++ b/sw/source/core/inc/AccessibilityCheck.hxx
@@ -51,6 +51,7 @@ public:
     void check() override;
     void checkObject(SdrObject* pObject);
     void checkNode(SwNode* pNode);
+    void checkDocumentProperties();
 };
 
 } // end sw namespace
diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx 
b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
index db1212600644..1188bc7d06c5 100644
--- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
+++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
@@ -135,11 +135,22 @@ void 
OnlineAccessibilityCheck::runAccessibilityCheck(SwNode* pNode)
         = std::make_unique<sfx::AccessibilityIssueCollection>(aCollection);
 }
 
+void OnlineAccessibilityCheck::runDocumentLevelAccessibilityCheck()
+{
+    m_aAccessibilityCheck.getIssueCollection().clear();
+    m_aAccessibilityCheck.checkDocumentProperties();
+    auto aCollection = m_aAccessibilityCheck.getIssueCollection();
+    m_pDocumentAccessibilityIssues
+        = std::make_unique<sfx::AccessibilityIssueCollection>(aCollection);
+}
+
 void OnlineAccessibilityCheck::initialCheck()
 {
     if (m_bInitialCheck)
         return;
 
+    runDocumentLevelAccessibilityCheck();
+
     auto const& pNodes = m_rDocument.GetNodes();
     for (SwNodeOffset n(0); n < pNodes.Count(); ++n)
     {

Reply via email to