sc/source/ui/docshell/docsh4.cxx |   46 ++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 24 deletions(-)

New commits:
commit 9c5f72071ea7f268cfbd5c7f76f8a6c3c970887b
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Oct 27 12:04:29 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Oct 27 17:47:31 2023 +0200

    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/+/158560
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index ceef6e3009f5..5c1f6b0505f7 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>
 
 using namespace ::com::sun::star;
@@ -55,6 +53,7 @@ using namespace ::com::sun::star;
 #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>
@@ -2531,32 +2530,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();
+    std::string aPayload(aAnnotation.extractAsStdString());
 
     ScViewData* pViewData = GetViewData();
     SfxViewShell* pThisViewShell = ( pViewData ? pViewData->GetViewShell() : 
nullptr );

Reply via email to