xref: /AOO41X/main/editeng/inc/editeng/splwrap.hxx (revision 4d7c9de063a797b8b4f3d45e3561e82ad1f8ef1f)
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 _SVX_SPLWRAP_HXX
24 #define _SVX_SPLWRAP_HXX
25 
26 // include ---------------------------------------------------------------
27 
28 #include <editeng/svxenum.hxx>
29 #include <tools/string.hxx>
30 #include <com/sun/star/uno/Reference.hxx>
31 #include "editeng/editengdllapi.h"
32 
33 // forward ---------------------------------------------------------------
34 
35 namespace com { namespace sun { namespace star { namespace linguistic2 {
36     class XDictionary;
37     class XSpellChecker1;
38     class XHyphenator;
39 }}}}
40 
41 class Window;
42 class SdrObject;
43 // misc functions ---------------------------------------------------------------
44 
45 void EDITENG_DLLPUBLIC SvxPrepareAutoCorrect( String &rOldText, String &rNewText );
46 
47 /*--------------------------------------------------------------------
48      Beschreibung: Der SpellWrapper
49  --------------------------------------------------------------------*/
50 
51 class EDITENG_DLLPUBLIC SvxSpellWrapper {
52 private:
53     friend class SvxSpellCheckDialog;
54     friend class SvxHyphenWordDialog;
55     friend class SvxHyphenWordDialog_Impl;
56 
57     Window*     pWin;
58     ::com::sun::star::uno::Reference<
59         ::com::sun::star::uno::XInterface >             xLast;  // result of last spelling/hyphenation attempt
60     ::com::sun::star::uno::Reference<
61         ::com::sun::star::linguistic2::XSpellChecker1 > xSpell;
62     ::com::sun::star::uno::Reference<
63         ::com::sun::star::linguistic2::XHyphenator >    xHyph;
64     SdrObject* mpTextObj;
65     sal_uInt16  nOldLang;       // Sprache merken, nur bei Aenderung SetLanguage rufen
66     sal_Bool    bOtherCntnt : 1; // gesetzt => Sonderbereiche zunaechst pruefen
67     sal_Bool    bDialog     : 1; // Ist pWin der Svx...Dialog?
68     sal_Bool    bHyphen     : 1; // Trennen statt Spellen
69     sal_Bool    bAuto       : 1; // Autokorrektur vorhanden?
70     sal_Bool    bReverse    : 1; // Rueckwaerts Spellen
71     sal_Bool    bStartDone  : 1; // Vorderen Teil bereits korrigiert
72     sal_Bool    bEndDone    : 1; // Hinteren Teil bereits korrigiert
73     sal_Bool    bStartChk   : 1; // Vorderen Teil pruefen
74     sal_Bool    bRevAllowed : 1; // Niemals rueckwaerts spellen
75     sal_Bool    bAllRight   : 1; // falsche Woerter in geignetes Woerterbuch
76                              // aufnehmen und nicht den Dialog starten.
77 
78     EDITENG_DLLPRIVATE sal_Bool     SpellNext();        // naechsten Bereich anwaehlen
79     sal_Bool    FindSpellError();   // Suche nach Fehlern ( ueber Bereiche hinweg )
80 
81 public:
82     SvxSpellWrapper( Window* pWn,
83                      ::com::sun::star::uno::Reference<
84                         ::com::sun::star::linguistic2::XSpellChecker1 >  &xSpellChecker,
85                      const sal_Bool bStart = sal_False, const sal_Bool bIsAllRight = sal_False,
86                      const sal_Bool bOther = sal_False, const sal_Bool bRevAllow = sal_True );
87     SvxSpellWrapper( Window* pWn,
88                      ::com::sun::star::uno::Reference<
89                         ::com::sun::star::linguistic2::XHyphenator >  &xHyphenator,
90                      const sal_Bool bStart = sal_False, const sal_Bool bOther = sal_False );
91 
92     virtual ~SvxSpellWrapper();
93 
94     static sal_Int16    CheckSpellLang(
95                             ::com::sun::star::uno::Reference<
96                                 ::com::sun::star::linguistic2::XSpellChecker1 >  xSpell,
97                             sal_Int16 nLang );
98     static sal_Int16    CheckHyphLang(
99                             ::com::sun::star::uno::Reference<
100                                 ::com::sun::star::linguistic2::XHyphenator >  xHyph,
101                             sal_Int16 nLang );
102 
103     static void         ShowLanguageErrors();
104 
105     void            SpellDocument();        // Rechtschreibpruefung durchfuehren
IsStartDone()106     inline sal_Bool IsStartDone(){ return bStartDone; }
IsEndDone()107     inline sal_Bool IsEndDone(){ return bEndDone; }
IsReverse()108     inline sal_Bool IsReverse(){ return bReverse; }
IsDialog()109     inline sal_Bool IsDialog(){ return bDialog; } // SvxSpellCheckDialog OnScreen
IsHyphen()110     inline sal_Bool IsHyphen(){ return bHyphen; } // Trennen statt Spellen
SetHyphen(const sal_Bool bNew=sal_True)111     inline void     SetHyphen( const sal_Bool bNew = sal_True ){ bHyphen = bNew; }
112     inline ::com::sun::star::uno::Reference<
113         ::com::sun::star::linguistic2::XSpellChecker1 >
GetXSpellChecker()114                     GetXSpellChecker() { return xSpell; }
115     inline ::com::sun::star::uno::Reference<
116         ::com::sun::star::linguistic2::XHyphenator >
GetXHyphenator()117                     GetXHyphenator()    { return xHyph; }
IsAllRight()118     inline sal_Bool             IsAllRight()        { return bAllRight; }
GetWin()119     inline Window*  GetWin() { return pWin; }
120     // kann evtl entfallen in ONE_LINGU:
SetOldLang(const sal_uInt16 nNew)121     inline void     SetOldLang( const sal_uInt16 nNew ){ nOldLang = nNew; }
122     // kann evtl entfallen in ONE_LINGU:
ChangeLanguage(const sal_uInt16 nNew)123     inline void     ChangeLanguage( const sal_uInt16 nNew ) // rufe ggf. SetLanguage
124         { if ( nNew != nOldLang ) { SetLanguage( nNew ); nOldLang = nNew; } }
EnableAutoCorrect()125     inline void     EnableAutoCorrect() { bAuto = sal_True; }
126 
127 protected:
128     ::com::sun::star::uno::Reference<
129         ::com::sun::star::uno::XInterface >
GetLast()130                      GetLast()      { return xLast; }
SetLast(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xNewLast)131     void             SetLast(const ::com::sun::star::uno::Reference<
132                                 ::com::sun::star::uno::XInterface >  &xNewLast)
133                             { xLast = xNewLast; }
134     virtual sal_Bool SpellMore();               // weitere Dokumente pruefen?
135     virtual sal_Bool HasOtherCnt();             // gibt es ueberhaupt Sonderbereiche
136     virtual void     SpellStart( SvxSpellArea eSpell ); // Bereich vorbereiten
137     virtual sal_Bool SpellContinue();           // Bereich pruefen
138                                             // Ergebnis mit GetLast verfuegbar
139     virtual void ReplaceAll( const String &rNewText, sal_Int16 nLanguage ); // Wort aus Replace-Liste ersetzen
140     virtual void StartThesaurus( const String &rWord, sal_uInt16 nLang );   // Thesaurus starten
141     virtual ::com::sun::star::uno::Reference<
142         ::com::sun::star::linguistic2::XDictionary >
143                  GetAllRightDic() const;
144     virtual void SpellEnd();                        // Bereich abschliessen
145     virtual void ScrollArea();                      // ScrollArea einstellen
146     // Wort ersetzen
147     virtual void ChangeWord( const String& rNewWord, const sal_uInt16 nLang );
148     virtual String GetThesWord();
149     // Wort via Thesaurus ersetzen
150     virtual void ChangeThesWord( const String& rNewWord );
151     virtual void SetLanguage( const sal_uInt16 nLang ); // Sprache aendern
152     virtual void AutoCorrect( const String& rAktStr, const String& rNewStr );
153     virtual void InsertHyphen( const sal_uInt16 nPos ); // Hyphen einfuegen
154 
SetCurTextObj(SdrObject * pObj)155     void SetCurTextObj( SdrObject* pObj ) { mpTextObj = pObj; }
GetCurTextObj()156     SdrObject* GetCurTextObj() { return mpTextObj; }
157 };
158 
159 #endif
160