Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / cui / source / inc / SpellDialog.hxx
blob3b8d2f9fa02f1e98338acb4ec56fb12adc54ea41
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
21 #include <sfx2/basedlgs.hxx>
22 #include <com/sun/star/uno/Reference.hxx>
25 #include <svx/langbox.hxx>
26 #include <memory>
27 #include <svl/undo.hxx>
28 #include <vcl/customweld.hxx>
29 #include <svx/weldeditview.hxx>
30 #include <editeng/SpellPortions.hxx>
32 #include <set>
34 namespace svx{ class SpellUndoAction_Impl;}
35 class UndoChangeGroupGuard;
37 // forward ---------------------------------------------------------------
39 struct SpellDialog_Impl;
40 namespace com::sun::star::linguistic2 { class XSpellChecker1; }
42 namespace svx{
43 class SpellDialog;
44 struct SpellErrorDescription;
46 class SentenceEditWindow_Impl : public WeldEditView
48 private:
49 std::set<sal_Int32> m_aIgnoreErrorsAt;
50 SpellDialog* m_pSpellDialog;
51 weld::Toolbar* m_pToolbar;
52 sal_Int32 m_nErrorStart;
53 sal_Int32 m_nErrorEnd;
54 bool m_bIsUndoEditMode;
56 Link<LinkParamNone*,void> m_aModifyLink;
58 void CallModifyLink() {m_aModifyLink.Call(nullptr); }
60 SpellDialog* GetSpellDialog() const { return m_pSpellDialog; }
62 bool GetErrorDescription(SpellErrorDescription& rSpellErrorDescription, sal_Int32 nPosition);
64 DECL_LINK(ToolbarHdl, const OUString&, void);
66 protected:
67 virtual bool KeyInput( const KeyEvent& rKEvt ) override;
69 public:
70 SentenceEditWindow_Impl();
71 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
72 void SetSpellDialog(SpellDialog* pDialog) { m_pSpellDialog = pDialog; }
73 virtual ~SentenceEditWindow_Impl() override;
75 void Init(weld::Toolbar* pToolbar);
76 void SetModifyHdl(const Link<LinkParamNone*,void>& rLink)
78 m_aModifyLink = rLink;
79 m_xEditEngine->SetModifyHdl(m_aModifyLink);
82 void SetAttrib(const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd);
84 void SetText(const OUString& rStr);
86 bool MarkNextError( bool bIgnoreCurrentError, const css::uno::Reference<css::linguistic2::XSpellChecker1>& );
87 int ChangeMarkedWord(const OUString& rNewWord, LanguageType eLanguage);
88 void MoveErrorMarkTo(sal_Int32 nErrorStart, sal_Int32 nErrorEnd, bool bGrammar);
89 OUString GetErrorText() const;
90 void RestoreCurrentError();
92 void SetAlternatives(
93 const css::uno::Reference<css::linguistic2::XSpellAlternatives>& );
95 bool GetAlternatives(SpellErrorDescription& rDesc);
97 void ClearModifyFlag() { m_xEditEngine->ClearModifyFlag(); }
98 void ResetModified() { ClearModifyFlag(); m_bIsUndoEditMode = false;}
99 bool IsModified() const { return m_xEditEngine->IsModified(); }
101 bool IsUndoEditMode() const { return m_bIsUndoEditMode;}
102 void SetUndoEditMode(bool bSet);
104 svx::SpellPortions CreateSpellPortions() const;
106 void ResetUndo();
107 void Undo();
108 void AddUndoAction( std::unique_ptr<SfxUndoAction> pAction );
109 size_t GetUndoActionCount() const;
110 void UndoActionStart( sal_uInt16 nId );
111 void UndoActionEnd();
113 void MoveErrorEnd(tools::Long nOffset);
115 void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt.clear(); }
118 // class SvxSpellDialog ---------------------------------------------
119 class SpellDialogChildWindow;
121 class SpellDialog : public SfxModelessDialogController
123 friend class SentenceEditWindow_Impl;
124 private:
125 OUString m_sResumeST;
126 OUString m_sIgnoreOnceST;
127 OUString m_sNoSuggestionsST;
129 OUString m_sTitleSpelling;
130 OUString m_sTitleSpellingGrammar;
132 Link<SpellUndoAction_Impl&,void> aDialogUndoLink;
133 ImplSVEvent * m_pInitHdlEvent;
134 bool bFocusLocked;
136 svx::SpellDialogChildWindow& rParent;
137 svx::SpellPortions m_aSavedSentence;
139 std::unique_ptr<SpellDialog_Impl> pImpl;
140 css::uno::Reference<
141 css::linguistic2::XSpellChecker1 > xSpell;
143 std::unique_ptr<weld::Label> m_xAltTitle;
144 std::unique_ptr<weld::Label> m_xResumeFT;
145 std::unique_ptr<weld::Label> m_xNoSuggestionsFT;
146 std::unique_ptr<weld::Label> m_xLanguageFT;
147 std::unique_ptr<SvxLanguageBox> m_xLanguageLB;
148 std::unique_ptr<weld::Label> m_xExplainFT;
149 std::unique_ptr<weld::LinkButton> m_xExplainLink;
150 std::unique_ptr<weld::Label> m_xNotInDictFT;
151 std::unique_ptr<SentenceEditWindow_Impl> m_xSentenceED;
152 std::unique_ptr<weld::Label> m_xSuggestionFT;
153 std::unique_ptr<weld::TreeView> m_xSuggestionLB;
154 std::unique_ptr<weld::Button> m_xIgnorePB;
155 std::unique_ptr<weld::Button> m_xIgnoreAllPB;
156 std::unique_ptr<weld::Button> m_xIgnoreRulePB;
157 std::unique_ptr<weld::Button> m_xAddToDictPB;
158 std::unique_ptr<weld::MenuButton> m_xAddToDictMB;
159 std::unique_ptr<weld::Button> m_xChangePB;
160 std::unique_ptr<weld::Button> m_xChangeAllPB;
161 std::unique_ptr<weld::Button> m_xAutoCorrPB;
162 std::unique_ptr<weld::CheckButton> m_xCheckGrammarCB;
163 std::unique_ptr<weld::Button> m_xOptionsPB;
164 std::unique_ptr<weld::Button> m_xUndoPB;
165 std::unique_ptr<weld::Button> m_xClosePB;
166 std::unique_ptr<weld::Toolbar> m_xToolbar;
167 std::unique_ptr<weld::CustomWeld> m_xSentenceEDWeld;
168 std::shared_ptr<SfxSingleTabDialogController> m_xOptionsDlg;
170 DECL_LINK(ChangeHdl, weld::Button&, void);
171 DECL_LINK(DoubleClickChangeHdl, weld::TreeView&, bool);
172 DECL_LINK(ChangeAllHdl, weld::Button&, void);
173 DECL_LINK(IgnoreAllHdl, weld::Button&, void);
174 DECL_LINK(IgnoreHdl, weld::Button&, void);
175 DECL_LINK(CheckGrammarHdl, weld::Toggleable&, void);
176 DECL_LINK(ExtClickHdl, weld::Button&, void);
177 DECL_LINK(CancelHdl, weld::Button&, void);
178 DECL_LINK(ModifyHdl, LinkParamNone*, void);
179 DECL_LINK(UndoHdl, weld::Button&, void);
180 DECL_LINK(AddToDictSelectHdl, const OUString&, void);
181 DECL_LINK(AddToDictClickHdl, weld::Button&, void);
182 DECL_LINK(LanguageSelectHdl, weld::ComboBox&, void);
183 DECL_LINK(DialogUndoHdl, SpellUndoAction_Impl&, void);
185 DECL_LINK(InitHdl, void*, void);
187 void AddToDictionaryExecute(const OUString& rItemId);
188 void StartSpellOptDlg_Impl();
189 int InitUserDicts();
190 void UpdateBoxes_Impl(bool bCallFromSelectHdl = false);
191 void Init_Impl();
192 void SpellContinue_Impl(std::unique_ptr<UndoChangeGroupGuard>* pGuard = nullptr, bool UseSavedSentence = false, bool bIgnoreCurrentError = false );
193 void LockFocusChanges( bool bLock ) {bFocusLocked = bLock;}
194 void ToplevelFocusChanged();
195 void Impl_Restore(bool bUseSavedSentence);
197 LanguageType GetSelectedLang_Impl() const;
199 /** Retrieves the next sentence.
201 bool GetNextSentence_Impl(std::unique_ptr<UndoChangeGroupGuard>* pGuard, bool bUseSavedSentence, bool bRecheck /*for rechecking the current sentence*/);
202 /** Corrects all errors that have been selected to be changed always
204 static bool ApplyChangeAllList_Impl(SpellPortions& rSentence, bool& bHasReplaced);
205 void SetTitle_Impl(LanguageType nLang);
207 protected:
209 OUString getReplacementString() const;
211 public:
212 SpellDialog(
213 svx::SpellDialogChildWindow* pChildWindow,
214 weld::Window * pParent,
215 SfxBindings* pBindings);
216 virtual ~SpellDialog() override;
218 virtual void Activate() override;
219 virtual void Deactivate() override;
221 virtual void Close() override;
223 void InvalidateDialog();
226 } //namespace svx
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */