1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef _EDTSPELL_HXX
25 #define _EDTSPELL_HXX
26
27 #include <svtools/svxbox.hxx>
28 #include <editeng/svxenum.hxx>
29 #include <editeng/splwrap.hxx>
30 #include <editeng/svxacorr.hxx>
31 #include <com/sun/star/uno/Reference.h>
32 #include <editeng/editengdllapi.h>
33
34 namespace com { namespace sun { namespace star { namespace linguistic2 {
35 class XSpellChecker1;
36 }}}}
37
38
39 class EditView;
40 class ImpEditEngine;
41 class ContentNode;
42
43 class EditSpellWrapper : public SvxSpellWrapper
44 {
45 private:
46 EditView* pEditView;
47 void CheckSpellTo();
48
49 protected:
50 virtual void SpellStart( SvxSpellArea eArea );
51 virtual sal_Bool SpellContinue(); // Bereich pruefen
52 virtual void ReplaceAll( const String &rNewText, sal_Int16 nLanguage );
53 virtual void SpellEnd();
54 virtual sal_Bool SpellMore();
55 virtual sal_Bool HasOtherCnt();
56 virtual void ScrollArea();
57 virtual void ChangeWord( const String& rNewWord, const sal_uInt16 nLang );
58 virtual void ChangeThesWord( const String& rNewWord );
59 virtual void AutoCorrect( const String& rOldWord, const String& rNewWord );
60
61 public:
62 EditSpellWrapper( Window* pWin,
63 ::com::sun::star::uno::Reference<
64 ::com::sun::star::linguistic2::XSpellChecker1 > &xChecker,
65 sal_Bool bIsStart,
66 sal_Bool bIsAllRight, EditView* pView );
67
68 };
69
70
71 struct WrongRange
72 {
73 sal_uInt16 nStart;
74 sal_uInt16 nEnd;
75
WrongRangeWrongRange76 WrongRange( sal_uInt16 nS, sal_uInt16 nE ) { nStart = nS; nEnd = nE; }
77 };
78
79 SV_DECL_VARARR( WrongRanges, WrongRange, 4, 4 )
80 #define NOT_INVALID 0xFFFF
81
82 class WrongList : private WrongRanges
83 {
84 private:
85 sal_uInt16 nInvalidStart;
86 sal_uInt16 nInvalidEnd;
87
88 sal_Bool DbgIsBuggy() const;
89
90 public:
91 WrongList();
92 ~WrongList();
93
IsInvalid() const94 sal_Bool IsInvalid() const { return nInvalidStart != NOT_INVALID; }
SetValid()95 void SetValid() { nInvalidStart = NOT_INVALID; nInvalidEnd = 0; }
96 void MarkInvalid( sal_uInt16 nS, sal_uInt16 nE );
97
Count() const98 sal_uInt16 Count() const { return WrongRanges::Count(); }
99
100 // Wenn man weiss was man tut:
GetObject(sal_uInt16 n) const101 WrongRange& GetObject( sal_uInt16 n ) const { return WrongRanges::GetObject( n ); }
102 void InsertWrong( const WrongRange& rWrong, sal_uInt16 nPos );
103
GetInvalidStart() const104 sal_uInt16 GetInvalidStart() const { return nInvalidStart; }
GetInvalidStart()105 sal_uInt16& GetInvalidStart() { return nInvalidStart; }
106
GetInvalidEnd() const107 sal_uInt16 GetInvalidEnd() const { return nInvalidEnd; }
GetInvalidEnd()108 sal_uInt16& GetInvalidEnd() { return nInvalidEnd; }
109
110 void TextInserted( sal_uInt16 nPos, sal_uInt16 nChars, sal_Bool bPosIsSep );
111 void TextDeleted( sal_uInt16 nPos, sal_uInt16 nChars );
112
ResetRanges()113 void ResetRanges() { Remove( 0, Count() ); }
HasWrongs() const114 sal_Bool HasWrongs() const { return Count() != 0; }
115 void InsertWrong( sal_uInt16 nStart, sal_uInt16 nEnd, sal_Bool bClearRange );
116 sal_Bool NextWrong( sal_uInt16& rnStart, sal_uInt16& rnEnd ) const;
117 sal_Bool HasWrong( sal_uInt16 nStart, sal_uInt16 nEnd ) const;
118 sal_Bool HasAnyWrong( sal_uInt16 nStart, sal_uInt16 nEnd ) const;
119 void ClearWrongs( sal_uInt16 nStart, sal_uInt16 nEnd, const ContentNode* pNode );
120 void MarkWrongsInvalid();
121
122 WrongList* Clone() const;
123
124 // #i102062#
125 bool operator==(const WrongList& rCompare) const;
126 };
127
InsertWrong(const WrongRange & rWrong,sal_uInt16 nPos)128 inline void WrongList::InsertWrong( const WrongRange& rWrong, sal_uInt16 nPos )
129 {
130 WrongRanges::Insert( rWrong, nPos );
131 #ifdef DBG_UTIL
132 DBG_ASSERT( !DbgIsBuggy(), "Insert: WrongList kaputt!" );
133 #endif
134 }
135
136
137
138 class EdtAutoCorrDoc : public SvxAutoCorrDoc
139 {
140 ImpEditEngine* pImpEE;
141 ContentNode* pCurNode;
142 sal_uInt16 nCursor;
143
144 sal_Bool bAllowUndoAction;
145 sal_Bool bUndoAction;
146
147 protected:
148 void ImplStartUndoAction();
149
150 public:
151 EdtAutoCorrDoc( ImpEditEngine* pImpEE, ContentNode* pCurNode, sal_uInt16 nCrsr, xub_Unicode cIns );
152 ~EdtAutoCorrDoc();
153
154 virtual sal_Bool Delete( sal_uInt16 nStt, sal_uInt16 nEnd );
155 virtual sal_Bool Insert( sal_uInt16 nPos, const String& rTxt );
156 virtual sal_Bool Replace( sal_uInt16 nPos, const String& rTxt );
157 virtual sal_Bool ReplaceRange( xub_StrLen nPos, xub_StrLen nLen, const String& rTxt );
158
159 virtual sal_Bool SetAttr( sal_uInt16 nStt, sal_uInt16 nEnd, sal_uInt16 nSlotId, SfxPoolItem& );
160 virtual sal_Bool SetINetAttr( sal_uInt16 nStt, sal_uInt16 nEnd, const String& rURL );
161
162 virtual sal_Bool HasSymbolChars( sal_uInt16 nStt, sal_uInt16 nEnd );
163
164 virtual const String* GetPrevPara( sal_Bool bAtNormalPos );
165
166 virtual sal_Bool ChgAutoCorrWord( sal_uInt16& rSttPos, sal_uInt16 nEndPos,
167 SvxAutoCorrect& rACorrect, const String** ppPara );
168
169 virtual LanguageType GetLanguage( sal_uInt16 nPos, sal_Bool bPrevPara = sal_False ) const;
170
GetCursor() const171 sal_uInt16 GetCursor() const { return nCursor; }
172
173 };
174
175 #endif // EDTSPELL
176
177