bool TextSearch::FindTextInPage(int pageNo)
{
    if (str::IsEmpty(findText))
        return false;
    if (!pageNo)
        pageNo = findPage;
    findPage = pageNo;

    const WCHAR *found;
    int length;
    do {
        if (!anchor)
            found = GetNextIndex(pageText, findIndex, forward);
        else if (forward)
            found = (caseSensitive ? StrStr : StrStrI)(pageText + findIndex, anchor);
        else
            found = StrRStrI(pageText, pageText + findIndex, anchor);
        if (!found)
            return false;
        findIndex = (int)(found - pageText) + (forward ? 1 : 0);
        length = MatchLen(found);
    } while (length <= 0);

    int offset = (int)(found - pageText);
    StartAt(pageNo, offset);
    SelectUpTo(pageNo, offset + length);
    findIndex = offset + (forward ? length : 0);

    // try again if the found text is completely outside the page's mediabox
    if (result.len == 0)
        return FindTextInPage(pageNo);

    return true;
}
void TextSelection::SelectWordAt(int pageNo, double x, double y) {
    int ix = FindClosestGlyph(pageNo, x, y);
    int textLen;
    const WCHAR* text = textCache->GetData(pageNo, &textLen);

    for (; ix > 0; ix--) {
        if (!isWordChar(text[ix - 1]))
            break;
    }
    StartAt(pageNo, ix);

    for (; ix < textLen; ix++) {
        if (!isWordChar(text[ix]))
            break;
    }
    SelectUpTo(pageNo, ix);
}
void TextSelection::CopySelection(TextSelection* orig) {
    Reset();
    StartAt(orig->startPage, orig->startGlyph);
    SelectUpTo(orig->endPage, orig->endGlyph);
}
Beispiel #4
0
 /**
  * This method schedules the timer to fire a @p dt milliseconds from now.
  *
  * @param[in]  aDt  The expire time in milliseconds from now.
  */
 void Start(uint32_t aDt) { StartAt(GetNow(), aDt); }