summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-05-28 15:39:33 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-05-28 15:57:12 +0200
commit9fa68f05e1678a0d3d941611fe9616b7191b1f03 (patch)
tree41388e25940c9996e204ce653576bbb3745b0650
parent31c4c834b84d3cadcba43eeaa9a6da7debb63de0 (diff)
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
-rw-r--r--sw/source/core/text/porfly.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index 5fb22df3fd39..d848bc1170ea 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();