Line data Source code
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 : #ifndef _SVX_SPLWRAP_HXX
20 : #define _SVX_SPLWRAP_HXX
21 :
22 : #include <editeng/svxenum.hxx>
23 : #include <tools/string.hxx>
24 : #include <com/sun/star/uno/Reference.hxx>
25 : #include "editeng/editengdllapi.h"
26 :
27 : // forward ---------------------------------------------------------------
28 :
29 : namespace com { namespace sun { namespace star { namespace linguistic2 {
30 : class XDictionary;
31 : class XSpellChecker1;
32 : class XHyphenator;
33 : }}}}
34 :
35 : class Window;
36 :
37 : // misc functions ---------------------------------------------------------------
38 :
39 : void EDITENG_DLLPUBLIC SvxPrepareAutoCorrect( String &rOldText, String &rNewText );
40 :
41 : /*--------------------------------------------------------------------
42 : Description: The SpellWrapper
43 : --------------------------------------------------------------------*/
44 :
45 : class EDITENG_DLLPUBLIC SvxSpellWrapper {
46 : private:
47 : friend class SvxSpellCheckDialog;
48 : friend class SvxHyphenWordDialog;
49 : friend struct SvxHyphenWordDialog_Impl;
50 :
51 : Window* pWin;
52 : ::com::sun::star::uno::Reference<
53 : ::com::sun::star::uno::XInterface > xLast; // result of last spelling/hyphenation attempt
54 : ::com::sun::star::uno::Reference<
55 : ::com::sun::star::linguistic2::XSpellChecker1 > xSpell;
56 : ::com::sun::star::uno::Reference<
57 : ::com::sun::star::linguistic2::XHyphenator > xHyph;
58 : sal_uInt16 nOldLang; // Set Language, only call SetLanguage on changes
59 : sal_Bool bOtherCntnt : 1; // set => Check special sections initially
60 : sal_Bool bDialog : 1; // Is pWin the Svx...Dialog?
61 : sal_Bool bHyphen : 1; // Split instead of spell checking
62 : sal_Bool bAuto : 1; // AutoCorrect available?
63 : sal_Bool bReverse : 1; // Reverse spell check
64 : sal_Bool bStartDone : 1; // Beginning already corrected
65 : sal_Bool bEndDone : 1; // End part already corrected
66 : sal_Bool bStartChk : 1; // Examine the beginning
67 : sal_Bool bRevAllowed : 1; // Reverse spell check prohibited
68 : sal_Bool bAllRight : 1; // Record wrong words in the dedicated
69 : // dictionary and do not start the dialog.
70 :
71 : EDITENG_DLLPRIVATE sal_Bool SpellNext(); // select next area
72 : sal_Bool FindSpellError(); // Check for errors (over areas)
73 :
74 : public:
75 : SvxSpellWrapper( Window* pWn,
76 : ::com::sun::star::uno::Reference<
77 : ::com::sun::star::linguistic2::XSpellChecker1 > &xSpellChecker,
78 : const sal_Bool bStart = sal_False, const sal_Bool bIsAllRight = sal_False,
79 : const sal_Bool bOther = sal_False, const sal_Bool bRevAllow = sal_True );
80 : SvxSpellWrapper( Window* pWn,
81 : ::com::sun::star::uno::Reference<
82 : ::com::sun::star::linguistic2::XHyphenator > &xHyphenator,
83 : const sal_Bool bStart = sal_False, const sal_Bool bOther = sal_False );
84 :
85 : virtual ~SvxSpellWrapper();
86 :
87 : static sal_Int16 CheckSpellLang(
88 : ::com::sun::star::uno::Reference<
89 : ::com::sun::star::linguistic2::XSpellChecker1 > xSpell,
90 : sal_Int16 nLang );
91 : static sal_Int16 CheckHyphLang(
92 : ::com::sun::star::uno::Reference<
93 : ::com::sun::star::linguistic2::XHyphenator > xHyph,
94 : sal_Int16 nLang );
95 :
96 : static void ShowLanguageErrors();
97 :
98 : void SpellDocument(); // Perform Spell Checking
99 6 : inline sal_Bool IsStartDone(){ return bStartDone; }
100 0 : inline sal_Bool IsEndDone(){ return bEndDone; }
101 : inline sal_Bool IsReverse(){ return bReverse; }
102 : inline sal_Bool IsDialog(){ return bDialog; } // SvxSpellCheckDialog OnScreen
103 6 : inline sal_Bool IsHyphen(){ return bHyphen; } // Split instead of Spell check
104 0 : inline void SetHyphen( const sal_Bool bNew = sal_True ){ bHyphen = bNew; }
105 : inline ::com::sun::star::uno::Reference<
106 : ::com::sun::star::linguistic2::XSpellChecker1 >
107 : GetXSpellChecker() { return xSpell; }
108 : inline ::com::sun::star::uno::Reference<
109 : ::com::sun::star::linguistic2::XHyphenator >
110 : GetXHyphenator() { return xHyph; }
111 6 : inline sal_Bool IsAllRight() { return bAllRight; }
112 : inline Window* GetWin() { return pWin; }
113 : // can possibly be omitted in ONE_LINGU:
114 : inline void SetOldLang( const sal_uInt16 nNew ){ nOldLang = nNew; }
115 : // can possibly be omitted in ONE_LINGU:
116 : inline void ChangeLanguage( const sal_uInt16 nNew ) // call SetLanguage if needed.
117 : { if ( nNew != nOldLang ) { SetLanguage( nNew ); nOldLang = nNew; } }
118 : inline void EnableAutoCorrect() { bAuto = sal_True; }
119 :
120 : protected:
121 : ::com::sun::star::uno::Reference<
122 : ::com::sun::star::uno::XInterface >
123 24 : GetLast() { return xLast; }
124 6 : void SetLast(const ::com::sun::star::uno::Reference<
125 : ::com::sun::star::uno::XInterface > &xNewLast)
126 6 : { xLast = xNewLast; }
127 : virtual sal_Bool SpellMore(); // examine further documents?
128 : virtual sal_Bool HasOtherCnt(); // Are there any special areas?
129 : virtual void SpellStart( SvxSpellArea eSpell ); // Preparing the area
130 : virtual sal_Bool SpellContinue(); // Check Areas
131 : // Result avaliable through GetLast
132 : virtual void ReplaceAll( const String &rNewText, sal_Int16 nLanguage ); //Replace word from the replace list
133 : virtual void StartThesaurus( const String &rWord, sal_uInt16 nLang );
134 : virtual ::com::sun::star::uno::Reference<
135 : ::com::sun::star::linguistic2::XDictionary >
136 : GetAllRightDic() const;
137 : virtual void SpellEnd(); // Finish area
138 : virtual void ScrollArea(); // Set ScrollArea
139 : // Replace word
140 : virtual void ChangeWord( const String& rNewWord, const sal_uInt16 nLang );
141 : virtual String GetThesWord();
142 : // Wort via Thesaurus ersetzen
143 : virtual void ChangeThesWord( const String& rNewWord );
144 : virtual void SetLanguage( const sal_uInt16 nLang ); // Change Language
145 : virtual void AutoCorrect( const String& rAktStr, const String& rNewStr );
146 : virtual void InsertHyphen( const sal_uInt16 nPos ); // Insert hyphen
147 :
148 : };
149 :
150 : #endif
151 :
152 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|