tdf#132744 sw: fix subtle difference when checking end of section
In a few places, such as CopyFlyInFlyImpl() and DelFlyInRange(),
the passed start/end positions aren't necessarily from a cursor but can
be section start/end nodes instead.
(regression from 971205dc2110c1c23ff1db1fc4041e2babf6fa9f)
Change-Id: I1fb24f1f9d027aa3685ac5a7459891cb8c2b9a41
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96124
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 54c5181..2fb9a44 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -1536,6 +1536,19 @@
return node == rAnchorPos.nNode && rAnchorPos.nContent == 0;
}
/// passed start / end position could be on section start / end node
static bool IsAtEndOfSection2(SwPosition const& rPos)
{
return rPos.nNode.GetNode().IsEndNode()
|| IsAtEndOfSection(rPos);
}
static bool IsAtStartOfSection2(SwPosition const& rPos)
{
return rPos.nNode.GetNode().IsStartNode()
|| IsAtStartOfSection(rPos);
}
static bool IsNotBackspaceHeuristic(
SwPosition const& rStart, SwPosition const& rEnd)
{
@@ -1577,13 +1590,13 @@
&& ((rStart.nNode != rEnd.nNode && rStart.nContent == 0
// but not if the selection is backspace/delete!
&& IsNotBackspaceHeuristic(rStart, rEnd))
|| (IsAtStartOfSection(rAnchorPos) && IsAtEndOfSection(rEnd)))))
|| (IsAtStartOfSection(rAnchorPos) && IsAtEndOfSection2(rEnd)))))
&& ((rAnchorPos < rEnd)
|| (rAnchorPos == rEnd
// special case: fully deleted node
&& ((rEnd.nNode != rStart.nNode && rEnd.nContent == rEnd.nNode.GetNode().GetTextNode()->Len()
&& IsNotBackspaceHeuristic(rStart, rEnd))
|| (IsAtEndOfSection(rAnchorPos) && IsAtStartOfSection(rStart)))));
|| (IsAtEndOfSection(rAnchorPos) && IsAtStartOfSection2(rStart)))));
}
bool IsSelectFrameAnchoredAtPara(SwPosition const & rAnchorPos,