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