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 CallModifyLink()80 void CallModifyLink() {m_aModifyLink.Call(this);} 81 GetSpellDialog() const82 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 SetModifyHdl(const Link & rLink)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 ResetModified()107 void ResetModified() { GetTextEngine()->SetModified(sal_False); m_bIsUndoEditMode = false;} IsModified() const108 sal_Bool IsModified() const { return GetTextEngine()->IsModified(); } 109 IsUndoEditMode() const110 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 ResetIgnoreErrorsAt()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: ExplainButton(Window * pParent,const ResId & rResId)137 ExplainButton( Window* pParent, const ResId& rResId ) : PushButton( pParent, rResId ){} 138 ~ExplainButton(); SetExplanation(const String & rText)139 void SetExplanation( const String& rText ) {m_sExplanation = rText;} HasExplanation()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( MenuButtonActivateHdl, MenuButton* ); 216 DECL_LINK( AddToDictionaryHdl, MenuButton* ); 217 DECL_LINK( LanguageSelectHdl, SvxLanguageBox* ); 218 DECL_LINK( DialogUndoHdl, SpellUndoAction_Impl* ); 219 220 DECL_STATIC_LINK( SpellDialog, InitHdl, SpellDialog * ); 221 222 void StartSpellOptDlg_Impl(); 223 void InitUserDicts(); 224 void UpdateBoxes_Impl(); 225 void Init_Impl(); 226 void SpellContinue_Impl(bool UseSavedSentence = false, bool bIgnoreCurrentError = false ); LockFocusChanges(bool bLock)227 void LockFocusChanges( bool bLock ) {bFocusLocked = bLock;} 228 void Impl_Restore(); 229 230 void SetSelectedLang_Impl( LanguageType nLang ); 231 LanguageType GetSelectedLang_Impl() const; 232 233 /** Retrieves the next sentence. 234 */ 235 bool GetNextSentence_Impl(bool bUseSavedSentence, bool bRechek /*for rechecking the curretn sentence*/); 236 /** Corrects all errors that have been selected to be changed always 237 */ 238 bool ApplyChangeAllList_Impl(SpellPortions& rSentence, bool& bHasReplaced); 239 void SetTitle_Impl(LanguageType nLang); 240 241 protected: 242 virtual void Paint( const Rectangle& rRect ); 243 virtual long Notify( NotifyEvent& rNEvt ); 244 245 public: 246 SpellDialog( 247 svx::SpellDialogChildWindow* pChildWindow, 248 Window * pParent, 249 SfxBindings* pBindings); 250 ~SpellDialog(); 251 252 void SetLanguage( sal_uInt16 nLang ); 253 virtual sal_Bool Close(); 254 255 void InvalidateDialog(); 256 }; 257 } //namespace svx 258 259 #endif 260 261