HRESULT CPdfFilter::GetNextChunkValue(CChunkValue &chunkValue) { ScopedMem<TCHAR> str; switch (m_state) { case STATE_PDF_START: m_state = STATE_PDF_AUTHOR; chunkValue.SetTextValue(PKEY_PerceivedType, L"document"); return S_OK; case STATE_PDF_AUTHOR: m_state = STATE_PDF_TITLE; str.Set(m_pdfEngine->GetProperty(Prop_Author)); if (!str::IsEmpty(str.Get())) { chunkValue.SetTextValue(PKEY_Author, AsWStrQ(str)); return S_OK; } // fall through case STATE_PDF_TITLE: m_state = STATE_PDF_DATE; str.Set(m_pdfEngine->GetProperty(Prop_Title)); if (!str) str.Set(m_pdfEngine->GetProperty(Prop_Subject)); if (!str::IsEmpty(str.Get())) { chunkValue.SetTextValue(PKEY_Title, AsWStrQ(str)); return S_OK; } // fall through case STATE_PDF_DATE: m_state = STATE_PDF_CONTENT; str.Set(m_pdfEngine->GetProperty(Prop_ModificationDate)); if (!str) str.Set(m_pdfEngine->GetProperty(Prop_CreationDate)); if (!str::IsEmpty(str.Get())) { SYSTEMTIME systime; if (PdfDateParse(str, &systime)) { FILETIME filetime; SystemTimeToFileTime(&systime, &filetime); chunkValue.SetFileTimeValue(PKEY_ItemDate, filetime); return S_OK; } } // fall through case STATE_PDF_CONTENT: while (++m_iPageNo <= m_pdfEngine->PageCount()) { str.Set(m_pdfEngine->ExtractPageText(m_iPageNo, _T("\r\n"))); if (str::IsEmpty(str.Get())) continue; chunkValue.SetTextValue(PKEY_Search_Contents, AsWStrQ(str), CHUNK_TEXT); return S_OK; } m_state = STATE_PDF_END; // fall through case STATE_PDF_END: default: return FILTER_E_END_OF_CHUNKS; } }
void EbookController::HandleFinishedMobiLoadingMsg(FinishedMobiLoadingData *finishedMobiLoading) { str::ReplacePtr(&fileBeingLoaded, NULL); if (NULL == finishedMobiLoading->doc) { // TODO: a better way to notify about this, should be a transient message ScopedMem<TCHAR> s(str::Format(_T("Failed to load %s!"), finishedMobiLoading->fileName)); ctrls->status->SetText(AsWStrQ(s.Get())); return; } SetDoc(*finishedMobiLoading->doc); }
/* Setting symbol path: add GetEnvironmentVariableA("_NT_SYMBOL_PATH", ..., ...) add GetEnvironmentVariableA("_NT_ALTERNATE_SYMBOL_PATH", ..., ...) add: "srv*c:\\symbols*http://msdl.microsoft.com/download/symbols;cache*c:\\symbols" (except a better directory than c:\\symbols Note: I've decided to use just one, known to me location rather than the more comprehensive list. It works so why give dbghelp.dll more directories to scan? */ static bool BuildSymbolPath() { str::Str<WCHAR> path(1024); #if 0 WCHAR buf[512]; DWORD res = GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", buf, dimof(buf)); if (0 < res && res < dimof(buf)) { path.Append(buf); path.Append(L";"); } res = GetEnvironmentVariableW(L"_NT_ALTERNATE_SYMBOL_PATH", buf, dimof(buf)); if (0 < res && res < dimof(buf)) { path.Append(buf); path.Append(L";"); } #endif path.Append(AsWStrQ(gSymbolsDir)); //path.Append(_T(";")); #if 0 // this probably wouldn't work anyway because it requires symsrv.dll in the same directory // as dbghelp.dll and it's not present with the os-provided dbghelp.dll path.Append(L"srv*"); path.Append(symDir); path.Append(L"*http://msdl.microsoft.com/download/symbols;cache*"); path.Append(symDir); #endif #if 0 // when running local builds, *.pdb is in the same dir as *.exe ScopedMem<TCHAR> exePath(GetExePath()); path.AppendFmt(L"%s", AsWStrQ(exePath)); #endif gSymbolPathW = path.StealData(); if (!gSymbolPathW) return false; return true; }