diff options
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 4 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 76 | ||||
-rw-r--r-- | desktop/source/lib/lokandroid.cxx | 2 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 3 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 16 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 2 |
6 files changed, 60 insertions, 43 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 3b7e2741778e..0874eeddba1b 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -283,7 +283,7 @@ void DesktopLOKTest::testSearchCalc() LibLibreOffice_Impl aOffice; comphelper::LibreOfficeKit::setActive(); LibLODocument_Impl* pDocument = loadDoc("search.ods"); - pDocument->pClass->initializeForRendering(pDocument); + pDocument->pClass->initializeForRendering(pDocument, nullptr); pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( @@ -406,7 +406,7 @@ void DesktopLOKTest::testRowColumnHeaders() */ LibLODocument_Impl* pDocument = loadDoc("search.ods"); - pDocument->pClass->initializeForRendering(pDocument); + pDocument->pClass->initializeForRendering(pDocument, nullptr); boost::property_tree::ptree aTree; char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders"); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 838073fa57a7..9f97dbcce32d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -261,6 +261,40 @@ static OUString getAbsoluteURL(const char* pURL) return OUString(); } +static void jsonToPropertyValues(const char* pJSON, uno::Sequence<beans::PropertyValue>& rPropertyValues) +{ + std::vector<beans::PropertyValue> aArguments; + if (pJSON) + { + boost::property_tree::ptree aTree; + std::stringstream aStream(pJSON); + boost::property_tree::read_json(aStream, aTree); + + for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aTree) + { + const std::string& rType = rPair.second.get<std::string>("type"); + const std::string& rValue = rPair.second.get<std::string>("value"); + + beans::PropertyValue aValue; + aValue.Name = OUString::fromUtf8(rPair.first.c_str()); + if (rType == "string") + aValue.Value <<= OUString::fromUtf8(rValue.c_str()); + else if (rType == "boolean") + aValue.Value <<= OString(rValue.c_str()).toBoolean(); + else if (rType == "float") + aValue.Value <<= OString(rValue.c_str()).toFloat(); + else if (rType == "long") + aValue.Value <<= OString(rValue.c_str()).toInt32(); + else if (rType == "unsigned short") + aValue.Value <<= static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32()); + else + SAL_WARN("desktop.lib", "jsonToPropertyValues: unhandled type '"<<rType<<"'"); + aArguments.push_back(aValue); + } + } + rPropertyValues = comphelper::containerToSequence(aArguments); +} + extern "C" { @@ -281,7 +315,8 @@ void doc_paintTile(LibreOfficeKitDocument* pThis, static void doc_getDocumentSize(LibreOfficeKitDocument* pThis, long* pWidth, long* pHeight); -static void doc_initializeForRendering(LibreOfficeKitDocument* pThis); +static void doc_initializeForRendering(LibreOfficeKitDocument* pThis, + const char* pArguments); static void doc_registerCallback(LibreOfficeKitDocument* pThis, LibreOfficeKitCallback pCallback, @@ -939,12 +974,15 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis, } } -static void doc_initializeForRendering(LibreOfficeKitDocument* pThis) +static void doc_initializeForRendering(LibreOfficeKitDocument* pThis, + const char* pArguments) { ITiledRenderable* pDoc = getTiledRenderable(pThis); if (pDoc) { doc_iniUnoCommands(); + uno::Sequence<beans::PropertyValue> aPropertyValues; + jsonToPropertyValues(pArguments, aPropertyValues); pDoc->initializeForTiledRendering(); } } @@ -988,40 +1026,6 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar pDoc->postKeyEvent(nType, nCharCode, nKeyCode); } -static void jsonToPropertyValues(const char* pJSON, uno::Sequence<beans::PropertyValue>& rPropertyValues) -{ - std::vector<beans::PropertyValue> aArguments; - if (pJSON) - { - boost::property_tree::ptree aTree; - std::stringstream aStream(pJSON); - boost::property_tree::read_json(aStream, aTree); - - for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aTree) - { - const std::string& rType = rPair.second.get<std::string>("type"); - const std::string& rValue = rPair.second.get<std::string>("value"); - - beans::PropertyValue aValue; - aValue.Name = OUString::fromUtf8(rPair.first.c_str()); - if (rType == "string") - aValue.Value <<= OUString::fromUtf8(rValue.c_str()); - else if (rType == "boolean") - aValue.Value <<= OString(rValue.c_str()).toBoolean(); - else if (rType == "float") - aValue.Value <<= OString(rValue.c_str()).toFloat(); - else if (rType == "long") - aValue.Value <<= OString(rValue.c_str()).toInt32(); - else if (rType == "unsigned short") - aValue.Value <<= static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32()); - else - SAL_WARN("desktop.lib", "jsonToPropertyValues: unhandled type '"<<rType<<"'"); - aArguments.push_back(aValue); - } - } - rPropertyValues = comphelper::containerToSequence(aArguments); -} - /** Class to react on finishing of a dispatched command. This will call a LOK_COMMAND_FINISHED callback when postUnoCommand was diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx index 0c360d3c2b9c..9f1579621fc1 100644 --- a/desktop/source/lib/lokandroid.cxx +++ b/desktop/source/lib/lokandroid.cxx @@ -256,7 +256,7 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_initial (JNIEnv* pEnv, jobject aObject) { LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject); - pDocument->pClass->initializeForRendering(pDocument); + pDocument->pClass->initializeForRendering(pDocument, NULL); } extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Office_saveAs diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 03210376c61e..93f7dca6d455 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -124,7 +124,8 @@ struct _LibreOfficeKitDocumentClass long* pHeight); /// @see lok::Document::initializeForRendering(). - void (*initializeForRendering) (LibreOfficeKitDocument* pThis); + void (*initializeForRendering) (LibreOfficeKitDocument* pThis, + const char* pArguments); /// @see lok::Document::registerCallback(). void (*registerCallback) (LibreOfficeKitDocument* pThis, diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index d21abddd0448..a3c0cd8c0f6a 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -156,10 +156,22 @@ public: * needed to render the document correctly using tiled rendering. This * method has to be called right after documentLoad() in case any of the * tiled rendering methods are to be used later. + * + * Example argument string for text documents: + * + * { + * ".uno:HideWhitespace": + * { + * "type": "boolean", + * "value": "true" + * } + * } + * + * @param pArguments arguments of the rendering */ - inline void initializeForRendering() + inline void initializeForRendering(const char* pArguments = NULL) { - mpDoc->pClass->initializeForRendering(mpDoc); + mpDoc->pClass->initializeForRendering(mpDoc, pArguments); } /** diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 5c5336da1fe3..55822cdbc0db 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -530,7 +530,7 @@ static gboolean postDocumentLoad(gpointer pData) LOKDocViewPrivate& priv = getPrivate(pLOKDocView); priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId); - priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument); + priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, nullptr); priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pLOKDocView); priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips); g_timeout_add(600, handleTimeout, pLOKDocView); |