1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _SVX_SPELLDDIALOG_HXX 24 #define _SVX_SPELLDDIALOG_HXX 25 26 // include --------------------------------------------------------------- 27 28 #include <sfx2/basedlgs.hxx> 29 #include <vcl/fixed.hxx> 30 #include <vcl/edit.hxx> 31 #include <vcl/lstbox.hxx> 32 #include <svtools/stdctrl.hxx> 33 #include <vcl/button.hxx> 34 #include <vcl/menubtn.hxx> 35 #include <vcl/group.hxx> 36 #include <vcl/decoview.hxx> 37 #include <vcl/image.hxx> 38 #include <com/sun/star/uno/Reference.hxx> 39 40 41 #include <svtools/svxbox.hxx> 42 #include <svx/langbox.hxx> 43 #include <memory> 44 #include <svtools/svmedit.hxx> 45 #include <svl/lstner.hxx> 46 #include <svtools/xtextedt.hxx> 47 #include <editeng/SpellPortions.hxx> 48 49 #include <set> 50 51 class ScrollBar; 52 class TextEngine; 53 class ExtTextView; 54 namespace svx{ class SpellUndoAction_Impl;} 55 56 // forward --------------------------------------------------------------- 57 58 struct SpellDialog_Impl; 59 60 namespace com{namespace sun{namespace star{ 61 namespace linguistic2{ 62 class XSpellChecker1; 63 }}}} 64 namespace svx{ 65 class SpellDialog; 66 struct SpellErrorDescription; 67 // ------------------------------------------------------------------ 68 class SentenceEditWindow_Impl : public MultiLineEdit/*, public SfxListener*/ 69 { 70 using MultiLineEdit::SetText; 71 72 private: 73 std::set< sal_uInt16 > m_aIgnoreErrorsAt; 74 sal_uInt16 m_nErrorStart; 75 sal_uInt16 m_nErrorEnd; 76 bool m_bIsUndoEditMode; 77 78 Link m_aModifyLink; 79 80 void CallModifyLink() {m_aModifyLink.Call(this);} 81 82 SpellDialog* GetSpellDialog() const {return (SpellDialog*)GetParent();} 83 protected: 84 virtual long PreNotify( NotifyEvent& rNEvt ); 85 86 public: 87 SentenceEditWindow_Impl( SpellDialog* pParent, const ResId& rResId ); 88 ~SentenceEditWindow_Impl(); 89 90 void SetModifyHdl(const Link& rLink) { m_aModifyLink = rLink;} 91 92 void SetAttrib( const TextAttrib& rAttr, sal_uLong nPara, sal_uInt16 nStart, sal_uInt16 nEnd ); 93 void SetText( const String& rStr ); 94 95 bool MarkNextError( bool bIgnoreCurrentError ); 96 void ChangeMarkedWord(const String& rNewWord, LanguageType eLanguage); 97 void MoveErrorMarkTo(sal_uInt16 nErrorStart, sal_uInt16 nErrorEnd, bool bGrammar); 98 String GetErrorText() const; 99 void RestoreCurrentError(); 100 101 void SetAlternatives( 102 com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellAlternatives> ); 103 104 const SpellErrorDescription* GetAlternatives(); 105 106 107 void ResetModified() { GetTextEngine()->SetModified(sal_False); m_bIsUndoEditMode = false;} 108 sal_Bool IsModified() const { return GetTextEngine()->IsModified(); } 109 110 bool IsUndoEditMode() const { return m_bIsUndoEditMode;} 111 void SetUndoEditMode(bool bSet); 112 113 svx::SpellPortions CreateSpellPortions( bool bSetIgnoreFlag ) const; 114 115 void ResetUndo(); 116 void Undo(); 117 void AddUndoAction( SfxUndoAction *pAction, sal_Bool bTryMerg=sal_False ); 118 sal_uInt16 GetUndoActionCount(); 119 void UndoActionStart( sal_uInt16 nId ); 120 void UndoActionEnd(); 121 122 void MoveErrorEnd(long nOffset); 123 124 void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt.clear(); } 125 }; 126 127 128 // class SvxSpellDialog --------------------------------------------- 129 class SpellDialogChildWindow; 130 class ExplainButton : public PushButton 131 { 132 String m_sExplanation; 133 134 virtual void RequestHelp( const HelpEvent& rHEvt ); 135 virtual void Click(); 136 public: 137 ExplainButton( Window* pParent, const ResId& rResId ) : PushButton( pParent, rResId ){} 138 ~ExplainButton(); 139 void SetExplanation( const String& rText ) {m_sExplanation = rText;} 140 bool HasExplanation() { return m_sExplanation.Len() > 0;} 141 142 }; 143 144 class SpellDialog : public SfxModelessDialog 145 { 146 using Window::Invalidate; 147 148 friend class SentenceEditWindow_Impl; 149 private: 150 151 FixedImage aVendorImageFI; 152 153 FixedText aLanguageFT; 154 SvxLanguageBox aLanguageLB; 155 156 FixedText aNotInDictFT; 157 SentenceEditWindow_Impl aSentenceED; 158 159 FixedText aSuggestionFT; 160 ListBox aSuggestionLB; 161 162 PushButton aIgnorePB; 163 PushButton aIgnoreAllPB; 164 PushButton aIgnoreRulePB; 165 MenuButton aAddToDictMB; 166 167 PushButton aChangePB; 168 PushButton aChangeAllPB; 169 ExplainButton aExplainPB; 170 PushButton aAutoCorrPB; 171 172 CheckBox aCheckGrammarCB; 173 174 HelpButton aHelpPB; 175 PushButton aOptionsPB; 176 PushButton aUndoPB; 177 PushButton aClosePB; 178 179 GroupBox aBackgroundGB; 180 181 Image aVendorImage; 182 Image aVendorImageHC; 183 184 String aResumeST; 185 String aIgnoreOnceST; 186 String aNoSuggestionsST; 187 188 const String m_sTitleSpelling; 189 const String m_sTitleSpellingGrammar; 190 const String m_sTitleSpellingGrammarVendor; 191 192 Size aOldWordEDSize; 193 Link aDialogUndoLink; 194 195 bool bModified; 196 bool bFocusLocked; 197 198 svx::SpellDialogChildWindow& rParent; 199 svx::SpellPortions m_aSavedSentence; 200 201 SpellDialog_Impl* pImpl; 202 ::com::sun::star::uno::Reference< 203 ::com::sun::star::linguistic2::XSpellChecker1 > xSpell; 204 LanguageType nOldLang; 205 206 DECL_LINK( ChangeHdl, Button * ); 207 DECL_LINK( ChangeAllHdl, Button * ); 208 DECL_LINK( IgnoreAllHdl, Button * ); 209 DECL_LINK( IgnoreHdl, Button * ); 210 DECL_LINK( CheckGrammarHdl, CheckBox* ); 211 DECL_LINK( ExtClickHdl, Button * ); 212 DECL_LINK( CancelHdl, Button * ); 213 DECL_LINK( ModifyHdl, SentenceEditWindow_Impl *); 214 DECL_LINK( UndoHdl, Button * ); 215 DECL_LINK( AddToDictionaryHdl, MenuButton* ); 216 DECL_LINK( LanguageSelectHdl, SvxLanguageBox* ); 217 DECL_LINK( DialogUndoHdl, SpellUndoAction_Impl* ); 218 219 DECL_STATIC_LINK( SpellDialog, InitHdl, SpellDialog * ); 220 221 void StartSpellOptDlg_Impl(); 222 void InitUserDicts(); 223 void UpdateBoxes_Impl(); 224 void Init_Impl(); 225 void SpellContinue_Impl(bool UseSavedSentence = false, bool bIgnoreCurrentError = false ); 226 void LockFocusChanges( bool bLock ) {bFocusLocked = bLock;} 227 void Impl_Restore(); 228 229 void SetSelectedLang_Impl( LanguageType nLang ); 230 LanguageType GetSelectedLang_Impl() const; 231 232 /** Retrieves the next sentence. 233 */ 234 bool GetNextSentence_Impl(bool bUseSavedSentence, bool bRechek /*for rechecking the curretn sentence*/); 235 /** Corrects all errors that have been selected to be changed always 236 */ 237 bool ApplyChangeAllList_Impl(SpellPortions& rSentence, bool& bHasReplaced); 238 void SetTitle_Impl(LanguageType nLang); 239 240 protected: 241 virtual void Paint( const Rectangle& rRect ); 242 virtual long Notify( NotifyEvent& rNEvt ); 243 244 public: 245 SpellDialog( 246 svx::SpellDialogChildWindow* pChildWindow, 247 Window * pParent, 248 SfxBindings* pBindings); 249 ~SpellDialog(); 250 251 void SetLanguage( sal_uInt16 nLang ); 252 virtual sal_Bool Close(); 253 254 void InvalidateDialog(); 255 }; 256 } //namespace svx 257 258 #endif 259 260