Blame SOURCES/0343-lok-Document-initializeForRendering-support-init.-ar.patch

f325b2
From 7c206a9cb06d70fb95f7f7eae137865bb68f5b1b Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Wed, 18 Nov 2015 14:59:51 +0100
f325b2
Subject: [PATCH 343/398] lok::Document::initializeForRendering: support init.
f325b2
 arguments
f325b2
f325b2
Change-Id: I8aaf19a50f25f495cb87fba7ff6a4b0f56ed7d80
f325b2
(cherry picked from commit 4bddfc00d25a42917db79ceaf0547c2e792132c4)
f325b2
---
f325b2
 desktop/qa/desktop_lib/test_desktop_lib.cxx |  4 +-
f325b2
 desktop/source/lib/init.cxx                 | 76 +++++++++++++++--------------
f325b2
 desktop/source/lib/lokandroid.cxx           |  2 +-
f325b2
 include/LibreOfficeKit/LibreOfficeKit.h     |  3 +-
f325b2
 include/LibreOfficeKit/LibreOfficeKit.hxx   | 16 +++++-
f325b2
 libreofficekit/source/gtk/lokdocview.cxx    |  2 +-
f325b2
 6 files changed, 60 insertions(+), 43 deletions(-)
f325b2
f325b2
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
index 1edf8d722d2f..4b08f9448f61 100644
f325b2
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
@@ -283,7 +283,7 @@ void DesktopLOKTest::testSearchCalc()
f325b2
     LibLibreOffice_Impl aOffice;
f325b2
     comphelper::LibreOfficeKit::setActive();
f325b2
     LibLODocument_Impl* pDocument = loadDoc("search.ods");
f325b2
-    pDocument->pClass->initializeForRendering(pDocument);
f325b2
+    pDocument->pClass->initializeForRendering(pDocument, nullptr);
f325b2
     pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
f325b2
 
f325b2
     uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
f325b2
@@ -406,7 +406,7 @@ void DesktopLOKTest::testRowColumnHeaders()
f325b2
      */
f325b2
     LibLODocument_Impl* pDocument = loadDoc("search.ods");
f325b2
 
f325b2
-    pDocument->pClass->initializeForRendering(pDocument);
f325b2
+    pDocument->pClass->initializeForRendering(pDocument, nullptr);
f325b2
 
f325b2
     boost::property_tree::ptree aTree;
f325b2
     char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders");
f325b2
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
f325b2
index 4ee862d21cd0..2ff0a9d02853 100644
f325b2
--- a/desktop/source/lib/init.cxx
f325b2
+++ b/desktop/source/lib/init.cxx
f325b2
@@ -260,6 +260,40 @@ static OUString getAbsoluteURL(const char* pURL)
f325b2
     return OUString();
f325b2
 }
f325b2
 
f325b2
+static void jsonToPropertyValues(const char* pJSON, uno::Sequence<beans::PropertyValue>& rPropertyValues)
f325b2
+{
f325b2
+    std::vector<beans::PropertyValue> aArguments;
f325b2
+    if (pJSON)
f325b2
+    {
f325b2
+        boost::property_tree::ptree aTree;
f325b2
+        std::stringstream aStream(pJSON);
f325b2
+        boost::property_tree::read_json(aStream, aTree);
f325b2
+
f325b2
+        for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aTree)
f325b2
+        {
f325b2
+            const std::string& rType = rPair.second.get<std::string>("type");
f325b2
+            const std::string& rValue = rPair.second.get<std::string>("value");
f325b2
+
f325b2
+            beans::PropertyValue aValue;
f325b2
+            aValue.Name = OUString::fromUtf8(rPair.first.c_str());
f325b2
+            if (rType == "string")
f325b2
+                aValue.Value <<= OUString::fromUtf8(rValue.c_str());
f325b2
+            else if (rType == "boolean")
f325b2
+                aValue.Value <<= OString(rValue.c_str()).toBoolean();
f325b2
+            else if (rType == "float")
f325b2
+                aValue.Value <<= OString(rValue.c_str()).toFloat();
f325b2
+            else if (rType == "long")
f325b2
+                aValue.Value <<= OString(rValue.c_str()).toInt32();
f325b2
+            else if (rType == "unsigned short")
f325b2
+                aValue.Value <<= static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32());
f325b2
+            else
f325b2
+                SAL_WARN("desktop.lib", "jsonToPropertyValues: unhandled type '"<
f325b2
+            aArguments.push_back(aValue);
f325b2
+        }
f325b2
+    }
f325b2
+    rPropertyValues = comphelper::containerToSequence(aArguments);
f325b2
+}
f325b2
+
f325b2
 extern "C"
