summaryrefslogtreecommitdiff
path: root/sc/source/ui/app
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2020-01-13 16:24:06 +0000
committerMichael Meeks <michael.meeks@collabora.com>2020-01-13 20:01:17 +0100
commit62ad8f6f42a5f8c0150770b3490988bac62178e9 (patch)
treefc209a9ad935c3666fc569a1e809835bc8e0e431 /sc/source/ui/app
parent96ab492b74d9e64051d82f220f65cadedf34a878 (diff)
mobile: escape JSON for function wizard, and emit only on mobile.
Otherwise typing "-> wa" into a cell gives JS exceptions. Change-Id: I5303186fe9f84e055d65cf1929ccf5a7a20cae35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86706 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sc/source/ui/app')
-rw-r--r--sc/source/ui/app/inputhdl.cxx21
1 files changed, 16 insertions, 5 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 52e2ee5bb546..acf924de9397 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -26,6 +26,7 @@
#include <editeng/eeitem.hxx>
#include <sfx2/app.hxx>
+#include <sfx2/lokhelper.hxx>
#include <editeng/acorrcfg.hxx>
#include <formula/errorcodes.hxx>
#include <editeng/adjustitem.hxx>
@@ -1281,9 +1282,21 @@ bool ScInputHandler::GetFuncName( OUString& aStart, OUString& aResult )
return true;
}
+namespace {
+ /// Rid ourselves of unwanted " quoted json characters.
+ OString escapeJSON(const OUString &aStr)
+ {
+ OUString aEscaped = aStr;
+ aEscaped = aEscaped.replaceAll("\n", " ");
+ aEscaped = aEscaped.replaceAll("\"", "'");
+ return OUStringToOString(aEscaped, RTL_TEXTENCODING_UTF8);
+ }
+}
+
void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec )
{
- if (comphelper::LibreOfficeKit::isActive())
+ if (comphelper::LibreOfficeKit::isActive() &&
+ comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()))
{
SfxViewShell* pViewShell = SfxViewShell::Current();
if (pViewShell && rFuncStrVec.size())
@@ -1315,12 +1328,10 @@ void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec
{
aPayload.append("{");
aPayload.append("\"signature\": \"");
- OUString aSignature = ppFDesc->getSignature();
- aPayload.append(OUStringToOString(aSignature, RTL_TEXTENCODING_UTF8));
+ aPayload.append(escapeJSON(ppFDesc->getSignature()));
aPayload.append("\", ");
aPayload.append("\"description\": \"");
- OUString aFuncDescr = ppFDesc->getDescription();
- aPayload.append(OUStringToOString(aFuncDescr, RTL_TEXTENCODING_UTF8));
+ aPayload.append(escapeJSON(ppFDesc->getDescription()));
aPayload.append("\"}, ");
}
}