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 <nemeth@numbertext.org>
Reviewed-by: Balazs Varga <varga.balazs3@nisz.hu>
Tested-by: Balazs Varga <varga.balazs3@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 0000000..a65bdd4
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf141220.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 91cb320..8c2624b 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 7cd60ce..762b272 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())