char *GetHtml() {
        // first add the homepage
        const char *index = doc->GetHomePath();
        ScopedMem<WCHAR> url(doc->ToStr(index));
        Visit(NULL, url, 0);

        // then add all pages linked to from the table of contents
        doc->ParseToc(this);

        // finally add all the remaining HTML files
        Vec<char *> *paths = doc->GetAllPaths();
        for (size_t i = 0; i < paths->Count(); i++) {
            char *path = paths->At(i);
            if (str::EndsWithI(path, ".htm") || str::EndsWithI(path, ".html")) {
                if (*path == '/')
                    path++;
                url.Set(str::conv::FromUtf8(path));
                Visit(NULL, url, -1);
            }
        }
        FreeVecMembers(*paths);
        delete paths;

        return html.StealData();
    }
Esempio n. 2
0
 void CreateThumbnail(HtmlWindow *hw) {
     this->hw = hw;
     homeUrl.Set(str::conv::FromAnsi(doc->GetHomePath()));
     if (*homeUrl == '/')
         homeUrl.Set(str::Dup(homeUrl + 1));
     hw->NavigateToDataUrl(homeUrl);
 }
Esempio n. 3
0
bool ChmEngineImpl::Load(const WCHAR *fileName)
{
    this->fileName = str::Dup(fileName);
    Timer t(true);
    doc = ChmDoc::CreateFromFile(fileName);
    dbglog::LogF("ChmDoc::CreateFromFile(): %.2f ms", t.GetTimeInMs());
    if (!doc)
        return false;

    // always make the document's homepage page 1
    pages.Append(str::conv::FromAnsi(doc->GetHomePath()));
    // parse the ToC here, since page numbering depends on it
    t.Start();
    doc->ParseToc(&ChmTocBuilder(doc, &pages, &tocRoot));
    dbglog::LogF("doc->ParseToc(): %.2f ms", t.GetTimeInMs());
    CrashIf(pages.Count() == 0);
    return pages.Count() > 0;
}