From 4692ad2debc22ba83d79b6c13e22e694f33b5a03 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Mon, 14 Sep 2015 14:36:56 +0200
Subject: [PATCH 119/398] lok::Document: add createView()
Change-Id: Ic871ec41992b611b10958799b2dc12375a91efe4
(cherry picked from commit 655c7877a0650b7bfd04a3294cdf92bc7ab94055)
---
desktop/source/lib/init.cxx | 19 +++++++++++++++++++
include/LibreOfficeKit/LibreOfficeKit.h | 3 +++
include/LibreOfficeKit/LibreOfficeKit.hxx | 10 ++++++++++
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 14 ++++++++++++++
4 files changed, 46 insertions(+)
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 87471454b5d2..ea5de4df1a5c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -53,6 +53,7 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/msgpool.hxx>
#include <sfx2/dispatch.hxx>
+#include <sfx2/lokhelper.hxx>
#include <svx/svxids.hrc>
#include <vcl/svapp.hxx>
#include <vcl/svpforlokit.hxx>
@@ -249,6 +250,7 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
static void doc_resetSelection (LibreOfficeKitDocument* pThis);
static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand);
+static int doc_createView(LibreOfficeKitDocument* pThis);
LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
mxComponent( xComponent )
@@ -280,6 +282,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->resetSelection = doc_resetSelection;
m_pDocumentClass->getCommandValues = doc_getCommandValues;
+ m_pDocumentClass->createView = doc_createView;
+
gDocumentClass = m_pDocumentClass;
}
pClass = m_pDocumentClass.get();
@@ -1032,6 +1036,21 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
}
}
+static int doc_createView(LibreOfficeKitDocument* pThis)
+{
+ SolarMutexGuard aGuard;
+
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return -1;
+ }
+
+ SfxViewShell* pViewShell = pDoc->getCurrentViewShell();
+ return SfxLokHelper::createView(pViewShell);
+}
+
static char* lo_getError (LibreOfficeKit *pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 8060f0e6ec7c..eae35374e032 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -162,6 +162,9 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document:getStyles
char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand);
+
+ /// @see lok::Document::createView().
+ int (*createView) (LibreOfficeKitDocument* pThis);
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 44599948e659..1a8b002ecba6 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -257,6 +257,16 @@ public:
{
return mpDoc->pClass->getCommandValues(mpDoc, pCommand);
}
+
+ /**
+ * Create a new view for an existing document.
+ * By default a loaded document has 1 view.
+ * @return the ID of the new view.
+ */
+ int createView()
+ {
+ return mpDoc->pClass->createView(mpDoc);
+ }
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index ab33fc703731..60c5281974f4 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -147,6 +147,14 @@ static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/)
}
}
+/// Calls lok::Document::createView().
+static void createView(GtkWidget* /*pButton*/, gpointer /*pItem*/)
+{
+ LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
+ LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView);
+ pDocument->pClass->createView(pDocument);
+}
+
/// Our GtkClipboardGetFunc implementation for HTML.
static void htmlGetFunc(GtkClipboard* /*pClipboard*/, GtkSelectionData* pSelectionData, guint /*info*/, gpointer pUserData)
{
@@ -554,6 +562,12 @@ int main( int argc, char* argv[] )
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pFindButton, -1);
g_signal_connect(G_OBJECT(pFindButton), "clicked", G_CALLBACK(toggleFindbar), NULL);
+ GtkToolItem* pNewViewButton = gtk_tool_button_new( NULL, NULL);
+ gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pNewViewButton), "view-continuous-symbolic");
+ gtk_tool_item_set_tooltip_text(pNewViewButton, "New View");
+ gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pNewViewButton, -1);
+ g_signal_connect(G_OBJECT(pNewViewButton), "clicked", G_CALLBACK(createView), NULL);
+
gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
pBold = gtk_toggle_tool_button_new();
--
2.12.0