loolwsd/LOKitClient.cpp | 4 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h | 20 +++- loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h | 49 ++++++++++- loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitInit.h | 31 ++++-- loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h | 4 5 files changed, 86 insertions(+), 22 deletions(-)
New commits: commit a45c895605f58c2478835d5affaa7fc0ed3c4595 Author: Miklos Vajna <[email protected]> Date: Fri Jan 29 14:36:14 2016 +0100 loolwsd: update bundled headers diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h index a78c0aa..ee9ac1a 100644 --- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h +++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h @@ -12,9 +12,10 @@ #include <stddef.h> -#ifdef LOK_USE_UNSTABLE_API +#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY // the unstable API needs C99's bool #include <stdbool.h> +#include <stdint.h> #endif #include <LibreOfficeKit/LibreOfficeKitTypes.h> @@ -55,14 +56,25 @@ struct _LibreOfficeKitClass LibreOfficeKitDocument* (*documentLoadWithOptions) (LibreOfficeKit* pThis, const char* pURL, const char* pOptions); -#ifdef LOK_USE_UNSTABLE_API + void (*freeError) (char* pFree); + +#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY void (*registerCallback) (LibreOfficeKit* pThis, LibreOfficeKitCallback pCallback, void* pData); /// @see lok::Office::getFilterTypes(). char* (*getFilterTypes) (LibreOfficeKit* pThis); + + /// @see lok::Office::setOptionalFeatures(). + void (*setOptionalFeatures)(LibreOfficeKit* pThis, uint64_t features); + + /// @see lok::Office::setDocumentPassword(). + void (*setDocumentPassword) (LibreOfficeKit* pThis, + char const* pURL, + char const* pPassword); #endif + }; #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize) @@ -83,7 +95,7 @@ struct _LibreOfficeKitDocumentClass const char* pFormat, const char* pFilterOptions); -#ifdef LOK_USE_UNSTABLE_API +#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY /// @see lok::Document::getDocumentType(). int (*getDocumentType) (LibreOfficeKitDocument* pThis); @@ -208,7 +220,7 @@ struct _LibreOfficeKitDocumentClass const char* pFontName, int* pFontWidth, int* pFontHeight); -#endif // LOK_USE_UNSTABLE_API +#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; #ifdef __cplusplus diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h index a0f5e88..b615bd9 100644 --- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -15,7 +15,7 @@ extern "C" { #endif -#ifdef LOK_USE_UNSTABLE_API +#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY typedef enum { LOK_DOCTYPE_TEXT, @@ -40,6 +40,32 @@ typedef enum } LibreOfficeKitTileMode; +/** Optional features of LibreOfficeKit, in particular callbacks that block + * LibreOfficeKit until the corresponding reply is received, which would + * deadlock if the client does not support the feature. + * + * @see lok::Office::setOptionalFeatures(). + */ +typedef enum +{ + /** + * Handle LOK_CALLBACK_DOCUMENT_PASSWORD by prompting the user + * for a password. + * + * @see lok::Office::setDocumentPassword(). + */ + LOK_FEATURE_DOCUMENT_PASSWORD = (1ULL << 0), + + /** + * Handle LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY by prompting the user + * for a password. + * + * @see lok::Office::setDocumentPassword(). + */ + LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY = (1ULL << 1), +} +LibreOfficeKitOptionalFeatures; + typedef enum { /** @@ -221,7 +247,24 @@ typedef enum /** * The text content of the formula bar in Calc. */ - LOK_CALLBACK_CELL_FORMULA + LOK_CALLBACK_CELL_FORMULA, + + /** + * Loading a document requires a password. + * + * Loading the document is blocked until the password is provided via + * lok::Office::setDocumentPassword(). The document cannot be loaded + * without the password. + */ + LOK_CALLBACK_DOCUMENT_PASSWORD, + + /** + * Editing a document requires a password. + * + * Loading the document is blocked until the password is provided via + * lok::Office::setDocumentPassword(). + */ + LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY, } LibreOfficeKitCallbackType; @@ -281,7 +324,7 @@ typedef enum } LibreOfficeKitSetGraphicSelectionType; -#endif // LOK_USE_UNSTABLE_API +#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY #ifdef __cplusplus } diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitInit.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitInit.h index e2af109..23e5772 100644 --- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitInit.h +++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitInit.h @@ -76,8 +76,7 @@ extern "C" #else - #include "prewin.h" - #include "postwin.h" + #include <windows.h> #define TARGET_LIB "sofficeapp" ".dll" #define TARGET_MERGED_LIB "mergedlo" ".dll" #define SEPARATOR '\\' @@ -85,7 +84,7 @@ extern "C" void *lok_loadlib(const char *pFN) { - return (void *) LoadLibrary(pFN); + return (void *) LoadLibraryA(pFN); } char *lok_dlerror(void) @@ -97,7 +96,7 @@ extern "C" void *lok_dlsym(void *Hnd, const char *pName) { - return GetProcAddress((HINSTANCE) Hnd, pName); + return reinterpret_cast<void *>(GetProcAddress((HINSTANCE) Hnd, pName)); } int lok_dlclose(void *Hnd) @@ -111,11 +110,11 @@ extern "C" return; char* sEnvPath = NULL; - DWORD cChars = GetEnvironmentVariable("PATH", sEnvPath, 0); + DWORD cChars = GetEnvironmentVariableA("PATH", sEnvPath, 0); if (cChars > 0) { sEnvPath = new char[cChars]; - cChars = GetEnvironmentVariable("PATH", sEnvPath, cChars); + cChars = GetEnvironmentVariableA("PATH", sEnvPath, cChars); //If PATH is not set then it is no error if (cChars == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND) { @@ -125,17 +124,18 @@ extern "C" } //prepare the new PATH. Add the Ure/bin directory at the front. //note also adding ';' - char * sNewPath = new char[strlen(sEnvPath) + strlen(pPath) + strlen(UNOPATH) + 2]; + char * sNewPath = new char[strlen(sEnvPath) + strlen(pPath) * 2 + strlen(UNOPATH) + 4]; sNewPath[0] = L'\0'; - strcat(sNewPath, pPath); - strcat(sNewPath, UNOPATH); + strcat(sNewPath, pPath); // program to PATH + strcat(sNewPath, ";"); + strcat(sNewPath, UNOPATH); // UNO to PATH if (strlen(sEnvPath)) { strcat(sNewPath, ";"); strcat(sNewPath, sEnvPath); } - SetEnvironmentVariable("PATH", sNewPath); + SetEnvironmentVariableA("PATH", sNewPath); delete[] sEnvPath; delete[] sNewPath; @@ -155,6 +155,13 @@ static void *lok_dlopen( const char *install_path, char ** _imp_lib ) if (!install_path) return NULL; + struct stat dir_st; + if (stat(install_path, &dir_st) != 0) + { + fprintf(stderr, "installation path \"%s\" does not exist\n", install_path); + return NULL; + } + // allocate large enough buffer partial_length = strlen(install_path); imp_lib = (char *) malloc(partial_length + sizeof(TARGET_LIB) + sizeof(TARGET_MERGED_LIB) + 2); @@ -220,6 +227,8 @@ static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_p LokHookFunction2 *pSym2; dlhandle = lok_dlopen(install_path, &imp_lib); + if (!dlhandle) + return NULL; pSym2 = (LokHookFunction2 *) lok_dlsym(dlhandle, "libreofficekit_hook_2"); if (!pSym2) @@ -253,7 +262,7 @@ static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_p } static -#ifdef __GNUC__ +#if defined __GNUC__ || defined __clang__ __attribute__((used)) #endif LibreOfficeKit *lok_init( const char *install_path ) diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h index 338f8b8..3383944 100644 --- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h +++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h @@ -17,9 +17,9 @@ extern "C" { #endif -#ifdef LOK_USE_UNSTABLE_API +#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY typedef void (*LibreOfficeKitCallback)(int nType, const char* pPayload, void* pData); -#endif // LOK_USE_UNSTABLE_API +#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY #ifdef __cplusplus } commit 4a492d81bb41b0c6ba0bafe9afefd69305ed5fd4 Author: Jan Holesovsky <[email protected]> Date: Mon Feb 1 19:38:40 2016 +0100 Tabs to spaces. diff --git a/loolwsd/LOKitClient.cpp b/loolwsd/LOKitClient.cpp index e66b80d..58c7e78 100644 --- a/loolwsd/LOKitClient.cpp +++ b/loolwsd/LOKitClient.cpp @@ -64,8 +64,8 @@ extern "C" CASE(DOCUMENT_SIZE_CHANGED); CASE(SET_PART); CASE(UNO_COMMAND_RESULT); - CASE(DOCUMENT_PASSWORD); - CASE(DOCUMENT_PASSWORD_TO_MODIFY); + CASE(DOCUMENT_PASSWORD); + CASE(DOCUMENT_PASSWORD_TO_MODIFY); #undef CASE } std::cout << " payload: " << pPayload << std::endl; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
