Line data Source code
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 _SVX_SPELLDDIALOG_HXX
20 : #define _SVX_SPELLDDIALOG_HXX
21 :
22 : #include <sfx2/basedlgs.hxx>
23 : #include <vcl/fixed.hxx>
24 : #include <vcl/edit.hxx>
25 : #include <vcl/lstbox.hxx>
26 : #include <svtools/stdctrl.hxx>
27 : #include <vcl/button.hxx>
28 : #include <vcl/menubtn.hxx>
29 : #include <vcl/group.hxx>
30 : #include <vcl/decoview.hxx>
31 : #include <vcl/image.hxx>
32 : #include <com/sun/star/uno/Reference.hxx>
33 :
34 :
35 : #include <svx/langbox.hxx>
36 : #include <memory>
37 : #include <svtools/svmedit.hxx>
38 : #include <svl/lstner.hxx>
39 : #include <vcl/fixedhyper.hxx>
40 : #include <vcl/xtextedt.hxx>
41 : #include <editeng/SpellPortions.hxx>
42 :
43 : #include <set>
44 :
45 : namespace svx{ class SpellUndoAction_Impl;}
46 :
47 : // forward ---------------------------------------------------------------
48 :
49 : struct SpellDialog_Impl;
50 :
51 : namespace com{namespace sun{namespace star{
52 : namespace linguistic2{
53 : class XSpellChecker1;
54 : }}}}
55 : namespace svx{
56 : class SpellDialog;
57 : struct SpellErrorDescription;
58 : // ------------------------------------------------------------------
59 : class SentenceEditWindow_Impl : public MultiLineEdit
60 : {
61 : using MultiLineEdit::SetText;
62 :
63 : private:
64 : std::set< sal_uInt16 > m_aIgnoreErrorsAt;
65 : sal_uInt16 m_nErrorStart;
66 : sal_uInt16 m_nErrorEnd;
67 : bool m_bIsUndoEditMode;
68 :
69 : Link m_aModifyLink;
70 :
71 0 : void CallModifyLink() {m_aModifyLink.Call(this);}
72 :
73 0 : SpellDialog* GetSpellDialog() const {return (SpellDialog*)GetParent();}
74 : protected:
75 : virtual long PreNotify( NotifyEvent& rNEvt );
76 :
77 : public:
78 : SentenceEditWindow_Impl( SpellDialog* pParent, const ResId& rResId );
79 : ~SentenceEditWindow_Impl();
80 :
81 0 : void SetModifyHdl(const Link& rLink) { m_aModifyLink = rLink;}
82 :
83 : void SetAttrib( const TextAttrib& rAttr, sal_uLong nPara, sal_uInt16 nStart, sal_uInt16 nEnd );
84 : void SetText( const String& rStr );
85 :
86 : bool MarkNextError( bool bIgnoreCurrentError );
87 : void ChangeMarkedWord(const String& rNewWord, LanguageType eLanguage);
88 : void MoveErrorMarkTo(sal_uInt16 nErrorStart, sal_uInt16 nErrorEnd, bool bGrammar);
89 : String GetErrorText() const;
90 : void RestoreCurrentError();
91 :
92 : void SetAlternatives(
93 : com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellAlternatives> );
94 :
95 : const SpellErrorDescription* GetAlternatives();
96 :
97 :
98 0 : void ResetModified() { GetTextEngine()->SetModified(sal_False); m_bIsUndoEditMode = false;}
99 0 : sal_Bool IsModified() const { return GetTextEngine()->IsModified(); }
100 :
101 0 : bool IsUndoEditMode() const { return m_bIsUndoEditMode;}
102 : void SetUndoEditMode(bool bSet);
103 :
104 : svx::SpellPortions CreateSpellPortions( bool bSetIgnoreFlag ) const;
105 :
106 : void ResetUndo();
107 : void Undo();
108 : void AddUndoAction( SfxUndoAction *pAction, sal_Bool bTryMerg=sal_False );
109 : sal_uInt16 GetUndoActionCount();
110 : void UndoActionStart( sal_uInt16 nId );
111 : void UndoActionEnd();
112 :
113 : void MoveErrorEnd(long nOffset);
114 :
115 0 : void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt.clear(); }
116 : };
117 :
118 0 : class HelpFixedText : public FixedText
119 : {
120 : public:
121 : HelpFixedText( Window* pParent, const ResId& rResId );
122 :
123 : virtual void Paint( const Rectangle& rRect );
124 : long GetActualHeight( );
125 : };
126 :
127 : // class SvxSpellDialog ---------------------------------------------
128 : class SpellDialogChildWindow;
129 :
130 : class SpellDialog : public SfxModelessDialog
131 : {
132 : using Window::Invalidate;
133 :
134 : friend class SentenceEditWindow_Impl;
135 : private:
136 :
137 : FixedText aLanguageFT;
138 : SvxLanguageBox aLanguageLB;
139 :
140 : HelpFixedText aExplainFT;
141 : FixedHyperlink aExplainLink;
142 :
143 : FixedText aNotInDictFT;
144 : SentenceEditWindow_Impl aSentenceED;
145 :
146 : FixedText aSuggestionFT;
147 : ListBox aSuggestionLB;
148 :
149 : PushButton aIgnorePB;
150 : PushButton aIgnoreAllPB;
151 : PushButton aIgnoreRulePB;
152 : MenuButton aAddToDictMB;
153 : PushButton aAddToDictPB;
154 :
155 : PushButton aChangePB;
156 : PushButton aChangeAllPB;
157 : PushButton aAutoCorrPB;
158 :
159 : CheckBox aCheckGrammarCB;
160 :
161 : HelpButton aHelpPB;
162 : PushButton aOptionsPB;
163 : PushButton aUndoPB;
164 : PushButton aClosePB;
165 :
166 : GroupBox aBackgroundGB;
167 :
168 : Image aVendorImage;
169 :
170 : String aResumeST;
171 : String aIgnoreOnceST;
172 : String aNoSuggestionsST;
173 :
174 : const String m_sTitleSpelling;
175 : const String m_sTitleSpellingGrammar;
176 : const String m_sTitleSpellingGrammarVendor;
177 :
178 : Size aOldWordEDSize;
179 : Link aDialogUndoLink;
180 :
181 : bool bModified;
182 : bool bFocusLocked;
183 :
184 : svx::SpellDialogChildWindow& rParent;
185 : svx::SpellPortions m_aSavedSentence;
186 :
187 : SpellDialog_Impl* pImpl;
188 : ::com::sun::star::uno::Reference<
189 : ::com::sun::star::linguistic2::XSpellChecker1 > xSpell;
190 :
191 : DECL_LINK(ChangeHdl, void *);
192 : DECL_LINK(ChangeAllHdl, void *);
193 : DECL_LINK( IgnoreAllHdl, Button * );
194 : DECL_LINK(IgnoreHdl, void *);
195 : DECL_LINK( CheckGrammarHdl, CheckBox* );
196 : DECL_LINK( ExtClickHdl, Button * );
197 : DECL_LINK(CancelHdl, void *);
198 : DECL_LINK( ModifyHdl, SentenceEditWindow_Impl *);
199 : DECL_LINK(UndoHdl, void *);
200 : DECL_LINK( AddToDictSelectHdl, MenuButton* );
201 : DECL_LINK( AddToDictClickHdl, PushButton* );
202 : DECL_LINK( LanguageSelectHdl, SvxLanguageBox* );
203 : DECL_LINK( DialogUndoHdl, SpellUndoAction_Impl* );
204 : DECL_LINK( HandleHyperlink, FixedHyperlink * );
205 :
206 : DECL_STATIC_LINK( SpellDialog, InitHdl, SpellDialog * );
207 :
208 : int AddToDictionaryExecute( sal_uInt16 ItemId, PopupMenu *pMenu );
209 : void StartSpellOptDlg_Impl();
210 : int InitUserDicts();
211 : void UpdateBoxes_Impl();
212 : void Init_Impl();
213 : void SpellContinue_Impl(bool UseSavedSentence = false, bool bIgnoreCurrentError = false );
214 0 : void LockFocusChanges( bool bLock ) {bFocusLocked = bLock;}
215 : void Impl_Restore();
216 :
217 : void SetSelectedLang_Impl( LanguageType nLang );
218 : LanguageType GetSelectedLang_Impl() const;
219 :
220 : /** Retrieves the next sentence.
221 : */
222 : bool GetNextSentence_Impl(bool bUseSavedSentence, bool bRechek /*for rechecking the current sentence*/);
223 : /** Corrects all errors that have been selected to be changed always
224 : */
225 : bool ApplyChangeAllList_Impl(SpellPortions& rSentence, bool& bHasReplaced);
226 : void SetTitle_Impl(LanguageType nLang);
227 :
228 : protected:
229 : virtual void Paint( const Rectangle& rRect );
230 : virtual long Notify( NotifyEvent& rNEvt );
231 :
232 : String getReplacementString() const;
233 :
234 : public:
235 : SpellDialog(
236 : svx::SpellDialogChildWindow* pChildWindow,
237 : Window * pParent,
238 : SfxBindings* pBindings);
239 : ~SpellDialog();
240 :
241 : void SetLanguage( sal_uInt16 nLang );
242 : virtual sal_Bool Close();
243 :
244 : void InvalidateDialog();
245 : };
246 : } //namespace svx
247 :
248 : #endif
249 :
250 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|