public bool FilterAppliesRanged(int offset, int length) { MarkupRange adjustedRange = currentWordRange.Clone(); MarkupHelpers.AdjustMarkupRange(ref stagingTextRange, adjustedRange, offset, length); return(filter != null && filter(adjustedRange)); }
//iterates through a word range checking for spelling errors //return: whether the word range is finished (true) or not private bool ProcessWordRange(MshtmlWordRange wordRange) { if (wordRange.CurrentWordRange.Positioned) { //track where we will need to clear; MarkupPointer start = _markupServices.CreateMarkupPointer(); start.MoveToPointer(wordRange.CurrentWordRange.End); ArrayList highlightwords = new ArrayList(NUMBER_OF_WORDS_TO_CHECK); int i = 0; //to do....the word range is losing its place when it stays in the queue while (wordRange.HasNext() && i < NUMBER_OF_WORDS_TO_CHECK) { // advance to the next word wordRange.Next(); // check the spelling int offset, length; if (ProcessWord(wordRange, out offset, out length)) { MarkupRange highlightRange = wordRange.CurrentWordRange.Clone(); MarkupHelpers.AdjustMarkupRange(ref stagingTextRange, highlightRange, offset, length); //note: cannot just push the current word range here, as it moves before we get to the highlighting step highlightwords.Add(highlightRange); } i++; } MarkupPointer end = wordRange.CurrentWordRange.End; //got our words, clear the checked range and then add the misspellings ClearRange(start, end); foreach (MarkupRange word in highlightwords) { HighlightWordRange(word); } return(!wordRange.HasNext()); } else { return(true); } }
/// <summary> /// Highlight the current word /// </summary> public void Highlight(int offset, int length) { // select word MarkupRange highlightRange = currentWordRange.Clone(); MarkupHelpers.AdjustMarkupRange(highlightRange, offset, length); try { highlightRange.ToTextRange().select(); } catch (COMException ce) { // Fix bug 772709: This error happens when we try to select un-selectable objects. if (ce.ErrorCode != unchecked ((int)0x800A025E)) { throw; } } }