sw/source/core/doc/textboxhelper.cxx |   29 +++++++++++++++++++++++++++++
 sw/source/core/draw/dcontact.cxx     |   11 +++++++++++
 2 files changed, 40 insertions(+)

New commits:
commit 23d8fd8dcde97e3e60ebcc75d05d9b39d3bc5a30
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Fri Jun 20 16:33:13 2014 +0200

    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

diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 06bbc7f..7e70b4e 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 4377594..1c400da 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);
+                    }
                 }
             }
         }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to