summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2021-08-09 18:42:02 +0300
committerMichael Stahl <michael.stahl@allotropia.de>2021-08-13 10:28:35 +0200
commit41c30076dded61163d3c765eb897bf6a62f75120 (patch)
tree9f7c84b014fc01861a7ad68f9e51d0832fad0d7e /sw
parent44a3231d03edc68209d0dd35391a146e4ed440b9 (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/+/120212 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit a72f2dcf73df9b9f4420cc93aa57a77c165a0fcb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120358
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/data/tdf129270.odtbin0 -> 9301 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter4.cxx26
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx10
3 files changed, 35 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf129270.odt b/sw/qa/extras/uiwriter/data/tdf129270.odt
new file mode 100644
index 000000000000..e86c1f872153
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf129270.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx
index 3d008a7e1801..ac0938d28624 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -278,6 +278,7 @@ public:
void testRedlineAutoCorrect();
void testRedlineAutoCorrect2();
void testEmojiAutoCorrect();
+ void testTdf129270();
void testInsertPdf();
CPPUNIT_TEST_SUITE(SwUiWriterTest4);
@@ -393,6 +394,7 @@ public:
CPPUNIT_TEST(testRedlineAutoCorrect);
CPPUNIT_TEST(testRedlineAutoCorrect2);
CPPUNIT_TEST(testEmojiAutoCorrect);
+ CPPUNIT_TEST(testTdf129270);
CPPUNIT_TEST(testInsertPdf);
CPPUNIT_TEST_SUITE_END();
};
@@ -3613,6 +3615,30 @@ void SwUiWriterTest4::testInsertLongDateFormat()
CPPUNIT_ASSERT(xField->getString().indexOf(" ") > -1);
}
+void SwUiWriterTest4::testTdf129270()
+{
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "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"));
+}
+
void SwUiWriterTest4::testInsertPdf()
{
auto pPdfium = vcl::pdf::PDFiumLibrary::get();
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index da69da7209d3..b4b70f52c7f9 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2497,7 +2497,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);
}
}