1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SpellDialog.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SVX_SPELLDDIALOG_HXX
31 #define _SVX_SPELLDDIALOG_HXX
33 // include ---------------------------------------------------------------
35 #include <sfx2/basedlgs.hxx>
36 #include <vcl/fixed.hxx>
37 #include <vcl/edit.hxx>
38 #include <vcl/lstbox.hxx>
39 #include <svtools/stdctrl.hxx>
40 #include <vcl/button.hxx>
41 #include <vcl/menubtn.hxx>
42 #include <vcl/group.hxx>
43 #include <vcl/decoview.hxx>
44 #include <vcl/image.hxx>
45 #include <com/sun/star/uno/Reference.hxx>
48 #include <svx/svxbox.hxx>
49 #include <svx/langbox.hxx>
51 #include <svtools/svmedit.hxx>
52 #include <svtools/lstner.hxx>
53 #include <svtools/xtextedt.hxx>
54 #include <svx/SpellPortions.hxx>
59 namespace svx
{ class SpellUndoAction_Impl
;}
61 // forward ---------------------------------------------------------------
63 struct SpellDialog_Impl
;
65 namespace com
{namespace sun
{namespace star
{
66 namespace linguistic2
{
71 struct SpellErrorDescription
;
72 // ------------------------------------------------------------------
73 class SentenceEditWindow_Impl
: public MultiLineEdit
/*, public SfxListener*/
75 using MultiLineEdit::SetText
;
80 bool m_bIsUndoEditMode
;
84 void CallModifyLink() {m_aModifyLink
.Call(this);}
86 SpellDialog
* GetSpellDialog() const {return (SpellDialog
*)GetParent();}
88 virtual long PreNotify( NotifyEvent
& rNEvt
);
91 SentenceEditWindow_Impl( SpellDialog
* pParent
, const ResId
& rResId
);
92 ~SentenceEditWindow_Impl();
94 void SetModifyHdl(const Link
& rLink
) { m_aModifyLink
= rLink
;}
96 void SetAttrib( const TextAttrib
& rAttr
, ULONG nPara
, USHORT nStart
, USHORT nEnd
);
97 void SetText( const String
& rStr
);
100 void ChangeMarkedWord(const String
& rNewWord
, LanguageType eLanguage
);
101 void MoveErrorMarkTo(USHORT nErrorStart
, USHORT nErrorEnd
, bool bGrammar
);
102 String
GetErrorText() const;
103 void RestoreCurrentError();
105 void SetAlternatives(
106 com::sun::star::uno::Reference
<com::sun::star::linguistic2::XSpellAlternatives
> );
108 const SpellErrorDescription
* GetAlternatives();
111 void ResetModified() { GetTextEngine()->SetModified(FALSE
); m_bIsUndoEditMode
= false;}
112 BOOL
IsModified() const { return GetTextEngine()->IsModified(); }
114 bool IsUndoEditMode() const { return m_bIsUndoEditMode
;}
115 void SetUndoEditMode(bool bSet
);
117 svx::SpellPortions
CreateSpellPortions( bool bSetIgnoreFlag
) const;
121 void AddUndoAction( SfxUndoAction
*pAction
, BOOL bTryMerg
=FALSE
);
122 USHORT
GetUndoActionCount();
123 void UndoActionStart( USHORT nId
);
124 void UndoActionEnd( USHORT nId
);
126 void MoveErrorEnd(long nOffset
);
130 // class SvxSpellDialog ---------------------------------------------
131 class SpellDialogChildWindow
;
132 class ExplainButton
: public PushButton
134 String m_sExplanation
;
136 virtual void RequestHelp( const HelpEvent
& rHEvt
);
137 virtual void Click();
139 ExplainButton( Window
* pParent
, const ResId
& rResId
) : PushButton( pParent
, rResId
){}
141 void SetExplanation( const String
& rText
) {m_sExplanation
= rText
;}
142 bool HasExplanation() { return m_sExplanation
.Len() > 0;}
146 class SpellDialog
: public SfxModelessDialog
148 using Window::Invalidate
;
150 friend class SentenceEditWindow_Impl
;
153 FixedImage aVendorImageFI
;
155 FixedText aLanguageFT
;
156 SvxLanguageBox aLanguageLB
;
158 FixedText aNotInDictFT
;
159 SentenceEditWindow_Impl aSentenceED
;
161 FixedText aSuggestionFT
;
162 ListBox aSuggestionLB
;
164 PushButton aIgnorePB
;
165 PushButton aIgnoreAllPB
;
166 PushButton aIgnoreRulePB
;
167 MenuButton aAddToDictMB
;
169 PushButton aChangePB
;
170 PushButton aChangeAllPB
;
171 ExplainButton aExplainPB
;
172 PushButton aAutoCorrPB
;
174 CheckBox aCheckGrammarCB
;
177 PushButton aOptionsPB
;
181 GroupBox aBackgroundGB
;
184 Image aVendorImageHC
;
187 String aIgnoreOnceST
;
188 String aNoSuggestionsST
;
190 const String m_sTitleSpelling
;
191 const String m_sTitleSpellingGrammar
;
192 const String m_sTitleSpellingGrammarVendor
;
195 Link aDialogUndoLink
;
200 svx::SpellDialogChildWindow
& rParent
;
201 svx::SpellPortions m_aSavedSentence
;
203 SpellDialog_Impl
* pImpl
;
204 ::com::sun::star::uno::Reference
<
205 ::com::sun::star::linguistic2::XSpellChecker1
> xSpell
;
206 LanguageType nOldLang
;
208 DECL_LINK( ChangeHdl
, Button
* );
209 DECL_LINK( ChangeAllHdl
, Button
* );
210 DECL_LINK( IgnoreAllHdl
, Button
* );
211 DECL_LINK( IgnoreHdl
, Button
* );
212 DECL_LINK( CheckGrammarHdl
, CheckBox
* );
213 DECL_LINK( ExtClickHdl
, Button
* );
214 DECL_LINK( CancelHdl
, Button
* );
215 DECL_LINK( ModifyHdl
, SentenceEditWindow_Impl
*);
216 DECL_LINK( UndoHdl
, Button
* );
217 DECL_LINK( AddToDictionaryHdl
, MenuButton
* );
218 DECL_LINK( LanguageSelectHdl
, SvxLanguageBox
* );
219 DECL_LINK( DialogUndoHdl
, SpellUndoAction_Impl
* );
221 DECL_STATIC_LINK( SpellDialog
, InitHdl
, SpellDialog
* );
223 void StartSpellOptDlg_Impl();
224 void InitUserDicts();
225 void UpdateBoxes_Impl();
227 void SpellContinue_Impl(bool UseSavedSentence
= false);
228 void LockFocusChanges( bool bLock
) {bFocusLocked
= bLock
;}
231 void SetSelectedLang_Impl( LanguageType nLang
);
232 LanguageType
GetSelectedLang_Impl() const;
234 /** Retrieves the next sentence.
236 bool GetNextSentence_Impl(bool bUseSavedSentence
);
237 /** Corrects all errors that have been selected to be changed always
239 bool ApplyChangeAllList_Impl(SpellPortions
& rSentence
, bool& bHasReplaced
);
240 void SetTitle_Impl(LanguageType nLang
);
243 virtual void Paint( const Rectangle
& rRect
);
244 virtual long Notify( NotifyEvent
& rNEvt
);
248 svx::SpellDialogChildWindow
* pChildWindow
,
250 SfxBindings
* pBindings
);
253 void SetLanguage( sal_uInt16 nLang
);
254 virtual sal_Bool
Close();
256 void InvalidateDialog();