1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_EDITENG_SPLWRAP_HXX
20 #define INCLUDED_EDITENG_SPLWRAP_HXX
22 #include <editeng/editengdllapi.h>
23 #include <editeng/svxenum.hxx>
24 #include <rtl/ustring.hxx>
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <vcl/vclptr.hxx>
28 // forward ---------------------------------------------------------------
30 namespace com
{ namespace sun
{ namespace star
{ namespace linguistic2
{
36 namespace vcl
{ class Window
; }
38 // misc functions ---------------------------------------------------------------
40 void EDITENG_DLLPUBLIC
SvxPrepareAutoCorrect( OUString
&rOldText
, const OUString
&rNewText
);
42 /*--------------------------------------------------------------------
43 Description: The SpellWrapper
44 --------------------------------------------------------------------*/
46 class EDITENG_DLLPUBLIC SvxSpellWrapper
{
48 friend class SvxSpellCheckDialog
;
49 friend class SvxHyphenWordDialog
;
50 friend struct SvxHyphenWordDialog_Impl
;
52 VclPtr
<vcl::Window
> pWin
;
53 ::com::sun::star::uno::Reference
<
54 ::com::sun::star::uno::XInterface
> xLast
; // result of last spelling/hyphenation attempt
55 ::com::sun::star::uno::Reference
<
56 ::com::sun::star::linguistic2::XSpellChecker1
> xSpell
;
57 ::com::sun::star::uno::Reference
<
58 ::com::sun::star::linguistic2::XHyphenator
> xHyph
;
60 bool bOtherCntnt
: 1; // set => Check special sections initially
61 bool bDialog
: 1; // Is pWin the Svx...Dialog?
62 bool bHyphen
: 1; // Split instead of spell checking
63 bool bAuto
: 1; // AutoCorrect available?
64 bool bReverse
: 1; // Reverse spell check
65 bool bStartDone
: 1; // Beginning already corrected
66 bool bEndDone
: 1; // End part already corrected
67 bool bStartChk
: 1; // Examine the beginning
68 bool bRevAllowed
: 1; // Reverse spell check prohibited
69 bool bAllRight
: 1; // Record wrong words in the dedicated
70 // dictionary and do not start the dialog.
72 EDITENG_DLLPRIVATE
bool SpellNext(); // select next area
73 bool FindSpellError(); // Check for errors (over areas)
76 SvxSpellWrapper( vcl::Window
* pWn
,
77 ::com::sun::star::uno::Reference
<
78 ::com::sun::star::linguistic2::XSpellChecker1
> &xSpellChecker
,
79 const bool bStart
= false, const bool bIsAllRight
= false,
80 const bool bOther
= false, const bool bRevAllow
= true );
81 SvxSpellWrapper( vcl::Window
* pWn
,
82 ::com::sun::star::uno::Reference
<
83 ::com::sun::star::linguistic2::XHyphenator
> &xHyphenator
,
84 const bool bStart
= false, const bool bOther
= false );
86 virtual ~SvxSpellWrapper();
88 static sal_Int16
CheckSpellLang(
89 ::com::sun::star::uno::Reference
<
90 ::com::sun::star::linguistic2::XSpellChecker1
> xSpell
,
92 static sal_Int16
CheckHyphLang(
93 ::com::sun::star::uno::Reference
<
94 ::com::sun::star::linguistic2::XHyphenator
> xHyph
,
97 static void ShowLanguageErrors();
99 void SpellDocument(); // Perform Spell Checking
100 inline bool IsStartDone(){ return bStartDone
; }
101 inline bool IsEndDone(){ return bEndDone
; }
102 inline bool IsReverse(){ return bReverse
; }
103 inline bool IsDialog(){ return bDialog
; } // SvxSpellCheckDialog OnScreen
104 inline bool IsHyphen(){ return bHyphen
; } // Split instead of Spell check
105 inline void SetHyphen( const bool bNew
= true ){ bHyphen
= bNew
; }
106 inline ::com::sun::star::uno::Reference
<
107 ::com::sun::star::linguistic2::XSpellChecker1
>
108 GetXSpellChecker() { return xSpell
; }
109 inline ::com::sun::star::uno::Reference
<
110 ::com::sun::star::linguistic2::XHyphenator
>
111 GetXHyphenator() { return xHyph
; }
112 inline bool IsAllRight() { return bAllRight
; }
113 inline vcl::Window
* GetWin() { return pWin
; }
114 inline void EnableAutoCorrect() { bAuto
= true; }
117 ::com::sun::star::uno::Reference
<
118 ::com::sun::star::uno::XInterface
>
119 GetLast() { return xLast
; }
120 void SetLast(const ::com::sun::star::uno::Reference
<
121 ::com::sun::star::uno::XInterface
> &xNewLast
)
122 { xLast
= xNewLast
; }
123 virtual bool SpellMore(); // examine further documents?
124 virtual bool HasOtherCnt(); // Are there any special areas?
125 virtual void SpellStart( SvxSpellArea eSpell
); // Preparing the area
126 virtual bool SpellContinue(); // Check Areas
127 // Result available through GetLast
128 virtual void ReplaceAll( const OUString
&rNewText
, sal_Int16 nLanguage
); //Replace word from the replace list
129 static ::com::sun::star::uno::Reference
<
130 ::com::sun::star::linguistic2::XDictionary
>
132 virtual void SpellEnd(); // Finish area
133 virtual void ScrollArea(); // Set ScrollArea
135 virtual void ChangeWord( const OUString
& rNewWord
, const sal_uInt16 nLang
);
136 // Wort via Thesaurus ersetzen
137 virtual void ChangeThesWord( const OUString
& rNewWord
);
138 virtual void AutoCorrect( const OUString
& rAktStr
, const OUString
& rNewStr
);
139 virtual void InsertHyphen( const sal_uInt16 nPos
); // Insert hyphen
141 void SetCurTextObj( SdrObject
* pObj
) { mpTextObj
= pObj
; }
142 SdrObject
* GetCurTextObj() { return mpTextObj
; }
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */