diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-06-26 09:06:18 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-06-28 08:51:59 +0200 |
commit | f008bd0277001226f2dd695836a019c9b9c84799 (patch) | |
tree | 392598edb0da3f98d176b662238c3e9ebd4863e4 /sd | |
parent | d53a4f126e9d3ec0a63684d4c7af3108f352791c (diff) |
sd: send annotation position for LOKit, fix multiple annotations
This adds support to send annotation position in the document when
sending the available annotations using LOKit.
It also fixes an issue with the json structure for the annotations,
which sends multiple annotation objects with the same (empty) key,
that after parsing reduces to only one (so only one of the many
annotations is present). This fix changes that so annotation
objects have each its own unique key.
Change-Id: I9d994383d6ee322f27f1426be5bd96ac81e8e609
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97329
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/core/annotations/Annotation.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx index bd0feacf8a68..bff000a229cd 100644 --- a/sd/source/core/annotations/Annotation.cxx +++ b/sd/source/core/annotations/Annotation.cxx @@ -433,6 +433,12 @@ std::string lcl_LOKGetCommentPayload(CommentNotificationType nType, Reference<XA 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()); } boost::property_tree::ptree aTree; diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index c72ef5725b89..ad460509dda0 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -118,6 +118,7 @@ #include <drawinglayer/primitive2d/structuretagprimitive2d.hxx> #include <sfx2/lokcharthelper.hxx> +#include <tools/gen.hxx> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> #include <tools/json_writer.hxx> @@ -2407,13 +2408,21 @@ void SdXImpressDocument::getPostIts(::tools::JsonWriter& rJsonWriter) for (const uno::Reference<office::XAnnotation>& xAnnotation : aPageAnnotations) { - auto commentNode = rJsonWriter.startNode(""); - rJsonWriter.put("id", sd::getAnnotationId(xAnnotation)); + sal_uInt32 nID = sd::getAnnotationId(xAnnotation); + OString nodeName = "comment" + OString::number(nID); + auto commentNode = rJsonWriter.startNode(nodeName.getStr()); + rJsonWriter.put("id", nID); rJsonWriter.put("author", xAnnotation->getAuthor()); rJsonWriter.put("dateTime", utl::toISO8601(xAnnotation->getDateTime())); uno::Reference<text::XText> xText(xAnnotation->getTextRange()); rJsonWriter.put("text", xText->getString()); rJsonWriter.put("parthash", pPage->GetHashCode()); + geometry::RealPoint2D const & rPoint = xAnnotation->getPosition(); + geometry::RealSize2D const & rSize = xAnnotation->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(); + rJsonWriter.put("rectangle", sRectangle.getStr()); } } } |