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_CUI_SOURCE_INC_SPELLDIALOG_HXX
20 #define INCLUDED_CUI_SOURCE_INC_SPELLDIALOG_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
;
59 class SentenceEditWindow_Impl
: public VclMultiLineEdit
61 using VclMultiLineEdit::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 inline SpellDialog
* GetSpellDialog() const;
75 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
78 SentenceEditWindow_Impl(vcl::Window
* pParent
, WinBits nBits
);
80 void SetModifyHdl(const Link
<>& rLink
) SAL_OVERRIDE
{ m_aModifyLink
= rLink
;}
82 void SetAttrib( const TextAttrib
& rAttr
, sal_uLong nPara
, sal_uInt16 nStart
, sal_uInt16 nEnd
);
83 void SetText( const OUString
& rStr
) SAL_OVERRIDE
;
85 bool MarkNextError( bool bIgnoreCurrentError
, com::sun::star::uno::Reference
<com::sun::star::linguistic2::XSpellChecker1
> );
86 void ChangeMarkedWord(const OUString
& rNewWord
, LanguageType eLanguage
);
87 void MoveErrorMarkTo(sal_uInt16 nErrorStart
, sal_uInt16 nErrorEnd
, bool bGrammar
);
88 OUString
GetErrorText() const;
89 void RestoreCurrentError();
92 com::sun::star::uno::Reference
<com::sun::star::linguistic2::XSpellAlternatives
> );
94 const SpellErrorDescription
* GetAlternatives();
97 void ResetModified() { GetTextEngine()->SetModified(false); m_bIsUndoEditMode
= false;}
98 virtual bool IsModified() const SAL_OVERRIDE
{ return GetTextEngine()->IsModified(); }
100 bool IsUndoEditMode() const { return m_bIsUndoEditMode
;}
101 void SetUndoEditMode(bool bSet
);
103 svx::SpellPortions
CreateSpellPortions( bool bSetIgnoreFlag
) const;
107 void AddUndoAction( SfxUndoAction
*pAction
, bool bTryMerg
=false );
108 sal_uInt16
GetUndoActionCount();
109 void UndoActionStart( sal_uInt16 nId
);
110 void UndoActionEnd();
112 void MoveErrorEnd(long nOffset
);
114 void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt
.clear(); }
117 // class SvxSpellDialog ---------------------------------------------
118 class SpellDialogChildWindow
;
120 class SpellDialog
: public SfxModelessDialog
122 using Window::Invalidate
;
124 friend class SentenceEditWindow_Impl
;
127 VclPtr
<FixedText
> m_pLanguageFT
;
128 VclPtr
<SvxLanguageBox
> m_pLanguageLB
;
130 VclPtr
<FixedText
> m_pExplainFT
;
131 VclPtr
<FixedHyperlink
> m_pExplainLink
;
133 VclPtr
<FixedText
> m_pNotInDictFT
;
134 VclPtr
<SentenceEditWindow_Impl
> m_pSentenceED
;
136 VclPtr
<FixedText
> m_pSuggestionFT
;
137 VclPtr
<ListBox
> m_pSuggestionLB
;
139 VclPtr
<PushButton
> m_pIgnorePB
;
140 VclPtr
<PushButton
> m_pIgnoreAllPB
;
141 VclPtr
<PushButton
> m_pIgnoreRulePB
;
142 VclPtr
<PushButton
> m_pAddToDictPB
;
143 VclPtr
<MenuButton
> m_pAddToDictMB
;
145 VclPtr
<PushButton
> m_pChangePB
;
146 VclPtr
<PushButton
> m_pChangeAllPB
;
147 VclPtr
<PushButton
> m_pAutoCorrPB
;
149 VclPtr
<CheckBox
> m_pCheckGrammarCB
;
151 VclPtr
<PushButton
> m_pOptionsPB
;
152 VclPtr
<PushButton
> m_pUndoPB
;
153 VclPtr
<CloseButton
> m_pClosePB
;
155 OUString m_sResumeST
;
156 OUString m_sIgnoreOnceST
;
157 OUString m_sNoSuggestionsST
;
159 OUString m_sTitleSpelling
;
160 OUString m_sTitleSpellingGrammar
;
162 Link
<> aDialogUndoLink
;
167 svx::SpellDialogChildWindow
& rParent
;
168 svx::SpellPortions m_aSavedSentence
;
170 SpellDialog_Impl
* pImpl
;
171 ::com::sun::star::uno::Reference
<
172 ::com::sun::star::linguistic2::XSpellChecker1
> xSpell
;
174 DECL_LINK(ChangeHdl
, void *);
175 DECL_LINK(ChangeAllHdl
, void *);
176 DECL_LINK( IgnoreAllHdl
, Button
* );
177 DECL_LINK(IgnoreHdl
, void *);
178 DECL_LINK( CheckGrammarHdl
, CheckBox
* );
179 DECL_LINK( ExtClickHdl
, Button
* );
180 DECL_LINK(CancelHdl
, void *);
181 DECL_LINK( ModifyHdl
, SentenceEditWindow_Impl
*);
182 DECL_LINK(UndoHdl
, void *);
183 DECL_LINK_TYPED( AddToDictSelectHdl
, MenuButton
*, void );
184 DECL_LINK( AddToDictClickHdl
, PushButton
* );
185 DECL_LINK( LanguageSelectHdl
, SvxLanguageBox
* );
186 DECL_LINK( DialogUndoHdl
, SpellUndoAction_Impl
* );
187 DECL_LINK( HandleHyperlink
, FixedHyperlink
* );
189 DECL_LINK( InitHdl
, SpellDialog
* );
191 int AddToDictionaryExecute( sal_uInt16 ItemId
, PopupMenu
*pMenu
);
192 void StartSpellOptDlg_Impl();
194 void UpdateBoxes_Impl();
196 void SpellContinue_Impl(bool UseSavedSentence
= false, bool bIgnoreCurrentError
= false );
197 void LockFocusChanges( bool bLock
) {bFocusLocked
= bLock
;}
200 void SetSelectedLang_Impl( LanguageType nLang
);
201 LanguageType
GetSelectedLang_Impl() const;
203 /** Retrieves the next sentence.
205 bool GetNextSentence_Impl(bool bUseSavedSentence
, bool bRechek
/*for rechecking the current sentence*/);
206 /** Corrects all errors that have been selected to be changed always
208 static bool ApplyChangeAllList_Impl(SpellPortions
& rSentence
, bool& bHasReplaced
);
209 void SetTitle_Impl(LanguageType nLang
);
212 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
214 OUString
getReplacementString() const;
218 svx::SpellDialogChildWindow
* pChildWindow
,
219 vcl::Window
* pParent
,
220 SfxBindings
* pBindings
);
221 virtual ~SpellDialog();
222 virtual void dispose() SAL_OVERRIDE
;
224 void SetLanguage( sal_uInt16 nLang
);
225 virtual bool Close() SAL_OVERRIDE
;
227 void InvalidateDialog();
230 SpellDialog
* SentenceEditWindow_Impl::GetSpellDialog() const {return static_cast<SpellDialog
*>(GetParentDialog());}
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */