sw/inc/textboxhelper.hxx             |    4 ++
 sw/source/core/doc/docfly.cxx        |    2 +
 sw/source/core/doc/textboxhelper.cxx |   50 +++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

New commits:
commit 8ba6d7a809d51edcb8b93d3298b9d27155276cec
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Thu Jun 19 17:10:59 2014 +0200

    SwDoc::SetFlyFrmAttr: sync position between draw shape and its textbox
    
    The effect of this is that if you move around a shape (having a textbox)
    with the keyboard or mouse, then the position of the textbox is now also
    adjusted as you would expect it, as a user.
    
    Change-Id: Ie079f8c7b76e9a97095e4233eded5bda514cf405

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 665f82a..c7ba2f4 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -23,6 +23,7 @@
 #include <swdllapi.h>
 
 class SdrPage;
+class SfxItemSet;
 class SwFrmFmt;
 class SwFrmFmts;
 class SwFmtCntnt;
@@ -57,6 +58,9 @@ public:
     /// Get a property of the underlying TextFrame.
     static void getProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 
nMemberID, css::uno::Any& rValue);
 
+    /// Similar to syncProperty(), but used by the internal API (e.g. for UI 
purposes).
+    static void syncFlyFrmAttr(SwFrmFmt& rShape, SfxItemSet& rSet);
+
     /// If we have an associated TextFrame, then return that.
     static SwFrmFmt* findTextBox(SwFrmFmt* pShape);
     static SwFrmFmt* findTextBox(css::uno::Reference<css::drawing::XShape> 
xShape);
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index d3982f1..79f516e 100644
--- a/sw/source/core/doc/docfly.cxx
+++ b/sw/source/core/doc/docfly.cxx
@@ -534,6 +534,8 @@ bool SwDoc::SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& 
rSet )
 
     SetModified();
 
+    SwTextBoxHelper::syncFlyFrmAttr(rFlyFmt, rSet);
+
     return bRet;
 }
 
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 39e9828..06bbc7f 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -12,6 +12,7 @@
 #include <fmtcntnt.hxx>
 #include <fmtanchr.hxx>
 #include <fmtcnct.hxx>
+#include <fmtornt.hxx>
 #include <doc.hxx>
 #include <docsh.hxx>
 #include <docary.hxx>
@@ -30,6 +31,7 @@
 #include <svx/svdoashp.hxx>
 #include <svx/unopage.hxx>
 #include <svx/svdpage.hxx>
+#include <svl/itemiter.hxx>
 
 #include <com/sun/star/document/XActionLockable.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
@@ -472,4 +474,52 @@ void SwTextBoxHelper::restoreLinks(std::set<_ZSortFly>& 
rOld, std::vector<SwFrmF
     }
 }
 
+void SwTextBoxHelper::syncFlyFrmAttr(SwFrmFmt& rShape, SfxItemSet& rSet)
+{
+    if (SwFrmFmt* pFmt = findTextBox(&rShape))
+    {
+        SfxItemSet aTextBoxSet(pFmt->GetDoc()->GetAttrPool(), aFrmFmtSetRange);
+
+        SfxItemIter aIter(rSet);
+        sal_uInt16 nWhich = aIter.GetCurItem()->Which();
+        do
+        {
+            switch (nWhich)
+            {
+            case RES_VERT_ORIENT:
+            {
+                const SwFmtVertOrient& rOrient = static_cast<const 
SwFmtVertOrient&>(*aIter.GetCurItem());
+                SwFmtVertOrient aOrient(rOrient);
+
+                Rectangle aRect = getTextRectangle(&rShape, 
/*bAbsolute=*/false);
+                if (!aRect.IsEmpty())
+                    aOrient.SetPos(aOrient.GetPos() + aRect.getY());
+
+                aTextBoxSet.Put(aOrient);
+            }
+            break;
+            case RES_HORI_ORIENT:
+            {
+                const SwFmtHoriOrient& rOrient = static_cast<const 
SwFmtHoriOrient&>(*aIter.GetCurItem());
+                SwFmtHoriOrient aOrient(rOrient);
+
+                Rectangle aRect = getTextRectangle(&rShape, 
/*bAbsolute=*/false);
+                if (!aRect.IsEmpty())
+                    aOrient.SetPos(aOrient.GetPos() + aRect.getX());
+
+                aTextBoxSet.Put(aOrient);
+            }
+            break;
+            }
+
+            if (aIter.IsAtEnd())
+                break;
+        }
+        while (0 != (nWhich = aIter.NextItem()->Which()));
+
+        if (aTextBoxSet.Count())
+            pFmt->GetDoc()->SetFlyFrmAttr(*pFmt, aTextBoxSet);
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to