LibreOffice Module editeng (master) 1
edtspell.hxx
Go to the documentation of this file.
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/svxenum.hxx>
26
28 class XSpellChecker1;
29}
30
31
32class EditView;
33class EditEngine;
34class ContentNode;
35
37{
38private:
40 void CheckSpellTo();
41
42 virtual void SpellStart( SvxSpellArea eArea ) override;
43 virtual void SpellContinue() override; // Check area
44 virtual void ReplaceAll( const OUString &rNewText ) override;
45 virtual bool SpellMore() override;
46
47public:
48 EditSpellWrapper(weld::Widget* pWin, bool bIsStart, EditView* pView);
49};
50
55{
56 static constexpr size_t Valid = std::numeric_limits<size_t>::max();
57
58 std::vector<editeng::MisspellRange> maRanges;
61
62 bool DbgIsBuggy() const;
63
64public:
65 typedef std::vector<editeng::MisspellRange>::iterator iterator;
66 typedef std::vector<editeng::MisspellRange>::const_iterator const_iterator;
67
68 WrongList();
69
70 const std::vector<editeng::MisspellRange>& GetRanges() const { return maRanges;}
71 void SetRanges( std::vector<editeng::MisspellRange>&& rRanges );
72
73 bool IsValid() const;
74 void SetValid();
75 void SetInvalidRange( size_t nStart, size_t nEnd );
76 void ResetInvalidRange( size_t nStart, size_t nEnd );
77
78 size_t GetInvalidStart() const { return mnInvalidStart; }
79 size_t GetInvalidEnd() const { return mnInvalidEnd; }
80
81 void TextInserted( size_t nPos, size_t nLength, bool bPosIsSep );
82 void TextDeleted( size_t nPos, size_t nLength );
83
84 void InsertWrong( size_t nStart, size_t nEnd );
85 bool NextWrong( size_t& rnStart, size_t& rnEnd ) const;
86 bool HasWrong( size_t nStart, size_t nEnd ) const;
87 bool HasAnyWrong( size_t nStart, size_t nEnd ) const;
88 void ClearWrongs( size_t nStart, size_t nEnd, const ContentNode* pNode );
89 void MarkWrongsInvalid();
90
91 WrongList* Clone() const;
92
93 // #i102062#
94 bool operator==(const WrongList& rCompare) const;
95
96 bool empty() const;
97 void push_back(const editeng::MisspellRange& rRange);
99 const editeng::MisspellRange& back() const;
100
101 iterator begin();
102 iterator end();
103 const_iterator begin() const;
104 const_iterator end() const;
105};
106
107class EdtAutoCorrDoc final : public SvxAutoCorrDoc
108{
111 sal_Int32 nCursor;
112
115
116 void ImplStartUndoAction();
117
118public:
119 EdtAutoCorrDoc(EditEngine* pE, ContentNode* pCurNode, sal_Int32 nCrsr, sal_Unicode cIns);
120 virtual ~EdtAutoCorrDoc() override;
121
122 virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) override;
123 virtual bool Insert( sal_Int32 nPos, const OUString& rTxt ) override;
124 virtual bool Replace( sal_Int32 nPos, const OUString& rTxt ) override;
125 virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rTxt ) override;
126
127 virtual void SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, SfxPoolItem& ) override;
128 virtual bool SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL ) override;
129
130 virtual OUString const* GetPrevPara(bool bAtNormalPos) override;
131
132 virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
133 SvxAutoCorrect& rACorrect, OUString* pPara ) override;
134 virtual bool TransliterateRTLWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
135 bool bApply = false ) override;
136
137
138 virtual LanguageType GetLanguage( sal_Int32 nPos ) const override;
139
140 sal_Int32 GetCursor() const { return nCursor; }
141
142};
143
144/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
EditSpellWrapper(weld::Widget *pWin, bool bIsStart, EditView *pView)
Definition: edtspell.cxx:39
virtual bool SpellMore() override
Definition: edtspell.cxx:109
void CheckSpellTo()
Definition: edtspell.cxx:136
virtual void SpellStart(SvxSpellArea eArea) override
Definition: edtspell.cxx:50
EditView * pEditView
Definition: edtspell.hxx:39
virtual void SpellContinue() override
Definition: edtspell.cxx:104
virtual void ReplaceAll(const OUString &rNewText) override
Definition: edtspell.cxx:129
virtual OUString const * GetPrevPara(bool bAtNormalPos) override
Definition: edtspell.cxx:609
virtual bool TransliterateRTLWord(sal_Int32 &rSttPos, sal_Int32 nEndPos, bool bApply=false) override
Definition: edtspell.cxx:683
virtual bool ChgAutoCorrWord(sal_Int32 &rSttPos, sal_Int32 nEndPos, SvxAutoCorrect &rACorrect, OUString *pPara) override
Definition: edtspell.cxx:643
virtual ~EdtAutoCorrDoc() override
Definition: edtspell.cxx:505
virtual bool Replace(sal_Int32 nPos, const OUString &rTxt) override
Definition: edtspell.cxx:537
void ImplStartUndoAction()
Definition: edtspell.cxx:699
virtual bool SetINetAttr(sal_Int32 nStt, sal_Int32 nEnd, const OUString &rURL) override
Definition: edtspell.cxx:590
sal_Int32 nCursor
Definition: edtspell.hxx:111
EdtAutoCorrDoc(EditEngine *pE, ContentNode *pCurNode, sal_Int32 nCrsr, sal_Unicode cIns)
Definition: edtspell.cxx:497
virtual bool ReplaceRange(sal_Int32 nPos, sal_Int32 nLen, const OUString &rTxt) override
Definition: edtspell.cxx:542
ContentNode * pCurNode
Definition: edtspell.hxx:110
EditEngine * mpEditEngine
Definition: edtspell.hxx:109
virtual LanguageType GetLanguage(sal_Int32 nPos) const override
Definition: edtspell.cxx:694
bool bAllowUndoAction
Definition: edtspell.hxx:113
sal_Int32 GetCursor() const
Definition: edtspell.hxx:140
virtual bool Insert(sal_Int32 nPos, const OUString &rTxt) override
Definition: edtspell.cxx:522
virtual void SetAttr(sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, SfxPoolItem &) override
Definition: edtspell.cxx:565
virtual bool Delete(sal_Int32 nStt, sal_Int32 nEnd) override
Definition: edtspell.cxx:511
weld::Widget * pWin
Definition: splwrap.hxx:51
Keeps track of misspelled ranges in paragraph.
Definition: edtspell.hxx:55
bool DbgIsBuggy() const
Definition: edtspell.cxx:484
void SetValid()
Definition: edtspell.cxx:163
void MarkWrongsInvalid()
Definition: edtspell.cxx:420
editeng::MisspellRange & back()
Definition: edtspell.cxx:454
static constexpr size_t Valid
Definition: edtspell.hxx:56
void ResetInvalidRange(size_t nStart, size_t nEnd)
Definition: edtspell.cxx:178
void SetInvalidRange(size_t nStart, size_t nEnd)
Definition: edtspell.cxx:169
size_t mnInvalidStart
Definition: edtspell.hxx:59
void TextDeleted(size_t nPos, size_t nLength)
Definition: edtspell.cxx:252
const std::vector< editeng::MisspellRange > & GetRanges() const
Definition: edtspell.hxx:70
bool IsValid() const
Definition: edtspell.cxx:158
void TextInserted(size_t nPos, size_t nLength, bool bPosIsSep)
Definition: edtspell.cxx:184
bool operator==(const WrongList &rCompare) const
Definition: edtspell.cxx:432
bool HasWrong(size_t nStart, size_t nEnd) const
Definition: edtspell.cxx:338
void push_back(const editeng::MisspellRange &rRange)
Definition: edtspell.cxx:449
WrongList * Clone() const
Definition: edtspell.cxx:426
void ClearWrongs(size_t nStart, size_t nEnd, const ContentNode *pNode)
Definition: edtspell.cxx:362
size_t GetInvalidEnd() const
Definition: edtspell.hxx:79
void InsertWrong(size_t nStart, size_t nEnd)
Definition: edtspell.cxx:396
bool NextWrong(size_t &rnStart, size_t &rnEnd) const
Definition: edtspell.cxx:320
iterator begin()
Definition: edtspell.cxx:464
void SetRanges(std::vector< editeng::MisspellRange > &&rRanges)
Definition: edtspell.cxx:153
size_t GetInvalidStart() const
Definition: edtspell.hxx:78
std::vector< editeng::MisspellRange > maRanges
Definition: edtspell.hxx:58
std::vector< editeng::MisspellRange >::const_iterator const_iterator
Definition: edtspell.hxx:66
std::vector< editeng::MisspellRange >::iterator iterator
Definition: edtspell.hxx:65
iterator end()
Definition: edtspell.cxx:469
bool empty() const
Definition: edtspell.cxx:444
size_t mnInvalidEnd
Definition: edtspell.hxx:60
bool HasAnyWrong(size_t nStart, size_t nEnd) const
Definition: edtspell.cxx:350
SvxSpellArea
Definition: svxenum.hxx:133
sal_uInt16 sal_Unicode