Kaydet (Commit) 9fa68f05 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 31c4c834
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "rootfrm.hxx" #include "rootfrm.hxx"
#include "frmfmt.hxx" #include "frmfmt.hxx"
#include "viewsh.hxx" #include "viewsh.hxx"
#include "textboxhelper.hxx"
#include <vcl/outdev.hxx> #include <vcl/outdev.hxx>
#include <editeng/lrspitem.hxx> #include <editeng/lrspitem.hxx>
...@@ -351,6 +352,35 @@ void SwFlyCntPortion::SetBase( const SwTxtFrm& rFrm, const Point &rBase, ...@@ -351,6 +352,35 @@ void SwFlyCntPortion::SetBase( const SwTxtFrm& rFrm, const Point &rBase,
aObjPositioning.CalcPosition(); 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() ); SetAlign( aObjPositioning.GetLineAlignment() );
aRef = aObjPositioning.GetAnchorPos(); aRef = aObjPositioning.GetAnchorPos();
......
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