sw/inc/OnlineAccessibilityCheck.hxx                 |    1 +
 sw/inc/node.hxx                                     |    3 +++
 sw/source/core/docnode/node.cxx                     |   16 ++++++++++++++++
 sw/source/core/txtnode/OnlineAccessibilityCheck.cxx |   17 +++++++++++++++--
 sw/source/core/txtnode/ndtxt.cxx                    |    9 +++++++++
 5 files changed, 44 insertions(+), 2 deletions(-)

New commits:
commit 5e9ba2e6bc08493b10268abdec0c22c1d7c307f6
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sun Nov 13 22:21:29 2022 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Nov 18 11:49:58 2022 +0100

    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>

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 e04266de1037..2807c0a5ef71 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -87,6 +87,7 @@ namespace sw
 struct AccessibilityCheckStatus
 {
     std::unique_ptr<sfx::AccessibilityIssueCollection> pCollection;
+    void reset();
 };
 
 }
@@ -335,6 +336,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 0ac601019a7e..684849468d12 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -70,12 +70,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.
@@ -2189,4 +2199,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 4b2f114d94a3..e1d7e92036e4 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -496,6 +496,9 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & 
rPos,
         }
         SetSmartTagDirty( true );
 
+        resetAndQueueAccessibilityCheck();
+        pNode->resetAndQueueAccessibilityCheck();
+
         if ( pNode->HasHints() )
         {
             if ( pNode->m_pSwpHints->CanBeDeleted() )
@@ -633,6 +636,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);
@@ -1091,6 +1097,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
@@ -1192,6 +1200,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

Reply via email to