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 989d8f1111e502bc100580a4f0c32c4a46b14fd2
Author:     Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu>
AuthorDate: Mon Sep 28 11:47:20 2020 +0200
Commit:     Gabor Kelemen <kelemen.gab...@nisz.hu>
CommitDate: Tue Feb 23 15:48:28 2021 +0100

    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>
    (cherry picked from commit e2a2165f27d2e5f9b6ac2d349e8b588921667ba4)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111331
    Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu>

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 da425a13e071..4391bccc8ff0 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -696,7 +696,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, testTdf96067)
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index d00d039647d4..69b369e2525c 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

Reply via email to