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 /sc/source/core | |
parent | 41d75ee814d71513922a12fae82f2e7eecbcd5f5 (diff) |
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 'sc/source/core')
-rw-r--r-- | sc/source/core/tool/chgtrack.cxx | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index 3a45a5f3be83..f734224ce3fa 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -47,6 +47,7 @@ #include <unotools/useroptions.hxx> #include <unotools/datetime.hxx> #include <sfx2/sfxsids.hrc> +#include <tools/json_writer.hxx> #include <algorithm> #include <memory> #include <boost/property_tree/json_parser.hpp> @@ -4676,34 +4677,31 @@ void ScChangeTrack::MergeActionState( ScChangeAction* pAct, const ScChangeAction } /// Get info about a single ScChangeAction element. -static void lcl_getTrackedChange(ScDocument* pDoc, int nIndex, const ScChangeAction* pAction, boost::property_tree::ptree& rRedlines) +static void lcl_getTrackedChange(ScDocument* pDoc, int nIndex, const ScChangeAction* pAction, tools::JsonWriter& rRedlines) { if (pAction->GetType() == SC_CAT_CONTENT) { - boost::property_tree::ptree aRedline; - aRedline.put("index", nIndex); + auto redlinesNode = rRedlines.startNode(""); + rRedlines.put("index", nIndex); - const OUString& sAuthor = pAction->GetUser(); - aRedline.put("author", sAuthor.toUtf8().getStr()); + rRedlines.put("author", pAction->GetUser()); - aRedline.put("type", "Modify"); + rRedlines.put("type", "Modify"); - aRedline.put("comment", pAction->GetComment().toUtf8().getStr()); + rRedlines.put("comment", pAction->GetComment()); OUString aDescription; pAction->GetDescription(aDescription, pDoc, true); - aRedline.put("description", aDescription); + rRedlines.put("description", aDescription); OUString sDateTime = utl::toISO8601(pAction->GetDateTimeUTC().GetUNODateTime()); - aRedline.put("dateTime", sDateTime.toUtf8().getStr()); - - rRedlines.push_back(std::make_pair("", aRedline)); + rRedlines.put("dateTime", sDateTime); } } -OUString ScChangeTrack::GetChangeTrackInfo() +void ScChangeTrack::GetChangeTrackInfo(tools::JsonWriter& aRedlines) { - boost::property_tree::ptree aRedlines; + auto redlinesNode = aRedlines.startNode("redlines"); ScChangeAction* pAction = GetFirst(); if (pAction) @@ -4717,12 +4715,6 @@ OUString ScChangeTrack::GetChangeTrackInfo() lcl_getTrackedChange(pDoc, i++, pAction, aRedlines); } } - - boost::property_tree::ptree aTree; - aTree.add_child("redlines", aRedlines); - std::stringstream aStream; - boost::property_tree::write_json(aStream, aTree); - return OUString::fromUtf8(aStream.str().c_str()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |