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 _SVX_SPELLDDIALOG_HXX
20 #define _SVX_SPELLDDIALOG_HXX
22 #include <sfx2/basedlgs.hxx>
23 #include <vcl/fixed.hxx>
24 #include <vcl/edit.hxx>
25 #include <vcl/lstbox.hxx>
26 #include <svtools/stdctrl.hxx>
27 #include <vcl/button.hxx>
28 #include <vcl/menubtn.hxx>
29 #include <vcl/group.hxx>
30 #include <vcl/decoview.hxx>
31 #include <vcl/image.hxx>
32 #include <com/sun/star/uno/Reference.hxx>
35 #include <svx/langbox.hxx>
37 #include <svtools/svmedit.hxx>
38 #include <svl/lstner.hxx>
39 #include <vcl/fixedhyper.hxx>
40 #include <vcl/xtextedt.hxx>
41 #include <editeng/SpellPortions.hxx>
45 namespace svx
{ class SpellUndoAction_Impl
;}
47 // forward ---------------------------------------------------------------
49 struct SpellDialog_Impl
;
51 namespace com
{namespace sun
{namespace star
{
52 namespace linguistic2
{
57 struct SpellErrorDescription
;
58 // ------------------------------------------------------------------
59 class SentenceEditWindow_Impl
: public MultiLineEdit
61 using MultiLineEdit::SetText
;
64 std::set
< sal_uInt16
> m_aIgnoreErrorsAt
;
65 sal_uInt16 m_nErrorStart
;
66 sal_uInt16 m_nErrorEnd
;
67 bool m_bIsUndoEditMode
;
71 void CallModifyLink() {m_aModifyLink
.Call(this);}
73 SpellDialog
* GetSpellDialog() const {return (SpellDialog
*)GetParent();}
75 virtual long PreNotify( NotifyEvent
& rNEvt
);
78 SentenceEditWindow_Impl( SpellDialog
* pParent
, const ResId
& rResId
);
79 ~SentenceEditWindow_Impl();
81 void SetModifyHdl(const Link
& rLink
) { m_aModifyLink
= rLink
;}
83 void SetAttrib( const TextAttrib
& rAttr
, sal_uLong nPara
, sal_uInt16 nStart
, sal_uInt16 nEnd
);
84 void SetText( const String
& rStr
);
86 bool MarkNextError( bool bIgnoreCurrentError
);
87 void ChangeMarkedWord(const String
& rNewWord
, LanguageType eLanguage
);
88 void MoveErrorMarkTo(sal_uInt16 nErrorStart
, sal_uInt16 nErrorEnd
, bool bGrammar
);
89 String
GetErrorText() const;
90 void RestoreCurrentError();
93 com::sun::star::uno::Reference
<com::sun::star::linguistic2::XSpellAlternatives
> );
95 const SpellErrorDescription
* GetAlternatives();
98 void ResetModified() { GetTextEngine()->SetModified(sal_False
); m_bIsUndoEditMode
= false;}
99 sal_Bool
IsModified() const { return GetTextEngine()->IsModified(); }
101 bool IsUndoEditMode() const { return m_bIsUndoEditMode
;}
102 void SetUndoEditMode(bool bSet
);
104 svx::SpellPortions
CreateSpellPortions( bool bSetIgnoreFlag
) const;
108 void AddUndoAction( SfxUndoAction
*pAction
, sal_Bool bTryMerg
=sal_False
);
109 sal_uInt16
GetUndoActionCount();
110 void UndoActionStart( sal_uInt16 nId
);
111 void UndoActionEnd();
113 void MoveErrorEnd(long nOffset
);
115 void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt
.clear(); }
118 class HelpFixedText
: public FixedText
121 HelpFixedText( Window
* pParent
, const ResId
& rResId
);
123 virtual void Paint( const Rectangle
& rRect
);
124 long GetActualHeight( );
127 // class SvxSpellDialog ---------------------------------------------
128 class SpellDialogChildWindow
;
130 class SpellDialog
: public SfxModelessDialog
132 using Window::Invalidate
;
134 friend class SentenceEditWindow_Impl
;
137 FixedText aLanguageFT
;
138 SvxLanguageBox aLanguageLB
;
140 HelpFixedText aExplainFT
;
141 FixedHyperlink aExplainLink
;
143 FixedText aNotInDictFT
;
144 SentenceEditWindow_Impl aSentenceED
;
146 FixedText aSuggestionFT
;
147 ListBox aSuggestionLB
;
149 PushButton aIgnorePB
;
150 PushButton aIgnoreAllPB
;
151 PushButton aIgnoreRulePB
;
152 MenuButton aAddToDictMB
;
153 PushButton aAddToDictPB
;
155 PushButton aChangePB
;
156 PushButton aChangeAllPB
;
157 PushButton aAutoCorrPB
;
159 CheckBox aCheckGrammarCB
;
162 PushButton aOptionsPB
;
166 GroupBox aBackgroundGB
;
171 String aIgnoreOnceST
;
172 String aNoSuggestionsST
;
174 const String m_sTitleSpelling
;
175 const String m_sTitleSpellingGrammar
;
176 const String m_sTitleSpellingGrammarVendor
;
179 Link aDialogUndoLink
;
184 svx::SpellDialogChildWindow
& rParent
;
185 svx::SpellPortions m_aSavedSentence
;
187 SpellDialog_Impl
* pImpl
;
188 ::com::sun::star::uno::Reference
<
189 ::com::sun::star::linguistic2::XSpellChecker1
> xSpell
;
191 DECL_LINK(ChangeHdl
, void *);
192 DECL_LINK(ChangeAllHdl
, void *);
193 DECL_LINK( IgnoreAllHdl
, Button
* );
194 DECL_LINK(IgnoreHdl
, void *);
195 DECL_LINK( CheckGrammarHdl
, CheckBox
* );
196 DECL_LINK( ExtClickHdl
, Button
* );
197 DECL_LINK(CancelHdl
, void *);
198 DECL_LINK( ModifyHdl
, SentenceEditWindow_Impl
*);
199 DECL_LINK(UndoHdl
, void *);
200 DECL_LINK( AddToDictSelectHdl
, MenuButton
* );
201 DECL_LINK( AddToDictClickHdl
, PushButton
* );
202 DECL_LINK( LanguageSelectHdl
, SvxLanguageBox
* );
203 DECL_LINK( DialogUndoHdl
, SpellUndoAction_Impl
* );
204 DECL_LINK( HandleHyperlink
, FixedHyperlink
* );
206 DECL_STATIC_LINK( SpellDialog
, InitHdl
, SpellDialog
* );
208 int AddToDictionaryExecute( sal_uInt16 ItemId
, PopupMenu
*pMenu
);
209 void StartSpellOptDlg_Impl();
211 void UpdateBoxes_Impl();
213 void SpellContinue_Impl(bool UseSavedSentence
= false, bool bIgnoreCurrentError
= false );
214 void LockFocusChanges( bool bLock
) {bFocusLocked
= bLock
;}
217 void SetSelectedLang_Impl( LanguageType nLang
);
218 LanguageType
GetSelectedLang_Impl() const;
220 /** Retrieves the next sentence.
222 bool GetNextSentence_Impl(bool bUseSavedSentence
, bool bRechek
/*for rechecking the current sentence*/);
223 /** Corrects all errors that have been selected to be changed always
225 bool ApplyChangeAllList_Impl(SpellPortions
& rSentence
, bool& bHasReplaced
);
226 void SetTitle_Impl(LanguageType nLang
);
229 virtual void Paint( const Rectangle
& rRect
);
230 virtual long Notify( NotifyEvent
& rNEvt
);
232 String
getReplacementString() const;
236 svx::SpellDialogChildWindow
* pChildWindow
,
238 SfxBindings
* pBindings
);
241 void SetLanguage( sal_uInt16 nLang
);
242 virtual sal_Bool
Close();
244 void InvalidateDialog();
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */