diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-02-14 16:29:44 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-02-14 18:37:34 +0100 |
commit | fd7749fddc5a767461dfced55369af48e5a6d561 (patch) | |
tree | 0a89f95af653d467958c008102a3126242a8d6b0 /sw/source/core/layout/tabfrm.cxx | |
parent | 10e08b1d398e6aa91aa4ced0ca6c966349be8b5d (diff) |
sw: fix handling of table vs fly overlaps in the AddVerticalFlyOffsets case
When a table overlaps with a fly frame, Writer creates a fly portion
inside the relevant cell frame (increasing its height), and Word shifts
the table down. Both are valid approaches, but the rendering result is
different in case the table has a border.
So keep the default unchanged, but in case the AddVerticalFlyOffsets
compat flag (set by the Word importers) is set, avoid the overlap the
Word way.
Note that the table frame uses the full width (available in the body)
even for e.g. 50% width tables, so check for the overlap using the print
area, which does not always overlap.
Finally, don't always require a valid frame area definition from the fly
frame:
- the mentioned i#46807 bugdoc currently doesn't need that check
- the fly frame area definition becomes valid only after already
positioning the table, leading to an overlap
Keep that check for the non-compat case, though.
Change-Id: I9202050befebf2efdbb5395ded6fcb52b378d8e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88724
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/source/core/layout/tabfrm.cxx')
-rw-r--r-- | sw/source/core/layout/tabfrm.cxx | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index b3f4ffef0ab2..48de92a8dc64 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -35,6 +35,7 @@ #include <editeng/ulspitem.hxx> #include <editeng/brushitem.hxx> #include <editeng/boxitem.hxx> +#include <basegfx/range/b1drange.hxx> #include <fmtlsplt.hxx> #include <fmtrowsplt.hxx> #include <fmtsrnd.hxx> @@ -2696,6 +2697,9 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, long nYDiff = aRectFnSet.YDiff( aRectFnSet.GetTop(getFramePrintArea()), rUpper ); if( nYDiff > 0 ) aRectFnSet.AddBottom( aRect, -nYDiff ); + + bool bAddVerticalFlyOffsets = rIDSA.get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS); + for ( size_t i = 0; i < pPage->GetSortedObjs()->size(); ++i ) { SwAnchoredObject* pAnchoredObj = (*pPage->GetSortedObjs())[i]; @@ -2723,7 +2727,7 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, bool bConsiderFly = // #i46807# - do not consider invalid // Writer fly frames. - pFly->isFrameAreaDefinitionValid() && + (pFly->isFrameAreaDefinitionValid() || bAddVerticalFlyOffsets) && // fly anchored at character pFly->IsFlyAtContentFrame() && // fly overlaps with corresponding table rectangle @@ -2767,7 +2771,29 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, { const SwFormatSurround &rSur = pFly->GetFormat()->GetSurround(); const SwFormatHoriOrient &rHori= pFly->GetFormat()->GetHoriOrient(); - if ( css::text::WrapTextMode_NONE == rSur.GetSurround() ) + bool bShiftDown = css::text::WrapTextMode_NONE == rSur.GetSurround(); + if (!bShiftDown && bAddVerticalFlyOffsets) + { + if (rSur.GetSurround() == text::WrapTextMode_PARALLEL + && rHori.GetHoriOrient() == text::HoriOrientation::NONE) + { + // We know that wrapping was requested and the table frame overlaps with + // the fly frame. Check if the print area overlaps with the fly frame as + // well (in case the table does not use all the available width). + basegfx::B1DRange aTabRange( + aRectFnSet.GetLeft(aRect) + aRectFnSet.GetLeft(getFramePrintArea()), + aRectFnSet.GetLeft(aRect) + aRectFnSet.GetLeft(getFramePrintArea()) + + aRectFnSet.GetWidth(getFramePrintArea())); + basegfx::B1DRange aFlyRange(aRectFnSet.GetLeft(aFlyRect), + aRectFnSet.GetRight(aFlyRect)); + // If it does, shift the table down. Do this only in the compat case, + // normally an SwFlyPortion is created instead that increases the height + // of the first table row. + bShiftDown = aTabRange.overlaps(aFlyRange); + } + } + + if (bShiftDown) { long nBottom = aRectFnSet.GetBottom(aFlyRect); if( aRectFnSet.YDiff( nPrtPos, nBottom ) < 0 ) |