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 66ef51e47102..666f3aefe5dc 100644 --- a/sw/qa/extras/uiwriter/uiwriter9.cxx +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -855,6 +855,33 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf163340) CPPUNIT_ASSERT_EQUAL(u"A."_ustr, getProperty(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 xModel(mxComponent, uno::UNO_QUERY); + uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference xText = xTextDocument->getText(); + uno::Reference xSelSupplier(xModel->getCurrentController(), + uno::UNO_QUERY_THROW); + uno::Reference 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(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(xParaCursor, u"ListLabelString"_ustr)); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf159023) { createSwDoc(); diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 2efcf0f94493..c2eca8469588 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -491,9 +491,9 @@ namespace if (pTextNd == nullptr || pEndTextNd == nullptr) return false; 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())