Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/inc/spellcheckcontext.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 */
9
10
#pragma once
11
12
#include <i18nlangtag/lang.h>
13
#include <editeng/misspellrange.hxx>
14
#include "types.hxx"
15
16
#include <memory>
17
#include <vector>
18
19
class ScDocument;
20
class ScTabEditEngine;
21
22
namespace sc
23
{
24
typedef std::vector<editeng::MisspellRanges> MisspellRangesVec;
25
26
struct MisspellRangeResult
27
{
28
    const MisspellRangesVec* mpRanges;
29
    LanguageType meCellLang;
30
31
    MisspellRangeResult()
32
0
        : mpRanges(nullptr)
33
0
        , meCellLang(LANGUAGE_DONTKNOW)
34
0
    {
35
0
    }
36
37
    MisspellRangeResult(const MisspellRangesVec* pRanges, LanguageType eCellLang)
38
0
        : mpRanges(pRanges)
39
0
        , meCellLang(eCellLang)
40
0
    {
41
0
    }
42
43
0
    bool HasRanges() const { return mpRanges != nullptr; }
44
};
45
46
/**
47
 * Class shared between grid windows to cache
48
 * spelling results.
49
 */
50
class SpellCheckContext
51
{
52
    class SpellCheckCache;
53
    struct SpellCheckStatus;
54
    struct SpellCheckResult;
55
56
    std::unique_ptr<SpellCheckCache> mpCache;
57
    std::unique_ptr<SpellCheckResult> mpResult;
58
    ScDocument& rDoc;
59
    std::unique_ptr<ScTabEditEngine> mpEngine;
60
    std::unique_ptr<SpellCheckStatus> mpStatus;
61
    SCTAB mnTab;
62
    LanguageType meLanguage;
63
64
public:
65
    SpellCheckContext(ScDocument& rDocument, SCTAB nTab);
66
    ~SpellCheckContext();
67
    void dispose();
68
69
    bool isMisspelled(SCCOL nCol, SCROW nRow) const;
70
    MisspellRangeResult getMisspellRanges(SCCOL nCol, SCROW nRow) const;
71
    void setMisspellRanges(SCCOL nCol, SCROW nRow, const MisspellRangeResult& rRangeResult);
72
73
    void reset();
74
    void resetForContentChange();
75
    void setTabNo(SCTAB nTab);
76
77
private:
78
    void ensureResults(SCCOL nCol, SCROW nRow);
79
    void resetCache(bool bContentChangeOnly = false);
80
    void setup();
81
};
82
}
83
84
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */