sw/qa/extras/uiwriter/data/tdf168157.docx |binary sw/qa/extras/uiwriter/uiwriter8.cxx | 27 ++++++++++++++++ sw/source/core/doc/DocumentContentOperationsManager.cxx | 3 - 3 files changed, 28 insertions(+), 2 deletions(-)
New commits: commit b0e8042e170fb900bd8f2ab2f561073534c267d6 Author: Xisco Fauli <[email protected]> AuthorDate: Tue Jan 13 13:02:51 2026 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Mon Jan 19 09:49:21 2026 +0100 tdf#168157: sw_uiwriter8: Add test Change-Id: Ib8e85cdfa32175c94df296a1f5c5b9e701faf102 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197193 Reviewed-by: Xisco Fauli <[email protected]> Tested-by: Jenkins Reviewed-by: Dan Williams <[email protected]> diff --git a/sw/qa/extras/uiwriter/data/tdf168157.docx b/sw/qa/extras/uiwriter/data/tdf168157.docx new file mode 100644 index 000000000000..e737fb68bb00 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf168157.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index f91a0db7e1b1..aebb38aa28b0 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -3067,6 +3067,33 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf153636) } } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf168157_crash_after_pasting_and_undoing) +{ + createSwDoc("tdf168157.docx"); + + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + dispatchCommand(mxComponent, u".uno:Copy"_ustr, {}); + + dispatchCommand(mxComponent, u".uno:Paste"_ustr, {}); + + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + + dispatchCommand(mxComponent, u".uno:Paste"_ustr, {}); + + CPPUNIT_ASSERT_EQUAL(2, getShapes()); + + dispatchCommand(mxComponent, u".uno:Undo"_ustr, {}); + + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + + // Without the fix in place, this test would have crashed here + dispatchCommand(mxComponent, u".uno:Undo"_ustr, {}); + + CPPUNIT_ASSERT_EQUAL(1, getShapes()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf157129) { // Unit test for tdf#157129 commit 875a2b85f1428bd442ab51e88c3535ff44fc1676 Author: Xisco Fauli <[email protected]> AuthorDate: Tue Jan 13 12:52:36 2026 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Mon Jan 19 09:49:14 2026 +0100 tdf#168157: Revert "writer: when pasting Copy paragraph style when dest node is " "" This reverts commit 251798c9b4f2ebad447953c3a4b1048e48cd30e3. The reverted commit doesn't point to any ticket in Bugzilla/Github, besides it doesn't have any test covering the fix, so it's very hard to tell what it tries to fix. There has not been any response from the author in https://gerrit.libreoffice.org/c/core/+/189900 or tdf#168157 either, so reverting it for now before the release of LibreOffice 26.2. Change-Id: I6ef5b81f33ab38cc180c457f04a238289d4d1513 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197192 Tested-by: Jenkins Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 61b9297ca4ef..0472afa6e1eb 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -5195,9 +5195,8 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo SwTextNode* pSttTextNd = pStart->GetNode().GetTextNode(); SwTextNode* pEndTextNd = pEnd->GetNode().GetTextNode(); SwTextNode* pDestTextNd = aInsPos.GetNode().GetTextNode(); - bool bDestTextNdEmpty = pDestTextNd && (pDestTextNd->GetText().isEmpty() || pDestTextNd->GetText() == " "); bool bCopyCollFormat = !rDoc.IsInsOnlyTextGlossary() && - ( bDestTextNdEmpty || + ( (pDestTextNd && !pDestTextNd->GetText().getLength()) || ( !bOneNode && !rPos.GetContentIndex() ) ); bool bCopyBookmarks = true; bool bCopyPageSource = false;
