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() {
78
78
this ->currentSpellchecker ->Release ();
79
79
this ->currentSpellchecker = NULL ;
80
80
}
81
-
81
+
82
82
if (this ->spellcheckerFactory ) {
83
83
this ->spellcheckerFactory ->Release ();
84
84
this ->spellcheckerFactory = NULL ;
@@ -187,6 +187,36 @@ bool WindowsSpellchecker::IsMisspelled(const std::string& word) {
187
187
return ret;
188
188
}
189
189
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
+
190
220
void WindowsSpellchecker::Add (const std::string& word) {
191
221
if (this ->currentSpellchecker == NULL ) {
192
222
return ;
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ class WindowsSpellchecker : public SpellcheckerImplementation {
18
18
19
19
std::vector<std::string> GetCorrectionsForMisspelling (const std::string& word);
20
20
bool IsMisspelled (const std::string& word);
21
+ std::vector<MisspelledRange> CheckSpelling (const char *text, size_t length);
21
22
void Add (const std::string& word);
22
23
23
24
private:
You can’t perform that action at this time.
0 commit comments