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 | |
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')
-rw-r--r-- | sc/inc/chgtrack.hxx | 3 | ||||
-rw-r--r-- | sc/inc/docuno.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/chgtrack.cxx | 30 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 8 |
4 files changed, 16 insertions, 27 deletions
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx index 544e2566fdba..146521538943 100644 --- a/sc/inc/chgtrack.hxx +++ b/sc/inc/chgtrack.hxx @@ -43,6 +43,7 @@ class ScFormulaCell; class ScChangeAction; class ScChangeTrack; class ScAppOptions; +namespace tools { class JsonWriter; } class ScActionColorChanger { @@ -1146,7 +1147,7 @@ public: SC_DLLPUBLIC ScChangeTrack* Clone( ScDocument* pDocument ) const; static void MergeActionState( ScChangeAction* pAct, const ScChangeAction* pOtherAct ); /// Get info about all ScChangeAction elements. - OUString GetChangeTrackInfo(); + void GetChangeTrackInfo(tools::JsonWriter&); }; #endif diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 7c9c87a4f109..02bd4c04981d 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -375,7 +375,7 @@ public: virtual PointerStyle getPointer() override; /// @see vcl::ITiledRenderable::getTrackedChanges(). - OUString getTrackedChanges() override; + void getTrackedChanges(tools::JsonWriter&) override; /// @see vcl::ITiledRenderable::setClientVisibleArea(). virtual void setClientVisibleArea(const tools::Rectangle& rRectangle) override; 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: */ diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 4592bdb9c04d..7e5dd7fe33dd 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -940,17 +940,13 @@ PointerStyle ScModelObj::getPointer() return pGridWindow->GetPointer(); } -OUString ScModelObj::getTrackedChanges() +void ScModelObj::getTrackedChanges(tools::JsonWriter& rJson) { - OUString aRet; - if (pDocShell) { if (ScChangeTrack* pChangeTrack = pDocShell->GetDocument().GetChangeTrack()) - aRet = pChangeTrack->GetChangeTrackInfo(); + pChangeTrack->GetChangeTrackInfo(rJson); } - - return aRet; } void ScModelObj::setClientVisibleArea(const tools::Rectangle& rRectangle) |