sw/qa/extras/tiledrendering/data/testTableCommentRemoveCallback.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx                      |   23 
++++++++++
 sw/source/uibase/docvw/PostItMgr.cxx                                |    1 
 3 files changed, 24 insertions(+)

New commits:
commit d365da2c47a4a40e0b33a34f559046d1162ae1fb
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Wed Aug 17 05:35:38 2022 +0530
Commit:     Pranam Lashkari <lpra...@collabora.com>
CommitDate: Wed Aug 17 20:03:50 2022 +0200

    sw: online: make sure commment removal notification is sent
    
    problem:
    when comment is added inside a table in online,
    and entire table is deleted, comments were not removed
    due to notification not being sent.
    
    Another failed case was when some text with comment is
    copy pasted, and then pasted text is undoed,
    text was removed but comment stayed.
    
    This patch will notify comment removal before actaully distroying the 
comment/note
    
    Signed-off-by: Pranam Lashkari <lpra...@collabora.com>
    Change-Id: I70aad7eb421b4bde52b9e54855e2360c59807852
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138398
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git 
a/sw/qa/extras/tiledrendering/data/testTableCommentRemoveCallback.odt 
b/sw/qa/extras/tiledrendering/data/testTableCommentRemoveCallback.odt
new file mode 100644
index 000000000000..09941166a718
Binary files /dev/null and 
b/sw/qa/extras/tiledrendering/data/testTableCommentRemoveCallback.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 5b0443884ad8..89a9acdba670 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3266,6 +3266,29 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTablePaintInvalidate)
     CPPUNIT_ASSERT_EQUAL(0, m_nInvalidations);
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTableCommentRemoveCallback)
+{
+    comphelper::LibreOfficeKit::setActive();
+    comphelper::LibreOfficeKit::setTiledAnnotations(false);
+
+    // Load a document with a comment in a table.
+    SwXTextDocument* pXTextDocument = 
createDoc("testTableCommentRemoveCallback.odt");
+    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
+    ViewCallback aView;
+
+    // delete all characters
+    comphelper::dispatchCommand(".uno:SelectAll", 
uno::Sequence<beans::PropertyValue>());
+    Scheduler::ProcessEventsToIdle();
+    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DELETE);
+    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_DELETE);
+    Scheduler::ProcessEventsToIdle();
+
+    //check for comment remove callback
+    OString 
sAction(aView.m_aComment.get_child("action").get_value<std::string>().c_str());
+    CPPUNIT_ASSERT_EQUAL(OString("Remove"), sAction);
+}
+
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSpellOnlineRenderParameter)
 {
     SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx 
b/sw/source/uibase/docvw/PostItMgr.cxx
index 234b6c5db0c5..bab23796a94b 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -247,6 +247,7 @@ bool SwPostItMgr::CheckForRemovedPostIts()
         if (!(*it)->UseElement(*mpWrtShell->GetLayout(), rIDRA))
         {
             
EndListening(const_cast<SfxBroadcaster&>(*(*it)->GetBroadcaster()));
+            lcl_CommentNotification(mpView, CommentNotificationType::Remove, 
nullptr, (*it)->mpPostIt->GetPostItField()->GetPostItId());
             std::unique_ptr<SwSidebarItem> p = std::move(*it);
             it = mvPostItFields.erase(it);
             if (GetActiveSidebarWin() == p->mpPostIt)

Reply via email to