xref: /trunk/main/sw/source/core/inc/acorrect.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _ACORRECT_HXX
28 #define _ACORRECT_HXX
29 
30 #include <editeng/svxacorr.hxx>
31 
32 #include <swundo.hxx>
33 
34 
35 class SwEditShell;
36 class SwPaM;
37 class SwNodeIndex;
38 struct SwPosition;
39 class SfxItemSet;
40 
41 class SwDontExpandItem
42 {
43     SfxItemSet* pDontExpItems;
44 public:
45     SwDontExpandItem() :
46         pDontExpItems(0){}
47     ~SwDontExpandItem();
48 
49     void SaveDontExpandItems( const SwPosition& rPos );
50     void RestoreDontExpandItems( const SwPosition& rPos );
51 
52 };
53 
54 class SwAutoCorrDoc : public SvxAutoCorrDoc
55 {
56     SwEditShell& rEditSh;
57     SwPaM& rCrsr;
58     SwNodeIndex* pIdx;
59     int m_nEndUndoCounter;
60     bool    bUndoIdInitialized;
61 
62     void DeleteSel( SwPaM& rDelPam );
63 
64 public:
65     SwAutoCorrDoc( SwEditShell& rEditShell, SwPaM& rPam, sal_Unicode cIns = 0 );
66     ~SwAutoCorrDoc();
67 
68     virtual sal_Bool Delete( xub_StrLen nStt, xub_StrLen nEnd );
69     virtual sal_Bool Insert( xub_StrLen nPos, const String& rTxt );
70     virtual sal_Bool Replace( xub_StrLen nPos, const String& rTxt );
71     virtual sal_Bool ReplaceRange( xub_StrLen nPos, xub_StrLen nLen, const String& rTxt );
72 
73     virtual sal_Bool SetAttr( xub_StrLen nStt, xub_StrLen nEnd, sal_uInt16 nSlotId,
74                             SfxPoolItem& );
75 
76     virtual sal_Bool SetINetAttr( xub_StrLen nStt, xub_StrLen nEnd, const String& rURL );
77 
78     // returne den Text eines vorherigen Absatzes.
79     // Dieser darf nicht leer sein!
80     // Gibt es diesen nicht oder gibt es davor nur Leere, dann returne 0
81     // Das Flag gibt an:
82     //      sal_True: den, vor der normalen Einfuegeposition (sal_True)
83     //      sal_False: den, in den das korrigierte Wort eingfuegt wurde.
84     //              (Muss nicht der gleiche Absatz sein!!!!)
85     virtual const String* GetPrevPara( sal_Bool bAtNormalPos );
86 
87     virtual sal_Bool ChgAutoCorrWord( xub_StrLen& rSttPos, xub_StrLen nEndPos,
88                                   SvxAutoCorrect& rACorrect,
89                                   const String** ppPara );
90 
91     // wird nach dem austauschen der Zeichen von den Funktionen
92     //  - FnCptlSttWrd
93     //  - FnCptlSttSntnc
94     // gerufen. Dann koennen die Worte ggfs. in die Ausnahmelisten
95     // aufgenommen werden.
96     virtual void SaveCpltSttWord( sal_uLong nFlag, xub_StrLen nPos,
97                                     const String& rExceptWord, sal_Unicode cChar );
98     virtual LanguageType GetLanguage( xub_StrLen nPos, sal_Bool bPrevPara ) const;
99 };
100 
101 class SwAutoCorrExceptWord
102 {
103     String sWord;
104     sal_uLong nFlags, nNode;
105     xub_StrLen nCntnt;
106     sal_Unicode cChar;
107     LanguageType eLanguage;
108     sal_Bool bDeleted;
109 public:
110     SwAutoCorrExceptWord( sal_uLong nAFlags, sal_uLong nNd, xub_StrLen nContent,
111                                         const String& rWord, sal_Unicode cChr,
112                                         LanguageType eLang )
113         : sWord(rWord), nFlags(nAFlags), nNode(nNd), nCntnt(nContent),
114         cChar(cChr), eLanguage(eLang), bDeleted(sal_False)
115     {}
116 
117     sal_Bool IsDeleted() const                          { return bDeleted; }
118     void CheckChar( const SwPosition& rPos, sal_Unicode cChar );
119     sal_Bool CheckDelChar( const SwPosition& rPos );
120 };
121 
122 
123 #endif
124