sw/qa/extras/uiwriter/uiwriter3.cxx | 6 ++++-- sw/source/core/doc/DocumentContentOperationsManager.cxx | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-)
New commits: commit 8885bdf2f564bb7b56181c50baf39ff99d551ec9 Author: Michael Stahl <[email protected]> AuthorDate: Fri Aug 27 14:38:18 2021 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Aug 31 11:09:43 2021 +0200 tdf#128106 sw: copy bookmarks at start if whole node is copied The CrossRefHeadingBookmarks are always at index 0 so copy them if the selection also starts at index 0. This happens in SwDoc::SplitDoc() for the 2nd etc. chapter. Change-Id: I4765d497e65d3c8257f7eab59b8ba2088688967e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121147 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 4bf04dea9afb30a9395e80b07a81d1908937ee8b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121152 Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 31a6c651f2fb..f8be215965d8 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -2626,7 +2626,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf128106) CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_BOOKMARK), fields[1]->GetField()->GetSubType()); CPPUNIT_ASSERT( static_cast<SwGetRefField const*>(fields[1]->GetField())->IsRefToHeadingCrossRefBookmark()); - // CPPUNIT_ASSERT_EQUAL(OUString("Chapter 2"), static_cast<SwGetRefField const*>(fields[1]->GetField())->GetPar2()); + CPPUNIT_ASSERT_EQUAL(OUString("Chapter 2"), + static_cast<SwGetRefField const*>(fields[1]->GetField())->GetPar2()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_BOOKMARK), fields[2]->GetField()->GetSubType()); CPPUNIT_ASSERT_EQUAL(OUString("Bookmarkchapter1"), static_cast<SwGetRefField const*>(fields[2]->GetField())->GetSetRefName()); @@ -2645,7 +2646,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf128106) CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_BOOKMARK), fields[5]->GetField()->GetSubType()); CPPUNIT_ASSERT( static_cast<SwGetRefField const*>(fields[5]->GetField())->IsRefToHeadingCrossRefBookmark()); - // CPPUNIT_ASSERT_EQUAL(OUString("Chapter 2"), static_cast<SwGetRefField const*>(fields[5]->GetField())->GetPar2()); + CPPUNIT_ASSERT_EQUAL(OUString("Chapter 2"), + static_cast<SwGetRefField const*>(fields[5]->GetField())->GetPar2()); tempDir.EnableKillingFile(); } diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 2f1818a64a15..743aaefdcd03 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -251,10 +251,21 @@ namespace sw const SwPosition& rMarkEnd = pMark->GetMarkEnd(); // only include marks that are in the range and not touching both start and end // - not for annotation or checkbox marks. + bool const isIncludeStart( + (rStt.nContent.GetIndex() == 0 // paragraph start selected? + // also: only if inserting at the start - cross reference + // marks require index to be 0, and there could be one + // on the target node already + && rCpyPam.nContent.GetIndex() == 0) + || rMarkStart != rStt); + bool const isIncludeEnd( + (rEnd.nNode.GetNode().IsTextNode() // paragraph end selected? + && rEnd.nContent.GetIndex() == rEnd.nNode.GetNode().GetTextNode()->Len()) + || rMarkEnd != rEnd); const bool bIsNotOnBoundary = pMark->IsExpanded() - ? (rMarkStart != rStt || rMarkEnd != rEnd) // rMarkStart != rMarkEnd - : (rMarkStart != rStt && rMarkEnd != rEnd); // rMarkStart == rMarkEnd + ? (isIncludeStart || isIncludeEnd) // rMarkStart != rMarkEnd + : (isIncludeStart && isIncludeEnd); // rMarkStart == rMarkEnd const IDocumentMarkAccess::MarkType aMarkType = IDocumentMarkAccess::GetType(*pMark); if ( rMarkStart >= rStt && rMarkEnd <= rEnd && ( bIsNotOnBoundary
