sw/qa/extras/uiwriter/data3/tdf107893.odt |binary sw/qa/extras/uiwriter/uiwriter3.cxx | 34 +++++++++++++++++++++++++++++- sw/source/core/doc/textboxhelper.cxx | 2 - 3 files changed, 34 insertions(+), 2 deletions(-)
New commits: commit e2a2165f27d2e5f9b6ac2d349e8b588921667ba4 Author: Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu> AuthorDate: Mon Sep 28 11:47:20 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Oct 6 08:31:16 2020 +0200 tdf#107893 sw: fix broken "Add Text Box" after Undo Adding text frame to a shape by "Add Text Box" menu item of its local menu and undoing the text frame by Undo resulted inoperative "Add Text Box", i.e. it was not possible to readd the text frame. Change-Id: Id871cecf9682cec040e9db7a0a3a68262c505833 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103541 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/uiwriter/data3/tdf107893.odt b/sw/qa/extras/uiwriter/data3/tdf107893.odt new file mode 100755 index 000000000000..9c24eccfa367 Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/tdf107893.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 315a6f9c4e0d..dc98dfffd686 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -1301,7 +1301,39 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130805) CPPUNIT_ASSERT(pShpAnch); CPPUNIT_ASSERT_EQUAL_MESSAGE("The textbox got apart!", pTxAnch->nNode, pShpAnch->nNode); - //CPPUNIT_ASSERT_EQUAL_MESSAGE("", xShp->getPosition().Y, xShp2->getPosition().Y); +} + +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107893) +{ + //Open the sample doc + load(DATA_DIRECTORY, "tdf107893.odt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + //Get the Writer shell + SwWrtShell* pWrtSh = pTextDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtSh); + + //Get the format of the shape + const SwFrameFormats& rFrmFormats = *pWrtSh->GetDoc()->GetSpzFrameFormats(); + CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); + SwFrameFormat* pShape = rFrmFormats.front(); + CPPUNIT_ASSERT(pShape); + + //Add a textbox + SwTextBoxHelper::create(pShape); + SwFrameFormat* pTxBxFrm = SwTextBoxHelper::getOtherTextBoxFormat(getShape(1)); + CPPUNIT_ASSERT(pTxBxFrm); + + //Remove the textbox using Undo + dispatchCommand(mxComponent, ".uno:Undo", {}); + + //Add again + SwTextBoxHelper::create(pShape); + pTxBxFrm = SwTextBoxHelper::getOtherTextBoxFormat(getShape(1)); + + //This was nullptr because of unsuccessful re-adding + CPPUNIT_ASSERT_MESSAGE("Textbox cannot be readd after Undo!", pTxBxFrm); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf121031) diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 0f095c7ab71c..15d80ea1ca93 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -52,7 +52,7 @@ using namespace com::sun::star; void SwTextBoxHelper::create(SwFrameFormat* pShape) { // If TextBox wasn't enabled previously - if (pShape->GetAttrSet().HasItem(RES_CNTNT)) + if (pShape->GetAttrSet().HasItem(RES_CNTNT) && pShape->GetOtherTextBoxFormat()) return; // Create the associated TextFrame and insert it into the document. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits