diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-11-18 14:59:51 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-11-18 16:39:17 +0100 |
commit | 4bddfc00d25a42917db79ceaf0547c2e792132c4 (patch) | |
tree | e74e06da83f92501b6a96b3d80ae1bae1bce70a8 /desktop | |
parent | 0a779d1dc3e08a9f5407f96b98d7fffa3e789a79 (diff) |
lok::Document::initializeForRendering: support init. arguments
Change-Id: I8aaf19a50f25f495cb87fba7ff6a4b0f56ed7d80
Diffstat (limited to 'desktop')
-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 |
3 files changed, 43 insertions, 39 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 |