diff options
author | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2021-08-09 18:42:02 +0300 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2021-08-13 16:12:03 +0200 |
commit | fb4fda4b8cf0007412030782ffa54beb0f2cbbe0 (patch) | |
tree | ab5046bcbacc9be011b792d5f4d91fe7b91aec3d | |
parent | fd7ac9010aabc89286e6e7d7ee5b565c8c5b22cb (diff) |
tdf#129270: sw: do not copy list level on paragraph cut
Current list level (RES_PARATR_LIST_LEVEL) is initialized
before, but current value can overwrite it with invalid
in given context. So we could have mismatch of outline
style (which are not overwritten) and actual list level.
Change-Id: Ibf34a6f35b922493c4a1477326ea6c1599b4938f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120398
Tested-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r-- | sw/qa/extras/uiwriter/data2/tdf129270.odt | bin | 0 -> 9301 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 10 |
3 files changed, 33 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/data2/tdf129270.odt b/sw/qa/extras/uiwriter/data2/tdf129270.odt Binary files differnew file mode 100644 index 000000000000..e86c1f872153 --- /dev/null +++ b/sw/qa/extras/uiwriter/data2/tdf129270.odt diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index f50a2ebe6959..c6da2d1878b0 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -2806,4 +2806,28 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf129655) xmlDocPtr pXmlDoc = parseLayoutDump(); assertXPath(pXmlDoc, "//fly/txt[@WritingMode='Vertical']", 1); } + +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf129270) +{ + SwDoc* pDoc = createDoc("tdf129270.odt"); + CPPUNIT_ASSERT(pDoc); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pXTextDocument); + + // Go to document end + pWrtShell->SttEndDoc(/*bStt=*/false); + + // Press enter + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RETURN); + Scheduler::ProcessEventsToIdle(); + + // Numbering for previous outline should remain the same "2" + CPPUNIT_ASSERT_EQUAL(OUString("2"), getProperty<OUString>(getParagraph(4), "ListLabelString")); + + // Numbering for newly created outline should be "2.1" + CPPUNIT_ASSERT_EQUAL(OUString("2.1"), + getProperty<OUString>(getParagraph(5), "ListLabelString")); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index eb77942b6fe7..8da4d4cbc876 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2492,7 +2492,15 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, const SwIndex & rDestStart, } else { - GetpSwAttrSet()->CopyToModify( *pDest ); + // Copy all attrs except RES_PARATR_LIST_LEVEL: it was initialized before + // and current SwTextNode can contain not suitable for pDest value + SfxItemSet aCharSet( + pDest->GetDoc()->GetAttrPool(), + svl::Items<RES_CHRATR_BEGIN, RES_PARATR_LIST_LEVEL - 1, + RES_PARATR_LIST_LEVEL + 1, HINT_END>{}); + aCharSet.Put(*GetpSwAttrSet()); + if (aCharSet.Count()) + pDest->SetAttr(aCharSet, nDestStart, nDestStart + nLen); } } |