// Since we need to show localized messages to user before starting LibreOffice, we need to // bootstrap part of LO (l10n machinery). This implies loading some LO libraries, and since // there are ActiveX controls for both x86 and x64 for use in corresponding clients, they // can't both load the libraries that exist only for one architecture, like sal. Thus we need // a dedicated helper process, which is launched by ActiveX, and handle user interactions.
// Report the error to user and return error
MessageBoxW(nullptr, o3tl::toW(sErrorMsg.getStr()), nullptr, MB_ICONERROR); return dwError;
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread); return ERROR_SUCCESS;
}
int CreateNewDocument(LPCWSTR TemplateLocation, LPCWSTR /*DefaultSaveLocation*/)
{ // TODO: resolve the program from varProgID (nullptr -> default?)
DWORD nResult = LOStart(L"-n", TemplateLocation); return nResult == ERROR_SUCCESS ? 0 : 2;
}
// UseLocalCopy would be either "0" or "1", denoting boolean value int EditDocument(LPCWSTR DocumentLocation, LPCWSTR /*UseLocalCopy*/, LPCWSTR /*varProgID*/)
{ // TODO: resolve the program from varProgID (nullptr -> default?)
DWORD nResult = LOStart(L"-o", DocumentLocation); return nResult == ERROR_SUCCESS ? 0 : 2;
}
// Possible values for OpenType // // "0" When checked out, or when the document library does not require check out, the user can read or edit the document // "1" When another user has checked it out, the user can only read the document // "2" When the current user has checked it out, the user can only edit the document // "3" When the document is not checked out and the document library requires that documents be checked out to be edited, the user can only read the document, or check it out and edit it // "4" When the current user has checked it out, the user can only edit the local copy of the document int ViewDocument(LPCWSTR DocumentLocation, LPCWSTR OpenType, LPCWSTR varProgID)
{ if (wcscmp(OpenType, L"0") == 0)
{ switch (AskIfUserWantsToEdit(DocumentLocation))
{ case Answer::Cancel: return1; case Answer::ReadOnly: break; case Answer::Edit: return EditDocument(DocumentLocation, L"0", varProgID);
}
} // TODO: resolve the program from varProgID (nullptr -> default?)
DWORD nResult = LOStart(L"--view", DocumentLocation); return nResult == ERROR_SUCCESS ? 0 : 2;
}
} // namespace
// Returns 0 on success, 1 when operation wasn't performed because user cancelled, 2 on an error int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
{ int argc = 0; const LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); if (argc < 2) return2; // Wrong argument count
if (wcscmp(argv[1], L"CreateNewDocument") == 0)
{ if (argc != 4) return2; // Wrong argument count return CreateNewDocument(argv[2], argv[3]);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.