From c8e49e7a49a99fd76a25ea825319d2243fed5c22 Mon Sep 17 00:00:00 2001 From: Pranam Lashkari Date: Thu, 19 Jan 2023 15:57:26 +0530 Subject: sw: send LOK call back on bookmark deletion this helps with zotero when user deletes a bookmark or use undo without this online will be unaware of any such changes made by user Signed-off-by: Pranam Lashkari Change-Id: Id5ea4ee0ee1d16c399460cd177ec8e33256ce3dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145777 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna (cherry picked from commit ea112b6d85a6914e1df40e064cd5df6d46248d68) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146022 Tested-by: Jenkins --- sw/source/core/crsr/bookmark.cxx | 21 +++++++++++++++++++++ sw/source/core/doc/docbm.cxx | 18 ++++++++++++++++++ sw/source/core/inc/bookmark.hxx | 1 + 3 files changed, 40 insertions(+) (limited to 'sw/source') diff --git a/sw/source/core/crsr/bookmark.cxx b/sw/source/core/crsr/bookmark.cxx index 8165b30a98b1..c43dd04c2496 100644 --- a/sw/source/core/crsr/bookmark.cxx +++ b/sw/source/core/crsr/bookmark.cxx @@ -420,6 +420,27 @@ namespace sw::mark m_aName = rName; } + void Bookmark::sendLOKDeleteCallback() + { + if (GetMarkPos().GetDoc().IsClipBoard()) + return; + + SfxViewShell* pViewShell = SfxViewShell::Current(); + if (!pViewShell) + return; + + OUString fieldCommand = GetName(); + tools::JsonWriter aJson; + aJson.put("commandName", ".uno:DeleteBookmark"); + aJson.put("success", true); + { + auto result = aJson.startNode("result"); + aJson.put("DeleteBookmark", fieldCommand); + } + + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_UNO_COMMAND_RESULT, aJson.extractData()); + } + void Bookmark::InitDoc(SwDoc& io_rDoc, sw::mark::InsertMode const, SwPosition const*const) { diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index cd6afc472350..e074d104b905 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1262,6 +1262,24 @@ namespace sw::mark switch(IDocumentMarkAccess::GetType(*pMark)) { case IDocumentMarkAccess::MarkType::BOOKMARK: + { + auto const ppBookmark = lcl_FindMark(m_vBookmarks, *ppMark.get()); + if ( ppBookmark != m_vBookmarks.end() ) + { + Bookmark* pBookmark = dynamic_cast(*ppBookmark); + + if(pBookmark) + pBookmark->sendLOKDeleteCallback(); + + m_vBookmarks.erase(ppBookmark); + } + else + { + assert(false && + " - Bookmark not found in Bookmark container."); + } + } + break; case IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK: case IDocumentMarkAccess::MarkType::CROSSREF_NUMITEM_BOOKMARK: { diff --git a/sw/source/core/inc/bookmark.hxx b/sw/source/core/inc/bookmark.hxx index b4630b18701c..6ba9484b3bd8 100644 --- a/sw/source/core/inc/bookmark.hxx +++ b/sw/source/core/inc/bookmark.hxx @@ -188,6 +188,7 @@ namespace sw::mark { bool IsInClipboard() const override; bool IsInUndo() const override; bool IsInContent() const override; + void sendLOKDeleteCallback(); css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override; private: -- cgit