summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Bakos (NISZ) <bakos.attilakaroly@nisz.hu>2020-09-28 11:47:20 +0200
committerLászló Németh <nemeth@numbertext.org>2020-10-06 08:31:16 +0200
commite2a2165f27d2e5f9b6ac2d349e8b588921667ba4 (patch)
treeb7b682009659dcf9095a20a8f2eb3cb0abc2b46d
parent93c833e848a4406f36bcb7925928554bb104aa32 (diff)
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 <nemeth@numbertext.org>
-rwxr-xr-xsw/qa/extras/uiwriter/data3/tdf107893.odtbin0 -> 9133 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx34
-rw-r--r--sw/source/core/doc/textboxhelper.cxx2
3 files changed, 34 insertions, 2 deletions
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
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf107893.odt
Binary files 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.