sw/inc/textboxhelper.hxx | 3 +++ sw/source/core/doc/textboxhelper.cxx | 17 ++++++++++++----- sw/source/core/docnode/nodedump.cxx | 1 + sw/source/core/text/porfly.cxx | 30 ++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 5 deletions(-)
New commits: commit 9fa68f05e1678a0d3d941611fe9616b7191b1f03 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed May 28 15:39:33 2014 +0200 SwFlyCntPortion::SetBase: adjust position of the textbox if necessary In case of inline shapes, it's not possible to just copy the AnchorType property of the shape to the textbox, as we want the textbox at the expected position, not inline. OTOH, an inline shape has an implicit position, so we can't position its textbox at import-time. Solve the problem by setting the position of the textbox as we create the layout of the inline shape. Change-Id: I425ff5e0760858ebcbe457ed0ce9e4977ae8bc74 diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 5fb22df..d848bc1 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -24,6 +24,7 @@ #include "rootfrm.hxx" #include "frmfmt.hxx" #include "viewsh.hxx" +#include "textboxhelper.hxx" #include <vcl/outdev.hxx> #include <editeng/lrspitem.hxx> @@ -351,6 +352,35 @@ void SwFlyCntPortion::SetBase( const SwTxtFrm& rFrm, const Point &rBase, aObjPositioning.CalcPosition(); } + SwFrmFmt* pShape = FindFrmFmt(pSdrObj); + const SwFmtAnchor& rAnchor(pShape->GetAnchor()); + if (rAnchor.GetAnchorId() == FLY_AS_CHAR) + { + // This is an inline draw shape, see if it has a textbox. + SwFrmFmt* pTextBox = SwTextBoxHelper::findTextBox(pShape); + if (pTextBox) + { + // It has, so look up its text rectangle, and adjust the position + // of the textbox accordingly. + Rectangle aTextRectangle = SwTextBoxHelper::getTextRectangle(pShape); + + SwFmtHoriOrient aHori(pTextBox->GetHoriOrient()); + aHori.SetHoriOrient(css::text::HoriOrientation::NONE); + sal_Int32 nLeft = aTextRectangle.getX() - rFrm.Frm().Left(); + aHori.SetPos(nLeft); + + SwFmtVertOrient aVert(pTextBox->GetVertOrient()); + aVert.SetVertOrient(css::text::VertOrientation::NONE); + sal_Int32 nTop = aTextRectangle.getY() - rFrm.Frm().Top() - nFlyAsc; + aVert.SetPos(nTop); + + pTextBox->LockModify(); + pTextBox->SetFmtAttr(aHori); + pTextBox->SetFmtAttr(aVert); + pTextBox->UnlockModify(); + } + } + SetAlign( aObjPositioning.GetLineAlignment() ); aRef = aObjPositioning.GetAnchorPos(); commit 31c4c834b84d3cadcba43eeaa9a6da7debb63de0 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed May 28 15:35:33 2014 +0200 SwTextBoxHelper: extract getTextRectangle() from syncProperty() Change-Id: I6265247593571ffba4cbda7f87bdde1e943aff51 diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index 28f8d71..747e729 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<SwFrmFmt*> findTextBoxes(const SwDoc* pDoc); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 3e64261..7735de5 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<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) { // 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<SdrObjCustomShape*>(pShape->FindRealSdrObject()); - if (pCustomShape) + Rectangle aRect = getTextRectangle(pShape); + if (!aRect.IsEmpty()) { - Rectangle aRect; - pCustomShape->GetTextBounds(aRect); - if (bAdjustX || bAdjustY) { sal_Int32 nValue; commit 5ed755ed8fa8edb27f43eb2c9d1efedd004e95b3 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed May 28 11:23:42 2014 +0200 SwFrmFmts::dumpAsXml: show address of the frame format Change-Id: I4dc0c51f90f06c85ca0da3d581060f29b029b762 diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx index 3266c1f..5283af3 100644 --- a/sw/source/core/docnode/nodedump.cxx +++ b/sw/source/core/docnode/nodedump.cxx @@ -561,6 +561,7 @@ void SwFrmFmts::dumpAsXml(xmlTextWriterPtr w, const char* pName) SwFrmFmt* pFmt = static_cast<SwFrmFmt*>(GetFmt(i)); writer.startElement("swfrmfmt"); OString aName = OUStringToOString(pFmt->GetName(), RTL_TEXTENCODING_UTF8); + writer.writeFormatAttribute("ptr", "%p", pFmt); writer.writeFormatAttribute("name", "%s", BAD_CAST(aName.getStr())); writer.writeFormatAttribute("whichId", TMP_FORMAT, pFmt->Which()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits