summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode/ndtxt.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-12-12 08:39:54 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-12-13 12:39:05 +0100
commit9a946645c8029bc6382d8e455b76430d4e4bc37f (patch)
tree0554dd3aa8cb300d8dc1c9af15b07fb83e46b8d6 /sw/source/core/txtnode/ndtxt.cxx
parent5b3af42f2a7e5b4330dfa88c912f1dd75f35b18a (diff)
sw floattable: fix split of anchor text in 2nd half of the paragraph
If you go to the anchor text of the floating table and you press enter in the second half of the anchor text, you get a layout loop. The reason for this: an invariant around split text frames were violated, later resulting in a layout loop. The rule is that in case you have a split frame, then there can't be a frame for a new text node between the two split frames. So no new text frame for an other node after the master anchor of the fly; no new text frame for an other node before the follow anchor of the fly. Fix the problem by improving SwTextNode::SplitContentNode() to check if this is an anchor for a split fly: if so, always insert the new text frame after the follow anchor of the fly, which doesn't break the above invariant. The layout loop is fixed, but the text in the follow anchor of the fly still has a bad position, that still needs fixing. Also currently testSplitFlyMoveMaster enforces that split at the para start inserts a paragraph before the floating table, so leave that case unchanged for now. (cherry picked from commit 0746d13365139c356eb9d297a358c486bf47d6fb) Change-Id: I77962a354e297d2e9957edcce9bf140f2c72fc6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160671 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sw/source/core/txtnode/ndtxt.cxx')
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx21
1 files changed, 20 insertions, 1 deletions
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 8dfb89835faa..ff05143b0052 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -82,6 +82,8 @@
#include <fmtpdsc.hxx>
#include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
#include <svl/itemiter.hxx>
+#include <undobj.hxx>
+#include <formatflysplit.hxx>
using namespace ::com::sun::star;
@@ -459,7 +461,24 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos,
ResetAttr( RES_PARATR_LIST_LEVEL );
}
- if ( HasWriterListeners() && !m_Text.isEmpty() && (nTextLen / 2) < nSplitPos )
+ bool bSplitFly = false;
+ std::optional<std::vector<SwFrameFormat*>> oFlys = sw::GetFlysAnchoredAt(GetDoc(), GetIndex());
+ if (oFlys.has_value() && nSplitPos > 0)
+ {
+ // See if one of the flys is a split fly. If so, we need to keep
+ // the potentially split text frames unchanged and create a new
+ // text frame at the end.
+ for (const auto& rFly : *oFlys)
+ {
+ if (rFly->GetFlySplit().GetValue())
+ {
+ bSplitFly = true;
+ break;
+ }
+ }
+ }
+
+ if ( HasWriterListeners() && !m_Text.isEmpty() && ((nTextLen / 2) < nSplitPos || bSplitFly) )
{
// optimization for SplitNode: If a split is at the end of a node then
// move the frames from the current to the new one and create new ones