Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SVX_SPLWRAP_HXX
29 : : #define _SVX_SPLWRAP_HXX
30 : :
31 : : #include <editeng/svxenum.hxx>
32 : : #include <tools/string.hxx>
33 : : #include <com/sun/star/uno/Reference.hxx>
34 : : #include "editeng/editengdllapi.h"
35 : :
36 : : // forward ---------------------------------------------------------------
37 : :
38 : : namespace com { namespace sun { namespace star { namespace linguistic2 {
39 : : class XDictionary;
40 : : class XSpellChecker1;
41 : : class XHyphenator;
42 : : }}}}
43 : :
44 : : class Window;
45 : :
46 : : // misc functions ---------------------------------------------------------------
47 : :
48 : : void EDITENG_DLLPUBLIC SvxPrepareAutoCorrect( String &rOldText, String &rNewText );
49 : :
50 : : /*--------------------------------------------------------------------
51 : : Description: The SpellWrapper
52 : : --------------------------------------------------------------------*/
53 : :
54 : : class EDITENG_DLLPUBLIC SvxSpellWrapper {
55 : : private:
56 : : friend class SvxSpellCheckDialog;
57 : : friend class SvxHyphenWordDialog;
58 : : friend struct SvxHyphenWordDialog_Impl;
59 : :
60 : : Window* pWin;
61 : : ::com::sun::star::uno::Reference<
62 : : ::com::sun::star::uno::XInterface > xLast; // result of last spelling/hyphenation attempt
63 : : ::com::sun::star::uno::Reference<
64 : : ::com::sun::star::linguistic2::XSpellChecker1 > xSpell;
65 : : ::com::sun::star::uno::Reference<
66 : : ::com::sun::star::linguistic2::XHyphenator > xHyph;
67 : : sal_uInt16 nOldLang; // Set Language, only call SetLanguage on changes
68 : : sal_Bool bOtherCntnt : 1; // set => Check special sections initially
69 : : sal_Bool bDialog : 1; // Is pWin the Svx...Dialog?
70 : : sal_Bool bHyphen : 1; // Split instead of spell checking
71 : : sal_Bool bAuto : 1; // AutoCorrect available?
72 : : sal_Bool bReverse : 1; // Reverse spell check
73 : : sal_Bool bStartDone : 1; // Beginning already corrected
74 : : sal_Bool bEndDone : 1; // End part already corrected
75 : : sal_Bool bStartChk : 1; // Examine the beginning
76 : : sal_Bool bRevAllowed : 1; // Reverse spell check prohibited
77 : : sal_Bool bAllRight : 1; // Record wrong words in the dedicated
78 : : // dictionary and do not start the dialog.
79 : :
80 : : EDITENG_DLLPRIVATE sal_Bool SpellNext(); // select next area
81 : : sal_Bool FindSpellError(); // Check for errors (over areas)
82 : :
83 : : public:
84 : : SvxSpellWrapper( Window* pWn,
85 : : ::com::sun::star::uno::Reference<
86 : : ::com::sun::star::linguistic2::XSpellChecker1 > &xSpellChecker,
87 : : const sal_Bool bStart = sal_False, const sal_Bool bIsAllRight = sal_False,
88 : : const sal_Bool bOther = sal_False, const sal_Bool bRevAllow = sal_True );
89 : : SvxSpellWrapper( Window* pWn,
90 : : ::com::sun::star::uno::Reference<
91 : : ::com::sun::star::linguistic2::XHyphenator > &xHyphenator,
92 : : const sal_Bool bStart = sal_False, const sal_Bool bOther = sal_False );
93 : :
94 : : virtual ~SvxSpellWrapper();
95 : :
96 : : static sal_Int16 CheckSpellLang(
97 : : ::com::sun::star::uno::Reference<
98 : : ::com::sun::star::linguistic2::XSpellChecker1 > xSpell,
99 : : sal_Int16 nLang );
100 : : static sal_Int16 CheckHyphLang(
101 : : ::com::sun::star::uno::Reference<
102 : : ::com::sun::star::linguistic2::XHyphenator > xHyph,
103 : : sal_Int16 nLang );
104 : :
105 : : static void ShowLanguageErrors();
106 : :
107 : : void SpellDocument(); // Perform Spell Checking
108 : 18 : inline sal_Bool IsStartDone(){ return bStartDone; }
109 : 0 : inline sal_Bool IsEndDone(){ return bEndDone; }
110 : : inline sal_Bool IsReverse(){ return bReverse; }
111 : : inline sal_Bool IsDialog(){ return bDialog; } // SvxSpellCheckDialog OnScreen
112 : 18 : inline sal_Bool IsHyphen(){ return bHyphen; } // Split instead of Spell check
113 : 0 : inline void SetHyphen( const sal_Bool bNew = sal_True ){ bHyphen = bNew; }
114 : : inline ::com::sun::star::uno::Reference<
115 : : ::com::sun::star::linguistic2::XSpellChecker1 >
116 : : GetXSpellChecker() { return xSpell; }
117 : : inline ::com::sun::star::uno::Reference<
118 : : ::com::sun::star::linguistic2::XHyphenator >
119 : : GetXHyphenator() { return xHyph; }
120 : 18 : inline sal_Bool IsAllRight() { return bAllRight; }
121 : : inline Window* GetWin() { return pWin; }
122 : : // can possibly be omitted in ONE_LINGU:
123 : : inline void SetOldLang( const sal_uInt16 nNew ){ nOldLang = nNew; }
124 : : // can possibly be omitted in ONE_LINGU:
125 : : inline void ChangeLanguage( const sal_uInt16 nNew ) // call SetLanguage if needed.
126 : : { if ( nNew != nOldLang ) { SetLanguage( nNew ); nOldLang = nNew; } }
127 : : inline void EnableAutoCorrect() { bAuto = sal_True; }
128 : :
129 : : protected:
130 : : ::com::sun::star::uno::Reference<
131 : : ::com::sun::star::uno::XInterface >
132 : 72 : GetLast() { return xLast; }
133 : 18 : void SetLast(const ::com::sun::star::uno::Reference<
134 : : ::com::sun::star::uno::XInterface > &xNewLast)
135 : 18 : { xLast = xNewLast; }
136 : : virtual sal_Bool SpellMore(); // examine further documents?
137 : : virtual sal_Bool HasOtherCnt(); // Are there any special areas?
138 : : virtual void SpellStart( SvxSpellArea eSpell ); // Preparing the area
139 : : virtual sal_Bool SpellContinue(); // Check Areas
140 : : // Result avaliable through GetLast
141 : : virtual void ReplaceAll( const String &rNewText, sal_Int16 nLanguage ); //Replace word from the replace list
142 : : virtual void StartThesaurus( const String &rWord, sal_uInt16 nLang );
143 : : virtual ::com::sun::star::uno::Reference<
144 : : ::com::sun::star::linguistic2::XDictionary >
145 : : GetAllRightDic() const;
146 : : virtual void SpellEnd(); // Finish area
147 : : virtual void ScrollArea(); // Set ScrollArea
148 : : // Replace word
149 : : virtual void ChangeWord( const String& rNewWord, const sal_uInt16 nLang );
150 : : virtual String GetThesWord();
151 : : // Wort via Thesaurus ersetzen
152 : : virtual void ChangeThesWord( const String& rNewWord );
153 : : virtual void SetLanguage( const sal_uInt16 nLang ); // Change Language
154 : : virtual void AutoCorrect( const String& rAktStr, const String& rNewStr );
155 : : virtual void InsertHyphen( const sal_uInt16 nPos ); // Insert hyphen
156 : :
157 : : };
158 : :
159 : : #endif
160 : :
161 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|