sw/qa/extras/ooxmlexport/data/tdf162746.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport21.cxx   |   14 ++++++++++++++
 sw/source/core/layout/tabfrm.cxx             |    6 ++++--
 3 files changed, 18 insertions(+), 2 deletions(-)

New commits:
commit e3786f684fd30d48ea0e00d81af9cbb88cd28cf4
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Sep 4 13:19:47 2024 +0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Sep 12 08:44:09 2024 +0200

    tdf#162781: also shift down tables with text::HoriOrientation::RIGHT
    
    As said in commit 7b1c03ed87f7a21606e09863b23074e6b96e26d1 (tdf#154775
    sw: layout: avoid breaking this with following commits, 2023-08-24), it
    would be best not to check HoriOrient at all, but needs checking first
    what Word does in other cases. So I just add another case that is known
    to require the shift.
    
    This backports the unit test from master commit
    74533c1f1d5e8e48a65d33bef236f1382d32aa06 (tdf#162746: sanitize width in
    SwTextFormatter::FeedInf, 2024-09-02), needed for this one.
    
    Change-Id: I05a8e17ec53741e99b004369629fd9fecf78526d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172855
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173228
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf162746.docx 
b/sw/qa/extras/ooxmlexport/data/tdf162746.docx
new file mode 100644
index 000000000000..6143196a13cb
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf162746.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index cd406e4d8541..3e30a030145e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -425,6 +425,20 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf162370)
     loadAndSave("too_many_styles.odt");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf162746)
+{
+    // Without the fix in place this hangs (and eventually OOMs) on opening
+    loadAndSave("tdf162746.docx");
+    // tdf#162781: test the page body table vertical offset and width
+    xmlDocUniquePtr pDump = parseLayoutDump();
+    // Without the fix, this would be 0 - i.e., the page body table didn't 
shift down
+    // below the header's floating table
+    assertXPath(pDump, "//page[1]/body/tab/infos/prtBounds"_ostr, "top"_ostr, 
u"35"_ustr);
+    // Without the fix, this would be 100, because the page body table only 
used tiny space
+    // to the left of the header's floating table
+    assertXPath(pDump, "//page[1]/body/tab/infos/prtBounds"_ostr, 
"width"_ostr, u"9360"_ustr);
+}
+
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index c765bd35e0cc..040635a513b7 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3294,7 +3294,8 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
         // TODO: why not just ignore HoriOrient?
         bool isHoriOrientShiftDown =
                rHori.GetHoriOrient() == text::HoriOrientation::NONE
-            || rHori.GetHoriOrient() == text::HoriOrientation::LEFT;
+            || rHori.GetHoriOrient() == text::HoriOrientation::LEFT
+            || rHori.GetHoriOrient() == text::HoriOrientation::RIGHT;
         // Only consider invalid Writer fly frames if they'll be shifted down.
         bool bIgnoreFlyValidity = bAddVerticalFlyOffsets && 
isHoriOrientShiftDown;
         bool bConsiderFly =
@@ -3460,7 +3461,8 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
         }
         if ((css::text::WrapTextMode_LEFT == nSurround
              || css::text::WrapTextMode_PARALLEL == nSurround)
-            && text::HoriOrientation::RIGHT == rHori.GetHoriOrient())
+            && text::HoriOrientation::RIGHT == rHori.GetHoriOrient()
+            && !bShiftDown)
         {
             const tools::Long nWidth
                 = 
aRectFnSet.XDiff(aRectFnSet.GetRight(pFly->GetAnchorFrame()->getFrameArea()),

Reply via email to