From 0cb370d02bebf6a9d65b5852815e2c617b33a89a Mon Sep 17 00:00:00 2001 From: "Attila Bakos (NISZ)" Date: Tue, 11 Jan 2022 12:09:46 +0100 Subject: Related tdf#66039 DOCX import: fix Z-order of group shapes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A missing function resulted covered textboxes which weren't visible in group shapes. Follow-up to 121cbc250b36290f0f8c7265fea57256dad69553 "tdf#66039 DOCX: import textboxes (with tables, images etc.) in group shapes". Change-Id: I08eb1c1cf4a4f4769af8812500b9cf9778b01e9c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128279 Tested-by: László Németh Reviewed-by: László Németh Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143372 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna --- sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx | Bin 0 -> 30061 bytes sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 4 +- sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 49 +++++++++++++++++++++++ sw/source/core/doc/textboxhelper.cxx | 15 ++++--- sw/source/core/draw/dcontact.cxx | 8 +++- 5 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx diff --git a/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx b/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx new file mode 100644 index 000000000000..664f47a0b623 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/testWPGZOrder.docx differ 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 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 #include #include +#include #include @@ -28,6 +29,7 @@ #include #include +#include #include #include @@ -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 xGroup(getShape(1), uno::UNO_QUERY_THROW); + uno::Reference xGroupProperties(xGroup, uno::UNO_QUERY_THROW); + + // Initialize a queue for subgroups + std::queue> 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 xChildShapeProperties(xGroup->getByIndex(i), + uno::UNO_QUERY_THROW); + // Check for textbox + if (!xChildShapeProperties->getPropertyValue("TextBox").get()) + { + // Is this a Group Shape? Put it into the queue. + uno::Reference xInnerGroup(xGroup->getByIndex(i), uno::UNO_QUERY); + if (xInnerGroup) + xGroupList.push(xInnerGroup); + continue; + } + + // Get the textbox properties + uno::Reference xTextBoxFrameProperties( + xChildShapeProperties->getPropertyValue("TextBoxContent"), uno::UNO_QUERY_THROW); + + // Assert that the textbox ZOrder greater than the groupshape + CPPUNIT_ASSERT_GREATER(xGroupProperties->getPropertyValue("ZOrder").get(), + xTextBoxFrameProperties->getPropertyValue("ZOrder").get()); + // 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(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()); -- cgit /mimo/mimo-7-4 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff