summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/OnlineAccessibilityCheck.hxx6
-rw-r--r--sw/inc/ndtxt.hxx13
-rw-r--r--sw/inc/node.hxx21
-rw-r--r--sw/source/core/txtnode/OnlineAccessibilityCheck.cxx85
4 files changed, 71 insertions, 54 deletions
diff --git a/sw/inc/OnlineAccessibilityCheck.hxx b/sw/inc/OnlineAccessibilityCheck.hxx
index f27f867ce96b..48a639b9d656 100644
--- a/sw/inc/OnlineAccessibilityCheck.hxx
+++ b/sw/inc/OnlineAccessibilityCheck.hxx
@@ -26,11 +26,11 @@ class OnlineAccessibilityCheck : public SvtListener
private:
SwDoc& m_rDocument;
sw::AccessibilityCheck m_aAccessibilityCheck;
- SwTextNode* m_pCurrentTextNode;
- SwNodeOffset m_aCurrentNodeIndex;
+ SwContentNode* m_pPreviousNode;
+ SwNodeOffset m_nPreviousNodeIndex;
sal_Int32 m_nAccessibilityIssues;
- void runCheck(SwTextNode* pTextNode);
+ void runCheck(SwContentNode* pNode);
public:
OnlineAccessibilityCheck(SwDoc& rDocument);
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 63b019cf8178..f28f2faf1e02 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -37,7 +37,6 @@
#include <memory>
#include <vector>
#include <functional>
-#include <sfx2/AccessibilityIssue.hxx>
class SfxHint;
class SwNumRule;
@@ -102,12 +101,6 @@ struct ParagraphIdleData
bool bAutoComplDirty = true; ///< auto complete list dirty
};
-struct AccessibilityCheckStatus
-{
- std::unique_ptr<sfx::AccessibilityIssueCollection> pCollection;
- bool bDirty = true;
-};
-
} // end namespace sw
/// SwTextNode is a paragraph in the document model.
@@ -135,7 +128,6 @@ class SW_DLLPUBLIC SwTextNode final
OUString m_Text;
mutable sw::ParagraphIdleData m_aParagraphIdleData;
- mutable sw::AccessibilityCheckStatus m_aAccessibilityCheckStatus;
/** Some of the chars this para are hidden. Paragraph has to be reformatted
on changing the view to print preview. */
@@ -242,11 +234,6 @@ public:
/// End: Data collected during idle time
- sw::AccessibilityCheckStatus& getAccessibilityCheckStatus()
- {
- return m_aAccessibilityCheckStatus;
- }
-
public:
using SwContentNode::GetAttr;
/// for hanging TextFormatCollections somewhere else (Outline-Numbering!)
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 75096dd2aa28..38fdf2417be7 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -30,6 +30,8 @@
#include "fmtcol.hxx"
#include "nodeoffset.hxx"
+#include <sfx2/AccessibilityIssue.hxx>
+
#include <memory>
#include <vector>
@@ -366,6 +368,18 @@ class SwEndNode final : public SwNode
SwEndNode & operator= ( const SwEndNode & rNode ) = delete;
};
+// Accessibiity check
+
+namespace sw
+{
+struct AccessibilityCheckStatus
+{
+ std::unique_ptr<sfx::AccessibilityIssueCollection> pCollection;
+ bool bDirty = true;
+};
+
+}
+
// SwContentNode
class SW_DLLPUBLIC SwContentNode: public sw::BroadcastingModify, public SwNode, public SwContentIndexReg
@@ -375,6 +389,8 @@ class SW_DLLPUBLIC SwContentNode: public sw::BroadcastingModify, public SwNode,
SwFormatColl* m_pCondColl;
mutable bool mbSetModifyAtAttr;
+ mutable sw::AccessibilityCheckStatus m_aAccessibilityCheckStatus;
+
protected:
/// only used by SwContentNodeTmp in SwTextNode::Update
SwContentNode();
@@ -499,6 +515,11 @@ public:
void UpdateAttr(const SwUpdateAttr&);
+ sw::AccessibilityCheckStatus& getAccessibilityCheckStatus()
+ {
+ return m_aAccessibilityCheckStatus;
+ }
+
private:
SwContentNode( const SwContentNode & rNode ) = delete;
SwContentNode & operator= ( const SwContentNode & rNode ) = delete;
diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
index a26be4e6e0ec..e34738466d99 100644
--- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
+++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
@@ -32,17 +32,19 @@ namespace sw
OnlineAccessibilityCheck::OnlineAccessibilityCheck(SwDoc& rDocument)
: m_rDocument(rDocument)
, m_aAccessibilityCheck(&m_rDocument)
- , m_pCurrentTextNode(nullptr)
- , m_aCurrentNodeIndex(-1)
+ , m_pPreviousNode(nullptr)
+ , m_nPreviousNodeIndex(-1)
, m_nAccessibilityIssues(0)
{
}
-void OnlineAccessibilityCheck::runCheck(SwTextNode* pTextNode)
+void OnlineAccessibilityCheck::runCheck(SwContentNode* pContentNode)
{
- m_aAccessibilityCheck.checkNode(pTextNode);
+ m_aAccessibilityCheck.getIssueCollection().clear();
+
+ m_aAccessibilityCheck.checkNode(pContentNode);
- for (SwFrameFormat* const& pFrameFormat : pTextNode->GetAnchoredFlys())
+ for (SwFrameFormat* const& pFrameFormat : pContentNode->GetAnchoredFlys())
{
SdrObject* pObject = pFrameFormat->FindSdrObject();
if (pObject)
@@ -51,17 +53,17 @@ void OnlineAccessibilityCheck::runCheck(SwTextNode* pTextNode)
auto aCollection = m_aAccessibilityCheck.getIssueCollection();
- pTextNode->getAccessibilityCheckStatus().pCollection
+ pContentNode->getAccessibilityCheckStatus().pCollection
= std::make_unique<sfx::AccessibilityIssueCollection>(aCollection);
m_nAccessibilityIssues = 0;
auto const& pNodes = m_rDocument.GetNodes();
for (SwNodeOffset n(0); n < pNodes.Count(); ++n)
{
- SwNode* pNode = pNodes[n];
- if (pNode && pNode->IsTextNode())
+ SwNode* pCurrent = pNodes[n];
+ if (pCurrent && pCurrent->IsTextNode())
{
- auto* pCurrentTextNode = pNode->GetTextNode();
+ auto* pCurrentTextNode = pCurrent->GetTextNode();
auto& rStatus = pCurrentTextNode->getAccessibilityCheckStatus();
if (rStatus.pCollection)
m_nAccessibilityIssues += rStatus.pCollection->getIssues().size();
@@ -83,49 +85,56 @@ void OnlineAccessibilityCheck::update(const SwPosition& rNewPos)
if (!bOnlineCheckStatus)
return;
+ auto nCurrenNodeIndex = rNewPos.GetNodeIndex();
+ if (!rNewPos.GetNode().IsContentNode())
+ return;
+
+ auto* pCurrentNode = rNewPos.GetNode().GetContentNode();
+
+ // Check if previous node was deleted
if (!HasBroadcaster())
{
- m_pCurrentTextNode = nullptr;
- m_aCurrentNodeIndex = SwNodeOffset(-1);
+ EndListeningAll();
+ StartListening(pCurrentNode->GetNotifier());
+ m_pPreviousNode = pCurrentNode;
+ m_nPreviousNodeIndex = nCurrenNodeIndex;
+ return;
}
- auto aNodeIndex = rNewPos.GetNodeIndex();
-
- m_aAccessibilityCheck.getIssueCollection().clear();
+ // Check if node index changed
+ if (nCurrenNodeIndex == m_nPreviousNodeIndex)
+ return;
- SwTextNode* pTextNode = rNewPos.GetNode().GetTextNode();
- if (!pTextNode)
+ // Check previous node is valid
+ if (m_nPreviousNodeIndex < SwNodeOffset(0)
+ || m_nPreviousNodeIndex >= rNewPos.GetNode().GetNodes().Count())
{
- m_pCurrentTextNode = nullptr;
- m_aCurrentNodeIndex = SwNodeOffset(-1);
+ EndListeningAll();
+ StartListening(pCurrentNode->GetNotifier());
+ m_pPreviousNode = pCurrentNode;
+ m_nPreviousNodeIndex = nCurrenNodeIndex;
return;
}
- if (pTextNode == m_pCurrentTextNode)
- {
- if (m_aCurrentNodeIndex != aNodeIndex && m_aCurrentNodeIndex >= SwNodeOffset(0)
- && m_aCurrentNodeIndex < pTextNode->GetNodes().Count())
- {
- pTextNode = pTextNode->GetNodes()[m_aCurrentNodeIndex]->GetTextNode();
+ // Get the real previous node from index
+ SwNode* pNode = rNewPos.GetNode().GetNodes()[m_nPreviousNodeIndex];
- if (pTextNode)
- {
- runCheck(pTextNode);
- }
- }
- }
- else if (m_pCurrentTextNode)
+ if (pNode && pNode->IsContentNode())
{
- runCheck(m_pCurrentTextNode);
- }
+ auto* pContentNode = pNode->GetContentNode();
- m_aCurrentNodeIndex = aNodeIndex;
+ runCheck(pContentNode);
- if (pTextNode && m_pCurrentTextNode != pTextNode)
- {
+ // Assign previous node and index
EndListeningAll();
- StartListening(pTextNode->GetNotifier());
- m_pCurrentTextNode = pTextNode;
+ StartListening(pCurrentNode->GetNotifier());
+ m_pPreviousNode = pCurrentNode;
+ m_nPreviousNodeIndex = nCurrenNodeIndex;
+ }
+ else
+ {
+ m_pPreviousNode = nullptr;
+ m_nPreviousNodeIndex = SwNodeOffset(-1);
}
}