summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-01-31 08:29:44 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-01-31 08:58:54 +0000
commited9d987e2ad8f6af554a5fc1f858ca48c6970446 (patch)
tree3f3ee02672843c8feea363e912f2b01b5f14097e /sw/source
parent07699b6e7847c141c0bdec2e5345f2d00cb219dd (diff)
sw: if the fly is to be split, then limit its growth in SwFlyFrame::Format()
It seems the first direct cause why flys are not split is because flys can grow forever, so an inner paragraph's SwContentFrame::MakeAll() will never hit the nBottomDist < 0 condition, which is necessary to call into SwFlowFrame::MoveFwd(). With this, at least nBottomDist is negative when a fly with two paragraphs is at the bottom of a page and only one of them fits the body frame. Also add a debug environment variable, so I can debug the "fly split" case till we don't have import/export filters for this. Towards an initial layout for multi-page fly frames. Change-Id: I43114b5795dd42e518a1d776ccd2e7ab607ad859 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146376 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/attr/formatflysplit.cxx9
-rw-r--r--sw/source/core/layout/fly.cxx16
2 files changed, 25 insertions, 0 deletions
diff --git a/sw/source/core/attr/formatflysplit.cxx b/sw/source/core/attr/formatflysplit.cxx
index 72816b2ead4e..bcbfcc2d5e96 100644
--- a/sw/source/core/attr/formatflysplit.cxx
+++ b/sw/source/core/attr/formatflysplit.cxx
@@ -21,6 +21,15 @@
#include <libxml/xmlwriter.h>
+SwFormatFlySplit::SwFormatFlySplit(bool bSplit)
+ : SfxBoolItem(RES_FLY_SPLIT, bSplit)
+{
+ if (getenv("SW_FORCE_FLY_SPLIT"))
+ {
+ SetValue(true);
+ }
+}
+
SwFormatFlySplit* SwFormatFlySplit::Clone(SfxItemPool*) const
{
return new SwFormatFlySplit(*this);
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 4cee6d9e712d..1ece49fb78b5 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -75,6 +75,7 @@
#include <bodyfrm.hxx>
#include <FrameControlsManager.hxx>
#include <ndtxt.hxx>
+#include <formatflysplit.hxx>
using namespace ::com::sun::star;
@@ -1303,6 +1304,21 @@ void SwFlyFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderA
if ( nRemaining < MINFLY )
nRemaining = MINFLY;
+ const SwFrame* pAnchor = GetAnchorFrame();
+ const SwFrame* pAnchorUpper = pAnchor ? pAnchor->GetUpper() : nullptr;
+ if (pAnchorUpper && GetFormat()->GetFlySplit().GetValue())
+ {
+ // If the fly is allowed to be split, then limit its size to the upper of the
+ // anchor.
+ SwTwips nDeadline = aRectFnSet.GetPrtBottom(*pAnchorUpper);
+ SwTwips nTop = aRectFnSet.GetTop(getFrameArea());
+ SwTwips nBottom = aRectFnSet.GetTop(getFrameArea()) + nRemaining;
+ if (nBottom > nDeadline)
+ {
+ nRemaining = nDeadline - nTop;
+ }
+ }
+
{
SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
aRectFnSet.SetHeight( aPrt, nRemaining );