From 31c4c834b84d3cadcba43eeaa9a6da7debb63de0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 28 May 2014 15:35:33 +0200 Subject: SwTextBoxHelper: extract getTextRectangle() from syncProperty() Change-Id: I6265247593571ffba4cbda7f87bdde1e943aff51 --- sw/inc/textboxhelper.hxx | 3 +++ sw/source/core/doc/textboxhelper.cxx | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index 28f8d71125ed..747e729762ef 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -19,6 +19,7 @@ class SdrPage; class SwFrmFmt; class SwDoc; +class Rectangle; /** * A TextBox is a TextFrame, that is tied to a drawinglayer shape. @@ -39,6 +40,8 @@ public: 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. 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. static std::list findTextBoxes(const SwDoc* pDoc); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 3e64261c4e06..7735de51a36d 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -192,6 +192,16 @@ uno::Any SwTextBoxHelper::queryInterface(SwFrmFmt* pShape, const uno::Type& rTyp return aRet; } +Rectangle SwTextBoxHelper::getTextRectangle(SwFrmFmt* pShape) +{ + Rectangle aRet; + aRet.SetEmpty(); + SdrObjCustomShape* pCustomShape = dynamic_cast(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) { // 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 // Position/size should be the text position/size, not the shape one as-is. if (bAdjustX || bAdjustY || bAdjustSize) { - SdrObjCustomShape* pCustomShape = dynamic_cast(pShape->FindRealSdrObject()); - if (pCustomShape) + Rectangle aRect = getTextRectangle(pShape); + if (!aRect.IsEmpty()) { - Rectangle aRect; - pCustomShape->GetTextBounds(aRect); - if (bAdjustX || bAdjustY) { sal_Int32 nValue; -- cgit