sw/qa/extras/uiwriter/data/tdf146449.odt |binary sw/qa/extras/uiwriter/uiwriter4.cxx | 30 ++++++++++++++++++++++++++++++ sw/source/core/doc/textboxhelper.cxx | 11 +++++------ sw/source/core/undo/undraw.cxx | 5 +++++ xmloff/qa/unit/draw.cxx | 2 +- 5 files changed, 41 insertions(+), 7 deletions(-)
New commits: commit a3e540304269772595439de22b54269011721bb2 Author: Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu> AuthorDate: Wed Mar 2 14:08:14 2022 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed Apr 27 16:44:09 2022 +0200 tdf#146449 sw: fix Z-order after undoing Textbox z-order synchronization was missing in case of Undo, resulting broken text boxes. Regression from 504d78acb866495fd954fcd6db22ea68f174a5ab "tdf#143574 sw: textboxes in group shapes - part 1". Change-Id: I2632b7fb40e327f083e680e10b19c8f405df1875 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130875 Tested-by: Jenkins Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: Attila Bakos <bakos.attilakar...@nisz.hu> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/uiwriter/data/tdf146449.odt b/sw/qa/extras/uiwriter/data/tdf146449.odt new file mode 100644 index 000000000000..c18d98e8aaec Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf146449.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index 6c3d3578ca26..d1aee7f23986 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -119,6 +119,36 @@ static OUString lcl_translitTest(SwDoc& rDoc, const SwPaM& rPaM, Transliteration return rPaM.GetNode(false).GetTextNode()->GetText(); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf146449) +{ + load(DATA_DIRECTORY, "tdf146449.odt"); + + auto pDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pDoc); + auto pShell = pDoc->GetDocShell()->GetFEShell(); + CPPUNIT_ASSERT(pShell); + + auto xTextBox = getShapeByName(u"Frame1"); + auto pObject = SdrObject::getSdrObjectFromXShape(xTextBox); + + CPPUNIT_ASSERT(pShell->SelectObj(Point(), 0, pObject)); + + dispatchCommand(mxComponent, ".uno:Cut", {}); + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + uno::Reference<beans::XPropertySet> xShapeProps(xTextBox, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xFrameProps(xShapeProps->getPropertyValue("TextBoxContent"), + uno::UNO_QUERY); + + const auto& nShapeZOrder = pObject->GetOrdNum(); + const auto& nFrameZOrder = xFrameProps->getPropertyValue("ZOrder"); + + CPPUNIT_ASSERT_MESSAGE("Wrong Zorder!", nShapeZOrder < nFrameZOrder.get<sal_uInt32>()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf49033) { SwDoc* pDoc = createSwDoc(); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 74d29aad270b..3eeed981d74f 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1329,7 +1329,6 @@ bool SwTextBoxHelper::changeAnchor(SwFrameFormat* pShape, SdrObject* pObj) bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pObj) { - bool bSuccess = false; // Set the position of the textboxes according to the position of its shape-pair const bool bIsGroupObj = (pObj != pShape->FindRealSdrObject()) && pObj; if (auto pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT, pObj)) @@ -1414,8 +1413,8 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb } } - bSuccess = pFormat->SetFormatAttr(aNewHOri); - bSuccess &= pFormat->SetFormatAttr(aNewVOri); + pFormat->SetFormatAttr(aNewHOri); + pFormat->SetFormatAttr(aNewVOri); } // Other cases when the shape has different anchor from AS_CHAR else @@ -1498,10 +1497,10 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb aNewVOri.SetPos(aNewVOri.GetPos() + nTableOffset.getY()); } - bSuccess = pFormat->SetFormatAttr(aNewHOri); - bSuccess &= pFormat->SetFormatAttr(aNewVOri); + pFormat->SetFormatAttr(aNewHOri); + pFormat->SetFormatAttr(aNewVOri); } - return bSuccess; + return true; } return false; diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index f316858c2bfd..9eb5502eceaa 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -601,6 +601,11 @@ void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext) pContact->MoveObjToVisibleLayer( pObj ); SwDrawFrameFormat* pDrawFrameFormat = rSave.pFormat; + if (pDrawFrameFormat->GetOtherTextBoxFormats()) + { + SwTextBoxHelper::synchronizeGroupTextBoxProperty( + SwTextBoxHelper::changeAnchor, pDrawFrameFormat, pObj); + } // #i45952# - notify that position attributes are already set OSL_ENSURE(pDrawFrameFormat, diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index 481561ff062a..f908de1d6c52 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -109,7 +109,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextBoxLoss) // Make sure that the shape is still a textbox. uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY); bool bTextBox = false; xShape->getPropertyValue("TextBox") >>= bTextBox;