Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/editeng/splwrap.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
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
#ifndef INCLUDED_EDITENG_SPLWRAP_HXX
20
#define INCLUDED_EDITENG_SPLWRAP_HXX
21
22
#include <editeng/editengdllapi.h>
23
#include <editeng/svxenum.hxx>
24
#include <i18nlangtag/lang.h>
25
#include <rtl/ustring.hxx>
26
#include <com/sun/star/uno/Reference.hxx>
27
#include <vcl/weld/weld.hxx>
28
29
// forward ---------------------------------------------------------------
30
31
namespace com::sun::star::linguistic2 {
32
    class XDictionary;
33
    class XSpellChecker1;
34
    class XHyphenator;
35
}
36
37
// misc functions ---------------------------------------------------------------
38
39
void EDITENG_DLLPUBLIC SvxPrepareAutoCorrect( OUString &rOldText, std::u16string_view rNewText );
40
41
/*--------------------------------------------------------------------
42
     Description: The SpellWrapper
43
 --------------------------------------------------------------------*/
44
45
class EDITENG_DLLPUBLIC SvxSpellWrapper {
46
private:
47
    friend class SvxSpellCheckDialog;
48
    friend class SvxHyphenWordDialog;
49
    friend struct SvxHyphenWordDialog_Impl;
50
51
    weld::Widget* pWin;
52
    std::unique_ptr<weld::WaitObject> xWait;
53
    css::uno::Reference<
54
        css::uno::XInterface >             xLast;  // result of last spelling/hyphenation attempt
55
    css::uno::Reference<
56
        css::linguistic2::XHyphenator >    xHyph;
57
    bool        bOtherCntnt : 1; // set => Check special sections initially
58
    bool        bReverse    : 1; // Reverse spell check
59
    bool        bStartDone  : 1; // Beginning already corrected
60
    bool        bEndDone    : 1; // End part already corrected
61
    bool        bStartChk   : 1; // Examine the beginning
62
    bool        bRevAllowed : 1; // Reverse spell check prohibited
63
    bool        bAllRight   : 1; // Record wrong words in the dedicated
64
                                 // dictionary and do not start the dialog.
65
66
    SAL_DLLPRIVATE bool     SpellNext();        // select next area
67
    bool    FindSpellError();   // Check for errors (over areas)
68
69
    SvxSpellWrapper(SvxSpellWrapper const &) = delete;
70
    void operator =(SvxSpellWrapper const &) = delete;
71
72
public:
73
    SvxSpellWrapper( weld::Widget* pWn,
74
                     const bool bStart, const bool bIsAllRight );
75
    SvxSpellWrapper( weld::Widget* pWn,
76
                     css::uno::Reference< css::linguistic2::XHyphenator > const &xHyphenator,
77
                     const bool bStart, const bool bOther );
78
79
    virtual ~SvxSpellWrapper();
80
81
    static sal_Int16    CheckSpellLang(
82
                            css::uno::Reference< css::linguistic2::XSpellChecker1 > const & xSpell,
83
                            LanguageType nLang );
84
    static sal_Int16    CheckHyphLang(
85
                            css::uno::Reference< css::linguistic2::XHyphenator >const & xHyph,
86
                            LanguageType nLang );
87
88
    static void         ShowLanguageErrors();
89
90
    void            SpellDocument();        // Perform Spell Checking
91
0
    bool     IsStartDone() const { return bStartDone; }
92
0
    bool     IsEndDone() const { return bEndDone; }
93
0
    bool     IsAllRight() const { return bAllRight; }
94
95
protected:
96
    const css::uno::Reference< css::uno::XInterface >&
97
0
                     GetLast() const { return xLast; }
98
    void             SetLast(const css::uno::Reference< css::uno::XInterface >  &xNewLast)
99
0
                            { xLast = xNewLast; }
100
    virtual bool SpellMore();               // examine further documents?
101
    virtual void SpellStart( SvxSpellArea eSpell ); // Preparing the area
102
    virtual void SpellContinue();     // Check Areas
103
                                          // Result available through GetLast
104
    virtual void ReplaceAll( const OUString &rNewText ); //Replace word from the replace list
105
    static css::uno::Reference< css::linguistic2::XDictionary >
106
                 GetAllRightDic();
107
    virtual void SpellEnd();                        // Finish area
108
    virtual void InsertHyphen( const sal_Int32 nPos ); // Insert hyphen
109
};
110
111
#endif
112
113
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */