sw/qa/extras/ooxmlexport/data/tdf148720.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 59 ++++++++++++++++++++++++++++ sw/source/core/doc/textboxhelper.cxx | 5 ++ 3 files changed, 64 insertions(+)
New commits: commit 5648363e8f70cd95b00db62f91effb7eb1385ac9 Author: Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu> AuthorDate: Wed May 11 09:12:12 2022 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Thu May 19 11:18:33 2022 +0200 tdf#148720 sw DOCX: fix jumbled group textbox regression Left-aligned group shape was synced to the textbox, resulting jumbled positions after DOCX export/import. To fix it, set horizontal orientation of the textbox back to NONE. Regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834 "tdf#143574 OOXML export/import of textboxes in group shapes". Change-Id: I02ee79862344f3495846091e3eef27c24d8ef162 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134149 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf148720.odt b/sw/qa/extras/ooxmlexport/data/tdf148720.odt new file mode 100644 index 000000000000..771c845053ee Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf148720.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 62f8095dabaf..5c25a3b5d369 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -442,6 +442,65 @@ DECLARE_OOXMLEXPORT_TEST(TestWPGZOrder, "testWPGZOrder.docx") } } +DECLARE_OOXMLEXPORT_TEST(testTdf148720, "tdf148720.odt") +{ + const auto& pLayout = parseLayoutDump(); + + const OString sShapeXPaths[] = + { + OString("/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObject[1]"), + OString("/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObjGroup/SdrObjList/SdrObjGroup/SdrObjList/SdrObject[1]"), + OString("/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObjGroup/SdrObjList/SdrObjGroup/SdrObjList/SdrObject[2]"), + OString("/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObject[2]") + }; + + const OString sTextXPaths[] = + { + OString("/root/page/body/txt/anchored/fly[1]/infos/bounds"), + OString("/root/page/body/txt/anchored/fly[2]/infos/bounds"), + OString("/root/page/body/txt/anchored/fly[3]/infos/bounds"), + OString("/root/page/body/txt/anchored/fly[4]/infos/bounds") + }; + + const OString sAttribs[] = + { + OString("left"), + OString("top"), + OString("width"), + OString("height") + }; + + for (sal_Int32 i = 0; i < 4; ++i) + { + OUString aShapeVals[4]; + int aTextVals[4] = {0, 0, 0, 0}; + + const auto aOutRect = getXPath(pLayout, sShapeXPaths[i], "aOutRect"); + + sal_uInt16 nCommaPos[4] = {0, 0, 0, 0}; + nCommaPos[1] = aOutRect.indexOf(","); + nCommaPos[2] = aOutRect.indexOf(",", nCommaPos[1] + 1); + nCommaPos[3] = aOutRect.indexOf(",", nCommaPos[2] + 1); + + + aShapeVals[0] = aOutRect.copy(nCommaPos[0], nCommaPos[1] - nCommaPos[0]); + aShapeVals[1] = aOutRect.copy(nCommaPos[1] + 2, nCommaPos[2] - nCommaPos[1] - 2); + aShapeVals[2] = aOutRect.copy(nCommaPos[2] + 2, nCommaPos[3] - nCommaPos[2] - 2); + aShapeVals[3] = aOutRect.copy(nCommaPos[3] + 2, aOutRect.getLength() - nCommaPos[3] - 2); + + for (int ii = 0; ii < 4; ++ii) + { + aTextVals[ii] = getXPath(pLayout, sTextXPaths[i], sAttribs[ii]).toInt32(); + } + + tools::Rectangle ShapeArea(Point(aShapeVals[0].toInt32(), aShapeVals[1].toInt32()), Size(aShapeVals[2].toInt32() + 5, aShapeVals[3].toInt32() + 5)); + + tools::Rectangle TextArea(Point(aTextVals[0], aTextVals[1]), Size(aTextVals[2], aTextVals[3])); + + CPPUNIT_ASSERT(ShapeArea.Contains(TextArea)); + } +} + DECLARE_OOXMLEXPORT_TEST(testTdf126287, "tdf126287.docx") { CPPUNIT_ASSERT_EQUAL(2, getPages()); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 676f31fd4022..68d42b7e91f7 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1344,6 +1344,8 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb // Set the textbox position at the X-axis: SwFormatHoriOrient aNewHOri(pFormat->GetHoriOrient()); + if (bIsGroupObj && aNewHOri.GetHoriOrient() != text::HoriOrientation::NONE) + aNewHOri.SetHoriOrient(text::HoriOrientation::NONE); aNewHOri.SetPos(aRect.Left() + nLeftSpace + (bIsGroupObj ? pObj->GetRelativePos().getX() : 0)); SwFormatVertOrient aNewVOri(pFormat->GetVertOrient()); @@ -1424,6 +1426,9 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb // Set the same position as the (child) shape has SwFormatHoriOrient aNewHOri(pShape->GetHoriOrient()); + if (bIsGroupObj && aNewHOri.GetHoriOrient() != text::HoriOrientation::NONE) + aNewHOri.SetHoriOrient(text::HoriOrientation::NONE); + aNewHOri.SetPos( (bIsGroupObj && pObj ? pObj->GetRelativePos().getX() : aNewHOri.GetPos()) + aRect.Left());