tdf#152576 - A11Y sidebar: improving update of issues on sidebar

Put the empty paragraph nodes to the correct WeakNodeContainer.

Change-Id: I2db5608b0f7a625b6221d9290ea3d2502f4cadea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153469
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index ec2a101..b9eeaaf 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -683,21 +683,20 @@ public:
class NewlineSpacingCheck : public NodeCheck
{
private:
    static SwTextNode* getNextTextNode(SwNode* pCurrent)
    static SwTextNode* getPrevTextNode(SwNode* pCurrent)
    {
        SwTextNode* pTextNode = nullptr;

        auto nIndex = pCurrent->GetIndex();
        auto nCount = pCurrent->GetNodes().Count();

        nIndex++; // go to next node
        nIndex--; // go to previous node

        while (pTextNode == nullptr && nIndex < nCount)
        while (pTextNode == nullptr && nIndex >= SwNodeOffset(0))
        {
            auto pNode = pCurrent->GetNodes()[nIndex];
            if (pNode->IsTextNode())
                pTextNode = pNode->GetTextNode();
            nIndex++;
            nIndex--;
        }

        return pTextNode;
@@ -721,16 +720,16 @@ public:
        auto nParagraphLength = pTextNode->GetText().getLength();
        if (nParagraphLength == 0)
        {
            SwTextNode* pNextTextNode = getNextTextNode(pCurrent);
            if (!pNextTextNode)
            SwTextNode* pPrevTextNode = getPrevTextNode(pCurrent);
            if (!pPrevTextNode)
                return;
            if (pNextTextNode->GetText().getLength() == 0)
            if (pPrevTextNode->GetText().getLength() == 0)
            {
                auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_NEWLINES_SPACE),
                                          sfx::AccessibilityIssueID::TEXT_FORMATTING);
                pIssue->setIssueObject(IssueObject::TEXT);
                pIssue->setNode(pNextTextNode);
                SwDoc& rDocument = pNextTextNode->GetDoc();
                pIssue->setNode(pTextNode);
                SwDoc& rDocument = pTextNode->GetDoc();
                pIssue->setDoc(rDocument);
            }
        }
diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
index d394433..4b2dfe9 100644
--- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
+++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
@@ -248,15 +248,16 @@ void OnlineAccessibilityCheck::lookForPreviousNodeAndUpdate(const SwPosition& rN
        return;
    }

    // Run the docement level Accessibility Check
    runDocumentLevelAccessibilityCheck();

    // Get the real previous node from index
    SwNode* pNode = pCurrentNode->GetNodes()[m_nPreviousNodeIndex];

    if (pNode && (pNode->IsContentNode() || pNode->IsTableNode()))
    {
        runDocumentLevelAccessibilityCheck();
        runAccessibilityCheck(pNode);
        updateNodeStatus(pNode);
        updateStatusbar();

        // Assign previous node and index
        m_pPreviousNode = std::move(pCurrentWeak);
@@ -264,9 +265,14 @@ void OnlineAccessibilityCheck::lookForPreviousNodeAndUpdate(const SwPosition& rN
    }
    else
    {
        runAccessibilityCheck(pCurrentNode);
        updateNodeStatus(pCurrentNode);

        m_pPreviousNode.reset();
        m_nPreviousNodeIndex = SwNodeOffset(-1);
    }

    updateStatusbar();
}

void OnlineAccessibilityCheck::clearAccessibilityIssuesFromAllNodes()