diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-06-20 16:33:13 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-06-20 16:53:51 +0200 |
commit | 23d8fd8dcde97e3e60ebcc75d05d9b39d3bc5a30 (patch) | |
tree | 8ae72a011dff947f415c8ea8cf27dc1c34cc1880 /sw | |
parent | 077121eb0debc1c78cf46038e2b90a0c2f381c44 (diff) |
SwDrawContact::Changed: sync position/size between draw shape and its textbox
This takes care of moving / resizing the textbox when the draw shape has
been resized.
Change-Id: If4c6f0bcdd03e00e3e49b0d30de3e1d0595977d4
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 29 | ||||
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 11 |
2 files changed, 40 insertions, 0 deletions
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 06bbc7fd3662..7e70b4e0f8ea 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -13,6 +13,7 @@ #include <fmtanchr.hxx> #include <fmtcnct.hxx> #include <fmtornt.hxx> +#include <fmtfsize.hxx> #include <doc.hxx> #include <docsh.hxx> #include <docary.hxx> @@ -510,6 +511,34 @@ void SwTextBoxHelper::syncFlyFrmAttr(SwFrmFmt& rShape, SfxItemSet& rSet) aTextBoxSet.Put(aOrient); } break; + case RES_FRM_SIZE: + { + // In case the shape got resized, then we need to adjust both + // the position and the size of the textbox (e.g. larger + // rounded edges of a rectangle -> need to push right/down the + // textbox). + SwFmtVertOrient aVertOrient(rShape.GetVertOrient()); + SwFmtHoriOrient aHoriOrient(rShape.GetHoriOrient()); + SwFmtFrmSize aSize(pFmt->GetFrmSize()); + + Rectangle aRect = getTextRectangle(&rShape, /*bAbsolute=*/false); + if (!aRect.IsEmpty()) + { + aVertOrient.SetPos(aVertOrient.GetPos() + aRect.getY()); + aTextBoxSet.Put(aVertOrient); + + aHoriOrient.SetPos(aHoriOrient.GetPos() + aRect.getX()); + aTextBoxSet.Put(aHoriOrient); + + aSize.SetWidth(aRect.getWidth()); + aSize.SetHeight(aRect.getHeight()); + aTextBoxSet.Put(aSize); + } + } + break; + default: + SAL_WARN("sw.core", "SwTextBoxHelper::syncFlyFrmAttr: unhandled which-id: " << nWhich); + break; } if (aIter.IsAtEnd()) diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 4377594104e5..1c400daac0fc 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -41,10 +41,12 @@ #include <fmtanchr.hxx> #include <node.hxx> #include <fmtcntnt.hxx> +#include <fmtfsize.hxx> #include <pagefrm.hxx> #include <rootfrm.hxx> #include <frmtool.hxx> #include <flyfrm.hxx> +#include <textboxhelper.hxx> #include <frmfmt.hxx> #include <dflyobj.hxx> #include <dcontact.hxx> @@ -1382,6 +1384,15 @@ void SwDrawContact::_Changed( const SdrObject& rObj, pAnchorFrm->Prepare( PREP_FLY_ATTR_CHG, GetFmt() ); } } + + if (SwTextBoxHelper::findTextBox(GetFmt())) + { + // Just notify the textbox that the size has changed, the actual object size is not interesting. + SfxItemSet aResizeSet(GetFmt()->GetDoc()->GetAttrPool(), RES_FRM_SIZE, RES_FRM_SIZE, 0); + SwFmtFrmSize aSize; + aResizeSet.Put(aSize); + SwTextBoxHelper::syncFlyFrmAttr(*GetFmt(), aResizeSet); + } } } } |