diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index 93a459deec41..0c992dc87493 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -26,6 +26,8 @@ class SwTextBoxHelper public: /// Create a TextBox for a shape. static void create(SwFrmFmt* pShape); + /// Destroy a TextBox for a shape. + static void destroy(SwFrmFmt* pShape); /// Get XTextAppend of a shape's TextBox, if there is any. static css::uno::Any getXTextAppend(SwFrmFmt* pShape, const css::uno::Type& rType); /// Sync property of TextBox with the one of the shape. diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 9937778721aa..faadb5f3f9e8 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -65,6 +65,22 @@ void SwTextBoxHelper::create(SwFrmFmt* pShape) } } +void SwTextBoxHelper::destroy(SwFrmFmt* pShape) +{ + // If a TextBox was enabled previously + if (pShape->GetAttrSet().HasItem(RES_CNTNT)) + { + SwFrmFmt* pFmt = findTextBox(pShape); + + // Unlink the TextBox's text range from the original shape. + pShape->ResetFmtAttr(RES_CNTNT); + + // Delete the associated TextFrame. + if (pFmt) + pShape->GetDoc()->DelLayoutFmt(pFmt); + } +} + SwFrmFmt* SwTextBoxHelper::findTextBox(SwFrmFmt* pShape) { SwFrmFmt* pRet = 0; diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 1c03330c0b3a..e506cd202c64 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1182,9 +1182,10 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a { bool bValue; aValue >>= bValue; - // If TextBox is to be enabled. if (bValue) SwTextBoxHelper::create(pFmt); + else + SwTextBoxHelper::destroy(pFmt); } // #i28749#