[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - include/LibreOfficeKit libreofficekit/qa libreofficekit/source

Miklos Vajna vmiklos at collabora.co.uk
Tue May 3 09:31:28 UTC 2016


 include/LibreOfficeKit/LibreOfficeKitGtk.h          |   17 +++++++++
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   12 +++++-
 libreofficekit/source/gtk/lokdocview.cxx            |   37 +++++++++++++++++++-
 3 files changed, 63 insertions(+), 3 deletions(-)

New commits:
commit 549f67a85774838abdefdb7916beb0f26e2f9d2c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Apr 19 09:09:19 2016 +0200

    tdf#99314 lokdocview: add new userprofileurl property
    
    So that users of the widget can use a custom user profile, allowing
    running widgets users and LibreOffice in parallel.
    
    (cherry picked from commit df784ec1bf3d1745a291056df28bec799d4fdee3)
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    
    Change-Id: I1bd0a8e53aa3216adc721052cf30f0dd174327bd
    Reviewed-on: https://gerrit.libreoffice.org/24591
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 1df27c1..91e29c8 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -55,6 +55,23 @@ GtkWidget*                     lok_doc_view_new                    (const gchar*
                                                                     GError **error);
 
 /**
+ * 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.
+ * @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.
+ *
+ * Returns: (transfer none): The #LOKDocView widget instance.
+ */
+GtkWidget*                     lok_doc_view_new_from_user_profile  (const gchar* pPath,
+                                                                    const gchar* pUserProfile,
+                                                                    GCancellable *cancellable,
+                                                                    GError **error);
+
+/**
  * lok_doc_view_new_from_widget:
  * @pDocView: The #LOKDocView instance
  *
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 595e677..d1befb8a 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -35,7 +35,7 @@ static int help()
     fprintf(stderr, "Usage: gtktiledviewer <absolute-path-to-libreoffice-install's-program-directory> <path-to-document> [<options> ... ]\n\n");
     fprintf(stderr, "Options:\n\n");
     fprintf(stderr, "--hide-whitespace: Hide whitespace between pages in text documents.\n");
-    fprintf(stderr, "--background-color <color>: Set custom background color, e.g. 'yellow'.\n");
+    fprintf(stderr, "--user-profile: Path to a custom user profile.\n");
     return 1;
 }
 
@@ -497,7 +497,15 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
 /// Creates a new model, i.e. LOK init and document load, one view implicitly.
 static void createModelAndView(const char* pLOPath, const char* pDocPath, const std::vector<std::string>& rArguments)
 {
-    GtkWidget* pDocView = lok_doc_view_new(pLOPath, nullptr, nullptr);
+    std::string aUserProfile;
+    for (size_t i = 0; i < rArguments.size(); ++i)
+    {
+        const std::string& rArgument = rArguments[i];
+        if (rArgument == "--user-profile" && i + 1 < rArguments.size())
+            aUserProfile = std::string("file://") + 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);
 
     setupWidgetAndCreateWindow(pDocView);
 
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 11589dd..175ba50 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -48,6 +48,7 @@
 struct LOKDocViewPrivateImpl
 {
     const gchar* m_aLOPath;
+    const gchar* m_pUserProfileURL;
     const gchar* m_aDocPath;
     std::string m_aRenderingArguments;
     gdouble m_nLoadProgress;
@@ -128,6 +129,7 @@ struct LOKDocViewPrivateImpl
 
     LOKDocViewPrivateImpl()
         : m_aLOPath(nullptr),
+        m_pUserProfileURL(nullptr),
         m_aDocPath(nullptr),
         m_nLoadProgress(0),
         m_bIsLoading(false),
@@ -206,6 +208,7 @@ enum
 
     PROP_LO_PATH,
     PROP_LO_POINTER,
+    PROP_USER_PROFILE_URL,
     PROP_DOC_PATH,
     PROP_DOC_POINTER,
     PROP_EDITABLE,
@@ -1934,6 +1937,9 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal
     case PROP_LO_POINTER:
         priv->m_pOffice = static_cast<LibreOfficeKit*>(g_value_get_pointer(value));
         break;
+    case PROP_USER_PROFILE_URL:
+        priv->m_pUserProfileURL = g_value_dup_string(value);
+        break;
     case PROP_DOC_PATH:
         priv->m_aDocPath = g_value_dup_string (value);
         break;
@@ -1984,6 +1990,9 @@ static void lok_doc_view_get_property (GObject* object, guint propId, GValue *va
     case PROP_LO_POINTER:
         g_value_set_pointer(value, priv->m_pOffice);
         break;
+    case PROP_USER_PROFILE_URL:
+        g_value_set_string(value, priv->m_pUserProfileURL);
+        break;
     case PROP_DOC_PATH:
         g_value_set_string (value, priv->m_aDocPath);
         break;
@@ -2058,7 +2067,7 @@ static gboolean lok_doc_view_initable_init (GInitable *initable, GCancellable* /
     if (priv->m_pOffice != nullptr)
         return TRUE;
 
-    priv->m_pOffice = lok_init (priv->m_aLOPath);
+    priv->m_pOffice = lok_init_2(priv->m_aLOPath, priv->m_pUserProfileURL);
 
     if (priv->m_pOffice == nullptr)
     {
@@ -2122,6 +2131,20 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
                                                       G_PARAM_STATIC_STRINGS));
 
     /**
+     * LOKDocView:userprofileurl:
+     *
+     * The absolute path of the LibreOffice user profile.
+     */
+    properties[PROP_USER_PROFILE_URL] =
+        g_param_spec_string("userprofileurl",
+                            "User profile path",
+                            "LibreOffice user profile path",
+                            nullptr,
+                            static_cast<GParamFlags>(G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT_ONLY |
+                                                     G_PARAM_STATIC_STRINGS));
+
+    /**
      * LOKDocView:docpath:
      *
      * The path of the document that is currently being viewed.
@@ -2512,11 +2535,23 @@ lok_doc_view_new (const gchar* pPath, GCancellable *cancellable, GError **error)
                                        nullptr));
 }
 
+SAL_DLLPUBLIC_EXPORT GtkWidget*
+lok_doc_view_new_from_user_profile (const gchar* pPath, const gchar* pUserProfile, GCancellable *cancellable, GError **error)
+{
+    return GTK_WIDGET(g_initable_new(LOK_TYPE_DOC_VIEW, cancellable, error,
+                                     "lopath", pPath == nullptr ? LOK_PATH : pPath,
+                                     "userprofileurl", pUserProfile,
+                                     "halign", GTK_ALIGN_CENTER,
+                                     "valign", GTK_ALIGN_CENTER,
+                                     nullptr));
+}
+
 SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* pOldLOKDocView)
 {
     LOKDocViewPrivate& pOldPriv = getPrivate(pOldLOKDocView);
     GtkWidget* pNewDocView = GTK_WIDGET(g_initable_new(LOK_TYPE_DOC_VIEW, /*cancellable=*/nullptr, /*error=*/nullptr,
                                                        "lopath", pOldPriv->m_aLOPath,
+                                                       "userprofileurl", pOldPriv->m_pUserProfileURL,
                                                        "lopointer", pOldPriv->m_pOffice,
                                                        "docpointer", pOldPriv->m_pDocument,
                                                        "halign", GTK_ALIGN_CENTER,


More information about the Libreoffice-commits mailing list