summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-11-24 15:03:27 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2021-04-28 12:13:10 +0200
commitc6664cf13d41b6ed38c38ac811198b630c333f85 (patch)
tree816f35e77e59af50400a9f7d48476d15d2a54744 /tools
parent16f61b20ebda66f44170c99adc7a339956895f53 (diff)
jsdialog: fix arrays in JsonWriter output
Change-Id: I5638b1b02afcdd57b16b60d83d3d15da45866060 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107066 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114767 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/misc/json_writer.cxx49
1 files changed, 35 insertions, 14 deletions
diff --git a/tools/source/misc/json_writer.cxx b/tools/source/misc/json_writer.cxx
index 814f6180a85f..c326201eb9e5 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -120,21 +120,8 @@ void JsonWriter::endStruct()
mbFirstFieldInNode = false;
}
-void JsonWriter::put(const char* pPropName, const OUString& rPropVal)
+void JsonWriter::writeEscapedOUString(const OUString& rPropVal)
{
- auto nPropNameLength = strlen(pPropName);
- auto nWorstCasePropValLength = rPropVal.getLength() * 2;
- ensureSpace(nPropNameLength + nWorstCasePropValLength + 8);
-
- addCommaBeforeField();
-
- *mPos = '"';
- ++mPos;
- memcpy(mPos, pPropName, nPropNameLength);
- mPos += nPropNameLength;
- memcpy(mPos, "\": \"", 4);
- mPos += 4;
-
// Convert from UTF-16 to UTF-8 and perform escaping
sal_Int32 i = 0;
while (i < rPropVal.getLength())
@@ -208,6 +195,24 @@ void JsonWriter::put(const char* pPropName, const OUString& rPropVal)
++mPos;
}
}
+}
+
+void JsonWriter::put(const char* pPropName, const OUString& rPropVal)
+{
+ auto nPropNameLength = strlen(pPropName);
+ auto nWorstCasePropValLength = rPropVal.getLength() * 2;
+ ensureSpace(nPropNameLength + nWorstCasePropValLength + 8);
+
+ addCommaBeforeField();
+
+ *mPos = '"';
+ ++mPos;
+ memcpy(mPos, pPropName, nPropNameLength);
+ mPos += nPropNameLength;
+ memcpy(mPos, "\": \"", 4);
+ mPos += 4;
+
+ writeEscapedOUString(rPropVal);
*mPos = '"';
++mPos;
@@ -365,6 +370,22 @@ void JsonWriter::put(const char* pPropName, bool nPropVal)
mPos += strlen(pVal);
}
+void JsonWriter::putSimpleValue(const OUString& rPropVal)
+{
+ auto nWorstCasePropValLength = rPropVal.getLength() * 2;
+ ensureSpace(nWorstCasePropValLength + 4);
+
+ addCommaBeforeField();
+
+ *mPos = '"';
+ ++mPos;
+
+ writeEscapedOUString(rPropVal);
+
+ *mPos = '"';
+ ++mPos;
+}
+
void JsonWriter::putRaw(const rtl::OStringBuffer& rRawBuf)
{
ensureSpace(rRawBuf.getLength() + 2);