/src/libreoffice/include/editeng/svxacorr.hxx
Line | Count | Source (jump to first uncovered line) |
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 | | #ifndef INCLUDED_EDITENG_SVXACORR_HXX |
21 | | #define INCLUDED_EDITENG_SVXACORR_HXX |
22 | | |
23 | | #include <o3tl/sorted_vector.hxx> |
24 | | #include <o3tl/typed_flags_set.hxx> |
25 | | #include <o3tl/string_view.hxx> |
26 | | #include <i18nlangtag/languagetag.hxx> |
27 | | #include <rtl/ref.hxx> |
28 | | #include <tools/time.hxx> |
29 | | #include <tools/date.hxx> |
30 | | #include <editeng/swafopt.hxx> |
31 | | #include <editeng/editengdllapi.h> |
32 | | #include <unotools/charclass.hxx> |
33 | | |
34 | | #include <optional> |
35 | | #include <map> |
36 | | #include <memory> |
37 | | #include <string_view> |
38 | | #include <utility> |
39 | | |
40 | | class SfxPoolItem; |
41 | | class SotStorage; |
42 | | class SvxAutoCorrect; |
43 | | class SfxObjectShell; |
44 | | namespace vcl { class Window; } |
45 | | namespace com::sun::star::embed { class XStorage; } |
46 | | |
47 | | struct CompareSvStringsISortDtor |
48 | | { |
49 | | bool operator()( std::u16string_view lhs, std::u16string_view rhs ) const |
50 | 0 | { |
51 | 0 | return o3tl::compareToIgnoreAsciiCase( lhs, rhs ) < 0; |
52 | 0 | } |
53 | | }; |
54 | | |
55 | | class SvStringsISortDtor |
56 | | : public o3tl::sorted_vector<OUString, CompareSvStringsISortDtor> |
57 | | { |
58 | | }; |
59 | | |
60 | | // Auto correct flags |
61 | | enum class ACFlags : sal_uInt32 { |
62 | | NONE = 0x00000000, |
63 | | CapitalStartSentence = 0x00000001, // Capital letters at the beginning of a sentence |
64 | | CapitalStartWord = 0x00000002, // not two Capital letters at the beginning of a word |
65 | | AddNonBrkSpace = 0x00000004, // Add non breaking space before :,?!% |
66 | | ChgOrdinalNumber = 0x00000008, // Ordinal-Number 1st, 2nd,.. |
67 | | ChgToEnEmDash = 0x00000010, // - -> Endash/Emdash |
68 | | ChgWeightUnderl = 0x00000020, // * -> Bold, _ -> Underscore |
69 | | SetINetAttr = 0x00000040, // Set INetAttribute |
70 | | Autocorrect = 0x00000080, // Call AutoCorrect |
71 | | ChgQuotes = 0x00000100, // replace double quotes |
72 | | SaveWordCplSttLst = 0x00000200, // Save Auto correction of Capital letter at beginning of sentence. |
73 | | SaveWordWordStartLst = 0x00000400, // Save Auto correction of TWo INitial CApitals or sMALL iNITIAL. |
74 | | IgnoreDoubleSpace = 0x00000800, // Ignore 2 Spaces |
75 | | ChgSglQuotes = 0x00001000, // Replace simple quotes |
76 | | CorrectCapsLock = 0x00002000, // Correct accidental use of cAPS LOCK key |
77 | | TransliterateRTL = 0x00004000, // Transliterate RTL text |
78 | | ChgAngleQuotes = 0x00008000, // >>, << -> angle quotes in some languages |
79 | | SetDOIAttr = 0x00010000, // Set DOIAttribute |
80 | | |
81 | | ChgWordLstLoad = 0x20000000, // Replacement list loaded |
82 | | CplSttLstLoad = 0x40000000, // Exception list for Capital letters Start loaded |
83 | | WordStartLstLoad = 0x80000000, // Exception list for Word Start loaded |
84 | | }; |
85 | | namespace o3tl { |
86 | | template<> struct typed_flags<ACFlags> : is_typed_flags<ACFlags, 0xe001ffff> {}; |
87 | | } |
88 | | |
89 | | enum class ACQuotes |
90 | | { |
91 | | NONE, |
92 | | NonBreakingSpace, |
93 | | CapitalizeIAm, |
94 | | DoubleAngleQuote, |
95 | | UseApostrophe, |
96 | | }; |
97 | | |
98 | | // TODO: handle code points > U+FFFF and check users of this class |
99 | | |
100 | | // only a mapping class |
101 | | class EDITENG_DLLPUBLIC SvxAutoCorrDoc |
102 | | { |
103 | | public: |
104 | | virtual ~SvxAutoCorrDoc(); |
105 | | |
106 | | virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) = 0; |
107 | | virtual bool Insert( sal_Int32 nPos, const OUString& rTxt ) = 0; |
108 | | virtual bool Replace( sal_Int32 nPos, const OUString& rTxt ) = 0; |
109 | | virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rTxt ) = 0; |
110 | | |
111 | | virtual void SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, |
112 | | SfxPoolItem& ) = 0; |
113 | | |
114 | | virtual bool SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL ) = 0; |
115 | | |
116 | | // Return the text of a previous paragraph. |
117 | | // If no paragraph exits or just an empty one, then return an empty string. |
118 | | // The flag indicates: |
119 | | // TRUE: before the normal insertion position (TRUE) |
120 | | // FALSE: in which the corrected word was inserted. |
121 | | // (Does not to have to be the same paragraph !!!!) |
122 | | virtual OUString const* GetPrevPara(bool bAtNormalPos) = 0; |
123 | | |
124 | | virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, |
125 | | SvxAutoCorrect& rACorrect, |
126 | | OUString* pPara ) = 0; |
127 | | virtual bool TransliterateRTLWord( sal_Int32& rSttPos, sal_Int32 nEndPos, |
128 | | bool bApply = false ) = 0; |
129 | | |
130 | | // Is called after the change of the signs by the functions |
131 | | // - FnCapitalStartWord |
132 | | // - FnCapitalStartSentence |
133 | | // As an option, the words can then be inserted into the exception lists. |
134 | | virtual void SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos, |
135 | | const OUString& rExceptWord, |
136 | | sal_Unicode cChar ); |
137 | | |
138 | | // which language at the position? |
139 | | virtual LanguageType GetLanguage( sal_Int32 nPos ) const; |
140 | | }; |
141 | | |
142 | | |
143 | | class EDITENG_DLLPUBLIC SvxAutocorrWord |
144 | | { |
145 | | OUString sShort, sLong; |
146 | | bool bIsTxtOnly; // Is pure ASCII - Text |
147 | | public: |
148 | | SvxAutocorrWord( OUString aS, OUString aL, bool bFlag = true ) |
149 | 0 | : sShort(std::move( aS )), sLong(std::move( aL )), bIsTxtOnly( bFlag ) |
150 | 0 | {} |
151 | | |
152 | 0 | const OUString& GetShort() const { return sShort; } |
153 | 0 | const OUString& GetLong() const { return sLong; } |
154 | 0 | bool IsTextOnly() const { return bIsTxtOnly; } |
155 | | }; |
156 | | |
157 | | class EDITENG_DLLPUBLIC SvxAutocorrWordList |
158 | | { |
159 | | struct Impl; |
160 | | std::unique_ptr<Impl> mpImpl; |
161 | | |
162 | | SvxAutocorrWordList( const SvxAutocorrWordList& ) = delete; |
163 | | const SvxAutocorrWordList& operator= ( const SvxAutocorrWordList& ) = delete; |
164 | | |
165 | | std::optional<SvxAutocorrWord> WordMatches(const SvxAutocorrWord *pFnd, |
166 | | std::u16string_view rTxt, |
167 | | sal_Int32 &rStt, |
168 | | sal_Int32 nEndPos) const; |
169 | | public: |
170 | | class EDITENG_DLLPUBLIC Iterator { |
171 | | struct Impl; |
172 | | std::unique_ptr<Impl> mpImpl; |
173 | | |
174 | | // For construction from containers in *SvxAutocorrWordList::mpImpl |
175 | | friend class SvxAutocorrWordList; |
176 | | Iterator(std::unique_ptr<Impl> pImpl); |
177 | | |
178 | | public: |
179 | | Iterator(const Iterator& it); |
180 | | ~Iterator(); |
181 | | bool Step(); |
182 | | const SvxAutocorrWord& operator*() const; |
183 | | const SvxAutocorrWord* operator->() const; |
184 | | }; |
185 | | |
186 | | class EDITENG_DLLPUBLIC WordSearchStatus { |
187 | | SvxAutocorrWord mFnd; |
188 | | |
189 | | // For iteration |
190 | | friend class SvxAutocorrWordList; |
191 | | const SvxAutocorrWordList* mpAutocorrWordList; |
192 | | SvxAutocorrWordList::Iterator mAutocorrWordListIter; |
193 | | |
194 | | public: |
195 | | WordSearchStatus( |
196 | | const SvxAutocorrWord& aFnd, |
197 | | const SvxAutocorrWordList* pAutocorrWordList, |
198 | | const SvxAutocorrWordList::Iterator& autocorrWordListIter |
199 | 0 | ) : mFnd(aFnd), mpAutocorrWordList(pAutocorrWordList), |
200 | 0 | mAutocorrWordListIter(autocorrWordListIter) |
201 | 0 | {} |
202 | 0 | const SvxAutocorrWord* GetAutocorrWord() const { |
203 | 0 | return &mFnd; |
204 | 0 | } |
205 | 0 | const SvxAutocorrWordList* GetAutocorrWordList() const { |
206 | 0 | return mpAutocorrWordList; |
207 | 0 | } |
208 | 0 | const SvxAutocorrWord* GetWordAtIter() const { |
209 | 0 | return &*mAutocorrWordListIter; |
210 | 0 | } |
211 | 0 | bool StepIter() { |
212 | 0 | return mAutocorrWordListIter.Step(); |
213 | 0 | } |
214 | | }; |
215 | | |
216 | | SvxAutocorrWordList(); |
217 | | // free any objects still in the set |
218 | | ~SvxAutocorrWordList(); |
219 | | void DeleteAndDestroyAll(); |
220 | | bool ContainsPattern(const OUString& sShort) const; |
221 | | const SvxAutocorrWord* Insert(SvxAutocorrWord aWord) const; |
222 | | std::optional<SvxAutocorrWord> FindAndRemove(const SvxAutocorrWord *pWord); |
223 | | void LoadEntry(const OUString& sWrong, const OUString& sRight, bool bOnlyTxt); |
224 | | bool empty() const; |
225 | | |
226 | | struct CompareSvxAutocorrWordList; |
227 | | typedef std::vector<SvxAutocorrWord> AutocorrWordSetType; |
228 | | const AutocorrWordSetType & getSortedContent() const; |
229 | | |
230 | | std::optional<WordSearchStatus> |
231 | | SearchWordsInList(std::u16string_view rTxt, sal_Int32& rStt, sal_Int32 nEndPos) const; |
232 | | bool |
233 | | SearchWordsNext(std::u16string_view rTxt, sal_Int32& rStt, sal_Int32 nEndPos, WordSearchStatus& rStatus) const; |
234 | | }; |
235 | | |
236 | | class EDITENG_DLLPUBLIC SvxAutoCorrectLanguageLists |
237 | | { |
238 | | OUString sShareAutoCorrFile, sUserAutoCorrFile; |
239 | | // If the AutoCorr file is newer |
240 | | Date aModifiedDate; |
241 | | tools::Time aModifiedTime, aLastCheckTime; |
242 | | |
243 | | std::unique_ptr<SvStringsISortDtor> pCplStt_ExcptLst; |
244 | | std::unique_ptr<SvStringsISortDtor> pWordStart_ExcptLst; |
245 | | std::unique_ptr<SvxAutocorrWordList> pAutocorr_List; |
246 | | SvxAutoCorrect& rAutoCorrect; |
247 | | |
248 | | ACFlags nFlags; |
249 | | |
250 | | bool IsFileChanged_Imp(); |
251 | | void LoadXMLExceptList_Imp( std::unique_ptr<SvStringsISortDtor>& rpLst, |
252 | | const OUString& sStrmName, |
253 | | rtl::Reference<SotStorage>& rStg); |
254 | | static void SaveExceptList_Imp( const SvStringsISortDtor& rLst, |
255 | | const OUString& sStrmName, |
256 | | rtl::Reference<SotStorage> const & rStg, |
257 | | bool bConvert = false); |
258 | | |
259 | | bool MakeBlocklist_Imp( SotStorage& rStg ); |
260 | | void RemoveStream_Imp( const OUString& rName ); |
261 | | void MakeUserStorage_Impl(); |
262 | | |
263 | | public: |
264 | | SvxAutoCorrectLanguageLists( SvxAutoCorrect& rParent, |
265 | | OUString aShareAutoCorrectFile, |
266 | | OUString aUserAutoCorrectFile); |
267 | | ~SvxAutoCorrectLanguageLists(); |
268 | | |
269 | | // Load, Set, Get - the replacement list |
270 | | SvxAutocorrWordList* LoadAutocorrWordList(); |
271 | | const SvxAutocorrWordList* GetAutocorrWordList(); |
272 | | |
273 | | // Load, Set, Get - the exception list for Capital letter at the |
274 | | // beginning of a sentence |
275 | | SvStringsISortDtor* LoadCplSttExceptList(); |
276 | | void SaveCplSttExceptList(); |
277 | | SvStringsISortDtor* GetCplSttExceptList(); |
278 | | bool AddToCplSttExceptList(const OUString& rNew); |
279 | | |
280 | | // Load, Set, Get the exception list for TWo INitial CApitals or sMALL iNITIAL |
281 | | SvStringsISortDtor* LoadWordStartExceptList(); |
282 | | void SaveWordStartExceptList(); |
283 | | SvStringsISortDtor* GetWordStartExceptList(); |
284 | | bool AddToWordStartExceptList(const OUString& rNew); |
285 | | |
286 | | // Save word substitutions: |
287 | | // Store these directly in the storage. The word list is updated |
288 | | // accordingly! |
289 | | // - pure Text |
290 | | bool PutText( const OUString& rShort, const OUString& rLong ); |
291 | | // - Text with attribution (only the SWG - SWG format!) |
292 | | void PutText( const OUString& rShort, SfxObjectShell& ); |
293 | | // - Make combined changes in one pass |
294 | | bool MakeCombinedChanges( std::vector<SvxAutocorrWord>& aNewEntries, std::vector<SvxAutocorrWord>& aDeleteEntries ); |
295 | | }; |
296 | | |
297 | | class EDITENG_DLLPUBLIC SvxAutoCorrect |
298 | | { |
299 | | friend class SvxAutoCorrectLanguageLists; |
300 | | |
301 | | OUString sShareAutoCorrFile, sUserAutoCorrFile; |
302 | | |
303 | | SvxSwAutoFormatFlags aSwFlags; // StarWriter AutoFormat Flags |
304 | | |
305 | | // all languages in a table |
306 | | std::map<LanguageTag, SvxAutoCorrectLanguageLists> m_aLangTable; |
307 | | std::map<LanguageTag, sal_Int64> aLastFileTable; |
308 | | std::optional<CharClass> moCharClass; |
309 | | |
310 | | LanguageType eCharClassLang; |
311 | | |
312 | | ACFlags nFlags; |
313 | | sal_Unicode cStartDQuote, cEndDQuote, cStartSQuote, cEndSQuote; |
314 | | |
315 | | |
316 | | // private methods |
317 | | SvxAutoCorrectLanguageLists& GetLanguageList_( LanguageType eLang ); |
318 | | |
319 | | void GetCharClass_( LanguageType eLang ); |
320 | | |
321 | | protected: |
322 | | // - Text with attribution (only the SWG - SWG format!) |
323 | | // rShort is the stream name - encrypted! |
324 | | virtual bool PutText( const css::uno::Reference < css::embed::XStorage >& rStg, |
325 | | const OUString& rFileName, const OUString& rShort, SfxObjectShell&, OUString& ); |
326 | | |
327 | | // required language in the table add if possible only when the file exists |
328 | | bool CreateLanguageFile(const LanguageTag& rLanguageTag, bool bNewFile = true); |
329 | | // - Return the replacement text (only for SWG format, all others can be |
330 | | // taken from the word list!) |
331 | | // rShort is the stream name - encrypted! |
332 | | public: |
333 | | |
334 | | sal_Unicode GetQuote( sal_Unicode cInsChar, bool bSttQuote, |
335 | | LanguageType eLang ) const; |
336 | | virtual bool GetLongText( const OUString& rShort, OUString& rLong ); |
337 | | |
338 | | virtual void refreshBlockList( const css::uno::Reference < css::embed::XStorage >& rStg); |
339 | | |
340 | | SvxAutoCorrect( OUString aShareAutocorrFile, |
341 | | OUString aUserAutocorrFile ); |
342 | | SvxAutoCorrect( const SvxAutoCorrect& ); |
343 | | virtual ~SvxAutoCorrect(); |
344 | | |
345 | | /** Execute an AutoCorrect. |
346 | | Returns what has been executed, according to the above auto correct flags. |
347 | | @param io_bNbspRunNext |
348 | | Remembers if a NO-BREAK SPACE was added (eg. in "fr" language) |
349 | | (set to <TRUE/>) at the last character input that may have to |
350 | | be removed again depending on what character is following. |
351 | | */ |
352 | | // FIXME: this has the horrible flaw that the rTxt must be a reference |
353 | | // to the actual SwTxtNode/EditNode string because it inserts the character |
354 | | // in rDoc and expects that to side-effect rTxt |
355 | | void DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, |
356 | | sal_Int32 nPos, sal_Unicode cInsChar, bool bInsert, bool& io_bNbspRunNext, |
357 | | vcl::Window const * pFrameWin = nullptr ); |
358 | | |
359 | | // Return for the autotext expansion the previous word, |
360 | | // AutoCorrect - corresponding algorithm |
361 | | OUString GetPrevAutoCorrWord(SvxAutoCorrDoc const& rDoc, const OUString& rTxt, sal_Int32 nPos); |
362 | | |
363 | | // Returns vector candidates for AutoText name match, starting with the longest string between |
364 | | // 3 and 9 characters long, that is a chunk of text starting with a whitespace or with a word's |
365 | | // first character, and ending at the current cursor position or empty string if no such string |
366 | | // exists |
367 | | static std::vector<OUString> GetChunkForAutoText(std::u16string_view rTxt, sal_Int32 nPos); |
368 | | |
369 | | // Search for the words in the replacement table. |
370 | | // rText - check in this text the words of the list |
371 | | // rStt - the detected starting position |
372 | | // nEnd - to check position - as of this item forward |
373 | | // rLang - Input: in which language is searched |
374 | | // Output: in which "language list" was it found |
375 | | std::optional<SvxAutocorrWordList::WordSearchStatus> |
376 | | SearchWordsInList( std::u16string_view rTxt, |
377 | | sal_Int32& rStt, sal_Int32 nEndPos, |
378 | | SvxAutoCorrDoc& rDoc, |
379 | | LanguageTag& rLang ); |
380 | | static bool SearchWordsNext( std::u16string_view rTxt, |
381 | | sal_Int32& rStt, sal_Int32 nEndPos, |
382 | | SvxAutocorrWordList::WordSearchStatus& rStatus ); |
383 | | |
384 | | // Query/Set the Character for the Quote substitution |
385 | 0 | sal_Unicode GetStartSingleQuote() const { return cStartSQuote; } |
386 | 0 | sal_Unicode GetEndSingleQuote() const { return cEndSQuote; } |
387 | 0 | sal_Unicode GetStartDoubleQuote() const { return cStartDQuote; } |
388 | 0 | sal_Unicode GetEndDoubleQuote() const { return cEndDQuote; } |
389 | | |
390 | 0 | void SetStartSingleQuote( const sal_Unicode cStart ) { cStartSQuote = cStart; } |
391 | 0 | void SetEndSingleQuote( const sal_Unicode cEnd ) { cEndSQuote = cEnd; } |
392 | 0 | void SetStartDoubleQuote( const sal_Unicode cStart ) { cStartDQuote = cStart; } |
393 | 0 | void SetEndDoubleQuote( const sal_Unicode cEnd ) { cEndDQuote = cEnd; } |
394 | | |
395 | | OUString GetQuote( SvxAutoCorrDoc const & rDoc, sal_Int32 nInsPos, |
396 | | sal_Unicode cInsChar, bool bSttQuote ); |
397 | | void InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos, |
398 | | sal_Unicode cInsChar, bool bSttQuote, bool bIns, |
399 | | LanguageType eLang, ACQuotes eType ) const; |
400 | | |
401 | | // Query/Set the name of the AutoCorrect file |
402 | | // the default is "autocorr.dat" |
403 | | OUString GetAutoCorrFileName( const LanguageTag& rLanguageTag /* = LANGUAGE_SYSTEM */ , |
404 | | bool bNewFile = false, |
405 | | bool bTstUserExist = false, |
406 | | bool bUnlocalized = false ) const; |
407 | | |
408 | | // Query/Set the current settings of AutoCorrect |
409 | 0 | ACFlags GetFlags() const { return nFlags; } |
410 | 0 | SvxSwAutoFormatFlags& GetSwFlags() { return aSwFlags;} |
411 | 0 | const SvxSwAutoFormatFlags& GetSwFlags() const { return aSwFlags; } |
412 | | bool IsAutoCorrFlag( ACFlags nFlag ) const |
413 | 0 | { return bool(nFlags & nFlag); } |
414 | | void SetAutoCorrFlag( ACFlags nFlag, bool bOn = true ); |
415 | | |
416 | | // Load, Set, Get - the replacement list |
417 | | SvxAutocorrWordList* LoadAutocorrWordList( LanguageType eLang ) |
418 | 0 | { return GetLanguageList_( eLang ).LoadAutocorrWordList(); } |
419 | | |
420 | | // Save word substitutions: |
421 | | // Save these directly in the storage. The word list is updated |
422 | | // accordingly! |
423 | | // - pure Text |
424 | | bool PutText( const OUString& rShort, const OUString& rLong, LanguageType eLang ); |
425 | | // - Text with attribution (only in the SWG - SWG format!) |
426 | | void PutText( const OUString& rShort, SfxObjectShell& rShell, LanguageType eLang ) |
427 | 0 | { GetLanguageList_( eLang ).PutText(rShort, rShell ); } |
428 | | |
429 | | void MakeCombinedChanges( std::vector<SvxAutocorrWord>& aNewEntries, |
430 | | std::vector<SvxAutocorrWord>& aDeleteEntries, |
431 | | LanguageType eLang ); |
432 | | |
433 | | // Load, Set, Get - the exception list for capital letters at the |
434 | | // beginning of a sentence |
435 | | void SaveCplSttExceptList( LanguageType eLang ); |
436 | | SvStringsISortDtor* LoadCplSttExceptList(LanguageType eLang) |
437 | 0 | { return GetLanguageList_( eLang ).LoadCplSttExceptList(); } |
438 | | const SvStringsISortDtor* GetCplSttExceptList( LanguageType eLang ) |
439 | 0 | { return GetLanguageList_( eLang ).GetCplSttExceptList(); } |
440 | | |
441 | | // Adds a single word. The list will be immediately written to the file! |
442 | | bool AddCplSttException( const OUString& rNew, LanguageType eLang ); |
443 | | |
444 | | // Load, Set, Get the exception list for TWo INitial CApitals or sMALL iNITIAL |
445 | | void SaveWordStartExceptList( LanguageType eLang ); |
446 | | SvStringsISortDtor* LoadWordStartExceptList( LanguageType eLang ) |
447 | 0 | { return GetLanguageList_( eLang ).LoadWordStartExceptList(); } |
448 | | const SvStringsISortDtor* GetWordStartExceptList( LanguageType eLang ) |
449 | 0 | { return GetLanguageList_( eLang ).GetWordStartExceptList(); } |
450 | | // Adds a single word. The list will be immediately written to the file! |
451 | | bool AddWordStartException( const OUString& rNew, LanguageType eLang); |
452 | | |
453 | | // Search through the Languages for the entry |
454 | | bool FindInWordStartExceptList( LanguageType eLang, const OUString& sWord ); |
455 | | bool FindInCplSttExceptList( LanguageType eLang, const OUString& sWord, |
456 | | bool bAbbreviation = false); |
457 | | |
458 | | // Methods for the auto-correction |
459 | | void FnCapitalStartWord( SvxAutoCorrDoc&, const OUString&, |
460 | | sal_Int32 nSttPos, sal_Int32 nEndPos, |
461 | | LanguageType eLang ); |
462 | | bool FnChgOrdinalNumber( SvxAutoCorrDoc&, const OUString&, |
463 | | sal_Int32 nSttPos, sal_Int32 nEndPos, |
464 | | LanguageType eLang ); |
465 | | bool FnChgToEnEmDash( SvxAutoCorrDoc&, const OUString&, |
466 | | sal_Int32 nSttPos, sal_Int32 nEndPos, |
467 | | LanguageType eLang ); |
468 | | // Returns an updated position, at which the insertion/removal happened. It may be |
469 | | // a smaller value, if leading spaces were removed. If unsuccessful, returns -1. |
470 | | sal_Int32 FnAddNonBrkSpace( SvxAutoCorrDoc&, std::u16string_view, |
471 | | sal_Int32 nEndPos, |
472 | | LanguageType eLang, bool& io_bNbspRunNext ); |
473 | | bool FnSetINetAttr( SvxAutoCorrDoc&, const OUString&, |
474 | | sal_Int32 nSttPos, sal_Int32 nEndPos, |
475 | | LanguageType eLang ); |
476 | | bool FnSetDOIAttr( SvxAutoCorrDoc&, std::u16string_view, |
477 | | sal_Int32 nSttPos, sal_Int32 nEndPos, |
478 | | LanguageType eLang ); |
479 | | bool FnChgWeightUnderl( SvxAutoCorrDoc&, const OUString&, |
480 | | sal_Int32 nEndPos ); |
481 | | void FnCapitalStartSentence( SvxAutoCorrDoc&, const OUString&, bool bNormalPos, |
482 | | sal_Int32 nSttPos, sal_Int32 nEndPos, |
483 | | LanguageType eLang); |
484 | | bool FnCorrectCapsLock( SvxAutoCorrDoc&, const OUString&, |
485 | | sal_Int32 nSttPos, sal_Int32 nEndPos, |
486 | | LanguageType eLang ); |
487 | | |
488 | | static ACFlags GetDefaultFlags(); |
489 | | |
490 | | // returns sal_True for characters where the function |
491 | | // 'SvxAutoCorrect::AutoCorrect' should be called. |
492 | | // (used to avoid occasional 'collisions' with (Thai) input-sequence-checking) |
493 | | static bool IsAutoCorrectChar( sal_Unicode cChar ); |
494 | | |
495 | | static bool NeedsHardspaceAutocorr( sal_Unicode cChar ); |
496 | | |
497 | | CharClass& GetCharClass( LanguageType eLang ) |
498 | 0 | { |
499 | 0 | if( !moCharClass || eLang != eCharClassLang ) |
500 | 0 | GetCharClass_( eLang ); |
501 | 0 | return *moCharClass; |
502 | 0 | } |
503 | | }; |
504 | | |
505 | | #endif |
506 | | |
507 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |