Exemple #1
0
void ChmEngineImpl::DisplayPage(const WCHAR *pageUrl)
{
    if (IsExternalUrl(pageUrl)) {
        // open external links in an external browser
        // (same as for PDF, XPS, etc. documents)
        if (navCb)
            navCb->LaunchBrowser(pageUrl);
        return;
    }

    int pageNo = pages.Find(ScopedMem<WCHAR>(str::ToPlainUrl(pageUrl))) + 1;
    if (pageNo)
        currentPageNo = pageNo;

    // This is a hack that seems to be needed for some chm files where
    // url starts with "..\" even though it's not accepted by ie as
    // a correct its: url. There's a possibility it breaks some other
    // chm files (I don't know such cases, though).
    // A more robust solution would try to match with the actual
    // names of files inside chm package.
    if (str::StartsWith(pageUrl, L"..\\"))
        pageUrl += 3;

    if (str::StartsWith(pageUrl, L"/"))
        pageUrl++;

    assert(htmlWindow);
    if (htmlWindow)
        htmlWindow->NavigateToDataUrl(pageUrl);
}
Exemple #2
0
void ChmModel::DisplayPage(const WCHAR *pageUrl)
{
    if (IsExternalUrl(pageUrl)) {
        // open external links in an external browser
        // (same as for PDF, XPS, etc. documents)
        if (cb) {
            ChmTocItem item(NULL, 0, pageUrl);
            cb->GotoLink(&item);
        }
        return;
    }

    int pageNo = pages.Find(ScopedMem<WCHAR>(url::GetFullPath(pageUrl))) + 1;
    if (pageNo)
        currentPageNo = pageNo;

    // This is a hack that seems to be needed for some chm files where
    // url starts with "..\" even though it's not accepted by ie as
    // a correct its: url. There's a possibility it breaks some other
    // chm files (I don't know such cases, though).
    // A more robust solution would try to match with the actual
    // names of files inside chm package.
    if (str::StartsWith(pageUrl, L"..\\"))
        pageUrl += 3;

    if (str::StartsWith(pageUrl, L"/"))
        pageUrl++;

    CrashIf(!htmlWindow);
    if (htmlWindow)
        htmlWindow->NavigateToDataUrl(pageUrl);
}
Exemple #3
0
    // We fake page numbers by doing a depth-first traversal of
    // toc tree and considering each unique html page in toc tree
    // as a page
    int CreatePageNoForURL(const WCHAR *url) {
        if (!url || IsExternalUrl(url))
            return 0;

        ScopedMem<WCHAR> plainUrl(str::ToPlainUrl(url));
        int pageNo = pages->Find(plainUrl) + 1;
        if (pageNo > 0)
            return pageNo;
        pages->Append(plainUrl.StealData());
        return pages->Count();
    }
Exemple #4
0
    int CreatePageNoForURL(const WCHAR *url) {
        if (!url || IsExternalUrl(url))
            return 0;

        ScopedMem<WCHAR> plainUrl(str::ToPlainUrl(url));
        int pageNo = pages->Count() + 1;
        bool inserted = urlsSet.Insert(plainUrl, pageNo, &pageNo);
        if (inserted) {
            pages->Append(plainUrl.StealData());
            CrashIf(pageNo != pages->Count());
        } else {
            CrashIf(pageNo == pages->Count() + 1);
        }
        return pageNo;
    }
Exemple #5
0
 virtual WCHAR *GetDestValue() const {
     if (url && IsExternalUrl(url))
         return str::Dup(url);
     return NULL;
 }
Exemple #6
0
 virtual PageDestType GetDestType() const {
     if (url && IsExternalUrl(url))
         return Dest_LaunchURL;
     return Dest_ScrollTo;
 }
Exemple #7
0
 virtual WCHAR *GetDestName() const {
     return url && !IsExternalUrl(url) ? str::Dup(url) : NULL;
 }
Exemple #8
0
 virtual PageDestType GetDestType() const {
     return !url ? Dest_None : IsExternalUrl(url) ? Dest_LaunchURL : Dest_ScrollTo;
 }
Exemple #9
0
 virtual WCHAR *GetDestValue() const {
     return url && IsExternalUrl(url) ? str::Dup(url) : nullptr;
 }