summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-03-24 11:29:59 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2022-03-28 11:33:37 +0200
commitbbf7906afda1e4147b81d5fd703d113f04244079 (patch)
tree0efa64fd3e7cc6f1c5c414707d7a00e83e108b37
parentNotebookbar style previews: use CJK or CTL fonts if needed (diff)
downloadcore-bbf7906afda1e4147b81d5fd703d113f04244079.tar.gz
core-bbf7906afda1e4147b81d5fd703d113f04244079.zip
lok: use JsonWriter for annotations notification
This will unify received objects in LOK. boost::property_tree used "string" for number values we expect them to be a "number" type. Change-Id: Ie90d7e2dd98bb371fc09878dcc6e96f4cdf73f3b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132054 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
-rw-r--r--sd/source/core/annotations/Annotation.cxx55
1 files changed, 27 insertions, 28 deletions
diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx
index d1562581c7bd..22e7a7fe24f2 100644
--- a/sd/source/core/annotations/Annotation.cxx
+++ b/sd/source/core/annotations/Annotation.cxx
@@ -21,8 +21,6 @@
#include <Annotation.hxx>
-#include <boost/property_tree/json_parser.hpp>
-
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <comphelper/processfactory.hxx>
@@ -37,6 +35,8 @@
#include <notifydocumentevent.hxx>
+#include <tools/json_writer.hxx>
+
using namespace css;
namespace com::sun::star::uno { class XComponentContext; }
@@ -341,34 +341,33 @@ namespace
{
std::string lcl_LOKGetCommentPayload(CommentNotificationType nType, uno::Reference<office::XAnnotation> const & rxAnnotation)
{
- boost::property_tree::ptree aAnnotation;
- aAnnotation.put("action", (nType == CommentNotificationType::Add ? "Add" :
- (nType == CommentNotificationType::Remove ? "Remove" :
- (nType == CommentNotificationType::Modify ? "Modify" : "???"))));
- aAnnotation.put("id", sd::getAnnotationId(rxAnnotation));
- if (nType != CommentNotificationType::Remove && rxAnnotation.is())
+ ::tools::JsonWriter aJsonWriter;
{
- aAnnotation.put("id", sd::getAnnotationId(rxAnnotation));
- aAnnotation.put("author", rxAnnotation->getAuthor());
- aAnnotation.put("dateTime", utl::toISO8601(rxAnnotation->getDateTime()));
- uno::Reference<text::XText> xText(rxAnnotation->getTextRange());
- aAnnotation.put("text", xText->getString());
- const SdPage* pPage = sd::getAnnotationPage(rxAnnotation);
- aAnnotation.put("parthash", pPage ? OString::number(pPage->GetHashCode()) : OString());
- geometry::RealPoint2D const & rPoint = rxAnnotation->getPosition();
- geometry::RealSize2D const & rSize = rxAnnotation->getSize();
- ::tools::Rectangle aRectangle(Point(rPoint.X * 100.0, rPoint.Y * 100.0), Size(rSize.Width * 100.0, rSize.Height * 100.0));
- aRectangle = OutputDevice::LogicToLogic(aRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
- OString sRectangle = aRectangle.toString();
- aAnnotation.put("rectangle", sRectangle.getStr());
+ auto aCommentNode = aJsonWriter.startNode("comment");
+
+ aJsonWriter.put("action", (nType == CommentNotificationType::Add ? "Add" :
+ (nType == CommentNotificationType::Remove ? "Remove" :
+ (nType == CommentNotificationType::Modify ? "Modify" : "???"))));
+ aJsonWriter.put("id", sd::getAnnotationId(rxAnnotation));
+
+ if (nType != CommentNotificationType::Remove && rxAnnotation.is())
+ {
+ aJsonWriter.put("id", sd::getAnnotationId(rxAnnotation));
+ aJsonWriter.put("author", rxAnnotation->getAuthor());
+ aJsonWriter.put("dateTime", utl::toISO8601(rxAnnotation->getDateTime()));
+ uno::Reference<text::XText> xText(rxAnnotation->getTextRange());
+ aJsonWriter.put("text", xText->getString());
+ const SdPage* pPage = sd::getAnnotationPage(rxAnnotation);
+ aJsonWriter.put("parthash", pPage ? OString::number(pPage->GetHashCode()) : OString());
+ geometry::RealPoint2D const & rPoint = rxAnnotation->getPosition();
+ geometry::RealSize2D const & rSize = rxAnnotation->getSize();
+ ::tools::Rectangle aRectangle(Point(rPoint.X * 100.0, rPoint.Y * 100.0), Size(rSize.Width * 100.0, rSize.Height * 100.0));
+ aRectangle = OutputDevice::LogicToLogic(aRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+ OString sRectangle = aRectangle.toString();
+ aJsonWriter.put("rectangle", sRectangle.getStr());
+ }
}
-
- boost::property_tree::ptree aTree;
- aTree.add_child("comment", aAnnotation);
- std::stringstream aStream;
- boost::property_tree::write_json(aStream, aTree);
-
- return aStream.str();
+ return aJsonWriter.extractData();
}
} // anonymous ns