sw/inc/txtrfmrk.hxx               |    2 ++
 sw/source/core/txtnode/atrref.cxx |   26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

New commits:
commit 06f98f94448fdf7b5dc3a55f45da8a27e5b212a8
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Thu Jan 19 15:27:31 2023 +0530
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jan 24 10:37:12 2023 +0000

    sw: send LOK call back on refmark deletion
    
    this helps with zotero when user deletes a refmark 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: Ia4326fd03f6b7d27fdb59ccc25d60331ba7923d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145774
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146005
    Tested-by: Jenkins

diff --git a/sw/inc/txtrfmrk.hxx b/sw/inc/txtrfmrk.hxx
index 4f55b4f28d38..f73f8cf71019 100644
--- a/sw/inc/txtrfmrk.hxx
+++ b/sw/inc/txtrfmrk.hxx
@@ -33,6 +33,8 @@ public:
     SwTextRefMark( SwFormatRefMark& rAttr,
             sal_Int32 const nStart, sal_Int32 const*const pEnd = nullptr);
 
+    ~SwTextRefMark();
+
     virtual const sal_Int32* GetEnd() const override;       // SwTextAttr
     virtual void SetEnd(sal_Int32) override;       // SwTextAttr
 
diff --git a/sw/source/core/txtnode/atrref.cxx 
b/sw/source/core/txtnode/atrref.cxx
index b7403518e930..e38156a9d170 100644
--- a/sw/source/core/txtnode/atrref.cxx
+++ b/sw/source/core/txtnode/atrref.cxx
@@ -26,6 +26,11 @@
 #include <txtrfmrk.hxx>
 #include <unorefmark.hxx>
 #include <utility>
+#include <sfx2/viewsh.hxx>
+#include <tools/json_writer.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <doc.hxx>
+#include <ndtxt.hxx>
 
 SwFormatRefMark::~SwFormatRefMark( )
 {
@@ -114,6 +119,27 @@ SwTextRefMark::SwTextRefMark( SwFormatRefMark& rAttr,
     SetOverlapAllowedAttr( true );
 }
 
+SwTextRefMark::~SwTextRefMark()
+{
+    if (GetTextNode().GetDoc().IsClipBoard())
+        return;
+
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+    if (!pViewShell)
+        return;
+
+    OUString fieldCommand = GetRefMark().GetRefName();
+    tools::JsonWriter aJson;
+    aJson.put("commandName", ".uno:DeleteField");
+    aJson.put("success", true);
+    {
+        auto result = aJson.startNode("result");
+        aJson.put("DeleteField", fieldCommand);
+    }
+
+    pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_UNO_COMMAND_RESULT, 
aJson.extractData());
+}
+
 const sal_Int32* SwTextRefMark::GetEnd() const
 {
     return m_pEnd;

Reply via email to