tdf#146272 sw: fix fly in fly hid by incomplete z-ordering
Fixing z-order was incomplete for textboxes
(shape + frame pair), because only the frame
moved to back, but not the shape, covering the
textbox.
Regression from commit 504d78acb866495fd954fcd6db22ea68f174a5ab
"tdf#143574 sw: textboxes in group shapes - part 1".
See also commit 0e6d963fbca16f98a3dbb6ef2fee3736a89d055b
"tdf#138141 sw: fix textbox z-order".
Change-Id: I03e3b55302c984e5968e579e77ccd5ed0a336dd9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134942
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/qa/extras/layout/data/tdf146272.odt b/sw/qa/extras/layout/data/tdf146272.odt
new file mode 100644
index 0000000..3652cf0
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf146272.odt
Binary files differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index f88fbdc..a47642a 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -1072,6 +1072,27 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194)
assertXPath(pXmlDoc, "//textarray", 8);
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf146272)
{
createSwDoc(DATA_DIRECTORY, "tdf146272.odt");
uno::Reference<beans::XPropertySet> xPicture(getShape(2), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xDrawing(getShape(1), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xFrame(xDrawing->getPropertyValue("TextBoxContent"),
uno::UNO_QUERY);
CPPUNIT_ASSERT(xPicture);
CPPUNIT_ASSERT(xDrawing);
CPPUNIT_ASSERT(xFrame);
const sal_uInt64 nPitureZorder = xPicture->getPropertyValue("ZOrder").get<sal_uInt64>();
const sal_uInt64 nDrawingZorder = xDrawing->getPropertyValue("ZOrder").get<sal_uInt64>();
const sal_uInt64 nFrameZorder = xFrame->getPropertyValue("ZOrder").get<sal_uInt64>();
CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nDrawingZorder < nFrameZorder);
CPPUNIT_ASSERT_MESSAGE("Bad ZOrder!", nFrameZorder < nPitureZorder);
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138773)
{
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf138773.docx");
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 0fc4462..cf5877e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -89,7 +89,7 @@ DECLARE_OOXMLEXPORT_TEST(testWPGtextboxes, "testWPGtextboxes.docx")
{
CPPUNIT_ASSERT_EQUAL(2, getShapes());
auto MyShape = getShape(2);
auto MyShape = getShape(1);
CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), MyShape->getShapeType());
uno::Reference<drawing::XShapes> xGroup(MyShape, uno::UNO_QUERY_THROW);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 67f3c83..d85a8da 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -645,7 +645,7 @@ DECLARE_OOXMLEXPORT_TEST(testWPGBodyPr, "WPGbodyPr.docx")
CPPUNIT_ASSERT_EQUAL(2, getShapes());
// Get the WPG shape
uno::Reference<drawing::XShapes> xGroup(getShape(2), uno::UNO_QUERY);
uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
// And the embed WPG
uno::Reference<drawing::XShapes> xEmbedGroup(xGroup->getByIndex(1), uno::UNO_QUERY);
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 8ffa9ff..38d8f28 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -810,10 +810,23 @@ void SwPageFrame::AppendFlyToPage( SwFlyFrame *pNew )
{
//#i119945# set pFly's OrdNum to _rNewObj's. So when pFly is removed by Undo, the original OrdNum will not be changed.
sal_uInt32 nNewNum = pObj->GetOrdNumDirect();
SdrObject* pDrawObj = nullptr;
if (auto pFormat = pFly->GetFormat())
if (auto pShapeFormat = SwTextBoxHelper::getOtherTextBoxFormat(pFormat, RES_FLYFRMFMT))
pDrawObj = pShapeFormat->FindRealSdrObject();
if (pDrawObj)
{
if (auto pPage = pDrawObj->getSdrPageFromSdrObject())
pPage->SetObjectOrdNum(pDrawObj->GetOrdNumDirect(), nNewNum);
else
pDrawObj->SetOrdNum(nNewNum);
}
if ( pObj->getSdrPageFromSdrObject() )
pObj->getSdrPageFromSdrObject()->SetObjectOrdNum( pFly->GetVirtDrawObj()->GetOrdNumDirect(), nNewNum );
pObj->getSdrPageFromSdrObject()->SetObjectOrdNum( pFly->GetVirtDrawObj()->GetOrdNumDirect(), nNewNum + (pDrawObj ? 1 : 0) );
else
pFly->GetVirtDrawObj()->SetOrdNum( nNewNum );
pFly->GetVirtDrawObj()->SetOrdNum( nNewNum + (pDrawObj ? 1 : 0));
}
// Don't look further at Flys that sit inside the Content.