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/+/180536
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Oliver Specht
2025-01-28 18:14:47 +01:00
committed by Gabor Kelemen
parent 1817760f56
commit 875bb514b9
3 changed files with 30 additions and 3 deletions
Binary file not shown.
+27
View File
@@ -855,6 +855,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, testTdf159023)
{
createSwDoc();
@@ -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())