Send various state changes to LOK
[LibreOffice.git] / editeng / inc / edtspell.hxx
blobefd9272f48599303f991376426f5f04ee4ce1728
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_EDITENG_INC_EDTSPELL_HXX
21 #define INCLUDED_EDITENG_INC_EDTSPELL_HXX
23 #include <editeng/splwrap.hxx>
24 #include <editeng/svxacorr.hxx>
25 #include <editeng/svxenum.hxx>
26 #include <editeng/misspellrange.hxx>
28 namespace com::sun::star::linguistic2 {
29 class XSpellChecker1;
33 class EditView;
34 class EditEngine;
35 class ContentNode;
37 class EditSpellWrapper final : public SvxSpellWrapper
39 private:
40 EditView* pEditView;
41 void CheckSpellTo();
43 virtual void SpellStart( SvxSpellArea eArea ) override;
44 virtual void SpellContinue() override; // Check area
45 virtual void ReplaceAll( const OUString &rNewText ) override;
46 virtual bool SpellMore() override;
48 public:
49 EditSpellWrapper(weld::Window* pWin, bool bIsStart, EditView* pView);
52 /**
53 * Keeps track of misspelled ranges in paragraph.
55 class WrongList
57 static constexpr size_t Valid = std::numeric_limits<size_t>::max();
59 std::vector<editeng::MisspellRange> maRanges;
60 size_t mnInvalidStart;
61 size_t mnInvalidEnd;
63 bool DbgIsBuggy() const;
65 public:
66 typedef std::vector<editeng::MisspellRange>::iterator iterator;
67 typedef std::vector<editeng::MisspellRange>::const_iterator const_iterator;
69 WrongList();
71 const std::vector<editeng::MisspellRange>& GetRanges() const { return maRanges;}
72 void SetRanges( const std::vector<editeng::MisspellRange>& rRanges );
74 bool IsValid() const;
75 void SetValid();
76 void SetInvalidRange( size_t nStart, size_t nEnd );
77 void ResetInvalidRange( size_t nStart, size_t nEnd );
79 size_t GetInvalidStart() const { return mnInvalidStart; }
80 size_t GetInvalidEnd() const { return mnInvalidEnd; }
82 void TextInserted( size_t nPos, size_t nLength, bool bPosIsSep );
83 void TextDeleted( size_t nPos, size_t nLength );
85 void InsertWrong( size_t nStart, size_t nEnd );
86 bool NextWrong( size_t& rnStart, size_t& rnEnd ) const;
87 bool HasWrong( size_t nStart, size_t nEnd ) const;
88 bool HasAnyWrong( size_t nStart, size_t nEnd ) const;
89 void ClearWrongs( size_t nStart, size_t nEnd, const ContentNode* pNode );
90 void MarkWrongsInvalid();
92 WrongList* Clone() const;
94 // #i102062#
95 bool operator==(const WrongList& rCompare) const;
97 bool empty() const;
98 void push_back(const editeng::MisspellRange& rRange);
99 editeng::MisspellRange& back();
100 const editeng::MisspellRange& back() const;
102 iterator begin();
103 iterator end();
104 const_iterator begin() const;
105 const_iterator end() const;
108 class EdtAutoCorrDoc final : public SvxAutoCorrDoc
110 EditEngine* mpEditEngine;
111 ContentNode* pCurNode;
112 sal_Int32 nCursor;
114 bool bAllowUndoAction;
115 bool bUndoAction;
117 void ImplStartUndoAction();
119 public:
120 EdtAutoCorrDoc(EditEngine* pE, ContentNode* pCurNode, sal_Int32 nCrsr, sal_Unicode cIns);
121 virtual ~EdtAutoCorrDoc() override;
123 virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) override;
124 virtual bool Insert( sal_Int32 nPos, const OUString& rTxt ) override;
125 virtual bool Replace( sal_Int32 nPos, const OUString& rTxt ) override;
126 virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rTxt ) override;
128 virtual void SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, SfxPoolItem& ) override;
129 virtual bool SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL ) override;
131 virtual OUString const* GetPrevPara(bool bAtNormalPos) override;
133 virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
134 SvxAutoCorrect& rACorrect, OUString* pPara ) override;
135 virtual bool TransliterateRTLWord( sal_Int32& rSttPos, sal_Int32 nEndPos ) override;
138 virtual LanguageType GetLanguage( sal_Int32 nPos ) const override;
140 sal_Int32 GetCursor() const { return nCursor; }
144 #endif
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */