llspellcheck.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * @file llspellcheck.h
  3. * @brief LLSpellCheck class definition
  4. *
  5. * $LicenseInfo:firstyear=2012&license=viewergpl$
  6. *
  7. * Copyright (c) 2009 LordGregGreg Back, 2012 Henri Beauchamp
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LLSPELLCHECK_H
  33. #define LLSPELLCHECK_H
  34. #include "llinitdestroyclass.h" // also includes "llsingleton.h"
  35. class Hunspell;
  36. class LLSpellCheck : public LLSingleton<LLSpellCheck>,
  37. public LLInitClass<LLSpellCheck>
  38. {
  39. friend class LLSingleton<LLSpellCheck>;
  40. friend class LLInitClass<LLSpellCheck>;
  41. protected:
  42. LOG_CLASS(LLSpellCheck);
  43. LLSpellCheck();
  44. ~LLSpellCheck() override;
  45. static void initClass(); // LLSingleton interface
  46. public:
  47. std::string getDicFullPath(const std::string& file);
  48. std::set<std::string> getBaseDicts();
  49. std::set<std::string> getExtraDicts();
  50. void addDictionary(const std::string& dict_name);
  51. void setDictionary(const std::string& dict_name);
  52. void addToCustomDictionary(const std::string& word);
  53. void addToIgnoreList(const std::string& word);
  54. void addWordsToIgnoreList(const std::string& words);
  55. const std::string& getCurrentDict() { return mCurrentDictName; }
  56. bool checkSpelling(const std::string& word);
  57. S32 getSuggestions(const std::string& word,
  58. std::vector<std::string>& suggestions);
  59. void setSpellCheck(bool enable) { mSpellCheckEnable = enable; }
  60. bool getSpellCheck() { return mSpellCheckEnable && mHunspell; }
  61. void setShowMisspelled(bool enable) { mShowMisspelled = enable; }
  62. bool getShowMisspelled() { return mShowMisspelled; }
  63. protected:
  64. Hunspell* mHunspell;
  65. std::string mCurrentDictName;
  66. std::string mDictEncoding;
  67. std::set<std::string> mIgnoreList;
  68. bool mSpellCheckEnable;
  69. bool mShowMisspelled;
  70. };
  71. #endif // LLSPELLCHECK_H