summaryrefslogtreecommitdiff
path: root/sw/source/core/doc
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-08-01 09:06:43 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-08-01 09:59:02 +0200
commit073072f0a3abacfe4f9cc920b8138d7abc84db70 (patch)
tree87725d2d8917b4f37404a012cb815c3271d1301b /sw/source/core/doc
parent2ef9880f97de6629ddef12eb788123ab4be1ec83 (diff)
tdf#156260 sw floattable: avoid overlapping flys on anchor change
Going to the end of the document, typing "dt" and F3 collapses the multi-page floating table into a single page, with overlapping text. In practice we insert a new paragraph before the "dt" one, insert the dummy text there and then re-anchor the floating table from the old paragraph to the new one. Such re-anchoring isn't really meant to be done with floating tables, which are always just anchored in the next paragraph in practice. An additional problem is that the amount of fly frames created depends on the position of the first fly frame, so if the anchor changes, we may need a different number of split fly frames. Fix the problem by not trying to reuse the old fly frames on anchor change: delete the old frames, change the anchor and finally create the new frames, which leads to correct layout with complicated logic trying to update the old fly chain to the new anchor. The original document still puts some dummy text on page 4 instead of starting it on page 5, that part is still unfixed. Change-Id: I74549e2ea8ca0d06a9e4814a58aaa8ca476263dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155122 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/core/doc')
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 0b51fc65e46e..4ad364ea6afc 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -70,6 +70,7 @@
#include <fmtflcnt.hxx>
#include <docedt.hxx>
#include <frameformats.hxx>
+#include <formatflysplit.hxx>
#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <unotools/charclass.hxx>
@@ -5241,7 +5242,27 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
{
SwFormatAnchor anchor(*pAnchor);
anchor.SetAnchor( &startPosAtPara );
+
+ bool bSplitFly = false;
+ if (pFly->GetFlySplit().GetValue())
+ {
+ SwIterator<SwFrame, SwModify> aIter(*pFly);
+ bSplitFly = aIter.First() && aIter.Next();
+ }
+ if (bSplitFly)
+ {
+ // This fly format has multiple frames, and we change the anchor. Remove the
+ // old frames, which were based on the old anchor position.
+ pFly->DelFrames();
+ }
+
pFly->SetFormatAttr(anchor);
+
+ if (bSplitFly)
+ {
+ // Re-create the frames now that the new anchor is set.
+ pFly->MakeFrames();
+ }
}
}
}