Kaydet (Commit) 31c4c834 authored tarafından Miklos Vajna's avatar Miklos Vajna

SwTextBoxHelper: extract getTextRectangle() from syncProperty()

Change-Id: I6265247593571ffba4cbda7f87bdde1e943aff51
üst 5ed755ed
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
class SdrPage; class SdrPage;
class SwFrmFmt; class SwFrmFmt;
class SwDoc; class SwDoc;
class Rectangle;
/** /**
* A TextBox is a TextFrame, that is tied to a drawinglayer shape. * A TextBox is a TextFrame, that is tied to a drawinglayer shape.
...@@ -39,6 +40,8 @@ public: ...@@ -39,6 +40,8 @@ public:
static void syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const OUString& rPropertyName, const css::uno::Any& rValue); static void syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, 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 (absolute values, in twips).
static Rectangle getTextRectangle(SwFrmFmt* pShape);
/// Look up TextFrames in a document, which are in fact TextBoxes. /// Look up TextFrames in a document, which are in fact TextBoxes.
static std::list<SwFrmFmt*> findTextBoxes(const SwDoc* pDoc); static std::list<SwFrmFmt*> findTextBoxes(const SwDoc* pDoc);
......
...@@ -192,6 +192,16 @@ uno::Any SwTextBoxHelper::queryInterface(SwFrmFmt* pShape, const uno::Type& rTyp ...@@ -192,6 +192,16 @@ uno::Any SwTextBoxHelper::queryInterface(SwFrmFmt* pShape, const uno::Type& rTyp
return aRet; return aRet;
} }
Rectangle SwTextBoxHelper::getTextRectangle(SwFrmFmt* pShape)
{
Rectangle aRet;
aRet.SetEmpty();
SdrObjCustomShape* pCustomShape = dynamic_cast<SdrObjCustomShape*>(pShape->FindRealSdrObject());
if (pCustomShape)
pCustomShape->GetTextBounds(aRet);
return aRet;
}
void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberId, const OUString& rPropertyName, const css::uno::Any& rValue) void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberId, const OUString& rPropertyName, 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().
...@@ -260,12 +270,9 @@ void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 ...@@ -260,12 +270,9 @@ void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8
// Position/size should be the text position/size, not the shape one as-is. // Position/size should be the text position/size, not the shape one as-is.
if (bAdjustX || bAdjustY || bAdjustSize) if (bAdjustX || bAdjustY || bAdjustSize)
{ {
SdrObjCustomShape* pCustomShape = dynamic_cast<SdrObjCustomShape*>(pShape->FindRealSdrObject()); Rectangle aRect = getTextRectangle(pShape);
if (pCustomShape) if (!aRect.IsEmpty())
{ {
Rectangle aRect;
pCustomShape->GetTextBounds(aRect);
if (bAdjustX || bAdjustY) if (bAdjustX || bAdjustY)
{ {
sal_Int32 nValue; sal_Int32 nValue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment