Blame SOURCES/0345-gtktiledviewer-allow-passing-initializeForRendering-.patch

135360
From 5192c15c3382caea037991cdbeca55c596fe042f Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Wed, 18 Nov 2015 15:57:36 +0100
135360
Subject: [PATCH 345/398] gtktiledviewer: allow passing
135360
 initializeForRendering() arguments
135360
135360
Change-Id: Ic7b52764cf2fedbf73d4dcaaf36d1055b8ee22f2
135360
(cherry picked from commit 0ea68eecddf0211f842645c4d257899531692770)
135360
---
135360
 include/LibreOfficeKit/LibreOfficeKitGtk.h         |  2 ++
135360
 .../qa/gtktiledviewer/gtktiledviewer.cxx           | 25 ++++++++++++++++++----
135360
 libreofficekit/source/gtk/lokdocview.cxx           |  5 ++++-
135360
 3 files changed, 27 insertions(+), 5 deletions(-)
135360
135360
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
135360
index 32cb66963220..c947ce3f8369 100644
135360
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
135360
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
135360
@@ -65,6 +65,7 @@ GtkWidget*                     lok_doc_view_new_from_widget        (LOKDocView*
135360
  * lok_doc_view_open_document:
135360
  * @pDocView: The #LOKDocView instance
135360
  * @pPath: (transfer full): The path of the document that #LOKDocView widget should try to open
135360
+ * @pRenderingArguments: lok::Document::initializeForRendering() arguments.
135360
  * @cancellable:
135360
  * @callback:
135360
  * @userdata:
135360
@@ -73,6 +74,7 @@ GtkWidget*                     lok_doc_view_new_from_widget        (LOKDocView*
135360
  */
135360
 void                           lok_doc_view_open_document          (LOKDocView* pDocView,
135360
                                                                     const gchar* pPath,
135360
+                                                                    const gchar* pRenderingArguments,
135360
                                                                     GCancellable* cancellable,
135360
                                                                     GAsyncReadyCallback callback,
135360
                                                                     gpointer userdata);
135360
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
135360
index 7dcd52446344..f9034298e65c 100644
135360
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
135360
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
135360
@@ -29,7 +29,9 @@
135360
 
135360
 static int help()
135360
 {
135360
-    fprintf( stderr, "Usage: gtktiledviewer <absolute-path-to-libreoffice-install's-program-directory> <path-to-document>\n" );
135360
+    fprintf(stderr, "Usage: gtktiledviewer <absolute-path-to-libreoffice-install's-program-directory> <path-to-document> [<options> ... ]\n\n");
135360
+    fprintf(stderr, "Options:\n\n");
135360
+    fprintf(stderr, "--hide-whitespace: Hide whitespace between pages in text documents.\n");
135360
     return 1;
135360
 }
135360
 
135360
@@ -475,13 +477,25 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
135360
 }
135360
 
135360
 /// Creates a new model, i.e. LOK init and document load, one view implicitly.
135360
-static void createModelAndView(const char* pLOPath, const char* pDocPath)
135360
+static void createModelAndView(const char* pLOPath, const char* pDocPath, const std::vector<std::string>& rArguments)
135360
 {
135360
     GtkWidget* pDocView = lok_doc_view_new(pLOPath, nullptr, nullptr);
135360
 
135360
     setupWidgetAndCreateWindow(pDocView);
135360
 
135360
-    lok_doc_view_open_document(LOK_DOC_VIEW(pDocView), pDocPath, nullptr, openDocumentCallback, pDocView);
135360
+    boost::property_tree::ptree aTree;
135360
+    for (const std::string& rArgument : rArguments)
135360
+    {
135360
+        if (rArgument == "--hide-whitespace")
135360
+        {
135360
+            aTree.put(boost::property_tree::ptree::path_type(".uno:HideWhitespace/type", '/'), "boolean");
135360
+            aTree.put(boost::property_tree::ptree::path_type(".uno:HideWhitespace/value", '/'), true);
135360
+        }
135360
+    }
135360
+    std::stringstream aStream;
135360
+    boost::property_tree::write_json(aStream, aTree);
135360
+    std::string aArguments = aStream.str();
135360
+    lok_doc_view_open_document(LOK_DOC_VIEW(pDocView), pDocPath, aArguments.c_str(), nullptr, openDocumentCallback, pDocView);
135360
 }
135360
 
135360
 /// Our GtkClipboardGetFunc implementation for HTML.
135360
@@ -1262,7 +1276,10 @@ int main( int argc, char* argv[] )
135360
 
135360
     gtk_init( &argc, &argv );
135360
 
135360
-    createModelAndView(argv[1], argv[2]);
135360
+    std::vector<std::string> aArguments;
135360
+    for (int i = 3; i < argc; ++i)
135360
+        aArguments.push_back(argv[i]);
135360
+    createModelAndView(argv[1], argv[2], aArguments);
135360
 
135360
     gtk_main();
135360
 
135360
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
135360
index 802d85dea553..464348d95f1c 100644
135360
--- a/libreofficekit/source/gtk/lokdocview.cxx
135360
+++ b/libreofficekit/source/gtk/lokdocview.cxx
135360
@@ -44,6 +44,7 @@ struct LOKDocViewPrivateImpl
135360
 {
135360
     const gchar* m_aLOPath;
135360
     const gchar* m_aDocPath;
135360
+    std::string m_aRenderingArguments;
135360
     gdouble m_nLoadProgress;
135360
     gboolean m_bIsLoading;
135360
     gboolean m_bCanZoomIn;
135360
@@ -530,7 +531,7 @@ static gboolean postDocumentLoad(gpointer pData)
135360
     LOKDocViewPrivate& priv = getPrivate(pLOKDocView);
135360
 
135360
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
135360
-    priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, nullptr);
135360
+    priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, priv->m_aRenderingArguments.c_str());
135360
     priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pLOKDocView);
135360
     priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips);
135360
     g_timeout_add(600, handleTimeout, pLOKDocView);
135360
@@ -2312,6 +2313,7 @@ lok_doc_view_open_document_finish (LOKDocView* pDocView, GAsyncResult* res, GErr
135360
 SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_open_document (LOKDocView* pDocView,
135360
                             const gchar* pPath,
135360
+                            const gchar* pRenderingArguments,
135360
                             GCancellable* cancellable,
135360
                             GAsyncReadyCallback callback,
135360
                             gpointer userdata)
135360
@@ -2324,6 +2326,7 @@ lok_doc_view_open_document (LOKDocView* pDocView,
135360
     pLOEvent->m_pPath = pPath;
135360
 
135360
     priv->m_aDocPath = pPath;
135360
+    priv->m_aRenderingArguments = pRenderingArguments;
135360
     g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
135360
 
135360
     g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), &error);
135360
-- 
135360
2.12.0
135360