From 334d3aff8d411ee5f2d612c8899a171716b8a3d1 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 27 Oct 2023 12:04:29 +0100 Subject: calc comment boost::property_tree::ptree use quotes comment id numbers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit which does not conform to JSON standard and means that added/deleted comment ids are strings and not numbers as created by the related getPostIts found during: https://github.com/CollaboraOnline/online/issues/7334 where if the regular updating of comments via getPostIts doesn't happen then deleting/adding comments doesn't appear to work boost bug report found as: https://svn.boost.org/trac/boost/ticket/9721 https://marc.info/?l=boost-bugs&m=139351272302586&w=2 Change-Id: I0c43588ce1f92b83fb82c582f0c2c18a6672dc54 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158561 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sc/source/ui/docshell/docsh4.cxx | 48 +++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 8b2599ab2684..0ef5be3c50e8 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -19,8 +19,6 @@ #include -#include - #include #include @@ -53,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -2543,32 +2542,31 @@ void ScDocShell::LOKCommentNotify(LOKCommentNotificationType nType, const ScDocu comphelper::LibreOfficeKit::isTiledAnnotations() ) return; - boost::property_tree::ptree aAnnotation; - aAnnotation.put("action", (nType == LOKCommentNotificationType::Add ? "Add" : - (nType == LOKCommentNotificationType::Remove ? "Remove" : - (nType == LOKCommentNotificationType::Modify ? "Modify" : "???")))); + tools::JsonWriter aAnnotation; + { + auto commentNode = aAnnotation.startNode("comment"); + aAnnotation.put("action", (nType == LOKCommentNotificationType::Add ? "Add" : + (nType == LOKCommentNotificationType::Remove ? "Remove" : + (nType == LOKCommentNotificationType::Modify ? "Modify" : "???")))); - assert(pNote); - aAnnotation.put("id", pNote->GetId()); - aAnnotation.put("tab", rPos.Tab()); + assert(pNote); + aAnnotation.put("id", pNote->GetId()); + aAnnotation.put("tab", rPos.Tab()); - if (nType != LOKCommentNotificationType::Remove) - { - aAnnotation.put("author", pNote->GetAuthor()); - aAnnotation.put("dateTime", pNote->GetDate()); - aAnnotation.put("text", pNote->GetText()); - - // Calculating the cell cursor position - ScViewData* pViewData = GetViewData(); - if (pViewData && pViewData->GetActiveWin()) - aAnnotation.put("cellRange", ScPostIt::NoteRangeToJsonString(*pDocument, rPos)); + if (nType != LOKCommentNotificationType::Remove) + { + aAnnotation.put("author", pNote->GetAuthor()); + aAnnotation.put("dateTime", pNote->GetDate()); + aAnnotation.put("text", pNote->GetText()); + + // Calculating the cell cursor position + ScViewData* pViewData = GetViewData(); + if (pViewData && pViewData->GetActiveWin()) + aAnnotation.put("cellRange", ScPostIt::NoteRangeToJsonString(*pDocument, rPos)); + } } - boost::property_tree::ptree aTree; - aTree.add_child("comment", aAnnotation); - std::stringstream aStream; - boost::property_tree::write_json(aStream, aTree); - std::string aPayload = aStream.str(); + OString aPayload = aAnnotation.finishAndGetAsOString(); ScViewData* pViewData = GetViewData(); SfxViewShell* pThisViewShell = ( pViewData ? pViewData->GetViewShell() : nullptr ); @@ -2576,7 +2574,7 @@ void ScDocShell::LOKCommentNotify(LOKCommentNotificationType nType, const ScDocu while (pViewShell) { if (pThisViewShell == nullptr || pViewShell->GetDocId() == pThisViewShell->GetDocId()) - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, OString(aPayload)); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload); pViewShell = SfxViewShell::GetNext(*pViewShell); } } -- cgit