summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-06-15 20:32:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-06-18 10:54:10 +0200
commitc8bed6445b244a5d9021dbd9a2ff19d80c03917b (patch)
treecdfdf457f2617b4480961009e6b50a645d48c592 /sw
parent41d75ee814d71513922a12fae82f2e7eecbcd5f5 (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 'sw')
-rw-r--r--sw/inc/unotxdoc.hxx2
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx36
2 files changed, 14 insertions, 24 deletions
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 8c6a1358520c..16780ce2edeb 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -436,7 +436,7 @@ public:
/// @see vcl::ITiledRenderable::getPointer().
virtual PointerStyle getPointer() override;
/// @see vcl::ITiledRenderable::getTrackedChanges().
- OUString getTrackedChanges() override;
+ void getTrackedChanges(tools::JsonWriter&) override;
/// @see vcl::ITiledRenderable::getTrackedChangeAuthors().
OUString getTrackedChangeAuthors() override;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 15be728d74af..0d934c32f39c 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -161,6 +161,7 @@
#include <redline.hxx>
#include <DocumentRedlineManager.hxx>
#include <xmloff/odffields.hxx>
+#include <tools/json_writer.hxx>
#define TWIPS_PER_PIXEL 15
@@ -3255,9 +3256,9 @@ PointerStyle SwXTextDocument::getPointer()
return pWrtShell->GetView().GetEditWin().GetPointer();
}
-OUString SwXTextDocument::getTrackedChanges()
+void SwXTextDocument::getTrackedChanges(tools::JsonWriter& rJson)
{
- boost::property_tree::ptree aTrackedChanges;
+ auto redlinesNode = rJson.startNode("redlines");
// Disable since usability is very low beyond some small number of changes.
static bool bDisableRedlineComments = getenv("DISABLE_REDLINE") != nullptr;
@@ -3267,19 +3268,17 @@ OUString SwXTextDocument::getTrackedChanges()
= pDocShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
{
- boost::property_tree::ptree aTrackedChange;
- aTrackedChange.put("index", rRedlineTable[i]->GetId());
- aTrackedChange.put("author", rRedlineTable[i]->GetAuthorString(1).toUtf8().getStr());
- aTrackedChange.put("type", SwRedlineTypeToOUString(
- rRedlineTable[i]->GetRedlineData().GetType())
- .toUtf8()
- .getStr());
- aTrackedChange.put("comment",
- rRedlineTable[i]->GetRedlineData().GetComment().toUtf8().getStr());
- aTrackedChange.put("description", rRedlineTable[i]->GetDescr().toUtf8().getStr());
+ auto redlineNode = rJson.startNode("");
+ rJson.put("index", rRedlineTable[i]->GetId());
+ rJson.put("author", rRedlineTable[i]->GetAuthorString(1));
+ rJson.put("type", SwRedlineTypeToOUString(
+ rRedlineTable[i]->GetRedlineData().GetType()));
+ rJson.put("comment",
+ rRedlineTable[i]->GetRedlineData().GetComment());
+ rJson.put("description", rRedlineTable[i]->GetDescr());
OUString sDateTime = utl::toISO8601(
rRedlineTable[i]->GetRedlineData().GetTimeStamp().GetUNODateTime());
- aTrackedChange.put("dateTime", sDateTime.toUtf8().getStr());
+ rJson.put("dateTime", sDateTime);
SwContentNode* pContentNd = rRedlineTable[i]->GetContentNode();
SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current());
@@ -3299,19 +3298,10 @@ OUString SwXTextDocument::getTrackedChanges()
aRects.push_back(rNextRect.SVRect().toString());
const OString sRects = comphelper::string::join("; ", aRects);
- aTrackedChange.put("textRange", sRects.getStr());
+ rJson.put("textRange", sRects);
}
-
- aTrackedChanges.push_back(std::make_pair("", aTrackedChange));
}
}
-
- boost::property_tree::ptree aTree;
- aTree.add_child("redlines", aTrackedChanges);
- std::stringstream aStream;
- boost::property_tree::write_json(aStream, aTree);
-
- return OUString::fromUtf8(aStream.str().c_str());
}
OUString SwXTextDocument::getTrackedChangeAuthors()