sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 11 ++++++++ sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx | 13 ++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-)
New commits: commit a4418c907fb40707f07a5794dd07a93e51140636 Author: Justin Luth <jl...@mail.com> AuthorDate: Sat Jul 27 08:35:32 2024 -0400 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Aug 14 11:22:21 2024 +0200 tdf#162211 tdf#137590 layoutInCell: vertical escaping with wrapThrough This patch allows shapes to go "from top" above the cell frame. (This was already working horizontally, and for positive, downward values). In theory, this should not be needed for ODT layout. ODT UI shouldn't allow cell-escaping values to be used. It does not currently affect FRAME/FRAME _shapes_ because those forcefully turn off layoutInCell, but it does affect FRAME/FRAME _images_ whose code path does not forcefully turn off layoutInCell. There are a few more places in the code where AdjustVertRelPos() is called, but most had no matching unit tests. I assume it is probably because we already don't CheckBottom. The following unit tests are affected by this patch PAGE/PAGE -tdf81345.docx (81345_045Original) [big green gradient - fixed] -tdf115883.docx [compat15 - miniscule .03cm offset] image - FRAME/FRAME -tdf135595_HFtableWrap_c12.docx [after round-trip - fixed] -tdf135595_HFtableWrap.odt [footer logo moves up - fixed] -layout-in-cell-2.docx [extremely minor offsets] make CppunitTest_sw_ooxmlexport14 \ CPPUNIT_TEST_NAME=testTdf135595_HFtableWrap These will be affected if layoutInCell is not forced off. shape - FRAME/FRAME -fdo68607.docx -test_segfault_while_save.docx [even zOrder is fixed somehow] -layout-in-cell-wrapnone-column.docx Change-Id: I13b030a2e7117557dd9794c0eb9bd74a0d67b82f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171436 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index d54ca9dd2ed8..1cc3cc849fc0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -97,6 +97,17 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf135595_HFtableWrap) // tdf#77794: always force bLayoutInCell from false to true for MSO2013+ // The fly is supposed to be inside the cell. Before, height was 998. Now it is 2839. CPPUNIT_ASSERT_MESSAGE("Image must be contained inside the table cell", nRowHeight > 2000); + + // tdf#162211: wrap-through fly can escape cell in upward direction now + sal_Int32 nFooterImageBottom + = getXPath(pXmlDoc, + "//page[1]/footer/tab/row/cell[1]/txt/anchored/fly/SwAnchoredObject/bounds"_ostr, + "bottom"_ostr) + .toInt32(); + sal_Int32 nFooterBottom + = getXPath(pXmlDoc, "//page[1]/footer/infos/bounds"_ostr, "bottom"_ostr).toInt32(); + // the image is above the botom of the footer + CPPUNIT_ASSERT(nFooterBottom > nFooterImageBottom); // image is higher footer } DECLARE_OOXMLEXPORT_TEST(testTdf135943_shapeWithText_L0c15, diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx index 50af1061151b..bc2f4ac608ad 100644 --- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx @@ -32,6 +32,7 @@ #include <fmtfsize.hxx> #include <fmtanchr.hxx> #include <fmtornt.hxx> +#include <IDocumentSettingAccess.hxx> #include <editeng/lrspitem.hxx> #include <editeng/ulspitem.hxx> #include <svx/svdobj.hxx> @@ -265,6 +266,14 @@ void SwToContentAnchoredObjectPosition::CalcPosition() } aRectFnSet.Refresh(pOrientFrame); + // Microsoft allows WrapThrough shapes to be placed outside of the cell despite layoutInCell + // (Re-use existing compat flag to identify MSO formats. The name also matches this purpose.) + const bool bMSOLayout = rFrameFormat.getIDocumentSettingAccess().get( + DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION); + const bool bMSOLayoutInCell + = bMSOLayout && DoesObjFollowsTextFlow() && GetAnchorTextFrame().IsInTab(); + const bool bIgnoreVertLayoutInCell = bMSOLayoutInCell && bWrapThrough; + // determine vertical position { @@ -663,7 +672,7 @@ void SwToContentAnchoredObjectPosition::CalcPosition() const bool bCheckBottom = !DoesObjFollowsTextFlow(); nRelPosY = AdjustVertRelPos( nTopOfAnch, aRectFnSet.IsVert(), aRectFnSet.IsVertL2R(), rVertEnvironLayFrame, nRelPosY, - DoesObjFollowsTextFlow(), + !bIgnoreVertLayoutInCell && DoesObjFollowsTextFlow(), bCheckBottom ); if ( aRectFnSet.IsVert() ) aRelPos.setX( nRelPosY ); @@ -887,7 +896,7 @@ void SwToContentAnchoredObjectPosition::CalcPosition() } } - if ( DoesObjFollowsTextFlow() && + if (!bIgnoreVertLayoutInCell && DoesObjFollowsTextFlow() && ( aVert.GetRelationOrient() != text::RelOrientation::PAGE_FRAME && aVert.GetRelationOrient() != text::RelOrientation::PAGE_PRINT_AREA ) ) {