sw/qa/core/txtnode/data/comment-reply-copy.odt |binary sw/qa/core/txtnode/txtnode.cxx | 36 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
New commits: commit 8b9bfe98259c54ba6e9407d3c486436965cdf7db Author: Gökay Şatır <gokaysa...@collabora.com> AuthorDate: Fri Nov 29 10:55:27 2024 +0300 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Feb 3 12:55:15 2025 +0100 cool#10610: Test for ensuring the parent-child relations of comments. Change-Id: Idacdc1df20049f4d5a0214570a3451cc4382d71e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181031 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/core/txtnode/data/comment-reply-copy.odt b/sw/qa/core/txtnode/data/comment-reply-copy.odt new file mode 100644 index 000000000000..0a046e2f85fc Binary files /dev/null and b/sw/qa/core/txtnode/data/comment-reply-copy.odt differ diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx index 1882602c8d93..0533c3601395 100644 --- a/sw/qa/core/txtnode/txtnode.cxx +++ b/sw/qa/core/txtnode/txtnode.cxx @@ -41,6 +41,9 @@ #include <rootfrm.hxx> #include <pagefrm.hxx> #include <txtfrm.hxx> +#include <PostItMgr.hxx> +#include <AnnotationWin.hxx> +#include <docufld.hxx> /// Covers sw/source/core/txtnode/ fixes. class SwCoreTxtnodeTest : public SwModelTestBase @@ -549,6 +552,39 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testPlainContentControlCopy) mxComponent.clear(); } +CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testCopyCommentsWithReplies) +{ + createSwDoc("comment-reply-copy.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDocShell* pShell = pTextDoc->GetDocShell(); + SwWrtShell* pWrtShell = pShell->GetWrtShell(); + SwDoc aClipboard; + pWrtShell->SelAll(); + pWrtShell->Copy(aClipboard); + pWrtShell->SttEndDoc(/*bStart=*/false); // Send the cursor to the end of the document. + pWrtShell->Paste(aClipboard); + + // Now we have selected all text (which is one line) and pasted it to the end. + // A comment and its reply should also be copied to the end of the document. + // We will check if our reply is referencing its copied parent instead of the source parent. + + SwPostItMgr* postItManager = pWrtShell->GetPostItMgr(); + + std::vector<const SwPostItField*> comments; + + Scheduler::ProcessEventsToIdle(); + + for (const auto& pItem : *postItManager) // There should be 4. + { + comments.push_back(pItem->mpPostIt->GetPostItField()); + } + + // parents (original-copied), replies (original-copied) + CPPUNIT_ASSERT_EQUAL(comments[0]->GetName(), comments[1]->GetParentName()); + CPPUNIT_ASSERT_EQUAL(comments[2]->GetName(), comments[3]->GetParentName()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */