sw/qa/extras/uiwriter/data/tdf163340.odt |binary sw/qa/extras/uiwriter/uiwriter9.cxx | 28 ++++++++++++++++ sw/source/core/doc/DocumentContentOperationsManager.cxx | 5 +- 3 files changed, 31 insertions(+), 2 deletions(-)
New commits: commit 2321626477d4ff930d8bc392efa6ea84e8825171 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Mon Oct 7 15:14:10 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Thu Oct 10 01:19:45 2024 +0200 tdf#163340 replace list on paste Pasting paragraph with list should apply the source list to the target paragraph if the target is empty or completely selected. Change-Id: I27d462f121c03b6c5625f8c0967bc975d3ac2f88 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174606 Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sw/qa/extras/uiwriter/data/tdf163340.odt b/sw/qa/extras/uiwriter/data/tdf163340.odt new file mode 100644 index 000000000000..cae622e5b5f3 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf163340.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx index 30e4d60481d9..f97d5a572d4d 100644 --- a/sw/qa/extras/uiwriter/uiwriter9.cxx +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -798,6 +798,34 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf162326_Character) CPPUNIT_ASSERT_EQUAL(short(1), getProperty<short>(getRun(getParagraph(3), 2), u"CharUnderline"_ustr)); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf163340) +{ + createSwDoc("tdf163340.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 < 14; i++) + xParaCursor->gotoNextParagraph(false); + xParaCursor->gotoEndOfParagraph(true); + xSelSupplier->select(uno::Any(xParaCursor)); + + CPPUNIT_ASSERT_EQUAL(u"A."_ustr, getProperty<OUString>(xParaCursor, u"ListLabelString"_ustr)); + dispatchCommand(mxComponent, u".uno:Copy"_ustr, {}); + + xParaCursor = uno::Reference<text::XParagraphCursor>(xText->createTextCursor(), uno::UNO_QUERY); + for (int i = 0; i < 3; i++) + xParaCursor->gotoNextParagraph(false); + xParaCursor->gotoEndOfParagraph(true); + CPPUNIT_ASSERT_EQUAL(u"1."_ustr, getProperty<OUString>(xParaCursor, u"ListLabelString"_ustr)); + xSelSupplier->select(uno::Any(xParaCursor)); + dispatchCommand(mxComponent, u".uno:Paste"_ustr, {}); + CPPUNIT_ASSERT_EQUAL(u"A."_ustr, getProperty<OUString>(xParaCursor, u"ListLabelString"_ustr)); +} } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 2588decb8136..e8c0055f9e49 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -5010,7 +5010,6 @@ static void lcl_PopNumruleState( // #i86492# - restore also <ListId> item if ( lcl_MarksWholeNode(rPam) ) return; - if (aNumRuleItemHolderIfSet) { pDestTextNd->SetAttr(*aNumRuleItemHolderIfSet); @@ -5202,9 +5201,11 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo // - source contains at least one paragraph which is not in a list // or // - source is a table + // - tdf#163340 overwrite list if source has a list + if ( pNumRuleToPropagate && ((pDestTextNd && !pDestTextNd->GetText().getLength() && - !pDestTextNd->IsInList() && + (!pDestTextNd->IsInList() || rPam.GetPointNode().GetTextNode()->IsInList() ) && !lcl_ContainsOnlyParagraphsInList(rPam)) || rPam.GetBound().nNode.GetNode().GetNodeType() == SwNodeType::Table) ) {