summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx6
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx15
2 files changed, 17 insertions, 4 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 64e3c8fb61cb..c283f3022803 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -2664,7 +2664,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());
@@ -2683,7 +2684,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 35044a92a3bd..9af97d1c4626 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