def __init__(self, mshtmlEditControl): ZBaseEditControlSpellCheckContext.__init__(self) self.mshtmlEditControl = mshtmlEditControl self.startRange = None self.endRange = None self.currRange = None self.ieWord = None self.ieSentence = None self.wordCount = 0
def _prepareResult(self, spellcheckResult): #@UnusedVariable ZBaseEditControlSpellCheckContext._prepareResult(self, spellcheckResult) if spellcheckResult and not spellcheckResult.isFinished() and self.currRange: word = spellcheckResult.getWord() # build partial sentence around word. left = u"" #$NON-NLS-1$ # right = u"" #$NON-NLS-1$ count = 0 # word count try: rng1 = self.currRange.duplicate() while count < 6: r = rng1.move(u"word", -1) #$NON-NLS-1$ if r == 0: # moved 0 words. (start of text) break rng1.expand(u"word") #$NON-NLS-1$ left = rng1.text + left count = count + 1 except: pass count = 0 try: rng2 = self.currRange.duplicate() while count < 8 : r = rng2.move(u"word", +1) #$NON-NLS-1$ if r == 0: # end of text break rng2.expand(u"word") #$NON-NLS-1$ right = right + rng2.text count = count + 1 except: pass sentence = left.strip() + u" " #$NON-NLS-1$ # word start pos p1 = len(sentence) # append word and calc end post sentence = sentence + word p2 = len(sentence) # append rest of sentence. sentence = sentence + u" " + right.strip() #$NON-NLS-1$ spellcheckResult.setWordContext(sentence) spellcheckResult.setRangeInContext(p1, p2)
def _cleanup(self): ZBaseEditControlSpellCheckContext._cleanup(self) self.startRange = None self.endRange = None self.currRange = None self.ieWord = None