1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
{
37 class EditSpellWrapper final
: public SvxSpellWrapper
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
;
49 EditSpellWrapper(weld::Window
* pWin
, bool bIsStart
, EditView
* pView
);
53 * Keeps track of misspelled ranges in paragraph.
57 static constexpr size_t Valid
= std::numeric_limits
<size_t>::max();
59 std::vector
<editeng::MisspellRange
> maRanges
;
60 size_t mnInvalidStart
;
63 bool DbgIsBuggy() const;
66 typedef std::vector
<editeng::MisspellRange
>::iterator iterator
;
67 typedef std::vector
<editeng::MisspellRange
>::const_iterator const_iterator
;
71 const std::vector
<editeng::MisspellRange
>& GetRanges() const { return maRanges
;}
72 void SetRanges( const std::vector
<editeng::MisspellRange
>& rRanges
);
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;
95 bool operator==(const WrongList
& rCompare
) const;
98 void push_back(const editeng::MisspellRange
& rRange
);
99 editeng::MisspellRange
& back();
100 const editeng::MisspellRange
& back() const;
104 const_iterator
begin() const;
105 const_iterator
end() const;
108 class EdtAutoCorrDoc final
: public SvxAutoCorrDoc
110 EditEngine
* mpEditEngine
;
111 ContentNode
* pCurNode
;
114 bool bAllowUndoAction
;
117 void ImplStartUndoAction();
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
; }
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */