LibreOffice Module cui (master) 1
SpellDialog.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <sfx2/basedlgs.hxx>
22#include <com/sun/star/uno/Reference.hxx>
23
24
25#include <svx/langbox.hxx>
26#include <memory>
27#include <svl/undo.hxx>
28#include <vcl/customweld.hxx>
29#include <svx/weldeditview.hxx>
31
32#include <set>
33
34namespace svx{ class SpellUndoAction_Impl;}
36
37// forward ---------------------------------------------------------------
38
39struct SpellDialog_Impl;
40namespace com::sun::star::linguistic2 { class XSpellChecker1; }
41
42namespace svx{
43class SpellDialog;
44struct SpellErrorDescription;
45
47{
48private:
49 std::set<sal_Int32> m_aIgnoreErrorsAt;
52 sal_Int32 m_nErrorStart;
53 sal_Int32 m_nErrorEnd;
55
57
58 void CallModifyLink() {m_aModifyLink.Call(nullptr); }
59
61
62 bool GetErrorDescription(SpellErrorDescription& rSpellErrorDescription, sal_Int32 nPosition);
63
64 DECL_LINK(ToolbarHdl, const OUString&, void);
65
66protected:
67 virtual bool KeyInput( const KeyEvent& rKEvt ) override;
68
69public:
71 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
72 void SetSpellDialog(SpellDialog* pDialog) { m_pSpellDialog = pDialog; }
73 virtual ~SentenceEditWindow_Impl() override;
74
75 void Init(weld::Toolbar* pToolbar);
77 {
78 m_aModifyLink = rLink;
79 m_xEditEngine->SetModifyHdl(m_aModifyLink);
80 }
81
82 void SetAttrib(const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd);
83
84 void SetText(const OUString& rStr);
85
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;
91
92 void SetAlternatives(
93 const css::uno::Reference<css::linguistic2::XSpellAlternatives>& );
94
96
97 void ClearModifyFlag() { m_xEditEngine->ClearModifyFlag(); }
99 bool IsModified() const { return m_xEditEngine->IsModified(); }
100
101 bool IsUndoEditMode() const { return m_bIsUndoEditMode;}
102 void SetUndoEditMode(bool bSet);
103
105
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();
112
113 void MoveErrorEnd(tools::Long nOffset);
114
116};
117
118// class SvxSpellDialog ---------------------------------------------
119class SpellDialogChildWindow;
120
122{
124private:
125 OUString m_sResumeST;
128
131
135
138
139 std::unique_ptr<SpellDialog_Impl> pImpl;
140 css::uno::Reference<
141 css::linguistic2::XSpellChecker1 > xSpell;
142
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;
169
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);
184
185 DECL_LINK(InitHdl, void*, void);
186
187 void AddToDictionaryExecute(const OUString& rItemId);
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;}
195 void Impl_Restore(bool bUseSavedSentence);
196
198
201 bool GetNextSentence_Impl(std::unique_ptr<UndoChangeGroupGuard>* pGuard, bool bUseSavedSentence, bool bRecheck /*for rechecking the current sentence*/);
204 static bool ApplyChangeAllList_Impl(SpellPortions& rSentence, bool& bHasReplaced);
205 void SetTitle_Impl(LanguageType nLang);
206
207protected:
208
209 OUString getReplacementString() const;
210
211public:
213 svx::SpellDialogChildWindow* pChildWindow,
214 weld::Window * pParent,
215 SfxBindings* pBindings);
216 virtual ~SpellDialog() override;
217
218 virtual void Activate() override;
219 virtual void Deactivate() override;
220
221 virtual void Close() override;
222
223 void InvalidateDialog();
224};
225
226} //namespace svx
227
228/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< EditEngine > m_xEditEngine
bool GetAlternatives(SpellErrorDescription &rDesc)
void MoveErrorMarkTo(sal_Int32 nErrorStart, sal_Int32 nErrorEnd, bool bGrammar)
virtual bool KeyInput(const KeyEvent &rKEvt) override
DECL_LINK(ToolbarHdl, const OUString &, void)
void SetModifyHdl(const Link< LinkParamNone *, void > &rLink)
Definition: SpellDialog.hxx:76
void Init(weld::Toolbar *pToolbar)
std::set< sal_Int32 > m_aIgnoreErrorsAt
Definition: SpellDialog.hxx:49
void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction)
void SetAlternatives(const css::uno::Reference< css::linguistic2::XSpellAlternatives > &)
SpellDialog * GetSpellDialog() const
Definition: SpellDialog.hxx:60
void UndoActionStart(sal_uInt16 nId)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
void SetSpellDialog(SpellDialog *pDialog)
Definition: SpellDialog.hxx:72
int ChangeMarkedWord(const OUString &rNewWord, LanguageType eLanguage)
void SetText(const OUString &rStr)
virtual ~SentenceEditWindow_Impl() override
void MoveErrorEnd(tools::Long nOffset)
Link< LinkParamNone *, void > m_aModifyLink
Definition: SpellDialog.hxx:56
svx::SpellPortions CreateSpellPortions() const
bool MarkNextError(bool bIgnoreCurrentError, const css::uno::Reference< css::linguistic2::XSpellChecker1 > &)
void SetAttrib(const SfxPoolItem &rItem, sal_Int32 nStart, sal_Int32 nEnd)
bool GetErrorDescription(SpellErrorDescription &rSpellErrorDescription, sal_Int32 nPosition)
std::unique_ptr< SvxLanguageBox > m_xLanguageLB
std::unique_ptr< weld::MenuButton > m_xAddToDictMB
std::unique_ptr< weld::CheckButton > m_xCheckGrammarCB
DECL_LINK(ChangeAllHdl, weld::Button &, void)
void ToplevelFocusChanged()
virtual void Deactivate() override
OUString m_sIgnoreOnceST
std::unique_ptr< weld::Label > m_xNoSuggestionsFT
void LockFocusChanges(bool bLock)
std::unique_ptr< weld::Button > m_xIgnoreRulePB
SpellDialog(svx::SpellDialogChildWindow *pChildWindow, weld::Window *pParent, SfxBindings *pBindings)
svx::SpellPortions m_aSavedSentence
DECL_LINK(DoubleClickChangeHdl, weld::TreeView &, bool)
DECL_LINK(AddToDictClickHdl, weld::Button &, void)
DECL_LINK(ExtClickHdl, weld::Button &, void)
std::unique_ptr< weld::CustomWeld > m_xSentenceEDWeld
DECL_LINK(InitHdl, void *, void)
void SpellContinue_Impl(std::unique_ptr< UndoChangeGroupGuard > *pGuard=nullptr, bool UseSavedSentence=false, bool bIgnoreCurrentError=false)
std::unique_ptr< weld::Button > m_xChangeAllPB
std::unique_ptr< SpellDialog_Impl > pImpl
std::unique_ptr< weld::Label > m_xResumeFT
std::unique_ptr< weld::Label > m_xExplainFT
Link< SpellUndoAction_Impl &, void > aDialogUndoLink
DECL_LINK(ModifyHdl, LinkParamNone *, void)
std::unique_ptr< weld::Button > m_xIgnorePB
DECL_LINK(IgnoreAllHdl, weld::Button &, void)
OUString m_sResumeST
void StartSpellOptDlg_Impl()
DECL_LINK(IgnoreHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xUndoPB
DECL_LINK(CheckGrammarHdl, weld::Toggleable &, void)
OUString m_sNoSuggestionsST
OUString m_sTitleSpellingGrammar
void Impl_Restore(bool bUseSavedSentence)
static bool ApplyChangeAllList_Impl(SpellPortions &rSentence, bool &bHasReplaced)
Corrects all errors that have been selected to be changed always.
ImplSVEvent * m_pInitHdlEvent
virtual void Close() override
css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpell
virtual void Activate() override
DECL_LINK(ChangeHdl, weld::Button &, void)
void SetTitle_Impl(LanguageType nLang)
LanguageType GetSelectedLang_Impl() const
std::unique_ptr< SentenceEditWindow_Impl > m_xSentenceED
OUString m_sTitleSpelling
std::unique_ptr< weld::Button > m_xAddToDictPB
void UpdateBoxes_Impl(bool bCallFromSelectHdl=false)
std::unique_ptr< weld::Button > m_xChangePB
std::unique_ptr< weld::Label > m_xNotInDictFT
DECL_LINK(UndoHdl, weld::Button &, void)
virtual ~SpellDialog() override
DECL_LINK(CancelHdl, weld::Button &, void)
DECL_LINK(LanguageSelectHdl, weld::ComboBox &, void)
DECL_LINK(AddToDictSelectHdl, const OUString &, void)
std::shared_ptr< SfxSingleTabDialogController > m_xOptionsDlg
std::unique_ptr< weld::Label > m_xSuggestionFT
std::unique_ptr< weld::Button > m_xAutoCorrPB
std::unique_ptr< weld::LinkButton > m_xExplainLink
void AddToDictionaryExecute(const OUString &rItemId)
svx::SpellDialogChildWindow & rParent
std::unique_ptr< weld::Label > m_xLanguageFT
std::unique_ptr< weld::Label > m_xAltTitle
std::unique_ptr< weld::Button > m_xIgnoreAllPB
std::unique_ptr< weld::Button > m_xOptionsPB
DECL_LINK(DialogUndoHdl, SpellUndoAction_Impl &, void)
std::unique_ptr< weld::Button > m_xClosePB
std::unique_ptr< weld::TreeView > m_xSuggestionLB
std::unique_ptr< weld::Toolbar > m_xToolbar
OUString getReplacementString() const
bool GetNextSentence_Impl(std::unique_ptr< UndoChangeGroupGuard > *pGuard, bool bUseSavedSentence, bool bRecheck)
Retrieves the next sentence.
std::vector< SpellPortion > SpellPortions
long Long