sw/source/core/layout/tabfrm.cxx |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit decade708924e8dbc416893734d2273fcc657dcf
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Wed Aug 23 15:51:32 2023 +0200
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Tue Sep 26 13:37:32 2023 +0200

    tdf#154775 sw: layout: avoid breaking this with following commits
    
    The problem with commit 1b5bc2ae2f19a190bf588a5a26c4d125c3960991 is that
    the fix only works in case the fly is invalid at the time when
    SwTabFrame::CalcFlyOffsets() is called; if it is valid (which will be
    the case with following commits, for non-obvious reasons) then the fix
    does nothing, causing testTablePrintAreaLeft to fail.
    
    In Word 2013, this fly causes the table to shift down, despite its
    HoriOrient being LEFT; so adapt SwTabFrame::CalcFlyOffsets() to also
    shift down in this case.
    
    Likely it would be best not to check HoriOrient at all for ShiftDown
    case, but needs checking first what Word does in other cases.
    
    Change-Id: I465a55bbf1a783abce8b8d6d65099bd9df5695f8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155987
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 7b1c03ed87f7a21606e09863b23074e6b96e26d1)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156964
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index c386bf2ab9de..1c3a878b85d2 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2973,9 +2973,12 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
         //   text frame has already changed its page.
         const SwTextFrame* pAnchorCharFrame = pFly->FindAnchorCharFrame();
         const SwFormatHoriOrient& rHori= pFly->GetFormat()->GetHoriOrient();
+        // TODO: why not just ignore HoriOrient?
+        bool isHoriOrientShiftDown =
+               rHori.GetHoriOrient() == text::HoriOrientation::NONE
+            || rHori.GetHoriOrient() == text::HoriOrientation::LEFT;
         // Only consider invalid Writer fly frames if they'll be shifted down.
-        bool bIgnoreFlyValidity
-            = bAddVerticalFlyOffsets && rHori.GetHoriOrient() == 
text::HoriOrientation::NONE;
+        bool bIgnoreFlyValidity = bAddVerticalFlyOffsets && 
isHoriOrientShiftDown;
         bool bConsiderFly =
             // #i46807# - do not consider invalid
             // Writer fly frames.
@@ -3031,8 +3034,7 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
         bool bShiftDown = css::text::WrapTextMode_NONE == nSurround;
         if (!bShiftDown && bAddVerticalFlyOffsets)
         {
-            if (nSurround == text::WrapTextMode_PARALLEL
-                && rHori.GetHoriOrient() == text::HoriOrientation::NONE)
+            if (nSurround == text::WrapTextMode_PARALLEL && 
isHoriOrientShiftDown)
             {
                 // 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
@@ -3094,7 +3096,8 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
 
         if ((css::text::WrapTextMode_RIGHT == nSurround
              || css::text::WrapTextMode_PARALLEL == nSurround)
-            && text::HoriOrientation::LEFT == rHori.GetHoriOrient())
+            && text::HoriOrientation::LEFT == rHori.GetHoriOrient()
+            && !bShiftDown)
         {
             const tools::Long nWidth
                 = aRectFnSet.XDiff(aRectFnSet.GetRight(aFlyRect),

Reply via email to