From c00540a0f89da14380cfb4e194206ecfb5ca0e7f Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Tue, 15 Sep 2015 14:23:53 +0200
Subject: [PATCH 132/398] lokdocview: allow not calling documentLoad()
Change-Id: I2ff57c4be11cd3908bc951ebf572a2c02e2c4585
(cherry picked from commit 4fd59356cb09e89324e8cd8ec84eef22a4c2031b)
---
include/LibreOfficeKit/LibreOfficeKitGtk.h | 2 ++
libreofficekit/source/gtk/lokdocview.cxx | 48 ++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 01009fb9eb40..f17925b4c53a 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -44,6 +44,8 @@ GtkWidget* lok_doc_view_new (const gchar*
GCancellable *cancellable,
GError **error);
+GtkWidget* lok_doc_view_new_from_widget (LOKDocView* pDocView);
+
void lok_doc_view_open_document (LOKDocView* pDocView,
const gchar* pPath,
GCancellable* cancellable,
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 27d2e1df983a..3cce40a94217 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -127,7 +127,9 @@ enum
PROP_0,
PROP_LO_PATH,
+ PROP_LO_POINTER,
PROP_DOC_PATH,
+ PROP_DOC_POINTER,
PROP_EDITABLE,
PROP_LOAD_PROGRESS,
PROP_ZOOM,
@@ -1388,9 +1390,15 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal
case PROP_LO_PATH:
priv->m_aLOPath = g_value_dup_string (value);
break;
+ case PROP_LO_POINTER:
+ priv->m_pOffice = static_cast<LibreOfficeKit*>(g_value_get_pointer(value));
+ break;
case PROP_DOC_PATH:
priv->m_aDocPath = g_value_dup_string (value);
break;
+ case PROP_DOC_POINTER:
+ priv->m_pDocument = static_cast<LibreOfficeKitDocument*>(g_value_get_pointer(value));
+ break;
case PROP_EDITABLE:
lok_doc_view_set_edit (pDocView, g_value_get_boolean (value));
break;
@@ -1418,9 +1426,15 @@ static void lok_doc_view_get_property (GObject* object, guint propId, GValue *va
case PROP_LO_PATH:
g_value_set_string (value, priv->m_aLOPath);
break;
+ case PROP_LO_POINTER:
+ g_value_set_pointer(value, priv->m_pOffice);
+ break;
case PROP_DOC_PATH:
g_value_set_string (value, priv->m_aDocPath);
break;
+ case PROP_DOC_POINTER:
+ g_value_set_pointer(value, priv->m_pDocument);
+ break;
case PROP_EDITABLE:
g_value_set_boolean (value, priv->m_bEdit);
break;
@@ -1531,6 +1545,20 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
| G_PARAM_CONSTRUCT_ONLY)));
/**
+ * LOKDocView:lopointer:
+ *
+ * A LibreOfficeKit* in case lok_init() is already called
+ * previously.
+ */
+ g_object_class_install_property (pGObjectClass,
+ PROP_LO_POINTER,
+ g_param_spec_pointer("lopointer",
+ "LO Pointer",
+ "A LibreOfficeKit* from lok_init()",
+ static_cast<GParamFlags>(G_PARAM_READWRITE
+ | G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
* LOKDocView:docpath:
*
* The path of the document that is currently being viewed.
@@ -1544,6 +1572,19 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
static_cast<GParamFlags>(G_PARAM_READWRITE)));
/**
+ * LOKDocView:docpointer:
+ *
+ * A LibreOfficeKitDocument* in case documentLoad() is already called
+ * previously.
+ */
+ g_object_class_install_property (pGObjectClass,
+ PROP_DOC_POINTER,
+ g_param_spec_pointer("docpointer",
+ "Document Pointer",
+ "A LibreOfficeKitDocument* from documentLoad()",
+ static_cast<GParamFlags>(G_PARAM_READWRITE)));
+
+ /**
* LOKDocView:editable:
*
* Whether the document loaded inside of #LOKDocView is editable or not.
@@ -1795,6 +1836,13 @@ lok_doc_view_new (const gchar* pPath, GCancellable *cancellable, GError **error)
return GTK_WIDGET (g_initable_new (LOK_TYPE_DOC_VIEW, cancellable, error, "lopath", pPath, NULL));
}
+SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* pLOKDocView)
+{
+ LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private(pLOKDocView));
+ return GTK_WIDGET(g_initable_new(LOK_TYPE_DOC_VIEW, /*cancellable=*/0, /*error=*/0,
+ "lopath", priv->m_aLOPath, "lopointer", priv->m_pOffice, "docpointer", priv->m_pDocument, NULL));
+}
+
/**
* lok_doc_view_open_document_finish:
* @pDocView: The #LOKDocView instance
--
2.12.0