summaryrefslogtreecommitdiff
path: root/sw/inc/OnlineAccessibilityCheck.hxx
blob: 47e42a27de2921e1bed5a6194d3249efa204d916 (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
/* -*- 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 content node and tracks if the node
/// gets deleted.
class WeakContentNodeContainer : public SvtListener
{
private:
    SwContentNode* m_pNode;

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

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

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

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

    SwDoc& m_rDocument;
    sw::AccessibilityCheck m_aAccessibilityCheck;
    SwContentNode* m_pPreviousNode;
    SwNodeOffset m_nPreviousNodeIndex;
    sal_Int32 m_nAccessibilityIssues;
    bool m_bInitialCheck;

    void runAccessibilityCheck(SwContentNode* pNode);
    void updateStatusbar();
    void updateNodeStatus(SwContentNode* pContentNode);
    void initialCheck();

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

} // end sw

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