本文整理汇总了C++中WStrVec类的典型用法代码示例。如果您正苦于以下问题:C++ WStrVec类的具体用法?C++ WStrVec怎么用?C++ WStrVec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WStrVec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseCommandLine
static void ParseCommandLine(WCHAR *cmdLine)
{
WStrVec argList;
ParseCmdLine(cmdLine, argList);
#define is_arg(param) str::EqI(arg + 1, TEXT(param))
#define is_arg_with_param(param) (is_arg(param) && i < argList.Count() - 1)
// skip the first arg (exe path)
for (size_t i = 1; i < argList.Count(); i++) {
WCHAR *arg = argList.At(i);
if ('-' != *arg && '/' != *arg)
continue;
if (is_arg("s"))
gGlobalData.silent = true;
else if (is_arg_with_param("d"))
str::ReplacePtr(&gGlobalData.installDir, argList.At(++i));
#ifndef BUILD_UNINSTALLER
else if (is_arg("register"))
gGlobalData.registerAsDefault = true;
else if (is_arg_with_param("opt")) {
WCHAR *opts = argList.At(++i);
str::ToLower(opts);
str::TransChars(opts, L" ;", L",,");
WStrVec optlist;
optlist.Split(opts, L",", true);
if (optlist.Contains(L"pdffilter"))
gGlobalData.installPdfFilter = true;
if (optlist.Contains(L"pdfpreviewer"))
gGlobalData.installPdfPreviewer = true;
// uninstall the deprecated browser plugin if it's not
// explicitly listed (only applies if the /opt flag is used)
if (!optlist.Contains(L"plugin"))
gGlobalData.keepBrowserPlugin = false;
}
else if (is_arg("x")) {
gGlobalData.justExtractFiles = true;
// silently extract files to the current directory (if /d isn't used)
gGlobalData.silent = true;
if (!gGlobalData.installDir)
str::ReplacePtr(&gGlobalData.installDir, L".");
}
else if (is_arg("autoupdate")) {
gGlobalData.autoUpdate = true;
}
#endif
else if (is_arg("h") || is_arg("help") || is_arg("?"))
gGlobalData.showUsageAndQuit = true;
#ifdef ENABLE_CRASH_TESTING
else if (is_arg("crash")) {
// will induce crash when 'Install' button is pressed
// for testing crash handling
gForceCrash = true;
}
#endif
}
}
示例2: TesterMain
int TesterMain()
{
RedirectIOToConsole();
WCHAR *cmdLine = GetCommandLine();
WStrVec argv;
ParseCmdLine(cmdLine, argv);
InitAllCommonControls();
ScopedGdiPlus gdi;
mui::Initialize();
WCHAR *dirOrFile = NULL;
bool mobiTest = false;
size_t i = 2; // skip program name and "/tester"
while (i < argv.Count()) {
if (str::Eq(argv[i], L"-mobi")) {
++i;
if (i == argv.Count())
return Usage();
mobiTest = true;
dirOrFile = argv[i];
++i;
} else if (str::Eq(argv[i], L"-layout")) {
gLayout = true;
++i;
} else if (str::Eq(argv[i], L"-save-html")) {
gSaveHtml = true;
++i;
} else if (str::Eq(argv[i], L"-save-images")) {
gSaveImages = true;
++i;
} else if (str::Eq(argv[i], L"-zip-create")) {
ZipCreateTest();
++i;
} else if (str::Eq(argv[i], L"-bench-md5")) {
BenchMD5();
++i;
} else {
// unknown argument
return Usage();
}
}
if (2 == i) {
// no arguments
return Usage();
}
if (mobiTest) {
MobiTest(dirOrFile);
}
mui::Destroy();
system("pause");
return 0;
}
示例3: free
/* Make a string safe to be displayed as a menu item
(preserving all & so that they don't get swallowed)
Caller needs to free() the result. */
WCHAR *ToSafeString(const WCHAR *str)
{
if (!str::FindChar(str, '&'))
return str::Dup(str);
WStrVec ampSplitter;
ampSplitter.Split(str, L"&");
return ampSplitter.Join(L"&&");
}
示例4: CopySelectionToClipboard
void CopySelectionToClipboard(WindowInfo* win) {
if (!win->currentTab || !win->currentTab->selectionOnPage)
return;
CrashIf(win->currentTab->selectionOnPage->size() == 0 && win->mouseAction != MouseAction::SelectingText);
if (win->currentTab->selectionOnPage->size() == 0)
return;
CrashIf(!win->AsFixed());
if (!win->AsFixed())
return;
if (!OpenClipboard(nullptr))
return;
EmptyClipboard();
DisplayModel* dm = win->AsFixed();
#ifndef DISABLE_DOCUMENT_RESTRICTIONS
if (!dm->GetEngine()->AllowsCopyingText())
win->ShowNotification(_TR("Copying text was denied (copying as image only)"));
else
#endif
if (!dm->GetEngine()->IsImageCollection()) {
AutoFreeW selText;
bool isTextSelection = dm->textSelection->result.len > 0;
if (isTextSelection) {
selText.Set(dm->textSelection->ExtractText(L"\r\n"));
} else {
WStrVec selections;
for (SelectionOnPage& sel : *win->currentTab->selectionOnPage) {
WCHAR* text = dm->GetTextInRegion(sel.pageNo, sel.rect);
if (text)
selections.Push(text);
}
selText.Set(selections.Join());
}
// don't copy empty text
if (!str::IsEmpty(selText.Get()))
CopyTextToClipboard(selText, true);
if (isTextSelection) {
// don't also copy the first line of a text selection as an image
CloseClipboard();
return;
}
}
/* also copy a screenshot of the current selection to the clipboard */
SelectionOnPage* selOnPage = &win->currentTab->selectionOnPage->at(0);
RenderedBitmap* bmp = dm->GetEngine()->RenderBitmap(selOnPage->pageNo, dm->GetZoomReal(), dm->GetRotation(),
&selOnPage->rect, RenderTarget::Export);
if (bmp)
CopyImageToClipboard(bmp->GetBitmap(), true);
delete bmp;
CloseClipboard();
}
示例5: DumpProperties
void DumpProperties(BaseEngine *engine, bool fullDump)
{
Out("\t<Properties\n");
ScopedMem<char> str;
str.Set(Escape(str::Dup(engine->FileName())));
Out("\t\tFilePath=\"%s\"\n", str.Get());
str.Set(Escape(engine->GetProperty(Prop_Title)));
if (str)
Out("\t\tTitle=\"%s\"\n", str.Get());
str.Set(Escape(engine->GetProperty(Prop_Subject)));
if (str)
Out("\t\tSubject=\"%s\"\n", str.Get());
str.Set(Escape(engine->GetProperty(Prop_Author)));
if (str)
Out("\t\tAuthor=\"%s\"\n", str.Get());
str.Set(Escape(engine->GetProperty(Prop_Copyright)));
if (str)
Out("\t\tCopyright=\"%s\"\n", str.Get());
str.Set(Escape(engine->GetProperty(Prop_CreationDate)));
if (str)
Out("\t\tCreationDate=\"%s\"\n", str.Get());
str.Set(Escape(engine->GetProperty(Prop_ModificationDate)));
if (str)
Out("\t\tModDate=\"%s\"\n", str.Get());
str.Set(Escape(engine->GetProperty(Prop_CreatorApp)));
if (str)
Out("\t\tCreator=\"%s\"\n", str.Get());
str.Set(Escape(engine->GetProperty(Prop_PdfProducer)));
if (str)
Out("\t\tPdfProducer=\"%s\"\n", str.Get());
str.Set(Escape(engine->GetProperty(Prop_PdfVersion)));
if (str)
Out("\t\tPdfVersion=\"%s\"\n", str.Get());
str.Set(Escape(engine->GetProperty(Prop_PdfFileStructure)));
if (str)
Out("\t\tPdfFileStructure=\"%s\"\n", str.Get());
if (!engine->AllowsPrinting())
Out("\t\tPrintingAllowed=\"no\"\n");
if (!engine->AllowsCopyingText())
Out("\t\tCopyingTextAllowed=\"no\"\n");
if (engine->IsImageCollection())
Out("\t\tImageCollection=\"yes\"\n");
if (engine->PreferredLayout())
Out("\t\tPreferredLayout=\"%d\"\n", engine->PreferredLayout());
Out("\t/>\n");
if (fullDump) {
ScopedMem<WCHAR> fontlist(engine->GetProperty(Prop_FontList));
if (fontlist) {
WStrVec fonts;
fonts.Split(fontlist, L"\n");
str.Set(Escape(fonts.Join(L"\n\t\t")));
Out("\t<FontList>\n\t\t%s\n\t</FontList>\n", str.Get());
}
}
}
示例6: ReadDirectoryChangesNotification
static void CALLBACK ReadDirectoryChangesNotification(DWORD errCode,
DWORD bytesTransfered, LPOVERLAPPED overlapped)
{
ScopedCritSec cs(&g_threadCritSec);
OverlappedEx *over = (OverlappedEx*)overlapped;
WatchedDir* wd = (WatchedDir*)over->data;
lf(L"ReadDirectoryChangesNotification() dir: %s, numBytes: %d", wd->dirPath, (int)bytesTransfered);
CrashIf(wd != wd->overlapped.data);
if (errCode == ERROR_OPERATION_ABORTED) {
lf(" ERROR_OPERATION_ABORTED");
DeleteWatchedDir(wd);
InterlockedDecrement(&gRemovalsPending);
return;
}
// This might mean overflow? Not sure.
if (!bytesTransfered)
return;
FILE_NOTIFY_INFORMATION *notify = (FILE_NOTIFY_INFORMATION*)wd->buf;
// collect files that changed, removing duplicates
WStrVec changedFiles;
for (;;) {
ScopedMem<WCHAR> fileName(str::DupN(notify->FileName, notify->FileNameLength / sizeof(WCHAR)));
// files can get updated either by writing to them directly or
// by writing to a .tmp file first and then moving that file in place
// (the latter only yields a RENAMED action with the expected file name)
if (notify->Action == FILE_ACTION_MODIFIED || notify->Action == FILE_ACTION_RENAMED_NEW_NAME) {
if (!changedFiles.Contains(fileName)) {
lf(L"ReadDirectoryChangesNotification() FILE_ACTION_MODIFIED, for '%s'", fileName);
changedFiles.Append(fileName.StealData());
} else {
lf(L"ReadDirectoryChangesNotification() eliminating duplicate notification for '%s'", fileName);
}
} else {
lf(L"ReadDirectoryChangesNotification() action=%d, for '%s'", (int)notify->Action, fileName);
}
// step to the next entry if there is one
DWORD nextOff = notify->NextEntryOffset;
if (!nextOff)
break;
notify = (FILE_NOTIFY_INFORMATION *)((char*)notify + nextOff);
}
StartMonitoringDirForChanges(wd);
for (const WCHAR *f : changedFiles) {
NotifyAboutFile(wd, f);
}
}
示例7: CopySelectionToClipboard
void CopySelectionToClipboard(WindowInfo *win)
{
if (!win->selectionOnPage) return;
CrashIf(win->selectionOnPage->Count() == 0);
if (win->selectionOnPage->Count() == 0) return;
CrashIf(!win->dm || !win->dm->engine);
if (!win->dm || !win->dm->engine) return;
if (!OpenClipboard(NULL)) return;
EmptyClipboard();
#ifndef DISABLE_DOCUMENT_RESTRICTIONS
if (!win->dm->engine->AllowsCopyingText())
ShowNotification(win, _TR("Copying text was denied (copying as image only)"));
else
#endif
if (!win->dm->engine->IsImageCollection()) {
ScopedMem<WCHAR> selText;
bool isTextSelection = win->dm->textSelection->result.len > 0;
if (isTextSelection) {
selText.Set(win->dm->textSelection->ExtractText(L"\r\n"));
}
else {
WStrVec selections;
for (size_t i = 0; i < win->selectionOnPage->Count(); i++) {
SelectionOnPage *selOnPage = &win->selectionOnPage->At(i);
WCHAR *text = win->dm->GetTextInRegion(selOnPage->pageNo, selOnPage->rect);
if (text)
selections.Push(text);
}
selText.Set(selections.Join());
}
// don't copy empty text
if (!str::IsEmpty(selText.Get()))
CopyTextToClipboard(selText, true);
if (isTextSelection) {
// don't also copy the first line of a text selection as an image
CloseClipboard();
return;
}
}
/* also copy a screenshot of the current selection to the clipboard */
SelectionOnPage *selOnPage = &win->selectionOnPage->At(0);
RenderedBitmap * bmp = win->dm->engine->RenderBitmap(selOnPage->pageNo,
win->dm->ZoomReal(), win->dm->Rotation(), &selOnPage->rect, Target_Export);
if (bmp)
CopyImageToClipboard(bmp->GetBitmap(), true);
delete bmp;
CloseClipboard();
}
示例8: ReadDirectoryChangesNotification
static void CALLBACK ReadDirectoryChangesNotification(DWORD errCode,
DWORD bytesTransfered, LPOVERLAPPED overlapped)
{
ScopedCritSec cs(&g_threadCritSec);
OverlappedEx *over = (OverlappedEx*)overlapped;
WatchedDir* wd = (WatchedDir*)over->data;
lf(L"ReadDirectoryChangesNotification() dir: %s, numBytes: %d", wd->dirPath, (int)bytesTransfered);
CrashIf(wd != wd->overlapped.data);
if (errCode == ERROR_OPERATION_ABORTED) {
lf(" ERROR_OPERATION_ABORTED");
DeleteWatchedDir(wd);
return;
}
// This might mean overflow? Not sure.
if (!bytesTransfered)
return;
FILE_NOTIFY_INFORMATION *notify = (FILE_NOTIFY_INFORMATION*)wd->buf;
// collect files that changed, removing duplicates
WStrVec changedFiles;
for (;;) {
WCHAR *fileName = str::DupN(notify->FileName, notify->FileNameLength / sizeof(WCHAR));
if (notify->Action == FILE_ACTION_MODIFIED) {
if (!changedFiles.Contains(fileName)) {
lf(L"ReadDirectoryChangesNotification() FILE_ACTION_MODIFIED, for '%s'", fileName);
changedFiles.Append(fileName);
fileName = NULL;
} else {
lf(L"ReadDirectoryChangesNotification() eliminating duplicate notification for '%s'", fileName);
}
} else {
lf(L"ReadDirectoryChangesNotification() action=%d, for '%s'", (int)notify->Action, fileName);
}
free(fileName);
// step to the next entry if there is one
DWORD nextOff = notify->NextEntryOffset;
if (!nextOff)
break;
notify = (FILE_NOTIFY_INFORMATION *)((char*)notify + nextOff);
}
StartMonitoringDirForChanges(wd);
for (WCHAR **f = changedFiles.IterStart(); f; f = changedFiles.IterNext()) {
NotifyAboutFile(wd, *f);
}
}
示例9: SetupPluginMode
static bool SetupPluginMode(CommandLineInfo& i)
{
if (!IsWindow(i.hwndPluginParent) || i.fileNames.Count() == 0)
return false;
gPluginURL = i.pluginURL;
if (!gPluginURL)
gPluginURL = i.fileNames.At(0);
assert(i.fileNames.Count() == 1);
while (i.fileNames.Count() > 1) {
free(i.fileNames.Pop());
}
i.reuseInstance = i.exitWhenDone = false;
gGlobalPrefs->reuseInstance = false;
// always display the toolbar when embedded (as there's no menubar in that case)
gGlobalPrefs->showToolbar = true;
// never allow esc as a shortcut to quit
gGlobalPrefs->escToExit = false;
// never show the sidebar by default
gGlobalPrefs->showToc = false;
if (DM_AUTOMATIC == gGlobalPrefs->defaultDisplayModeEnum) {
// if the user hasn't changed the default display mode,
// display documents as single page/continuous/fit width
// (similar to Adobe Reader, Google Chrome and how browsers display HTML)
gGlobalPrefs->defaultDisplayModeEnum = DM_CONTINUOUS;
gGlobalPrefs->defaultZoomFloat = ZOOM_FIT_WIDTH;
}
// use fixed page UI for all document types (so that the context menu always
// contains all plugin specific entries and the main window is never closed)
gGlobalPrefs->ebookUI.useFixedPageUI = gGlobalPrefs->chmUI.useFixedPageUI = true;
// extract some command line arguments from the URL's hash fragment where available
// see http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf#nameddest=G4.1501531
if (i.pluginURL && str::FindChar(i.pluginURL, '#')) {
ScopedMem<WCHAR> args(str::Dup(str::FindChar(i.pluginURL, '#') + 1));
str::TransChars(args, L"#", L"&");
WStrVec parts;
parts.Split(args, L"&", true);
for (size_t k = 0; k < parts.Count(); k++) {
WCHAR *part = parts.At(k);
int pageNo;
if (str::StartsWithI(part, L"page=") && str::Parse(part + 4, L"=%d%$", &pageNo))
i.pageNumber = pageNo;
else if (str::StartsWithI(part, L"nameddest=") && part[10])
str::ReplacePtr(&i.destName, part + 10);
else if (!str::FindChar(part, '=') && part[0])
str::ReplacePtr(&i.destName, part);
}
}
return true;
}
示例10:
// returns a list of permissions denied by this document
// Caller needs to free the result
static WCHAR *FormatPermissions(Controller *ctrl)
{
if (!ctrl->AsFixed())
return nullptr;
WStrVec denials;
BaseEngine *engine = ctrl->AsFixed()->GetEngine();
if (!engine->AllowsPrinting())
denials.Push(str::Dup(_TR("printing document")));
if (!engine->AllowsCopyingText())
denials.Push(str::Dup(_TR("copying text")));
return denials.Join(L", ");
}
示例11: OpenDir
bool DirFileProvider::OpenDir(const WCHAR* dirPath) {
AssertCrash(filesToOpen.size() == 0);
bool hasFiles = CollectStressTestSupportedFilesFromDirectory(dirPath, fileFilter, filesToOpen);
filesToOpen.SortNatural();
AutoFreeW pattern(str::Format(L"%s\\*", dirPath));
bool hasSubDirs = CollectPathsFromDirectory(pattern, dirsToVisit, true);
return hasFiles || hasSubDirs;
}
示例12: Execute
virtual void Execute() {
for (size_t i = 0; i < paths.Count(); i++) {
gFileHistory.MarkFileInexistent(paths.At(i), true);
}
// update the Frequently Read page in case it's been displayed already
if (paths.Count() > 0 && gWindows.Count() > 0 && gWindows.At(0)->IsAboutWindow())
gWindows.At(0)->RedrawAll(true);
// prepare for clean-up (Join() just to be safe)
gFileExistenceChecker = NULL;
Join();
}
示例13: SetCloseProcessMsg
static void SetCloseProcessMsg() {
AutoFreeW procNames(str::Dup(ReadableProcName(gProcessesToClose.at(0))));
for (size_t i = 1; i < gProcessesToClose.size(); i++) {
const WCHAR* name = ReadableProcName(gProcessesToClose.at(i));
if (i < gProcessesToClose.size() - 1)
procNames.Set(str::Join(procNames, L", ", name));
else
procNames.Set(str::Join(procNames, L" and ", name));
}
AutoFreeW s(str::Format(_TR("Please close %s to proceed!"), procNames));
SetMsg(s, COLOR_MSG_FAILED);
}
示例14: GetPageByLabel
int ImageDirEngineImpl::GetPageByLabel(const WCHAR *label)
{
for (size_t i = 0; i < pageFileNames.Count(); i++) {
const WCHAR *fileName = path::GetBaseName(pageFileNames.At(i));
const WCHAR *fileExt = path::GetExt(fileName);
if (str::StartsWithI(fileName, label) &&
(fileName + str::Len(label) == fileExt || fileName[str::Len(label)] == '\0'))
return (int)i + 1;
}
return BaseEngine::GetPageByLabel(label);
}
示例15: OpenDir
bool DirFileProvider::OpenDir(const WCHAR *dirPath)
{
assert(filesToOpen.Count() == 0);
bool hasFiles = CollectStressTestSupportedFilesFromDirectory(dirPath, fileFilter, filesToOpen);
filesToOpen.SortNatural();
ScopedMem<WCHAR> pattern(str::Format(L"%s\\*", dirPath));
bool hasSubDirs = CollectPathsFromDirectory(pattern, dirsToVisit, true);
return hasFiles || hasSubDirs;
}