diff options
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx | bin | 0 -> 30061 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 49 | ||||
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 8 |
5 files changed, 68 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx b/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx Binary files differnew file mode 100644 index 000000000000..664f47a0b623 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index e23a42bf4983..3dafae143432 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -116,9 +116,9 @@ protected: DECLARE_OOXMLEXPORT_TEST(testWPGtextboxes, "testWPGtextboxes.docx") { - CPPUNIT_ASSERT_EQUAL(1, getShapes()); + CPPUNIT_ASSERT_EQUAL(2, getShapes()); - auto MyShape = getShape(1); + auto MyShape = getShape(2); 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 395f0dbf03fc..42b7a0891877 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/awt/FontSlant.hpp> #include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/drawing/XShapes.hpp> #include <comphelper/configuration.hxx> @@ -28,6 +29,7 @@ #include <officecfg/Office/Common.hxx> #include <comphelper/propertyvalue.hxx> +#include <queue> #include <swmodeltestbase.hxx> #include <unotxdoc.hxx> @@ -390,6 +392,53 @@ DECLARE_OOXMLEXPORT_TEST(testTdf126287, "tdf126287.docx") CPPUNIT_ASSERT_EQUAL(2, getPages()); } +DECLARE_OOXMLEXPORT_TEST(TestWPGZOrder, "testWPGZOrder.docx") +{ + // Check if the load failed. + CPPUNIT_ASSERT(mxComponent); + + // Get the WPG + uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xGroupProperties(xGroup, uno::UNO_QUERY_THROW); + + // Initialize a queue for subgroups + std::queue<uno::Reference<drawing::XShapes>> xGroupList; + xGroupList.push(xGroup); + + // Every textbox shall be visible. + while (xGroupList.size()) + { + // Get the first group + xGroup = xGroupList.front(); + xGroupList.pop(); + for (sal_Int32 i = 0; i < xGroup->getCount(); ++i) + { + // Get the child shape + uno::Reference<beans::XPropertySet> xChildShapeProperties(xGroup->getByIndex(i), + uno::UNO_QUERY_THROW); + // Check for textbox + if (!xChildShapeProperties->getPropertyValue("TextBox").get<bool>()) + { + // Is this a Group Shape? Put it into the queue. + uno::Reference<drawing::XShapes> xInnerGroup(xGroup->getByIndex(i), uno::UNO_QUERY); + if (xInnerGroup) + xGroupList.push(xInnerGroup); + continue; + } + + // Get the textbox properties + uno::Reference<beans::XPropertySet> xTextBoxFrameProperties( + xChildShapeProperties->getPropertyValue("TextBoxContent"), uno::UNO_QUERY_THROW); + + // Assert that the textbox ZOrder greater than the groupshape + CPPUNIT_ASSERT_GREATER(xGroupProperties->getPropertyValue("ZOrder").get<long>(), + xTextBoxFrameProperties->getPropertyValue("ZOrder").get<long>()); + // Before the fix, this failed because that was less, and the textboxes were covered. + } + + } +} + DECLARE_OOXMLEXPORT_TEST(testTdf123642_BookmarkAtDocEnd, "tdf123642.docx") { // get bookmark interface diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index bcdf25002305..bb1d6f331dbc 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1432,15 +1432,20 @@ bool SwTextBoxHelper::DoTextBoxZOrderCorrection(SwFrameFormat* pShape, const Sdr { // TODO: do this with group shape textboxes. SdrObject* pShpObj = nullptr; - //if (pObj) - // pShpObj = pObj; - //else + pShpObj = pShape->FindRealSdrObject(); if (pShpObj) { - if (SdrObject* pFrmObj - = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT, pObj)->FindRealSdrObject()) + auto pTextBox = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT, pObj); + SdrObject* pFrmObj = pTextBox->FindRealSdrObject(); + if (!pFrmObj) + { + // During doc-loading there is no ready SdrObj for z-ordering, so create one here and cache it. + pFrmObj + = SwXTextFrame::GetOrCreateSdrObject(*dynamic_cast<SwFlyFrameFormat*>(pTextBox)); + } + if (pFrmObj) { // Get the draw model from the doc SwDrawModel* pDrawModel diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 35085e42740f..63011f0171a8 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1369,7 +1369,13 @@ void SwDrawContact::Changed_( const SdrObject& rObj, aSet.Put(aSyncSet); aSet.Put(pSdrObj->GetMergedItem(RES_FRM_SIZE)); SwTextBoxHelper::syncFlyFrameAttr(*GetFormat(), aSet, pSdrObj); - SwTextBoxHelper::changeAnchor(GetFormat(), pSdrObj); + + SwTextBoxHelper::synchronizeGroupTextBoxProperty( + &SwTextBoxHelper::changeAnchor, GetFormat(), + GetFormat()->FindRealSdrObject()); + SwTextBoxHelper::synchronizeGroupTextBoxProperty( + &SwTextBoxHelper::syncTextBoxSize, GetFormat(), + GetFormat()->FindRealSdrObject()); } else SwTextBoxHelper::syncFlyFrameAttr(*GetFormat(), aSyncSet, GetFormat()->FindRealSdrObject()); |