summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx21
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitInit.h36
2 files changed, 46 insertions, 11 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 94c95edc515e..186f60bf29f3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -268,7 +268,7 @@ static void doc_destroy(LibreOfficeKitDocument *pThis)
}
static void lo_destroy (LibreOfficeKit* pThis);
-static int lo_initialize (LibreOfficeKit* pThis, const char* pInstallPath);
+static int lo_initialize (LibreOfficeKit* pThis, const char* pInstallPath, const char* pUserProfilePath);
static LibreOfficeKitDocument* lo_documentLoad (LibreOfficeKit* pThis, const char* pURL);
static char * lo_getError (LibreOfficeKit* pThis);
static LibreOfficeKitDocument* lo_documentLoadWithOptions (LibreOfficeKit* pThis,
@@ -839,7 +839,7 @@ static void lo_startmain(void*)
static bool bInitialized = false;
-static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
+static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char* pUserProfilePath)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
@@ -848,6 +848,9 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
comphelper::LibreOfficeKit::setActive();
+ if (pUserProfilePath)
+ rtl::Bootstrap::set(OUString("UserInstallation"), OUString(pUserProfilePath, strlen(pUserProfilePath), RTL_TEXTENCODING_UTF8));
+
OUString aAppPath;
if (pAppPath)
{
@@ -947,14 +950,14 @@ __attribute__ ((visibility("default")))
#else
SAL_DLLPUBLIC_EXPORT
#endif
-LibreOfficeKit *libreofficekit_hook(const char* install_path)
+LibreOfficeKit *libreofficekit_hook_2(const char* install_path, const char* user_profile_path)
{
if (!gImpl)
{
SAL_INFO("lok", "Create libreoffice object");
gImpl = new LibLibreOffice_Impl();
- if (!lo_initialize(gImpl, install_path))
+ if (!lo_initialize(gImpl, install_path, user_profile_path))
{
lo_destroy(gImpl);
}
@@ -962,6 +965,16 @@ LibreOfficeKit *libreofficekit_hook(const char* install_path)
return static_cast<LibreOfficeKit*>(gImpl);
}
+#if defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE) && defined(DISABLE_DYNLOADING)
+__attribute__ ((visibility("default")))
+#else
+SAL_DLLPUBLIC_EXPORT
+#endif
+LibreOfficeKit *libreofficekit_hook(const char* install_path)
+{
+ return libreofficekit_hook_2(install_path, NULL);
+}
+
static void lo_destroy(LibreOfficeKit* pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index fe10cd9ffa1b..c0d3d5d06e0e 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -126,11 +126,14 @@ extern "C"
typedef LibreOfficeKit *(HookFunction)( const char *install_path);
-static LibreOfficeKit *lok_init( const char *install_path )
+typedef LibreOfficeKit *(HookFunction2)( const char *install_path, const char *user_profile_path );
+
+static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_profile_path )
{
char *imp_lib;
void *dlhandle;
HookFunction *pSym;
+ HookFunction2 *pSym2;
#if !(defined(__APPLE__) && defined(__arm__))
size_t partial_length;
@@ -173,17 +176,36 @@ static LibreOfficeKit *lok_init( const char *install_path )
dlhandle = RTLD_MAIN_ONLY;
#endif
- pSym = (HookFunction *) _dlsym( dlhandle, "libreofficekit_hook" );
- if (!pSym)
+ pSym2 = (HookFunction2 *) _dlsym( dlhandle, "libreofficekit_hook_2" );
+ if (!pSym2)
{
- fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
- _dlclose( dlhandle );
+ if (user_profile_path != NULL)
+ {
+ fprintf( stderr, "the LibreOffice version in '%s' does not support passing a user profile to the hook function\n",
+ imp_lib );
+ _dlclose( dlhandle );
+ free( imp_lib );
+ return NULL;
+ }
+ pSym = (HookFunction *) _dlsym( dlhandle, "libreofficekit_hook" );
+ if (!pSym)
+ {
+ fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
+ _dlclose( dlhandle );
+ free( imp_lib );
+ return NULL;
+ }
free( imp_lib );
- return NULL;
+ return pSym( install_path );
}
free( imp_lib );
- return pSym( install_path );
+ return pSym2( install_path, user_profile_path );
+}
+
+static LibreOfficeKit *lok_init( const char *install_path )
+{
+ return lok_init_2( install_path, NULL );
}
#undef SEPARATOR // It is used at least in enum class MenuItemType