sw/qa/extras/layout/data/tdf69648.docx |binary sw/qa/extras/layout/layout2.cxx | 42 +++++++++++++++++++++++++++++++++ sw/source/core/doc/textboxhelper.cxx | 20 +++++++++++++++ 3 files changed, 62 insertions(+)
New commits: commit 9c0779cfe6a091e222a35b068e9354dce32cc2dc Author: Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu> AuthorDate: Thu Feb 10 18:59:11 2022 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed Mar 2 09:11:23 2022 +0100 tdf#69648 tdf#119234 sw: fix at-char group textbox position in case of it has at-page relative position. This fixes missing or invisible text content of shapes. Note: the remaining problem (original DOCX resaved in MSO 2016) was fixed at tdf#119234. Partial regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834 "tdf#143574 OOXML export/import of textboxes in group shapes". Change-Id: I5c9af0d9a50e4251d3017862ad1fc94eca7d40c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129796 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/layout/data/tdf69648.docx b/sw/qa/extras/layout/data/tdf69648.docx new file mode 100644 index 000000000000..5bf8fcc70911 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf69648.docx differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 8b457c7f3f9c..38451465bab0 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -946,6 +946,48 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHorizontal_multilevel) CPPUNIT_ASSERT_DOUBLES_EQUAL(8057, nYposition, 20); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf69648) +{ + createSwDoc(DATA_DIRECTORY, "tdf69648.docx"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + + OString sShapeXPath[2] = { + "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObject[1]", + "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObject[2]" + }; + OString sFrameXPath[2] = { "/root/page/body/txt/anchored/fly[1]/infos/bounds", + "/root/page/body/txt/anchored/fly[2]/infos/bounds" }; + + for (int i = 0; i < 2; ++i) + { + const auto sDrawRect = getXPath(pXmlDoc, sShapeXPath[i], "aOutRect"); + const auto nComaPos1 = sDrawRect.indexOf(',', 0); + const auto nComaPos2 = sDrawRect.indexOf(',', nComaPos1 + 1); + const auto nComaPos3 = sDrawRect.indexOf(',', nComaPos2 + 1); + + const auto nDraw1 = OUString(sDrawRect.subView(0, nComaPos1).data()).toInt64(); + const auto nDraw2 + = OUString(sDrawRect.subView(nComaPos1 + 1, nComaPos2 - nComaPos1).data()).toInt64(); + const auto nDraw3 + = OUString(sDrawRect.subView(nComaPos2 + 1, nComaPos3 - nComaPos2).data()).toInt64(); + const auto nDraw4 + = OUString( + sDrawRect.subView(nComaPos3 + 1, sDrawRect.getLength() - nComaPos3 - 1).data()) + .toInt64(); + const auto aChildShape = SwRect(nDraw1, nDraw2, nDraw3, nDraw4); + + const auto nFlyLeft = getXPath(pXmlDoc, sFrameXPath[i], "left").toInt64(); + const auto nFlyTop = getXPath(pXmlDoc, sFrameXPath[i], "top").toInt64(); + const auto nFlyWidth = getXPath(pXmlDoc, sFrameXPath[i], "width").toInt64(); + const auto nFlyHeight = getXPath(pXmlDoc, sFrameXPath[i], "height").toInt64(); + + const auto aFrame = SwRect(nFlyLeft, nFlyTop, nFlyWidth, nFlyHeight); + + CPPUNIT_ASSERT_MESSAGE("Textbox must be inside the shape!", aChildShape.Contains(aFrame)); + } +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194) { SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "xaxis-labelbreak.docx"); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 206e05dc811e..6657a5244305 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1408,6 +1408,26 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb (bIsGroupObj && pObj ? pObj->GetRelativePos().getY() : aNewVOri.GetPos()) + aRect.Top()); + const auto& nInshapePos + = pObj ? pObj->GetRelativePos() - pShape->FindRealSdrObject()->GetRelativePos() + : Point(); + + if (pShape->GetHoriOrient().GetRelationOrient() == text::RelOrientation::PAGE_FRAME + && pShape->GetAnchor().GetAnchorId() != RndStdIds::FLY_AT_PAGE) + { + aNewHOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME); + aNewHOri.SetPos(pShape->GetHoriOrient().GetPos() + nInshapePos.getX() + + aRect.Left()); + } + + if (pShape->GetVertOrient().GetRelationOrient() == text::RelOrientation::PAGE_FRAME + && pShape->GetAnchor().GetAnchorId() != RndStdIds::FLY_AT_PAGE) + { + aNewVOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME); + aNewVOri.SetPos(pShape->GetVertOrient().GetPos() + nInshapePos.getY() + + aRect.Top()); + } + pFormat->SetFormatAttr(aNewHOri); pFormat->SetFormatAttr(aNewVOri); }