sw/qa/extras/ooxmlexport/data/tdf76022_textboxWrap.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 13 +++++++++ sw/source/core/layout/tabfrm.cxx | 23 +++++++++++------ 3 files changed, 29 insertions(+), 7 deletions(-)
New commits: commit afbe948d4c47391092c8fcf4130bd7501c3d5062 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Thu Mar 23 12:17:28 2023 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Fri Mar 24 18:25:37 2023 +0000 tdf#115625 tdf#76022 sw table: CalcFlyOffset: get correct surround for textbox The function thought it was dealing with a wrap-through shape, but actually it is wrap parallel. Attempts to syncProperty of RES_SURROUND meet with instant disaster, and likely this emulation works better if the doubled-up shape only has one wrap anyway. There is a helper function for this after all, so that highly suggests workarounds are necessary instead of just syncing the wrap property. There were two existing unit tests identified: -tdf123163-1.docx (doesn't even open in MS Word 2010/2003) -testCustomShapePresetExport.odt (on round-trip) -no differences noticed. Change-Id: I7b0828ce6406fa9cfb1debb68040ea02e8d6fe45 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149463 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf76022_textboxWrap.odt b/sw/qa/extras/ooxmlexport/data/tdf76022_textboxWrap.odt new file mode 100644 index 000000000000..b08fe002f32b Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf76022_textboxWrap.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index b784724fce6f..3f0a92bf95c7 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -367,6 +367,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153964_firstIndentAfterBreak14, "tdf153964_first CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaFirstLineIndent")); } +CPPUNIT_TEST_FIXTURE(Test, testTdf76022_textboxWrap) +{ + // Granted, this is an ODT with a bit of an anomoly - tables ignore fly wrapping. + createSwDoc("tdf76022_textboxWrap.odt"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Did you make wrapping sane/interoperable?", 1, getPages()); + + // When saving to DOCX, the table should obey the fly wrapping + reload("Office Open XML Text", ""); + + // The fly takes up the whole page, so the table needs to shift down to the next page. + CPPUNIT_ASSERT_EQUAL(2, getPages()); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert) { // Given a docx document with a shape with vert="mongolianVert". diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 71d736499d8e..900f3ba71fe1 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -2914,12 +2914,21 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, if ( bConsiderFly ) { - const SwFormatSurround &rSur = pFly->GetFormat()->GetSurround(); + text::WrapTextMode nSurround = pFly->GetFormat()->GetSurround().GetSurround(); + // If the frame format is a TextBox of a draw shape, + // then use the surround of the original shape. + bool bWrapThrough = nSurround == text::WrapTextMode_THROUGH; + SwTextBoxHelper::getShapeWrapThrough(pFly->GetFormat(), bWrapThrough); + if (bWrapThrough && nSurround != text::WrapTextMode_THROUGH) + nSurround = text::WrapTextMode_THROUGH; + else if (!bWrapThrough && nSurround == text::WrapTextMode_THROUGH) + nSurround = text::WrapTextMode_PARALLEL; + const SwFormatHoriOrient &rHori= pFly->GetFormat()->GetHoriOrient(); - bool bShiftDown = css::text::WrapTextMode_NONE == rSur.GetSurround(); + bool bShiftDown = css::text::WrapTextMode_NONE == nSurround; if (!bShiftDown && bAddVerticalFlyOffsets) { - if (rSur.GetSurround() == text::WrapTextMode_PARALLEL + if (nSurround == text::WrapTextMode_PARALLEL && rHori.GetHoriOrient() == text::HoriOrientation::NONE) { // We know that wrapping was requested and the table frame overlaps with @@ -2979,8 +2988,8 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, bInvalidatePrtArea = true; } } - if ( (css::text::WrapTextMode_RIGHT == rSur.GetSurround() || - css::text::WrapTextMode_PARALLEL == rSur.GetSurround())&& + if ((css::text::WrapTextMode_RIGHT == nSurround + || css::text::WrapTextMode_PARALLEL == nSurround) && text::HoriOrientation::LEFT == rHori.GetHoriOrient() ) { const tools::Long nWidth = aRectFnSet.XDiff( @@ -2989,8 +2998,8 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, rLeftOffset = std::max( rLeftOffset, nWidth ); bInvalidatePrtArea = true; } - if ( (css::text::WrapTextMode_LEFT == rSur.GetSurround() || - css::text::WrapTextMode_PARALLEL == rSur.GetSurround())&& + if ((css::text::WrapTextMode_LEFT == nSurround + || css::text::WrapTextMode_PARALLEL == nSurround) && text::HoriOrientation::RIGHT == rHori.GetHoriOrient() ) { const tools::Long nWidth = aRectFnSet.XDiff(