sw/qa/extras/layout/data/tdf141220.docx |binary sw/qa/extras/layout/layout2.cxx | 12 ++++++++++++ sw/source/core/draw/dcontact.cxx | 6 +++--- 3 files changed, 15 insertions(+), 3 deletions(-)
New commits: commit 8da3586cff9cc11cf5db985d19851f21f0d42eb8 Author: Daniel Arato (NISZ) <arato.dan...@nisz.hu> AuthorDate: Mon Sep 27 12:49:57 2021 +0200 Commit: Balazs Varga <varga.bala...@nisz.hu> CommitDate: Fri Oct 1 12:30:52 2021 +0200 tdf#141220 sw: fix textbox popped out of off-page shape When you moved it downwards off the page it was anchored to, the textbox inside a shape used to appear exactly one page above the shape it was supposed to follow. This is hopefully fixed by the present commit. Regression from c9eb53f200225f2ee6ca695e1326843a487aee51 (tdf#135198 sw editing: text box fell out of its shape). Change-Id: Ib388292ca26444daa1900417347824059ee03f07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122687 Reviewed-by: László Németh <nem...@numbertext.org> Reviewed-by: Balazs Varga <varga.bala...@nisz.hu> Tested-by: Balazs Varga <varga.bala...@nisz.hu> diff --git a/sw/qa/extras/layout/data/tdf141220.docx b/sw/qa/extras/layout/data/tdf141220.docx new file mode 100644 index 000000000000..a65bdd4b8a51 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf141220.docx differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 91cb32016942..8c2624b1a389 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -1419,6 +1419,18 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf127118) assertXPath(pXmlDoc, "/root/page[2]/body/tab/row[1]/cell[1]/txt[1]", "WritingMode", "VertBTLR"); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf141220) +{ + createSwDoc(DATA_DIRECTORY, "tdf141220.docx"); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nShapeTop + = getXPath(pXmlDoc, "//anchored/SwAnchoredDrawObject/bounds", "top").toInt32(); + sal_Int32 nTextBoxTop = getXPath(pXmlDoc, "//anchored/fly/infos/bounds", "top").toInt32(); + // Make sure the textbox stays inside the shape. + CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(15), nTextBoxTop - nShapeTop); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf121509) { auto pDoc = createSwDoc(DATA_DIRECTORY, "Tdf121509.odt"); diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 7cd60ce197d0..762b27251cbe 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1342,7 +1342,6 @@ void SwDrawContact::Changed_( const SdrObject& rObj, } // tdf#135198: keep text box together with its shape - SwRect aObjRect(rObj.GetSnapRect()); const SwPageFrame* rPageFrame = pAnchoredDrawObj->GetPageFrame(); if (rPageFrame && rPageFrame->isFrameAreaPositionValid() && !rObj.getChildrenOfSdrObject()) { @@ -1359,10 +1358,11 @@ void SwDrawContact::Changed_( const SdrObject& rObj, pDoc->GetAttrPool(), svl::Items<RES_VERT_ORIENT, RES_HORI_ORIENT, RES_ANCHOR, RES_ANCHOR>); aSyncSet.Put(GetFormat()->GetHoriOrient()); - aSyncSet.Put(SwFormatVertOrient(aObjRect.Top() - rPageFrame->getFrameArea().Top(), + bool bRelToTableCell(false); + aSyncSet.Put(SwFormatVertOrient(pAnchoredDrawObj->GetRelPosToPageFrame(false, bRelToTableCell).getY(), text::VertOrientation::NONE, text::RelOrientation::PAGE_FRAME)); - aSyncSet.Put(SwFormatAnchor(RndStdIds::FLY_AT_PAGE, pAnchoredDrawObj->GetPageFrame()->GetPhyPageNum())); + aSyncSet.Put(SwFormatAnchor(RndStdIds::FLY_AT_PAGE, rPageFrame->GetPhyPageNum())); auto pSdrObj = const_cast<SdrObject*>(&rObj); if (pSdrObj != GetFormat()->FindRealSdrObject())