SwTextBoxHelper: handle size when it's set before CustomShapeGeometry
E.g. the ODF import won't set an explicit size, it'll just set a Transformation property, and a CustomShapeGeometry one, which contains the textbox rectangle. Change-Id: I9ac7ab5a324dc9c7c5ce3196fee8d257b7426f41
This commit is contained in:
@@ -36,8 +36,12 @@ public:
|
|||||||
static void destroy(SwFrmFmt* pShape);
|
static void destroy(SwFrmFmt* pShape);
|
||||||
/// Get interface of a shape's TextBox, if there is any.
|
/// Get interface of a shape's TextBox, if there is any.
|
||||||
static css::uno::Any queryInterface(SwFrmFmt* pShape, const css::uno::Type& rType);
|
static css::uno::Any queryInterface(SwFrmFmt* pShape, const css::uno::Type& rType);
|
||||||
|
|
||||||
/// Sync property of TextBox with the one of the shape.
|
/// Sync property of TextBox with the one of the shape.
|
||||||
static void syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const css::uno::Any& rValue);
|
static void syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const css::uno::Any& rValue);
|
||||||
|
/// Does the same, but works on properties which lack an sw-specific WID / MemberID.
|
||||||
|
static void syncProperty(SwFrmFmt* pShape, const OUString& rPropertyName, const css::uno::Any& rValue);
|
||||||
|
|
||||||
/// If we have an associated TextFrame, then return that.
|
/// If we have an associated TextFrame, then return that.
|
||||||
static SwFrmFmt* findTextBox(SwFrmFmt* pShape);
|
static SwFrmFmt* findTextBox(SwFrmFmt* pShape);
|
||||||
/// Return the textbox rectangle of a draw shape (in twips).
|
/// Return the textbox rectangle of a draw shape (in twips).
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include <svx/unopage.hxx>
|
#include <svx/unopage.hxx>
|
||||||
#include <svx/svdpage.hxx>
|
#include <svx/svdpage.hxx>
|
||||||
|
|
||||||
|
#include <com/sun/star/document/XActionLockable.hpp>
|
||||||
#include <com/sun/star/table/BorderLine2.hpp>
|
#include <com/sun/star/table/BorderLine2.hpp>
|
||||||
#include <com/sun/star/text/SizeType.hpp>
|
#include <com/sun/star/text/SizeType.hpp>
|
||||||
#include <com/sun/star/text/TextContentAnchorType.hpp>
|
#include <com/sun/star/text/TextContentAnchorType.hpp>
|
||||||
@@ -212,7 +213,18 @@ Rectangle SwTextBoxHelper::getTextRectangle(SwFrmFmt* pShape, bool bAbsolute)
|
|||||||
aRet.SetEmpty();
|
aRet.SetEmpty();
|
||||||
SdrObjCustomShape* pCustomShape = dynamic_cast<SdrObjCustomShape*>(pShape->FindRealSdrObject());
|
SdrObjCustomShape* pCustomShape = dynamic_cast<SdrObjCustomShape*>(pShape->FindRealSdrObject());
|
||||||
if (pCustomShape)
|
if (pCustomShape)
|
||||||
|
{
|
||||||
|
// Need to temporarily release the lock acquired in
|
||||||
|
// SdXMLShapeContext::AddShape(), otherwise we get an empty rectangle,
|
||||||
|
// see EnhancedCustomShapeEngine::getTextBounds().
|
||||||
|
uno::Reference<document::XActionLockable> xLockable(pCustomShape->getUnoShape(), uno::UNO_QUERY);
|
||||||
|
sal_Int16 nLocks = 0;
|
||||||
|
if (xLockable.is())
|
||||||
|
nLocks = xLockable->resetActionLocks();
|
||||||
pCustomShape->GetTextBounds(aRet);
|
pCustomShape->GetTextBounds(aRet);
|
||||||
|
if (nLocks)
|
||||||
|
xLockable->setActionLocks(nLocks);
|
||||||
|
}
|
||||||
|
|
||||||
if (!bAbsolute)
|
if (!bAbsolute)
|
||||||
{
|
{
|
||||||
@@ -228,6 +240,12 @@ Rectangle SwTextBoxHelper::getTextRectangle(SwFrmFmt* pShape, bool bAbsolute)
|
|||||||
return aRet;
|
return aRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, const OUString& rPropertyName, const css::uno::Any& /*rValue*/)
|
||||||
|
{
|
||||||
|
if (rPropertyName == "CustomShapeGeometry")
|
||||||
|
syncProperty(pShape, RES_FRM_SIZE, MID_FRMSIZE_SIZE, uno::Any());
|
||||||
|
}
|
||||||
|
|
||||||
void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberId, const css::uno::Any& rValue)
|
void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberId, const css::uno::Any& rValue)
|
||||||
{
|
{
|
||||||
// No shape yet? Then nothing to do, initial properties are set by create().
|
// No shape yet? Then nothing to do, initial properties are set by create().
|
||||||
|
@@ -1442,6 +1442,13 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
xPrSet->setPropertyValue(rPropertyName, aValue);
|
xPrSet->setPropertyValue(rPropertyName, aValue);
|
||||||
|
|
||||||
|
if (pFmt)
|
||||||
|
{
|
||||||
|
// We have a pFmt (but no pEntry): try to sync TextBox property.
|
||||||
|
SwTextBoxHelper::syncProperty(pFmt, rPropertyName, aValue);
|
||||||
|
}
|
||||||
|
|
||||||
// #i31698# - restore object position, if caption point is set.
|
// #i31698# - restore object position, if caption point is set.
|
||||||
if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
|
if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user