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 #ifndef INCLUDED_CUI_SOURCE_INC_SPELLDIALOG_HXX
20 #define INCLUDED_CUI_SOURCE_INC_SPELLDIALOG_HXX
21 
22 #include <sfx2/basedlgs.hxx>
23 #include <com/sun/star/uno/Reference.hxx>
24 
25 
26 #include <svx/langbox.hxx>
27 #include <memory>
28 #include <svl/undo.hxx>
29 #include <vcl/customweld.hxx>
30 #include <svx/weldeditview.hxx>
32 
33 #include <set>
34 
35 namespace svx{ class SpellUndoAction_Impl;}
37 
38 // forward ---------------------------------------------------------------
39 
40 struct SpellDialog_Impl;
41 namespace com::sun::star::linguistic2 { class XSpellChecker1; }
42 
43 namespace svx{
44 class SpellDialog;
45 struct SpellErrorDescription;
46 
48 {
49 private:
50  std::set<sal_Int32> m_aIgnoreErrorsAt;
53  sal_Int32 m_nErrorStart;
54  sal_Int32 m_nErrorEnd;
56 
58 
59  void CallModifyLink() {m_aModifyLink.Call(nullptr); }
60 
62 
63  bool GetErrorDescription(SpellErrorDescription& rSpellErrorDescription, sal_Int32 nPosition);
64 
65  DECL_LINK(ToolbarHdl, const OString&, void);
66 
67 protected:
68  virtual bool KeyInput( const KeyEvent& rKEvt ) override;
69 
70 public:
72  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
73  void SetSpellDialog(SpellDialog* pDialog) { m_pSpellDialog = pDialog; }
74  virtual ~SentenceEditWindow_Impl() override;
75 
76  void Init(weld::Toolbar* pToolbar);
78  {
79  m_aModifyLink = rLink;
80  m_xEditEngine->SetModifyHdl(m_aModifyLink);
81  }
82 
83  void SetAttrib(const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd);
84 
85  void SetText(const OUString& rStr);
86 
87  bool MarkNextError( bool bIgnoreCurrentError, const css::uno::Reference<css::linguistic2::XSpellChecker1>& );
88  int ChangeMarkedWord(const OUString& rNewWord, LanguageType eLanguage);
89  void MoveErrorMarkTo(sal_Int32 nErrorStart, sal_Int32 nErrorEnd, bool bGrammar);
90  OUString GetErrorText() const;
91  void RestoreCurrentError();
92 
93  void SetAlternatives(
94  const css::uno::Reference<css::linguistic2::XSpellAlternatives>& );
95 
97 
98  void ClearModifyFlag() { m_xEditEngine->ClearModifyFlag(); }
99  void ResetModified() { ClearModifyFlag(); m_bIsUndoEditMode = false;}
100  bool IsModified() const { return m_xEditEngine->IsModified(); }
101 
102  bool IsUndoEditMode() const { return m_bIsUndoEditMode;}
103  void SetUndoEditMode(bool bSet);
104 
106 
107  void ResetUndo();
108  void Undo();
109  void AddUndoAction( std::unique_ptr<SfxUndoAction> pAction );
110  size_t GetUndoActionCount() const;
111  void UndoActionStart( sal_uInt16 nId );
112  void UndoActionEnd();
113 
114  void MoveErrorEnd(long nOffset);
115 
116  void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt.clear(); }
117 };
118 
119 // class SvxSpellDialog ---------------------------------------------
120 class SpellDialogChildWindow;
121 
123 {
125 private:
126  OUString m_sResumeST;
127  OUString m_sIgnoreOnceST;
129 
132 
134 
136 
139 
140  std::unique_ptr<SpellDialog_Impl> pImpl;
141  css::uno::Reference<
142  css::linguistic2::XSpellChecker1 > xSpell;
143 
144  std::unique_ptr<weld::Label> m_xAltTitle;
145  std::unique_ptr<weld::Label> m_xResumeFT;
146  std::unique_ptr<weld::Label> m_xNoSuggestionsFT;
147  std::unique_ptr<weld::Label> m_xIgnoreOnceFT;
148  std::unique_ptr<weld::Label> m_xLanguageFT;
149  std::unique_ptr<SvxLanguageBox> m_xLanguageLB;
150  std::unique_ptr<weld::Label> m_xExplainFT;
151  std::unique_ptr<weld::LinkButton> m_xExplainLink;
152  std::unique_ptr<weld::Label> m_xNotInDictFT;
153  std::unique_ptr<SentenceEditWindow_Impl> m_xSentenceED;
154  std::unique_ptr<weld::Label> m_xSuggestionFT;
155  std::unique_ptr<weld::TreeView> m_xSuggestionLB;
156  std::unique_ptr<weld::Button> m_xIgnorePB;
157  std::unique_ptr<weld::Button> m_xIgnoreAllPB;
158  std::unique_ptr<weld::Button> m_xIgnoreRulePB;
159  std::unique_ptr<weld::Button> m_xAddToDictPB;
160  std::unique_ptr<weld::MenuButton> m_xAddToDictMB;
161  std::unique_ptr<weld::Button> m_xChangePB;
162  std::unique_ptr<weld::Button> m_xChangeAllPB;
163  std::unique_ptr<weld::Button> m_xAutoCorrPB;
164  std::unique_ptr<weld::CheckButton> m_xCheckGrammarCB;
165  std::unique_ptr<weld::Button> m_xOptionsPB;
166  std::unique_ptr<weld::Button> m_xUndoPB;
167  std::unique_ptr<weld::Button> m_xClosePB;
168  std::unique_ptr<weld::Toolbar> m_xToolbar;
169  std::unique_ptr<weld::CustomWeld> m_xSentenceEDWeld;
170 
171  DECL_LINK(ChangeHdl, weld::Button&, void);
172  DECL_LINK(DoubleClickChangeHdl, weld::TreeView&, bool);
173  DECL_LINK(ChangeAllHdl, weld::Button&, void);
174  DECL_LINK(IgnoreAllHdl, weld::Button&, void);
175  DECL_LINK(IgnoreHdl, weld::Button&, void);
176  DECL_LINK(CheckGrammarHdl, weld::Button&, void);
177  DECL_LINK(ExtClickHdl, weld::Button&, void);
178  DECL_LINK(CancelHdl, weld::Button&, void);
179  DECL_LINK(ModifyHdl, LinkParamNone*, void);
180  DECL_LINK(UndoHdl, weld::Button&, void);
181  DECL_LINK(AddToDictSelectHdl, const OString&, void);
182  DECL_LINK(AddToDictClickHdl, weld::Button&, void);
183  DECL_LINK(LanguageSelectHdl, weld::ComboBox&, void);
184  DECL_LINK(DialogUndoHdl, SpellUndoAction_Impl&, void);
185 
186  DECL_LINK(InitHdl, void*, void);
187 
188  void AddToDictionaryExecute(const OString& rItemId);
189  void StartSpellOptDlg_Impl();
190  int InitUserDicts();
191  void UpdateBoxes_Impl(bool bCallFromSelectHdl = false);
192  void Init_Impl();
193  void SpellContinue_Impl(std::unique_ptr<UndoChangeGroupGuard>* pGuard = nullptr, bool UseSavedSentence = false, bool bIgnoreCurrentError = false );
194  void LockFocusChanges( bool bLock ) {bFocusLocked = bLock;}
195  void ToplevelFocusChanged();
196  void Impl_Restore(bool bUseSavedSentence);
197 
199 
202  bool GetNextSentence_Impl(std::unique_ptr<UndoChangeGroupGuard>* pGuard, bool bUseSavedSentence, bool bRecheck /*for rechecking the current sentence*/);
205  static bool ApplyChangeAllList_Impl(SpellPortions& rSentence, bool& bHasReplaced);
206  void SetTitle_Impl(LanguageType nLang);
207 
208 protected:
209 
210  OUString getReplacementString() const;
211 
212 public:
213  SpellDialog(
214  svx::SpellDialogChildWindow* pChildWindow,
215  weld::Window * pParent,
216  SfxBindings* pBindings);
217  virtual ~SpellDialog() override;
218 
219  virtual void Activate() override;
220  virtual void Deactivate() override;
221 
222  virtual void Close() override;
223 
224  void InvalidateDialog();
225 };
226 
227 } //namespace svx
228 
229 #endif
230 
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Label > m_xResumeFT
std::unique_ptr< weld::CustomWeld > m_xSentenceEDWeld
std::unique_ptr< weld::Label > m_xExplainFT
std::unique_ptr< weld::TreeView > m_xSuggestionLB
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
OUString m_sResumeST
std::unique_ptr< SvxLanguageBox > m_xLanguageLB
std::unique_ptr< weld::Label > m_xNotInDictFT
std::unique_ptr< SpellDialog_Impl > pImpl
void AddToDictionaryExecute(const OString &rItemId)
std::unique_ptr< weld::Label > m_xSuggestionFT
void SetTitle_Impl(LanguageType nLang)
void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction)
std::set< sal_Int32 > m_aIgnoreErrorsAt
Definition: SpellDialog.hxx:50
std::unique_ptr< weld::Button > m_xOptionsPB
bool GetErrorDescription(SpellErrorDescription &rSpellErrorDescription, sal_Int32 nPosition)
OUString getReplacementString() const
void ToplevelFocusChanged()
void Init(weld::Toolbar *pToolbar)
OUString GetErrorText() const
OUString m_sIgnoreOnceST
void SpellContinue_Impl(std::unique_ptr< UndoChangeGroupGuard > *pGuard=nullptr, bool UseSavedSentence=false, bool bIgnoreCurrentError=false)
void SetText(const OUString &rStr)
std::unique_ptr< weld::Button > m_xIgnoreAllPB
std::unique_ptr< weld::Label > m_xNoSuggestionsFT
svx::SpellPortions CreateSpellPortions() const
std::unique_ptr< weld::Button > m_xIgnoreRulePB
std::unique_ptr< weld::Button > m_xAutoCorrPB
bool GetNextSentence_Impl(std::unique_ptr< UndoChangeGroupGuard > *pGuard, bool bUseSavedSentence, bool bRecheck)
Retrieves the next sentence.
virtual void Deactivate() override
std::unique_ptr< weld::Button > m_xAddToDictPB
svx::SpellDialogChildWindow & rParent
std::unique_ptr< weld::Label > m_xLanguageFT
DECL_LINK(ToolbarHdl, const OString &, void)
void UndoActionStart(sal_uInt16 nId)
virtual bool KeyInput(const KeyEvent &rKEvt) override
std::unique_ptr< weld::Button > m_xUndoPB
std::vector< SpellPortion > SpellPortions
virtual void Close() override
std::unique_ptr< weld::CheckButton > m_xCheckGrammarCB
std::unique_ptr< weld::Toolbar > m_xToolbar
std::unique_ptr< weld::Button > m_xIgnorePB
OUString m_sTitleSpellingGrammar
std::unique_ptr< weld::LinkButton > m_xExplainLink
void MoveErrorEnd(long nOffset)
OUString m_sTitleSpelling
std::unique_ptr< weld::Button > m_xClosePB
Link< SpellUndoAction_Impl &, void > aDialogUndoLink
virtual void Activate() override
std::unique_ptr< SentenceEditWindow_Impl > m_xSentenceED
size_t GetUndoActionCount() const
std::unique_ptr< weld::Button > m_xChangeAllPB
void Impl_Restore(bool bUseSavedSentence)
void LockFocusChanges(bool bLock)
void UpdateBoxes_Impl(bool bCallFromSelectHdl=false)
static bool ApplyChangeAllList_Impl(SpellPortions &rSentence, bool &bHasReplaced)
Corrects all errors that have been selected to be changed always.
virtual ~SentenceEditWindow_Impl() override
LanguageType GetSelectedLang_Impl() const
OUString m_sNoSuggestionsST
void SetAlternatives(const css::uno::Reference< css::linguistic2::XSpellAlternatives > &)
bool GetAlternatives(SpellErrorDescription &rDesc)
int ChangeMarkedWord(const OUString &rNewWord, LanguageType eLanguage)
std::unique_ptr< weld::MenuButton > m_xAddToDictMB
bool MarkNextError(bool bIgnoreCurrentError, const css::uno::Reference< css::linguistic2::XSpellChecker1 > &)
std::unique_ptr< weld::Label > m_xAltTitle
void SetAttrib(const SfxPoolItem &rItem, sal_Int32 nStart, sal_Int32 nEnd)
void MoveErrorMarkTo(sal_Int32 nErrorStart, sal_Int32 nErrorEnd, bool bGrammar)
Link< LinkParamNone *, void > m_aModifyLink
Definition: SpellDialog.hxx:57
svx::SpellPortions m_aSavedSentence
std::unique_ptr< EditEngine > m_xEditEngine
SpellDialog * GetSpellDialog() const
Definition: SpellDialog.hxx:61
void SetSpellDialog(SpellDialog *pDialog)
Definition: SpellDialog.hxx:73
void StartSpellOptDlg_Impl()
std::unique_ptr< weld::Button > m_xChangePB
virtual ~SpellDialog() override
css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpell
std::unique_ptr< weld::Label > m_xIgnoreOnceFT
void SetModifyHdl(const Link< LinkParamNone *, void > &rLink)
Definition: SpellDialog.hxx:77
SpellDialog(svx::SpellDialogChildWindow *pChildWindow, weld::Window *pParent, SfxBindings *pBindings)
DECL_LINK(ChangeHdl, weld::Button &, void)