summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-10-03 12:08:36 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-10-03 17:29:14 +0200
commit695390b08799af34b393c81c834d615bea330d89 (patch)
treefa6efc4d63e70a72910ede5526b3ac81f0328fcd /sw/source
parent140dc375adfffa59dff2652eb8b9625c23d81c8b (diff)
tdf#126449 sw floattable: fix too small height of non-last anchors
The bugdoc had an outer inline table, a middle inline table and an inner floating table. The floating table is expected to be on pages 2, 3 and 4; actually it was only on page 2 and 3. This happened because the fly frame that should be on page 4 was on page 3, leading to overlapping text. And that bad fly position seems to happen because the anchor frames just have a 1 line height (~269 twips instead of the fly height). Fix this similar to how "first paragraph only" wrapping works: increase the (anchor) text frame height, even if the contained lines would not require that amount of height. With this, finally the DOCX version of the bugdoc lays out reasonable (all 5 pages). Change-Id: Ib08bf34be61eb2b4d8656887f83ac7fd17e3b252 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157507 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/text/porrst.cxx26
1 files changed, 24 insertions, 2 deletions
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index 5c6ea428c1db..bd3589b25676 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -51,6 +51,8 @@
#include <crsrsh.hxx>
#include <swtypes.hxx>
#include <strings.hrc>
+#include <flyfrms.hxx>
+#include <bodyfrm.hxx>
SwTmpEndPortion::SwTmpEndPortion( const SwLinePortion &rPortion,
const FontLineStyle eUL,
@@ -412,7 +414,8 @@ bool SwTextFrame::FormatEmpty()
// sw_redlinehide: just disable FormatEmpty optimisation for now
// Split fly frames: non-last parts of the anchor want this optimization to clear the old
// content.
- bool bHasNonLastSplitFlyDrawObj = HasNonLastSplitFlyDrawObj();
+ SwFlyAtContentFrame* pNonLastSplitFlyDrawObj = HasNonLastSplitFlyDrawObj();
+ bool bHasNonLastSplitFlyDrawObj = pNonLastSplitFlyDrawObj != nullptr;
if ((HasFollow() && !bHasNonLastSplitFlyDrawObj) || GetMergedPara() || (GetTextNodeFirst()->GetpSwpHints() && !bHasNonLastSplitFlyDrawObj) ||
nullptr != GetTextNodeForParaProps()->GetNumRule() ||
GetTextNodeFirst()->HasHiddenCharAttribute(true) ||
@@ -468,7 +471,26 @@ bool SwTextFrame::FormatEmpty()
}
SwRectFnSet aRectFnSet(this);
- const SwTwips nChg = nHeight - aRectFnSet.GetHeight(getFramePrintArea());
+ SwTwips nChg = nHeight - aRectFnSet.GetHeight(getFramePrintArea());
+ const SwBodyFrame* pBody = FindBodyFrame();
+ if (pNonLastSplitFlyDrawObj && pBody)
+ {
+ // See if we need to increase the text frame height due to split flys. This is necessary for
+ // anchors of inner floating tables, where moving to a next page moves indirectly, so we
+ // want a correct text frame height.
+ SwTwips nFrameBottom = aRectFnSet.GetBottom(getFrameArea()) + nChg;
+ SwTwips nFlyBottom = aRectFnSet.GetBottom(pNonLastSplitFlyDrawObj->getFrameArea());
+ SwTwips nBodyBottom = aRectFnSet.GetBottom(pBody->getFrameArea());
+ if (nFlyBottom > nBodyBottom)
+ {
+ // This is the legacy case where flys may overlap with footer frames.
+ nFlyBottom = nBodyBottom;
+ }
+ if (pNonLastSplitFlyDrawObj->isFrameAreaPositionValid() && nFlyBottom > nFrameBottom)
+ {
+ nChg += (nFlyBottom - nFrameBottom);
+ }
+ }
if( !nChg )
SetUndersized( false );