1 /* 2 * This file is part of SpellChecker plugin for Code::Blocks Studio 3 * Copyright (C) 2009 Daniel Anselmi 4 * 5 * SpellChecker plugin is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * SpellChecker plugin is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with SpellChecker. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 #ifndef __HUNSPELL_CHECK_INTERFACE__ 20 #define __HUNSPELL_CHECK_INTERFACE__ 21 22 // For compilers that support precompilation, includes "wx/wx.h". 23 #include "wx/wxprec.h" 24 25 #ifndef WX_PRECOMP 26 #include "wx/wx.h" 27 #endif 28 29 #include "wx/string.h" 30 31 // spell checker/thingie 32 #include "wx/process.h" 33 #include "wx/txtstrm.h" 34 #include "wx/file.h" 35 36 #include "SpellCheckUserInterface.h" 37 #include "PersonalDictionary.h" 38 39 40 // Get rid of the warning about identifiers being truncated in the debugger. Using the STL collections 41 // will produce this everywhere. Must disable at beginning of stdafx.h because it doesn't work if 42 // placed elsewhere. 43 #ifdef __VISUALC__ 44 #pragma warning(disable:4786) 45 #endif 46 class Hunspell; 47 class HunspellInterface : public wxSpellCheckEngineInterface 48 { 49 public: 50 HunspellInterface(wxSpellCheckUserInterface* pDlg = NULL); 51 ~HunspellInterface(); 52 53 // Spell Checker functions GetSpellCheckEngineName()54 virtual wxString GetSpellCheckEngineName() { return _T("Hunspell"); } 55 virtual int InitializeSpellCheckEngine(); 56 virtual int UninitializeSpellCheckEngine(); 57 virtual int SetOption(SpellCheckEngineOption& Option); 58 virtual void UpdatePossibleValues(SpellCheckEngineOption& OptionDependency, SpellCheckEngineOption& OptionToUpdate); 59 virtual wxString CheckSpelling(wxString strText); 60 wxArrayString GetSuggestions(const wxString& strMisspelledWord); 61 62 virtual bool IsWordInDictionary(const wxString& strWord); 63 virtual int AddWordToDictionary(const wxString& strWord); 64 virtual int RemoveWordFromDictionary(const wxString& strWord); 65 virtual wxArrayString GetWordListAsArray(); 66 void OpenPersonalDictionary(const wxString& strPersonalDictionaryFile); GetPersonalDictionary()67 PersonalDictionary* GetPersonalDictionary() { return &m_PersonalDictionary; } 68 void AddCustomMySpellDictionary(const wxString& strDictionaryName, const wxString& strDictionaryFileRoot); CleanCustomMySpellDictionaries()69 void CleanCustomMySpellDictionaries() { m_CustomMySpellDictionaryMap.clear(); } 70 71 virtual wxString GetCharacterEncoding(); 72 73 private: 74 void PopulateDictionaryMap(StringToStringMap* pLookupMap, const wxString& strDictionaryPath); 75 void AddDictionaryElement(StringToStringMap* pLookupMap, const wxString& strDictionaryPath, const wxString& strDictionaryName, const wxString& strDictionaryFileRoot); 76 wxString GetSelectedLanguage(); 77 wxString GetAffixFileName(); 78 wxString GetAffixFileName(const wxString& strDictionaryName); 79 wxString GetDictionaryFileName(); 80 wxString GetDictionaryFileName(const wxString& strDictionaryName); 81 82 Hunspell* m_pHunspell; 83 84 StringToStringMap m_DictionaryLookupMap; 85 StringToStringMap m_CustomMySpellDictionaryMap; 86 wxString m_strDictionaryPath; 87 88 PersonalDictionary m_PersonalDictionary; 89 }; 90 91 #endif // __MYSPELL_CHECK_INTERFACE__ 92