本文整理汇总了C++中Doc::IsNone方法的典型用法代码示例。如果您正苦于以下问题:C++ Doc::IsNone方法的具体用法?C++ Doc::IsNone怎么用?C++ Doc::IsNone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doc
的用法示例。
在下文中一共展示了Doc::IsNone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateFromFile
Doc Doc::CreateFromFile(const WCHAR *filePath)
{
Doc doc;
if (EpubDoc::IsSupportedFile(filePath))
doc = Doc(EpubDoc::CreateFromFile(filePath));
else if (Fb2Doc::IsSupportedFile(filePath))
doc = Doc(Fb2Doc::CreateFromFile(filePath));
else if (MobiDoc::IsSupportedFile(filePath)) {
doc = Doc(MobiDoc::CreateFromFile(filePath));
// MobiDoc is also used for loading PalmDoc - don't expose that to Doc users, though
if (doc.mobiDoc && doc.mobiDoc->GetDocType() != Pdb_Mobipocket) {
doc.Delete();
// .prc files can be both MobiDoc or PalmDoc
if (PalmDoc::IsSupportedFile(filePath))
doc = Doc(PalmDoc::CreateFromFile(filePath));
}
}
else if (PalmDoc::IsSupportedFile(filePath))
doc = Doc(PalmDoc::CreateFromFile(filePath));
// if failed to load and more specific error message hasn't been
// set above, set a generic error message
if (doc.IsNone()) {
CrashIf(doc.error);
doc.error = Error_Unknown;
doc.filePath.Set(str::Dup(filePath));
}
else {
CrashIf(!Doc::IsSupportedFile(filePath));
}
CrashIf(!doc.generic && !doc.IsNone());
return doc;
}
示例2: CreateFromFile
Doc Doc::CreateFromFile(const WCHAR *filePath)
{
Doc doc;
if (EpubDoc::IsSupportedFile(filePath))
doc = Doc(EpubDoc::CreateFromFile(filePath));
else if (Fb2Doc::IsSupportedFile(filePath))
doc = Doc(Fb2Doc::CreateFromFile(filePath));
else if (MobiDoc::IsSupportedFile(filePath))
doc = Doc(MobiDoc::CreateFromFile(filePath));
// if failed to load and more specific error message hasn't been
// set above, set a generic error message
if (doc.IsNone()) {
CrashIf(doc.error);
doc.error = Error_Unknown;
doc.filePath.Set(str::Dup(filePath));
}
CrashIf(!doc.generic && !doc.IsNone());
return doc;
}
示例3: doc
EbookFormattingThread::EbookFormattingThread(Doc doc, HtmlFormatterArgs *args, EbookController *ctrl) :
doc(doc), formatterArgs(args), controller(ctrl), pageCount(0)
{
AssertCrash(doc.IsEbook() || (doc.IsNone() && (NULL != args->htmlStr)));
}
示例4: doc
EbookFormattingThread::EbookFormattingThread(Doc doc, HtmlFormatterArgs *args, EbookController *ctrl, int reparseIdx, ControllerCallback *cb) :
doc(doc), formatterArgs(args), cb(cb), controller(ctrl), pageCount(0), reparseIdx(reparseIdx), pagesAfterReparseIdx(0)
{
CrashIf(reparseIdx < 0);
AssertCrash(doc.IsDocLoaded() || (doc.IsNone() && (nullptr != args->htmlStr)));
}
示例5: OpenMobiInWindow
void OpenMobiInWindow(Doc doc, SumatraWindow& winToReplace)
{
const WCHAR *fullPath = doc.GetFilePath();
DisplayState *ds = gFileHistory.Find(fullPath);
if (doc.IsNone()) {
// TODO: a hack. In LoadDocumentOld(), if current window IsAboutWindow(),
// we set loadedFilePath to prevent a crash if multiple ebook files are
// dropped on about window. We need to undo that in case of failure
// or else the window will be stuck in an invalid state (not about window
// but not a document window either)
WindowInfo *w = winToReplace.AsWindowInfo();
if (str::Eq(w->loadedFilePath, doc.GetFilePath())) {
free(w->loadedFilePath);
w->loadedFilePath = NULL;
// this is now about window. We don't want to show it if we're already
// showing other windows (the scenario: dragging ebook file on a window
// showing a document, we create invisible window for this document and
// we don't want to show empty window if loading fails
if (gEbookWindows.Count() > 0 || gWindows.Count() > 1) {
CloseWindow(w, false);
if (gFileHistory.MarkFileInexistent(fullPath))
prefs::Save();
// TODO: notify the use that loading failed (e.g. show a notification)
return;
}
}
// TODO: notify the user that loading failed (e.g. show a notification)
// TODO: this is not a great solution. In case of opening
// file from cmd-line, we create a window but don't show it
// if loading afils, we have to show the window. If window
// is already visible, this is a no-op
ShowWindow(winToReplace.HwndFrame(), SW_SHOW);
if (gFileHistory.MarkFileInexistent(fullPath))
prefs::Save();
return;
}
if (gGlobalPrefs->rememberOpenedFiles) {
ds = gFileHistory.MarkFileLoaded(fullPath);
if (gGlobalPrefs->showStartPage) {
// TODO: do it on a background thread?
CreateThumbnailForDoc(doc, *ds);
}
prefs::Save();
}
int startReparseIdx = -1;
if (ds && gGlobalPrefs->rememberStatePerDocument && !ds->useDefaultState)
startReparseIdx = ds->reparseIdx;
// Add the file also to Windows' recently used documents (this doesn't
// happen automatically on drag&drop, reopening from history, etc.)
if (HasPermission(Perm_DiskAccess) && !gPluginMode)
SHAddToRecentDocs(SHARD_PATH, fullPath);
ScopedMem<WCHAR> winTitle(str::Format(L"%s - %s", path::GetBaseName(fullPath), SUMATRA_WINDOW_TITLE));
if (winToReplace.AsEbookWindow()) {
EbookWindow *mw = winToReplace.AsEbookWindow();
CrashIf(!mw);
mw->ebookController->SetDoc(doc);
win::SetText(mw->hwndFrame, winTitle);
// TODO: if we have window position/last position for this file, restore it
return;
}
RectI windowPos = gGlobalPrefs->windowPos;
if (!windowPos.IsEmpty())
EnsureAreaVisibility(windowPos);
else
windowPos = GetDefaultWindowPos();
if (ds && !ds->windowPos.IsEmpty()) {
// Make sure it doesn't have a position like outside of the screen etc.
windowPos = ShiftRectToWorkArea(ds->windowPos);
}
WindowInfo *winInfo = winToReplace.AsWindowInfo();
bool wasMaximized = false;
if (winInfo && winInfo->hwndFrame) {
wasMaximized = IsZoomed(winInfo->hwndFrame);
// hide the window instead of destroying it so that
// windows doesn't set a window from a different
// process as foreground window instead of the once
// created below
ShowWindow(winInfo->hwndFrame, SW_HIDE);
}
HWND hwnd = CreateWindow(
MOBI_FRAME_CLASS_NAME, SUMATRA_WINDOW_TITLE,
WS_OVERLAPPEDWINDOW,
windowPos.x, windowPos.y, windowPos.dx, windowPos.dy,
NULL, NULL,
ghinst, NULL);
if (!hwnd) {
CloseDocumentAndDeleteWindowInfo(winInfo);
return;
}
//.........这里部分代码省略.........