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 <vcl/button.hxx>
27 #include <vcl/menubtn.hxx>
28 #include <vcl/decoview.hxx>
29 #include <vcl/image.hxx>
30 #include <vcl/toolbox.hxx>
31 #include <com/sun/star/uno/Reference.hxx>
34 #include <svx/langbox.hxx>
36 #include <svtools/svmedit.hxx>
37 #include <svl/lstner.hxx>
38 #include <vcl/fixedhyper.hxx>
39 #include <vcl/xtextedt.hxx>
40 #include <editeng/SpellPortions.hxx>
44 namespace svx
{ class SpellUndoAction_Impl
;}
46 // forward ---------------------------------------------------------------
48 struct SpellDialog_Impl
;
50 namespace com
{namespace sun
{namespace star
{
51 namespace linguistic2
{
56 struct SpellErrorDescription
;
58 class SentenceEditWindow_Impl
: public VclMultiLineEdit
60 using VclMultiLineEdit::SetText
;
63 std::set
< sal_Int32
> m_aIgnoreErrorsAt
;
64 VclPtr
<ToolBox
> m_xToolbar
;
65 sal_Int32 m_nErrorStart
;
66 sal_Int32 m_nErrorEnd
;
67 bool m_bIsUndoEditMode
;
69 Link
<Edit
&,void> m_aModifyLink
;
71 void CallModifyLink() {m_aModifyLink
.Call(*this);}
73 inline SpellDialog
* GetSpellDialog() const;
75 DECL_LINK(ToolbarHdl
, ToolBox
*, void);
77 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
80 SentenceEditWindow_Impl(vcl::Window
* pParent
, WinBits nBits
);
81 virtual ~SentenceEditWindow_Impl() override
;
83 void Init(VclPtr
<ToolBox
> const &rToolbar
);
84 void SetModifyHdl(const Link
<Edit
&,void>& rLink
) override
{ m_aModifyLink
= rLink
;}
86 void SetAttrib( const TextAttrib
& rAttr
, sal_uInt32 nPara
, sal_Int32 nStart
, sal_Int32 nEnd
);
87 void SetText( const OUString
& rStr
) override
;
89 bool MarkNextError( bool bIgnoreCurrentError
, const css::uno::Reference
<css::linguistic2::XSpellChecker1
>& );
90 void ChangeMarkedWord(const OUString
& rNewWord
, LanguageType eLanguage
);
91 void MoveErrorMarkTo(sal_Int32 nErrorStart
, sal_Int32 nErrorEnd
, bool bGrammar
);
92 OUString
GetErrorText() const;
93 void RestoreCurrentError();
96 const css::uno::Reference
<css::linguistic2::XSpellAlternatives
>& );
98 const SpellErrorDescription
* GetAlternatives();
101 void ResetModified() { GetTextEngine()->SetModified(false); m_bIsUndoEditMode
= false;}
102 virtual bool IsModified() const override
{ return GetTextEngine()->IsModified(); }
103 virtual void dispose() override
;
105 bool IsUndoEditMode() const { return m_bIsUndoEditMode
;}
106 void SetUndoEditMode(bool bSet
);
108 svx::SpellPortions
CreateSpellPortions() const;
112 void AddUndoAction( std::unique_ptr
<SfxUndoAction
> pAction
);
113 size_t GetUndoActionCount();
114 void UndoActionStart( sal_uInt16 nId
);
115 void UndoActionEnd();
117 void MoveErrorEnd(long nOffset
);
119 void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt
.clear(); }
122 // class SvxSpellDialog ---------------------------------------------
123 class SpellDialogChildWindow
;
125 class SpellDialog
: public SfxModelessDialog
127 using Window::Invalidate
;
129 friend class SentenceEditWindow_Impl
;
132 VclPtr
<FixedText
> m_pLanguageFT
;
133 VclPtr
<SvxLanguageBox
> m_pLanguageLB
;
135 VclPtr
<FixedText
> m_pExplainFT
;
136 VclPtr
<FixedHyperlink
> m_pExplainLink
;
138 VclPtr
<FixedText
> m_pNotInDictFT
;
139 VclPtr
<SentenceEditWindow_Impl
> m_pSentenceED
;
141 VclPtr
<FixedText
> m_pSuggestionFT
;
142 VclPtr
<ListBox
> m_pSuggestionLB
;
144 VclPtr
<PushButton
> m_pIgnorePB
;
145 VclPtr
<PushButton
> m_pIgnoreAllPB
;
146 VclPtr
<PushButton
> m_pIgnoreRulePB
;
147 VclPtr
<PushButton
> m_pAddToDictPB
;
148 VclPtr
<MenuButton
> m_pAddToDictMB
;
150 VclPtr
<PushButton
> m_pChangePB
;
151 VclPtr
<PushButton
> m_pChangeAllPB
;
152 VclPtr
<PushButton
> m_pAutoCorrPB
;
154 VclPtr
<CheckBox
> m_pCheckGrammarCB
;
156 VclPtr
<PushButton
> m_pOptionsPB
;
157 VclPtr
<PushButton
> m_pUndoPB
;
158 VclPtr
<CloseButton
> m_pClosePB
;
159 VclPtr
<ToolBox
> m_pToolbar
;
161 OUString m_sResumeST
;
162 OUString m_sIgnoreOnceST
;
163 OUString m_sNoSuggestionsST
;
165 OUString m_sTitleSpelling
;
166 OUString m_sTitleSpellingGrammar
;
168 Link
<SpellUndoAction_Impl
&,void> aDialogUndoLink
;
172 svx::SpellDialogChildWindow
& rParent
;
173 svx::SpellPortions m_aSavedSentence
;
175 std::unique_ptr
<SpellDialog_Impl
> pImpl
;
177 css::linguistic2::XSpellChecker1
> xSpell
;
179 DECL_LINK(ChangeHdl
, Button
*, void);
180 DECL_LINK(DoubleClickChangeHdl
, ListBox
&, void);
181 DECL_LINK(ChangeAllHdl
, Button
*, void);
182 DECL_LINK( IgnoreAllHdl
, Button
*, void );
183 DECL_LINK(IgnoreHdl
, Button
*, void);
184 DECL_LINK( CheckGrammarHdl
, Button
*, void );
185 DECL_LINK( ExtClickHdl
, Button
*, void );
186 DECL_LINK(CancelHdl
, Button
*, void);
187 DECL_LINK( ModifyHdl
, Edit
&, void);
188 DECL_LINK(UndoHdl
, Button
*, void);
189 DECL_LINK( AddToDictSelectHdl
, MenuButton
*, void );
190 DECL_LINK( AddToDictClickHdl
, Button
*, void );
191 DECL_LINK( LanguageSelectHdl
, ListBox
&, void );
192 DECL_LINK( DialogUndoHdl
, SpellUndoAction_Impl
&, void );
194 DECL_LINK( InitHdl
, void*, void );
196 void AddToDictionaryExecute( sal_uInt16 ItemId
, PopupMenu
const *pMenu
);
197 void StartSpellOptDlg_Impl();
199 void UpdateBoxes_Impl(bool bCallFromSelectHdl
= false);
201 void SpellContinue_Impl(bool UseSavedSentence
= false, bool bIgnoreCurrentError
= false );
202 void LockFocusChanges( bool bLock
) {bFocusLocked
= bLock
;}
203 void Impl_Restore(bool bUseSavedSentence
);
205 LanguageType
GetSelectedLang_Impl() const;
207 /** Retrieves the next sentence.
209 bool GetNextSentence_Impl(bool bUseSavedSentence
, bool bRechek
/*for rechecking the current sentence*/);
210 /** Corrects all errors that have been selected to be changed always
212 static bool ApplyChangeAllList_Impl(SpellPortions
& rSentence
, bool& bHasReplaced
);
213 void SetTitle_Impl(LanguageType nLang
);
216 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
218 OUString
getReplacementString() const;
222 svx::SpellDialogChildWindow
* pChildWindow
,
223 vcl::Window
* pParent
,
224 SfxBindings
* pBindings
);
225 virtual ~SpellDialog() override
;
226 virtual void dispose() override
;
228 virtual bool Close() override
;
230 void InvalidateDialog();
233 SpellDialog
* SentenceEditWindow_Impl::GetSpellDialog() const {return static_cast<SpellDialog
*>(GetParentDialog());}
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */