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 faf24c3aa5cbefda77367600f5c2185ca7886b3c
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Wed Aug 17 05:35:38 2022 +0530
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Fri Aug 19 19:17:27 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>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138521
    Tested-by: Jenkins

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 d4cbf8d60c41..9aa5fc7e2fb3 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3265,6 +3265,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 ce02a1c39a2a..e21209a79766 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -250,6 +250,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