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

New commits:
commit 50817b21dd7bc5a757da5b5aec531fe83b9b3388
Author:     Pranam Lashkari <[email protected]>
AuthorDate: Wed Aug 17 05:35:38 2022 +0530
Commit:     Gökay ŞATIR <[email protected]>
CommitDate: Thu Aug 18 10:09:31 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 <[email protected]>
    Change-Id: I70aad7eb421b4bde52b9e54855e2360c59807852
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138398
    Reviewed-by: Szymon Kłos <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138464

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 f0b8e3923158..3fa21a1405ec 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -159,6 +159,7 @@ public:
     void testDropDownFormFieldButtonNoSelection();
     void testDropDownFormFieldButtonNoItem();
     void testTablePaintInvalidate();
+    void testTableCommentRemoveCallback();
     void testSpellOnlineRenderParameter();
     void testExtTextInputReadOnly();
     void testBulletDeleteInvalidation();
@@ -246,6 +247,7 @@ public:
     CPPUNIT_TEST(testDropDownFormFieldButtonNoSelection);
     CPPUNIT_TEST(testDropDownFormFieldButtonNoItem);
     CPPUNIT_TEST(testTablePaintInvalidate);
+    CPPUNIT_TEST(testTableCommentRemoveCallback);
     CPPUNIT_TEST(testSpellOnlineRenderParameter);
     CPPUNIT_TEST(testExtTextInputReadOnly);
     CPPUNIT_TEST(testBulletDeleteInvalidation);
@@ -3360,6 +3362,29 @@ void SwTiledRenderingTest::testTablePaintInvalidate()
     CPPUNIT_ASSERT_EQUAL(0, m_nInvalidations);
 }
 
+void 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);
+}
+
 void SwTiledRenderingTest::testSpellOnlineRenderParameter()
 {
     SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx 
b/sw/source/uibase/docvw/PostItMgr.cxx
index 5ec87bc820d9..55085a5e9f10 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -248,6 +248,7 @@ void 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