summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-11-18 14:59:51 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-11-18 16:44:34 +0100
commitb95434954822dfa8a42cf96a647985c3f491896f (patch)
tree12fcf6b2ea8a3171de594a5633ef3898fbf17015 /desktop
parentc23afd9232a1b73d8838b3912ba2a4361ffe9fd1 (diff)
lok::Document::initializeForRendering: support init. arguments
(cherry picked from commit 4bddfc00d25a42917db79ceaf0547c2e792132c4) Conflicts: libreofficekit/source/gtk/lokdocview.cxx Change-Id: I8aaf19a50f25f495cb87fba7ff6a4b0f56ed7d80
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx4
-rw-r--r--desktop/source/lib/init.cxx76
-rw-r--r--desktop/source/lib/lokandroid.cxx2
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 e289be8a0497..fa432de49856 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -287,7 +287,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(
@@ -410,7 +410,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 f62fcde62c92..dce9644a704f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -270,6 +270,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"
{
@@ -290,7 +324,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,
@@ -947,12 +982,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();
}
}
@@ -996,40 +1034,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