sw/qa/extras/uiwriter/data/tdf163340_2.odt |binary sw/qa/extras/uiwriter/uiwriter9.cxx | 27 ++++++++++++++++ sw/source/core/doc/DocumentContentOperationsManager.cxx | 6 +-- 3 files changed, 30 insertions(+), 3 deletions(-)
New commits: commit 61a27bda71d40a63cbfaf64d49d060c132e5f8a1 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Tue Jan 21 09:25:21 2025 +0100 Commit: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> CommitDate: Tue Jan 28 18:15:05 2025 +0100 tdf#163340 fixes regression Pasting a single paragraph with a list into an empty paragraph with a different list should keep that target list and not apply the source list. Change-Id: Ife81aa9553bb2396082d23cc86336ad773b83a16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180618 Tested-by: allotropia jenkins <jenk...@allotropia.de> Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> diff --git a/sw/qa/extras/uiwriter/data/tdf163340_2.odt b/sw/qa/extras/uiwriter/data/tdf163340_2.odt new file mode 100644 index 000000000000..c58a181a0846 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf163340_2.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx index ec6e29db4061..c8d145e3a034 100644 --- a/sw/qa/extras/uiwriter/uiwriter9.cxx +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -790,6 +790,33 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf163340) CPPUNIT_ASSERT_EQUAL(u"A."_ustr, getProperty<OUString>(xParaCursor, u"ListLabelString"_ustr)); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf163340_2) +{ + //selects and copies a single paragraph with a list (bullets) + //and pastes it into an empty paragraph with a different list (numbers) + //checks that the resulting paragraph keeps that different list + createSwDoc("tdf163340_2.odt"); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XText> xText = xTextDocument->getText(); + uno::Reference<view::XSelectionSupplier> xSelSupplier(xModel->getCurrentController(), + uno::UNO_QUERY_THROW); + uno::Reference<text::XParagraphCursor> xParaCursor(xTextDocument->getText()->createTextCursor(), + uno::UNO_QUERY); + + for (int i = 0; i < 2; i++) + xParaCursor->gotoNextParagraph(false); + xParaCursor->gotoEndOfParagraph(true); + xSelSupplier->select(uno::Any(xParaCursor)); + + xParaCursor = uno::Reference<text::XParagraphCursor>(xText->createTextCursor(), uno::UNO_QUERY); + for (int i = 0; i < 10; i++) + xParaCursor->gotoNextParagraph(false); + xParaCursor->gotoEndOfParagraph(true); + dispatchCommand(mxComponent, u".uno:Paste"_ustr, {}); + CPPUNIT_ASSERT_EQUAL(u"5."_ustr, getProperty<OUString>(xParaCursor, u"ListLabelString"_ustr)); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf162326_Pargraph) { createSwDoc("tdf162326.odt"); diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 62c929f6f469..3d743c949458 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -489,9 +489,9 @@ namespace const SwTextNode* pTextNd = rPam.Start()->GetNode().GetTextNode(); const SwTextNode* pEndTextNd = rPam.End()->GetNode().GetTextNode(); bool bRet = pTextNd->IsInListFromStyle(); - //prefer list if it's a single paragraph with list from style - if (pTextNd == pEndTextNd && bRet) - return true; + //single paragraphs are preferred only if it's a has a list from style + if (pTextNd == pEndTextNd) + return bRet; if (pTextNd && pTextNd->IsInList() && !pTextNd->IsInListFromStyle() && pEndTextNd && pEndTextNd->IsInList() && !pEndTextNd->IsInListFromStyle())