diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-11-24 15:03:27 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-12-03 08:45:24 +0100 |
commit | 7fc2fe5c612f95b9624f49b5fdea2d3c8c94caf1 (patch) | |
tree | 66c04c37a6eff2d6abae5886bff4edfd10dcbfb7 /tools/source | |
parent | 1d3d958e0089429e05265cfd13dc540fce5887d1 (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>
Diffstat (limited to 'tools/source')
-rw-r--r-- | tools/source/misc/json_writer.cxx | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/tools/source/misc/json_writer.cxx b/tools/source/misc/json_writer.cxx index 1ccee8569480..a0e0280b840e 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 for (int i = 0; i < rPropVal.getLength(); ++i) { @@ -175,6 +162,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; @@ -332,6 +337,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); |