[Libreoffice-commits] core.git: desktop/source include/LibreOfficeKit libreofficekit/qa

Stephan Bergmann sbergman at redhat.com
Tue Apr 19 13:54:12 UTC 2016


 desktop/source/lib/init.cxx                         |   21 +++++++++++++++++---
 include/LibreOfficeKit/LibreOfficeKit.hxx           |    4 +--
 include/LibreOfficeKit/LibreOfficeKitGtk.h          |    5 ++--
 include/LibreOfficeKit/LibreOfficeKitInit.h         |   10 ++++-----
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |    3 +-
 5 files changed, 30 insertions(+), 13 deletions(-)

New commits:
commit 024d2fde2aae13b07cf5c7b4d85fc3c6abce6913
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Apr 19 12:30:27 2016 +0200

    In lok_init_2, allow vnd.sun.star.pathname user_profile_url
    
    ...which takes a raw filesystem pathname that is internally converted to a file
    URL (similarly to what is supported for the INIFILENAME and URE_BOOTSTRAP
    bootstrap variables in rtl::Bootstrap).  That way, the gtktiledviewer executable
    doesn't need to try convert a pathname into a URL.
    
    Also adapted various parameter names to make it obvious that URLs get passed,
    not pathnames.
    
    Change-Id: I33ab31fe142d94ee47885033ef48278ef5ff55a2
    Reviewed-on: https://gerrit.libreoffice.org/24241
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b58f23e..0f46a04 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1816,7 +1816,7 @@ static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit:
     }
 }
 
-static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char* pUserProfilePath)
+static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char* pUserProfileUrl)
 {
     enum {
         PRE_INIT,     // setup shared data in master process
@@ -1849,8 +1849,23 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
     if (eStage != PRE_INIT)
         comphelper::LibreOfficeKit::setStatusIndicatorCallback(lo_status_indicator_callback, pLib);
 
-    if (eStage != SECOND_INIT && pUserProfilePath)
-        rtl::Bootstrap::set("UserInstallation", OUString(pUserProfilePath, strlen(pUserProfilePath), RTL_TEXTENCODING_UTF8));
+    if (eStage != SECOND_INIT && pUserProfileUrl)
+    {
+        OUString url(
+            pUserProfileUrl, strlen(pUserProfileUrl), RTL_TEXTENCODING_UTF8);
+        OUString path;
+        if (url.startsWithIgnoreAsciiCase("vnd.sun.star.pathname:", &path))
+        {
+            OUString url2;
+            osl::FileBase::RC e = osl::FileBase::getFileURLFromSystemPath(
+                path, url2);
+            if (e == osl::FileBase::E_None)
+                url = url2;
+            else
+                SAL_WARN("lok", "resolving <" << url << "> failed with " << +e);
+        }
+        rtl::Bootstrap::set("UserInstallation", url);
+    }
 
     OUString aAppPath;
     if (pAppPath)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 9e18df0..44e321f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -523,9 +523,9 @@ public:
 };
 
 /// Factory method to create a lok::Office instance.
-inline Office* lok_cpp_init(const char* pInstallPath, const char* pUserProfilePath = NULL)
+inline Office* lok_cpp_init(const char* pInstallPath, const char* pUserProfileUrl = NULL)
 {
-    LibreOfficeKit* pThis = lok_init_2(pInstallPath, pUserProfilePath);
+    LibreOfficeKit* pThis = lok_init_2(pInstallPath, pUserProfileUrl);
     if (pThis == NULL || pThis->pClass->nSize == 0)
         return NULL;
     return new ::lok::Office(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 8a64bff..a0082be 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -58,8 +58,9 @@ GtkWidget*                     lok_doc_view_new                    (const gchar*
  * lok_doc_view_new_from_user_profile:
  * @pPath: (nullable): LibreOffice install path. Pass null to set it to default
  * path which in most cases would be $libdir/libreoffice/program
- * @pUserProfile: (nullable): User profile URL. Pass non-null to be able to
- * use this widget and LibreOffice itself in parallel.
+ * @pUserProfile: (nullable): User profile URL. Must be either a file URL or a
+ * special vnd.sun.star.pathname URL. Pass non-null to be able to use this
+ * widget and LibreOffice itself in parallel.
  * @cancellable: The cancellable object that you can use to cancel this
  * operation.
  * @error: The error that will be set if the object fails to initialize.
diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index f1e513e..bdda642 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -212,11 +212,11 @@ static void *lok_dlopen( const char *install_path, char ** _imp_lib )
 
 typedef LibreOfficeKit *(LokHookFunction)( const char *install_path);
 
-typedef LibreOfficeKit *(LokHookFunction2)( const char *install_path, const char *user_profile_path );
+typedef LibreOfficeKit *(LokHookFunction2)( const char *install_path, const char *user_profile_url );
 
-typedef int             (LokHookPreInit)  ( const char *install_path, const char *user_profile_path );
+typedef int             (LokHookPreInit)  ( const char *install_path, const char *user_profile_url );
 
-static LibreOfficeKit *lok_init_2( const char *install_path,  const char *user_profile_path )
+static LibreOfficeKit *lok_init_2( const char *install_path,  const char *user_profile_url )
 {
     char *imp_lib;
     void *dlhandle;
@@ -230,7 +230,7 @@ static LibreOfficeKit *lok_init_2( const char *install_path,  const char *user_p
     pSym2 = (LokHookFunction2 *) lok_dlsym(dlhandle, "libreofficekit_hook_2");
     if (!pSym2)
     {
-        if (user_profile_path != NULL)
+        if (user_profile_url != NULL)
         {
             fprintf( stderr, "the LibreOffice version in '%s' does not support passing a user profile to the hook function\n",
                      imp_lib );
@@ -255,7 +255,7 @@ static LibreOfficeKit *lok_init_2( const char *install_path,  const char *user_p
     free( imp_lib );
     // dlhandle is "leaked"
     // coverity[leaked_storage]
-    return pSym2( install_path, user_profile_path );
+    return pSym2( install_path, user_profile_url );
 }
 
 static
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index b3079a7..8a3099e 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -535,7 +535,8 @@ static void createModelAndView(const char* pLOPath, const char* pDocPath, const
     {
         const std::string& rArgument = rArguments[i];
         if (rArgument == "--user-profile" && i + 1 < rArguments.size())
-            aUserProfile = std::string("file://") + rArguments[i + 1].c_str();
+            aUserProfile = std::string("vnd.sun.star.pathname:")
+                + rArguments[i + 1].c_str();
     }
     const gchar* pUserProfile = aUserProfile.empty() ? nullptr : aUserProfile.c_str();
     GtkWidget* pDocView = lok_doc_view_new_from_user_profile(pLOPath, pUserProfile, nullptr, nullptr);


More information about the Libreoffice-commits mailing list