tdf#135198: fix unittest
The problem was reintroduced in
f2eef84ff03660cbb46a76c317e640e054ed0a56
and the previous unittest didn't fail.
Change-Id: I7e25afd265d8f19fdced17efe5815fb93321a9ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105805
Tested-by: Jenkins
Reviewed-by: Dániel Arató <arato.daniel@nisz.hu>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/qa/core/layout/data/shape-textbox.odt b/sw/qa/core/layout/data/shape-textbox.odt
index 26a9eb7..15b0aa4 100644
--- a/sw/qa/core/layout/data/shape-textbox.odt
+++ b/sw/qa/core/layout/data/shape-textbox.odt
Binary files differ
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
index a992a32..b66a4f5 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -14,10 +14,6 @@
#include <wrtsh.hxx>
#include <docsh.hxx>
#include <unotxdoc.hxx>
#include <flyfrm.hxx>
#include <fmtornt.hxx>
#include <frmtool.hxx>
#include <textboxhelper.hxx>
#include <drawdoc.hxx>
#include <IDocumentDrawModelAccess.hxx>
#include <svx/svdpage.hxx>
@@ -174,26 +170,14 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxStaysInsideShape)
{
// tdf#135198: check whether text box stays inside shape after moving it upwards
load(DATA_DIRECTORY, "shape-textbox.odt");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
SdrObject* pTextBoxObj = pPage->GetObj(0);
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT(pXmlDoc);
xmlDocUniquePtr pLayoutBefore = parseLayoutDump();
CPPUNIT_ASSERT(pLayoutBefore);
const int nTextBoxTopBefore = getXPath(pLayoutBefore, "//fly/infos/bounds", "top").toInt32();
uno::Reference<drawing::XShape> xShape(pTextBoxObj->getUnoShape(), uno::UNO_QUERY_THROW);
auto aPosition = xShape->getPosition();
aPosition.Y -= 500;
xShape->setPosition(aPosition);
discardDumpedLayout();
xmlDocUniquePtr pLayoutAfter = parseLayoutDump();
CPPUNIT_ASSERT(pLayoutAfter);
const int nTextBoxTopAfter = getXPath(pLayoutAfter, "//fly/infos/bounds", "top").toInt32();
CPPUNIT_ASSERT_MESSAGE("text box was supposed to stay inside its shape",
nTextBoxTopAfter < nTextBoxTopBefore);
// Without the fix in place, this test would have failed with
// - Expected: 1932
// - Actual : 7476
assertXPath(pXmlDoc, "//fly/infos/bounds", "top", "1932");
assertXPath(pXmlDoc, "//fly/infos/bounds", "bottom", "7184");
}
CPPUNIT_PLUGIN_IMPLEMENT();