f325b2
 {
f325b2
 
f325b2
@@ -280,7 +314,8 @@ void        doc_paintTile(LibreOfficeKitDocument* pThis,
f325b2
 static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
f325b2
                                 long* pWidth,
f325b2
                                 long* pHeight);
f325b2
-static void doc_initializeForRendering(LibreOfficeKitDocument* pThis);
f325b2
+static void doc_initializeForRendering(LibreOfficeKitDocument* pThis,
f325b2
+                                       const char* pArguments);
f325b2
 
f325b2
 static void doc_registerCallback(LibreOfficeKitDocument* pThis,
f325b2
                                 LibreOfficeKitCallback pCallback,
f325b2
@@ -938,12 +973,15 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
f325b2
     }
f325b2
 }
f325b2
 
f325b2
-static void doc_initializeForRendering(LibreOfficeKitDocument* pThis)
f325b2
+static void doc_initializeForRendering(LibreOfficeKitDocument* pThis,
f325b2
+                                       const char* pArguments)
f325b2
 {
f325b2
     ITiledRenderable* pDoc = getTiledRenderable(pThis);
f325b2
     if (pDoc)
f325b2
     {
f325b2
         doc_iniUnoCommands();
f325b2
+        uno::Sequence<beans::PropertyValue> aPropertyValues;
f325b2
+        jsonToPropertyValues(pArguments, aPropertyValues);
f325b2
         pDoc->initializeForTiledRendering();
f325b2
     }
f325b2
 }
f325b2
@@ -987,40 +1025,6 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar
f325b2
     pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
f325b2
 }
f325b2
 
f325b2
-static void jsonToPropertyValues(const char* pJSON, uno::Sequence<beans::PropertyValue>& rPropertyValues)
f325b2
-{
f325b2
-    std::vector<beans::PropertyValue> aArguments;
f325b2
-    if (pJSON)
f325b2
-    {
f325b2
-        boost::property_tree::ptree aTree;
f325b2
-        std::stringstream aStream(pJSON);
f325b2
-        boost::property_tree::read_json(aStream, aTree);
f325b2
-
f325b2
-        for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aTree)
f325b2
-        {
f325b2
-            const std::string& rType = rPair.second.get<std::string>("type");
f325b2
-            const std::string& rValue = rPair.second.get<std::string>("value");
f325b2
-
f325b2
-            beans::PropertyValue aValue;
f325b2
-            aValue.Name = OUString::fromUtf8(rPair.first.c_str());
f325b2
-            if (rType == "string")
f325b2
-                aValue.Value <<= OUString::fromUtf8(rValue.c_str());
f325b2
-            else if (rType == "boolean")
f325b2
-                aValue.Value <<= OString(rValue.c_str()).toBoolean();
f325b2
-            else if (rType == "float")
f325b2
-                aValue.Value <<= OString(rValue.c_str()).toFloat();
f325b2
-            else if (rType == "long")
f325b2
-                aValue.Value <<= OString(rValue.c_str()).toInt32();
f325b2
-            else if (rType == "unsigned short")
f325b2
-                aValue.Value <<= static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32());
f325b2
-            else
f325b2
-                SAL_WARN("desktop.lib", "jsonToPropertyValues: unhandled type '"<
f325b2
-            aArguments.push_back(aValue);
f325b2
-        }
f325b2
-    }
f325b2
-    rPropertyValues = comphelper::containerToSequence(aArguments);
f325b2
-}
f325b2
-
f325b2
 /** Class to react on finishing of a dispatched command.
f325b2
 
f325b2
     This will call a LOK_COMMAND_FINISHED callback when postUnoCommand was
f325b2
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
f325b2
index bb1813d6c28d..f0b7db0e918f 100644
f325b2
--- a/desktop/source/lib/lokandroid.cxx
f325b2
+++ b/desktop/source/lib/lokandroid.cxx
f325b2
@@ -247,7 +247,7 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_initial
f325b2
     (JNIEnv* pEnv, jobject aObject)
f325b2
 {
f325b2
     LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
f325b2
-    pDocument->pClass->initializeForRendering(pDocument);
f325b2
+    pDocument->pClass->initializeForRendering(pDocument, NULL);
f325b2
 }
f325b2
 
f325b2
 extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Office_saveAs
f325b2
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
f325b2
index 03210376c61e..93f7dca6d455 100644
f325b2
--- a/include/LibreOfficeKit/LibreOfficeKit.h
f325b2
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
f325b2
@@ -124,7 +124,8 @@ struct _LibreOfficeKitDocumentClass
f325b2
                              long* pHeight);
f325b2
 
f325b2
     /// @see lok::Document::initializeForRendering().
f325b2
-    void (*initializeForRendering) (LibreOfficeKitDocument* pThis);
f325b2
+    void (*initializeForRendering) (LibreOfficeKitDocument* pThis,
f325b2
+                                    const char* pArguments);
f325b2
 
f325b2
     /// @see lok::Document::registerCallback().
f325b2
     void (*registerCallback) (LibreOfficeKitDocument* pThis,
f325b2
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
f325b2
index c474195de213..152d0f415f17 100644
f325b2
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
f325b2
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
f325b2
@@ -156,10 +156,22 @@ public:
f325b2
      * needed to render the document correctly using tiled rendering. This
f325b2
      * method has to be called right after documentLoad() in case any of the
f325b2
      * tiled rendering methods are to be used later.
f325b2
+     *
f325b2
+     * Example argument string for text documents:
f325b2
+     *
f325b2
+     * {
f325b2
+     *     ".uno:HideWhitespace":
f325b2
+     *     {
f325b2
+     *         "type": "boolean",
f325b2
+     *         "value": "true"
f325b2
+     *     }
f325b2
+     * }
f325b2
+     *
f325b2
+     * @param pArguments arguments of the rendering
f325b2
      */
f325b2
-    inline void initializeForRendering()
f325b2
+    inline void initializeForRendering(const char* pArguments = NULL)
f325b2
     {
f325b2
-        mpDoc->pClass->initializeForRendering(mpDoc);
f325b2
+        mpDoc->pClass->initializeForRendering(mpDoc, pArguments);
f325b2
     }
f325b2
 
f325b2
     /**
f325b2
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
f325b2
index 47ada280dde3..802d85dea553 100644
f325b2
--- a/libreofficekit/source/gtk/lokdocview.cxx
f325b2
+++ b/libreofficekit/source/gtk/lokdocview.cxx
f325b2
@@ -530,7 +530,7 @@ static gboolean postDocumentLoad(gpointer pData)
f325b2
     LOKDocViewPrivate& priv = getPrivate(pLOKDocView);
f325b2
 
f325b2
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
f325b2
-    priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument);
f325b2
+    priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, nullptr);
f325b2
     priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pLOKDocView);
f325b2
     priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips);
f325b2
     g_timeout_add(600, handleTimeout, pLOKDocView);
f325b2
-- 
f325b2
2.12.0
f325b2