diff options
author | Aron Budea <aron.budea@collabora.com> | 2018-03-25 08:33:16 +0200 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2019-08-01 15:59:19 +0200 |
commit | 4d9a4b597d16b42852d986db0701d75318912a2a (patch) | |
tree | 3159d69f46b605bb9ecf25c181b13a0010280808 | |
parent | ofz#7121 NamedDBs::insert takes ownership of its argument (diff) | |
download | core-4d9a4b597d16b42852d986db0701d75318912a2a.tar.gz core-4d9a4b597d16b42852d986db0701d75318912a2a.zip |
tdf#106746: pDelPam is a bit special
Regression from db17d3c17c40d6b0e92392cf3c6e343d1d17b771
Change-Id: I17e2fef2eb16a900cc487b75c3b9dbba2764ac71
Reviewed-on: https://gerrit.libreoffice.org/51814
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Aron Budea <aron.budea@collabora.com>
(cherry picked from commit 7b1d50e97eaa00855152e74f42b789fc643e0bac)
Reviewed-on: https://gerrit.libreoffice.org/52017
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit cba73f04699592c7038156f91ed92be026ed2536)
-rwxr-xr-x | sw/qa/extras/uiwriter/uiwriter.cxx | 36 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentContentOperationsManager.cxx | 2 |
2 files changed, 37 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 73530817ce34..c19b76cf7c44 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -208,6 +208,7 @@ public: void testTdf99004(); void testTdf84695(); void testTdf84695NormalChar(); + void testRedlineCopyPaste(); void testTdf78727(); void testTdf104814(); void testTdf105417(); @@ -325,6 +326,7 @@ public: CPPUNIT_TEST(testTdf99004); CPPUNIT_TEST(testTdf84695); CPPUNIT_TEST(testTdf84695NormalChar); + CPPUNIT_TEST(testRedlineCopyPaste); CPPUNIT_TEST(testTdf78727); CPPUNIT_TEST(testTdf104814); CPPUNIT_TEST(testTdf105417); @@ -3780,6 +3782,40 @@ void SwUiWriterTest::testTdf84695NormalChar() CPPUNIT_ASSERT_EQUAL(OUString("a"), xShape->getString()); } +void SwUiWriterTest::testRedlineCopyPaste() +{ + // regressed in tdf#106746 + SwDoc* pDoc = createDoc(); + + SwNodeIndex aIdx(pDoc->GetNodes().GetEndOfContent(), -1); + SwPaM aPaM(aIdx); + + pDoc->getIDocumentContentOperations().InsertString(aPaM, "abzdezgh"); + SwTextNode* pTextNode = aPaM.GetNode().GetTextNode(); + + // Turn on track changes, make changes, turn off track changes + uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY); + xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true)); + lcl_selectCharacters(aPaM, 2, 3); + pDoc->getIDocumentContentOperations().ReplaceRange(aPaM, "c", false); + lcl_selectCharacters(aPaM, 6, 7); + pDoc->getIDocumentContentOperations().ReplaceRange(aPaM, "f", false); + xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(false)); + + // Create the clipboard document. + SwDoc aClipboard; + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + // Select the whole content, copy, delete the original and paste the copied content + pWrtShell->SelAll(); + pWrtShell->Copy(&aClipboard); + pWrtShell->Delete(); + pWrtShell->Paste(&aClipboard); + + // With the bug this is "abzcdefgh", ie. contains the first deleted piece, too + CPPUNIT_ASSERT_EQUAL(OUString("abcdefgh"), pTextNode->GetText()); +} + void SwUiWriterTest::testTdf78727() { SwDoc* pDoc = createDoc("tdf78727.docx"); diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index f15934de43aa..b3d761192b25 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -349,7 +349,7 @@ namespace default: { - pDelPam.reset(new SwPaM( *pCpyStt, pDelPam.get() )); + pDelPam.reset(new SwPaM( *pCpyStt, pDelPam.release() )); if( *pStt < *pRStt ) { lcl_NonCopyCount( rPam, aCorrIdx, pRStt->nNode.GetIndex(), nDelCount ); |