sw/source/core/crsr/bookmark.cxx |   20 ++++++++++++++++++++
 sw/source/core/inc/bookmark.hxx  |    1 +
 2 files changed, 21 insertions(+)

New commits:
commit 3a6b7e2c07566f22f33189ad4e8393767df5b9f8
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Thu Jan 19 00:14:50 2023 +0530
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Jan 19 14:44:53 2023 +0000

    sw: send LOK call back on fieldmark deletion
    
    this helps with zotero when user deletes a fieldmark or use undo
    without this online will be unaware of any such changes made by user
    
    Signed-off-by: Pranam Lashkari <lpra...@collabora.com>
    Change-Id: I93cf102c20b3861140508aee5d81e65f5b9207ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145753
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/source/core/crsr/bookmark.cxx b/sw/source/core/crsr/bookmark.cxx
index 95de1b15a0df..23e7ed6f85fe 100644
--- a/sw/source/core/crsr/bookmark.cxx
+++ b/sw/source/core/crsr/bookmark.cxx
@@ -47,6 +47,7 @@
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <rtl/strbuf.hxx>
 #include <strings.hrc>
+#include <tools/json_writer.hxx>
 
 using namespace ::sw::mark;
 using namespace ::com::sun::star;
@@ -565,6 +566,25 @@ namespace sw::mark
             m_aName = rName;
     }
 
+    TextFieldmark::~TextFieldmark()
+    {
+        SfxViewShell* pViewShell = SfxViewShell::Current();
+        if (!pViewShell)
+            return;
+
+        OUString fieldCommand;
+        (*GetParameters())[OUString(ODF_CODE_PARAM)] >>= fieldCommand;
+        tools::JsonWriter aJson;
+        aJson.put("commandName", ".uno:DeleteTextFormField");
+        aJson.put("success", true);
+        {
+            auto result = aJson.startNode("result");
+            aJson.put("DeleteTextFormField", fieldCommand);
+        }
+
+        
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_UNO_COMMAND_RESULT, 
aJson.extractData());
+    }
+
     void TextFieldmark::InitDoc(SwDoc& io_rDoc,
             sw::mark::InsertMode const eMode, SwPosition const*const pSepPos)
     {
diff --git a/sw/source/core/inc/bookmark.hxx b/sw/source/core/inc/bookmark.hxx
index 8769dfffb1ee..5d44c3454882 100644
--- a/sw/source/core/inc/bookmark.hxx
+++ b/sw/source/core/inc/bookmark.hxx
@@ -239,6 +239,7 @@ namespace sw::mark {
         {
         public:
             TextFieldmark(const SwPaM& rPaM, const OUString& rName);
+            ~TextFieldmark();
             void InitDoc(SwDoc& io_rDoc, sw::mark::InsertMode eMode, 
SwPosition const* pSepPos) override;
             void ReleaseDoc(SwDoc& rDoc) override;
 

Reply via email to