diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-06-15 20:32:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-06-18 10:54:10 +0200 |
commit | c8bed6445b244a5d9021dbd9a2ff19d80c03917b (patch) | |
tree | cdfdf457f2617b4480961009e6b50a645d48c592 /desktop | |
parent | tdf#128964 Add time pause/resume button to Impress Presenter console (diff) | |
download | core-c8bed6445b244a5d9021dbd9a2ff19d80c03917b.tar.gz core-c8bed6445b244a5d9021dbd9a2ff19d80c03917b.zip |
new json writer for LOK
we shave about 3 memory copies off in the process, and
make the class play nicely with our string types.
Change-Id: I1f614fb35b1de499ac99e3b33ac638ad81054bed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96393
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 8b3ba76bfaf9..2843c0f5c250 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -118,6 +118,7 @@ #include <vcl/svapp.hxx> #include <unotools/resmgr.hxx> #include <tools/fract.hxx> +#include <tools/json_writer.hxx> #include <svtools/ctrltool.hxx> #include <svtools/langtab.hxx> #include <vcl/floatwin.hxx> @@ -4658,47 +4659,41 @@ static char* getTrackedChanges(LibreOfficeKitDocument* pThis) LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); uno::Reference<document::XRedlinesSupplier> xRedlinesSupplier(pDocument->mxComponent, uno::UNO_QUERY); - std::stringstream aStream; + tools::JsonWriter aJson; // We want positions of the track changes also which is not possible from // UNO. Enable positioning information for text documents only for now, so // construct the tracked changes JSON from inside the sw/, not here using UNO if (doc_getDocumentType(pThis) != LOK_DOCTYPE_TEXT && xRedlinesSupplier.is()) { + auto redlinesNode = aJson.startNode("redlines"); uno::Reference<container::XEnumeration> xRedlines = xRedlinesSupplier->getRedlines()->createEnumeration(); - boost::property_tree::ptree aRedlines; for (size_t nIndex = 0; xRedlines->hasMoreElements(); ++nIndex) { uno::Reference<beans::XPropertySet> xRedline(xRedlines->nextElement(), uno::UNO_QUERY); - boost::property_tree::ptree aRedline; - aRedline.put("index", nIndex); + auto redlineNode = aJson.startNode(""); + aJson.put("index", nIndex); OUString sAuthor; xRedline->getPropertyValue("RedlineAuthor") >>= sAuthor; - aRedline.put("author", sAuthor.toUtf8().getStr()); + aJson.put("author", sAuthor); OUString sType; xRedline->getPropertyValue("RedlineType") >>= sType; - aRedline.put("type", sType.toUtf8().getStr()); + aJson.put("type", sType); OUString sComment; xRedline->getPropertyValue("RedlineComment") >>= sComment; - aRedline.put("comment", sComment.toUtf8().getStr()); + aJson.put("comment", sComment); OUString sDescription; xRedline->getPropertyValue("RedlineDescription") >>= sDescription; - aRedline.put("description", sDescription.toUtf8().getStr()); + aJson.put("description", sDescription); util::DateTime aDateTime; xRedline->getPropertyValue("RedlineDateTime") >>= aDateTime; OUString sDateTime = utl::toISO8601(aDateTime); - aRedline.put("dateTime", sDateTime.toUtf8().getStr()); - - aRedlines.push_back(std::make_pair("", aRedline)); + aJson.put("dateTime", sDateTime); } - - boost::property_tree::ptree aTree; - aTree.add_child("redlines", aRedlines); - boost::property_tree::write_json(aStream, aTree); } else { @@ -4708,12 +4703,10 @@ static char* getTrackedChanges(LibreOfficeKitDocument* pThis) SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } - OUString aTrackedChanges = pDoc->getTrackedChanges(); - aStream << aTrackedChanges.toUtf8(); + pDoc->getTrackedChanges(aJson); } - char* pJson = strdup(aStream.str().c_str()); - return pJson; + return aJson.extractData(); } |