summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2023-10-27 12:04:29 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-10-27 17:53:42 +0200
commit334d3aff8d411ee5f2d612c8899a171716b8a3d1 (patch)
treedca04f54efc5e18c0a3982a5c3b5e4d5a756ec8e /sc
parent2186fd52d1ef909d4398e84408f76c8357718e1e (diff)
calc comment boost::property_tree::ptree use quotes comment id numbers
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 <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/docshell/docsh4.cxx48
1 files changed, 23 insertions, 25 deletions
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 <config_features.h>
-#include <boost/property_tree/json_parser.hpp>
-
#include <com/sun/star/frame/Desktop.hpp>
#include <scitems.hxx>
@@ -53,6 +51,7 @@
#include <svl/PasswordHelper.hxx>
#include <svl/documentlockfile.hxx>
#include <svl/sharecontrolfile.hxx>
+#include <tools/json_writer.hxx>
#include <unotools/securityoptions.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <sal/log.hxx>
@@ -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);
}
}