SwXShape: allow setting TextBox property to false

Change-Id: I23d79fc3f5c020c86296bfc84bb0824e1ca68228
This commit is contained in:
Miklos Vajna
2014-05-27 09:05:36 +02:00
parent 0baec97070
commit f8ef170acf
3 changed files with 20 additions and 1 deletions

View File

@@ -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.

View File

@@ -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;

View File

@@ -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#