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 <com/sun/star/uno/Reference.hxx>
26 #include <svx/langbox.hxx>
28 #include <svl/undo.hxx>
29 #include <vcl/customweld.hxx>
30 #include <svx/weldeditview.hxx>
31 #include <editeng/SpellPortions.hxx>
35 namespace svx
{ class SpellUndoAction_Impl
;}
36 class UndoChangeGroupGuard
;
38 // forward ---------------------------------------------------------------
40 struct SpellDialog_Impl
;
42 namespace com
{namespace sun
{namespace star
{
43 namespace linguistic2
{
48 struct SpellErrorDescription
;
50 class SentenceEditWindow_Impl
: public WeldEditView
53 std::set
<sal_Int32
> m_aIgnoreErrorsAt
;
54 SpellDialog
* m_pSpellDialog
;
55 weld::Toolbar
* m_pToolbar
;
56 sal_Int32 m_nErrorStart
;
57 sal_Int32 m_nErrorEnd
;
58 bool m_bIsUndoEditMode
;
60 Link
<LinkParamNone
*,void> m_aModifyLink
;
62 void CallModifyLink() {m_aModifyLink
.Call(nullptr); }
64 SpellDialog
* GetSpellDialog() const { return m_pSpellDialog
; }
66 bool GetErrorDescription(SpellErrorDescription
& rSpellErrorDescription
, sal_Int32 nPosition
);
68 DECL_LINK(ToolbarHdl
, const OString
&, void);
71 virtual bool KeyInput( const KeyEvent
& rKEvt
) override
;
74 SentenceEditWindow_Impl();
75 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
76 void SetSpellDialog(SpellDialog
* pDialog
) { m_pSpellDialog
= pDialog
; }
77 virtual ~SentenceEditWindow_Impl() override
;
79 void Init(weld::Toolbar
* pToolbar
);
80 void SetModifyHdl(const Link
<LinkParamNone
*,void>& rLink
)
82 m_aModifyLink
= rLink
;
83 m_xEditEngine
->SetModifyHdl(m_aModifyLink
);
86 void SetAttrib(const SfxPoolItem
& rItem
, sal_Int32 nStart
, sal_Int32 nEnd
);
88 void SetText(const OUString
& rStr
);
90 bool MarkNextError( bool bIgnoreCurrentError
, const css::uno::Reference
<css::linguistic2::XSpellChecker1
>& );
91 int ChangeMarkedWord(const OUString
& rNewWord
, LanguageType eLanguage
);
92 void MoveErrorMarkTo(sal_Int32 nErrorStart
, sal_Int32 nErrorEnd
, bool bGrammar
);
93 OUString
GetErrorText() const;
94 void RestoreCurrentError();
97 const css::uno::Reference
<css::linguistic2::XSpellAlternatives
>& );
99 bool GetAlternatives(SpellErrorDescription
& rDesc
);
101 void ClearModifyFlag() { m_xEditEngine
->ClearModifyFlag(); }
102 void ResetModified() { ClearModifyFlag(); m_bIsUndoEditMode
= false;}
103 bool IsModified() const { return m_xEditEngine
->IsModified(); }
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() const;
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 SfxModelessDialogController
127 friend class SentenceEditWindow_Impl
;
129 OUString m_sResumeST
;
130 OUString m_sIgnoreOnceST
;
131 OUString m_sNoSuggestionsST
;
133 OUString m_sTitleSpelling
;
134 OUString m_sTitleSpellingGrammar
;
136 Link
<SpellUndoAction_Impl
&,void> aDialogUndoLink
;
140 svx::SpellDialogChildWindow
& rParent
;
141 svx::SpellPortions m_aSavedSentence
;
143 std::unique_ptr
<SpellDialog_Impl
> pImpl
;
145 css::linguistic2::XSpellChecker1
> xSpell
;
147 std::unique_ptr
<weld::Label
> m_xAltTitle
;
148 std::unique_ptr
<weld::Label
> m_xResumeFT
;
149 std::unique_ptr
<weld::Label
> m_xNoSuggestionsFT
;
150 std::unique_ptr
<weld::Label
> m_xIgnoreOnceFT
;
151 std::unique_ptr
<weld::Label
> m_xLanguageFT
;
152 std::unique_ptr
<SvxLanguageBox
> m_xLanguageLB
;
153 std::unique_ptr
<weld::Label
> m_xExplainFT
;
154 std::unique_ptr
<weld::LinkButton
> m_xExplainLink
;
155 std::unique_ptr
<weld::Label
> m_xNotInDictFT
;
156 std::unique_ptr
<SentenceEditWindow_Impl
> m_xSentenceED
;
157 std::unique_ptr
<weld::Label
> m_xSuggestionFT
;
158 std::unique_ptr
<weld::TreeView
> m_xSuggestionLB
;
159 std::unique_ptr
<weld::Button
> m_xIgnorePB
;
160 std::unique_ptr
<weld::Button
> m_xIgnoreAllPB
;
161 std::unique_ptr
<weld::Button
> m_xIgnoreRulePB
;
162 std::unique_ptr
<weld::Button
> m_xAddToDictPB
;
163 std::unique_ptr
<weld::MenuButton
> m_xAddToDictMB
;
164 std::unique_ptr
<weld::Button
> m_xChangePB
;
165 std::unique_ptr
<weld::Button
> m_xChangeAllPB
;
166 std::unique_ptr
<weld::Button
> m_xAutoCorrPB
;
167 std::unique_ptr
<weld::CheckButton
> m_xCheckGrammarCB
;
168 std::unique_ptr
<weld::Button
> m_xOptionsPB
;
169 std::unique_ptr
<weld::Button
> m_xUndoPB
;
170 std::unique_ptr
<weld::Button
> m_xClosePB
;
171 std::unique_ptr
<weld::Toolbar
> m_xToolbar
;
172 std::unique_ptr
<weld::CustomWeld
> m_xSentenceEDWeld
;
174 DECL_LINK(ChangeHdl
, weld::Button
&, void);
175 DECL_LINK(DoubleClickChangeHdl
, weld::TreeView
&, bool);
176 DECL_LINK(ChangeAllHdl
, weld::Button
&, void);
177 DECL_LINK(IgnoreAllHdl
, weld::Button
&, void);
178 DECL_LINK(IgnoreHdl
, weld::Button
&, void);
179 DECL_LINK(CheckGrammarHdl
, weld::Button
&, void);
180 DECL_LINK(ExtClickHdl
, weld::Button
&, void);
181 DECL_LINK(CancelHdl
, weld::Button
&, void);
182 DECL_LINK(ModifyHdl
, LinkParamNone
*, void);
183 DECL_LINK(UndoHdl
, weld::Button
&, void);
184 DECL_LINK(AddToDictSelectHdl
, const OString
&, void);
185 DECL_LINK(AddToDictClickHdl
, weld::Button
&, void);
186 DECL_LINK(LanguageSelectHdl
, weld::ComboBox
&, void);
187 DECL_LINK(DialogUndoHdl
, SpellUndoAction_Impl
&, void);
189 DECL_LINK(InitHdl
, void*, void);
191 void AddToDictionaryExecute(const OString
& rItemId
);
192 void StartSpellOptDlg_Impl();
194 void UpdateBoxes_Impl(bool bCallFromSelectHdl
= false);
196 void SpellContinue_Impl(std::unique_ptr
<UndoChangeGroupGuard
>* pGuard
= nullptr, bool UseSavedSentence
= false, bool bIgnoreCurrentError
= false );
197 void LockFocusChanges( bool bLock
) {bFocusLocked
= bLock
;}
198 void ToplevelFocusChanged();
199 void Impl_Restore(bool bUseSavedSentence
);
201 LanguageType
GetSelectedLang_Impl() const;
203 /** Retrieves the next sentence.
205 bool GetNextSentence_Impl(std::unique_ptr
<UndoChangeGroupGuard
>* pGuard
, bool bUseSavedSentence
, bool bRecheck
/*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
);
213 OUString
getReplacementString() const;
217 svx::SpellDialogChildWindow
* pChildWindow
,
218 weld::Window
* pParent
,
219 SfxBindings
* pBindings
);
220 virtual ~SpellDialog() override
;
222 virtual void Activate() override
;
223 virtual void Deactivate() override
;
225 virtual void Close() override
;
227 void InvalidateDialog();
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */