static WindowInfo *LoadOnStartup(const WCHAR *filePath, CommandLineInfo& i, bool isFirstWin) { LoadArgs args(filePath); args.showWin = !(i.printDialog && i.exitWhenDone) && !gPluginMode; WindowInfo *win = LoadDocument(args); if (!win) return win; if (win->IsDocLoaded() && i.destName && isFirstWin) { win->linkHandler->GotoNamedDest(i.destName); } else if (win->IsDocLoaded() && i.pageNumber > 0 && isFirstWin) { if (win->ctrl->ValidPageNo(i.pageNumber)) win->ctrl->GoToPage(i.pageNumber, false); } if (i.hwndPluginParent) MakePluginWindow(*win, i.hwndPluginParent); if (!win->IsDocLoaded() || !isFirstWin) return win; if (i.enterPresentation || i.enterFullScreen) { if (i.enterPresentation && win->isFullScreen || i.enterFullScreen && win->presentation) ExitFullScreen(*win); EnterFullScreen(*win, i.enterPresentation); } if (i.startView != DM_AUTOMATIC) SwitchToDisplayMode(win, i.startView); if (i.startZoom != INVALID_ZOOM) ZoomToSelection(win, i.startZoom); if ((i.startScroll.x != -1 || i.startScroll.y != -1) && win->AsFixed()) { DisplayModel *dm = win->AsFixed(); ScrollState ss = dm->GetScrollState(); ss.x = i.startScroll.x; ss.y = i.startScroll.y; dm->SetScrollState(ss); } if (i.forwardSearchOrigin && i.forwardSearchLine && win->AsFixed() && win->AsFixed()->pdfSync) { UINT page; Vec<RectI> rects; ScopedMem<WCHAR> sourcePath(path::Normalize(i.forwardSearchOrigin)); int ret = win->AsFixed()->pdfSync->SourceToDoc(sourcePath, i.forwardSearchLine, 0, &page, rects); ShowForwardSearchResult(win, sourcePath, i.forwardSearchLine, 0, ret, page, rects); } return win; }
// Set view mode and zoom level. Format: // [<DDECOMMAND_SETVIEW>("<pdffilepath>", "<view mode>", <zoom level>[, <scrollX>, <scrollY>])] static const WCHAR *HandleSetViewCmd(const WCHAR *cmd, DDEACK& ack) { ScopedMem<WCHAR> pdfFile, viewMode; float zoom = INVALID_ZOOM; PointI scroll(-1, -1); const WCHAR *next = str::Parse(cmd, L"[" DDECOMMAND_SETVIEW L"(\"%S\",%? \"%S\",%f)]", &pdfFile, &viewMode, &zoom); if (!next) next = str::Parse(cmd, L"[" DDECOMMAND_SETVIEW L"(\"%S\",%? \"%S\",%f,%d,%d)]", &pdfFile, &viewMode, &zoom, &scroll.x, &scroll.y); if (!next) return NULL; WindowInfo *win = FindWindowInfoByFile(pdfFile); if (!win) return next; if (!win->IsDocLoaded()) { ReloadDocument(win); if (!win->IsDocLoaded()) return next; } DisplayMode mode = DisplayModeConv::EnumFromName(viewMode, DM_AUTOMATIC); if (mode != DM_AUTOMATIC) SwitchToDisplayMode(win, mode); if (zoom != INVALID_ZOOM) ZoomToSelection(win, zoom); if (scroll.x != -1 || scroll.y != -1) { ScrollState ss = win->dm->GetScrollState(); ss.x = scroll.x; ss.y = scroll.y; win->dm->SetScrollState(ss); } ack.fAck = 1; return next; }