sw/qa/extras/layout/data/tdf146272.odt     |binary
 sw/qa/extras/layout/layout2.cxx            |   21 +++++++++++++++++++++
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |    2 +-
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx |    2 +-
 sw/source/core/layout/flylay.cxx           |   17 +++++++++++++++--
 5 files changed, 38 insertions(+), 4 deletions(-)

New commits:
commit e1f6b136fd125c5d3648c51b202a698d418afc18
Author:     Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu>
AuthorDate: Wed May 25 15:40:57 2022 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Mon May 30 13:21:10 2022 +0200

    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 <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@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 000000000000..3652cf06f110
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf146272.odt differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index f88fbdc94f71..a47642acfb8d 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 0fc4462e32b7..cf5877ea873d 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 67f3c838e759..d85a8da12f18 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 8ffa9ff3d860..38d8f2887c48 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.

Reply via email to