void SpellcheckerExt::checkSpellingOfString (const QString& word, int *misspellingLocation, int *misspellingLength) { if (!misspellingLength || !misspellingLocation) return; *misspellingLocation = 0; *misspellingLength = 0; QTextBoundaryFinder finder { QTextBoundaryFinder::Word, word }; bool isInWord = false; int start = -1; int end = -1; do { const auto reasons = finder.boundaryReasons (); if (IsWordStart (reasons, finder.type ())) { start = finder.position (); isInWord = true; } if (isInWord && IsWordEnd (reasons, finder.type ())) { end = finder.position (); const auto& str = word.mid (start, end - start); if (std::none_of (Spellcheckers_.begin (), Spellcheckers_.end (), [&str] (const ISpellChecker_ptr& sc) { return sc->IsCorrect (str); })) { *misspellingLocation = start; *misspellingLength = end - start; return; } isInWord = false; } } while (finder.toNextBoundary () > 0); }