summaryrefslogtreecommitdiff
path: root/sw/inc/OnlineAccessibilityCheck.hxx
blob: e87f24d61d44c7e3dc1ab620d72bb50a51fcffa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 */

#pragma once

#include "ndindex.hxx"
#include "ndtxt.hxx"
#include <svl/listener.hxx>
#include <vcl/timer.hxx>
#include <AccessibilityCheck.hxx>
#include <map>

struct SwPosition;
class SwTextNode;

namespace sw
{
/// Contains the node and tracks if the node gets deleted.
/// Note: the node needs to extend sw::BroadcastingModify.
class WeakContentNodeContainer : public SvtListener
{
private:
    SwNode* m_pNode;

public:
    WeakContentNodeContainer(SwNode* pNode);
    ~WeakContentNodeContainer();

    /// Is the node still alive or it was deleted?
    bool isAlive();

    /// Returns the pointer of the node or nullptr if the node
    /// got deleted.
    SwNode* getNode();
};

class OnlineAccessibilityCheck : public SvtListener
{
private:
    std::map<SwNode*, std::unique_ptr<WeakContentNodeContainer>> m_aNodes;

    SwDoc& m_rDocument;
    sw::AccessibilityCheck m_aAccessibilityCheck;
    SwNode* m_pPreviousNode;
    SwNodeOffset m_nPreviousNodeIndex;
    sal_Int32 m_nAccessibilityIssues;
    bool m_bInitialCheck;
    bool m_bOnlineCheckStatus;
    std::unique_ptr<sfx::AccessibilityIssueCollection> m_pDocumentAccessibilityIssues;

    void runAccessibilityCheck(SwNode* pNode);
    void updateStatusbar();
    void updateNodeStatus(SwNode* pContentNode);
    void initialCheck();
    void lookForPreviousNodeAndUpdate(SwPosition const& rNewPos);
    void clearAccessibilityIssuesFromAllNodes();
    void runDocumentLevelAccessibilityCheck();

public:
    OnlineAccessibilityCheck(SwDoc& rDocument);
    void update(SwPosition const& rNewPos);
    void resetAndQueue(SwNode* pNode);
    void updateCheckerActivity();
    sal_Int32 getNumberOfAccessibilityIssues() { return m_nAccessibilityIssues; }
};

} // end sw

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */