kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

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

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