xref: /AOO41X/main/sw/source/core/inc/acorrect.hxx (revision 67e470dafe1997e73f56ff7ff4878983707e3e07)
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 #ifndef _ACORRECT_HXX
24 #define _ACORRECT_HXX
25 
26 #include <editeng/svxacorr.hxx>
27 
28 #include <swundo.hxx>
29 
30 
31 class SwEditShell;
32 class SwPaM;
33 class SwNodeIndex;
34 struct SwPosition;
35 class SfxItemSet;
36 
37 class SwDontExpandItem
38 {
39     SfxItemSet* pDontExpItems;
40 public:
SwDontExpandItem()41     SwDontExpandItem() :
42         pDontExpItems(0){}
43     ~SwDontExpandItem();
44 
45     void SaveDontExpandItems( const SwPosition& rPos );
46     void RestoreDontExpandItems( const SwPosition& rPos );
47 
48 };
49 
50 class SwAutoCorrDoc : public SvxAutoCorrDoc
51 {
52     SwEditShell& rEditSh;
53     SwPaM& rCrsr;
54     SwNodeIndex* pIdx;
55     int m_nEndUndoCounter;
56     bool    bUndoIdInitialized;
57 
58     void DeleteSel( SwPaM& rDelPam );
59 
60 public:
61     SwAutoCorrDoc( SwEditShell& rEditShell, SwPaM& rPam, sal_Unicode cIns = 0 );
62     ~SwAutoCorrDoc();
63 
64     virtual sal_Bool Delete( xub_StrLen nStt, xub_StrLen nEnd );
65     virtual sal_Bool Insert( xub_StrLen nPos, const String& rTxt );
66     virtual sal_Bool Replace( xub_StrLen nPos, const String& rTxt );
67     virtual sal_Bool ReplaceRange( xub_StrLen nPos, xub_StrLen nLen, const String& rTxt );
68 
69     virtual sal_Bool SetAttr( xub_StrLen nStt, xub_StrLen nEnd, sal_uInt16 nSlotId,
70                             SfxPoolItem& );
71 
72     virtual sal_Bool SetINetAttr( xub_StrLen nStt, xub_StrLen nEnd, const String& rURL );
73 
74     // returne den Text eines vorherigen Absatzes.
75     // Dieser darf nicht leer sein!
76     // Gibt es diesen nicht oder gibt es davor nur Leere, dann returne 0
77     // Das Flag gibt an:
78     //      sal_True: den, vor der normalen Einfuegeposition (sal_True)
79     //      sal_False: den, in den das korrigierte Wort eingfuegt wurde.
80     //              (Muss nicht der gleiche Absatz sein!!!!)
81     virtual const String* GetPrevPara( sal_Bool bAtNormalPos );
82 
83     virtual sal_Bool ChgAutoCorrWord( xub_StrLen& rSttPos, xub_StrLen nEndPos,
84                                   SvxAutoCorrect& rACorrect,
85                                   const String** ppPara );
86 
87     // wird nach dem austauschen der Zeichen von den Funktionen
88     //  - FnCptlSttWrd
89     //  - FnCptlSttSntnc
90     // gerufen. Dann koennen die Worte ggfs. in die Ausnahmelisten
91     // aufgenommen werden.
92     virtual void SaveCpltSttWord( sal_uLong nFlag, xub_StrLen nPos,
93                                     const String& rExceptWord, sal_Unicode cChar );
94     virtual LanguageType GetLanguage( xub_StrLen nPos, sal_Bool bPrevPara ) const;
95 };
96 
97 class SwAutoCorrExceptWord
98 {
99     String sWord;
100     sal_uLong nFlags, nNode;
101     xub_StrLen nCntnt;
102     sal_Unicode cChar;
103     LanguageType eLanguage;
104     sal_Bool bDeleted;
105 public:
SwAutoCorrExceptWord(sal_uLong nAFlags,sal_uLong nNd,xub_StrLen nContent,const String & rWord,sal_Unicode cChr,LanguageType eLang)106     SwAutoCorrExceptWord( sal_uLong nAFlags, sal_uLong nNd, xub_StrLen nContent,
107                                         const String& rWord, sal_Unicode cChr,
108                                         LanguageType eLang )
109         : sWord(rWord), nFlags(nAFlags), nNode(nNd), nCntnt(nContent),
110         cChar(cChr), eLanguage(eLang), bDeleted(sal_False)
111     {}
112 
IsDeleted() const113     sal_Bool IsDeleted() const                          { return bDeleted; }
114     void CheckChar( const SwPosition& rPos, sal_Unicode cChar );
115     sal_Bool CheckDelChar( const SwPosition& rPos );
116 };
117 
118 
119 #endif
120