/src/libreoffice/editeng/inc/edtspell.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 | | |
20 | | #pragma once |
21 | | |
22 | | #include <editeng/splwrap.hxx> |
23 | | #include <editeng/svxacorr.hxx> |
24 | | #include <editeng/misspellrange.hxx> |
25 | | |
26 | | |
27 | | class EditView; |
28 | | class EditEngine; |
29 | | class ContentNode; |
30 | | |
31 | | class EditSpellWrapper final : public SvxSpellWrapper |
32 | | { |
33 | | private: |
34 | | EditView* pEditView; |
35 | | void CheckSpellTo(); |
36 | | |
37 | | virtual void SpellStart( SvxSpellArea eArea ) override; |
38 | | virtual void SpellContinue() override; // Check area |
39 | | virtual void ReplaceAll( const OUString &rNewText ) override; |
40 | | virtual bool SpellMore() override; |
41 | | |
42 | | public: |
43 | | EditSpellWrapper(weld::Widget* pWin, bool bIsStart, EditView* pView); |
44 | | }; |
45 | | |
46 | | /** |
47 | | * Keeps track of misspelled ranges in paragraph. |
48 | | */ |
49 | | class WrongList |
50 | | { |
51 | | static constexpr size_t Valid = std::numeric_limits<size_t>::max(); |
52 | | |
53 | | std::vector<editeng::MisspellRange> maRanges; |
54 | | size_t mnInvalidStart; |
55 | | size_t mnInvalidEnd; |
56 | | |
57 | | bool DbgIsBuggy() const; |
58 | | |
59 | | public: |
60 | | typedef std::vector<editeng::MisspellRange>::iterator iterator; |
61 | | typedef std::vector<editeng::MisspellRange>::const_iterator const_iterator; |
62 | | |
63 | | WrongList(); |
64 | | |
65 | 0 | const std::vector<editeng::MisspellRange>& GetRanges() const { return maRanges;} |
66 | | void SetRanges( std::vector<editeng::MisspellRange>&& rRanges ); |
67 | | |
68 | | bool IsValid() const; |
69 | | void SetValid(); |
70 | | void SetInvalidRange( size_t nStart, size_t nEnd ); |
71 | | void ResetInvalidRange( size_t nStart, size_t nEnd ); |
72 | | |
73 | 0 | size_t GetInvalidStart() const { return mnInvalidStart; } |
74 | 0 | size_t GetInvalidEnd() const { return mnInvalidEnd; } |
75 | | |
76 | | void TextInserted( size_t nPos, size_t nLength, bool bPosIsSep ); |
77 | | void TextDeleted( size_t nPos, size_t nLength ); |
78 | | |
79 | | void InsertWrong( size_t nStart, size_t nEnd ); |
80 | | bool NextWrong( size_t& rnStart, size_t& rnEnd ) const; |
81 | | bool HasWrong( size_t nStart, size_t nEnd ) const; |
82 | | bool HasAnyWrong( size_t nStart, size_t nEnd ) const; |
83 | | void ClearWrongs( size_t nStart, size_t nEnd, const ContentNode* pNode ); |
84 | | void MarkWrongsInvalid(); |
85 | | |
86 | | WrongList* Clone() const; |
87 | | |
88 | | // #i102062# |
89 | | bool operator==(const WrongList& rCompare) const; |
90 | | |
91 | | bool empty() const; |
92 | | void push_back(const editeng::MisspellRange& rRange); |
93 | | editeng::MisspellRange& back(); |
94 | | const editeng::MisspellRange& back() const; |
95 | | |
96 | | iterator begin(); |
97 | | iterator end(); |
98 | | const_iterator begin() const; |
99 | | const_iterator end() const; |
100 | | }; |
101 | | |
102 | | class EdtAutoCorrDoc final : public SvxAutoCorrDoc |
103 | | { |
104 | | EditEngine* mpEditEngine; |
105 | | ContentNode* pCurNode; |
106 | | sal_Int32 nCursor; |
107 | | |
108 | | bool bAllowUndoAction; |
109 | | bool bUndoAction; |
110 | | |
111 | | void ImplStartUndoAction(); |
112 | | |
113 | | public: |
114 | | EdtAutoCorrDoc(EditEngine* pE, ContentNode* pCurNode, sal_Int32 nCrsr, sal_Unicode cIns); |
115 | | virtual ~EdtAutoCorrDoc() override; |
116 | | |
117 | | virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) override; |
118 | | virtual bool Insert( sal_Int32 nPos, const OUString& rTxt ) override; |
119 | | virtual bool Replace( sal_Int32 nPos, const OUString& rTxt ) override; |
120 | | virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rTxt ) override; |
121 | | |
122 | | virtual void SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, SfxPoolItem& ) override; |
123 | | virtual bool SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL ) override; |
124 | | |
125 | | virtual OUString const* GetPrevPara(bool bAtNormalPos) override; |
126 | | |
127 | | virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, |
128 | | SvxAutoCorrect& rACorrect, OUString* pPara ) override; |
129 | | virtual bool TransliterateRTLWord( sal_Int32& rSttPos, sal_Int32 nEndPos, |
130 | | bool bApply = false ) override; |
131 | | |
132 | | |
133 | | virtual LanguageType GetLanguage( sal_Int32 nPos ) const override; |
134 | | |
135 | 0 | sal_Int32 GetCursor() const { return nCursor; } |
136 | | |
137 | | }; |
138 | | |
139 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |