This repository was archived by the owner on Dec 15, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ WindowsSpellchecker::~WindowsSpellchecker() {
7878 this ->currentSpellchecker ->Release ();
7979 this ->currentSpellchecker = NULL ;
8080 }
81-
81+
8282 if (this ->spellcheckerFactory ) {
8383 this ->spellcheckerFactory ->Release ();
8484 this ->spellcheckerFactory = NULL ;
@@ -187,6 +187,36 @@ bool WindowsSpellchecker::IsMisspelled(const std::string& word) {
187187 return ret;
188188}
189189
190+ std::vector<MisspelledRange> WindowsSpellchecker::CheckSpelling (const char *text, size_t length) {
191+ std::vector<MisspelledRange> result;
192+
193+ if (this ->currentSpellchecker == NULL ) {
194+ return result;
195+ }
196+
197+ IEnumSpellingError* errors = NULL ;
198+ std::wstring wtext = ToWString (text);
199+ if (FAILED (this ->currentSpellchecker ->Check (wtext.c_str (), &errors))) {
200+ return result;
201+ }
202+
203+ ISpellingError *error;
204+ while (errors->Next (&error) == S_OK) {
205+ ULONG start, length;
206+ error->get_StartIndex (&start);
207+ error->get_Length (&length);
208+
209+ MisspelledRange range;
210+ range.start = start;
211+ range.end = start + length;
212+ result.push_back (range);
213+ error->Release ();
214+ }
215+
216+ errors->Release ();
217+ return result;
218+ }
219+
190220void WindowsSpellchecker::Add (const std::string& word) {
191221 if (this ->currentSpellchecker == NULL ) {
192222 return ;
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ class WindowsSpellchecker : public SpellcheckerImplementation {
1818
1919 std::vector<std::string> GetCorrectionsForMisspelling (const std::string& word);
2020 bool IsMisspelled (const std::string& word);
21+ std::vector<MisspelledRange> CheckSpelling (const char *text, size_t length);
2122 void Add (const std::string& word);
2223
2324private:
You can’t perform that action at this time.
0 commit comments