summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-06-11 15:26:27 +0200
committerMichael Stahl <michael.stahl@cib.de>2020-06-11 19:09:41 +0200
commitcc4b5091e739116a7ec83513fa1cd856f0130330 (patch)
tree1f5ad67072dd3ca8dc1df77c5c7e9144ca3ddd58
parent708260185151d7e71e7bf5d298eba0e638fd2a1b (diff)
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>
-rw-r--r--sw/source/core/undo/undobj.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 54c5181b43f4..2fb9a44da30b 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -1536,6 +1536,19 @@ static bool IsAtStartOfSection(SwPosition const& rAnchorPos)
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 @@ bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos,
&& ((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,