[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sw/source

Bakos Attila (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 17 06:51:01 UTC 2020


 sw/source/core/doc/DocumentLayoutManager.cxx |    3 -
 sw/source/core/doc/textboxhelper.cxx         |   60 +++++++++++++++++++++------
 sw/source/core/frmedt/fefly1.cxx             |    4 +
 3 files changed, 54 insertions(+), 13 deletions(-)

New commits:
commit 0fc835f5d9effe1b53b563583adda879b83f1d2a
Author:     Bakos Attila <bakos.attilakaroly at nisz.hu>
AuthorDate: Thu Jul 16 16:56:33 2020 +0200
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Sep 17 08:50:28 2020 +0200

    tdf#107225 tdf#122887 sw: fix reanchoring of textboxes
    
    This commit fixes the following commits:
    -tdf#130805 SwTextBoxHelper::create:
     fix frame position in shape
     (2479ae3ee20fc5f3cbb0c88eb09110a36e86710c)
    -tdf#130802 SwTextBoxHelper::syncFlyFrameAttr:
     fix dragging
     (c1c93987acbb83d8352656d77ee515e98c63d46b)
    
    Change-Id: I31abf364549778a4bbd3c4effc84df7d8b59d9e0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98915
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit fd88bb81236ad6d1a63436b7ce20f2f93410d359)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102767
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx
index 67875e86efbb..4d594165ca3c 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -470,7 +470,8 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat(
             boxAnchor.SetType(RndStdIds::FLY_AT_CHAR);
         }
         // presumably these anchors are supported though not sure
-        assert(RndStdIds::FLY_AT_CHAR == boxAnchor.GetAnchorId() || RndStdIds::FLY_AT_PARA == boxAnchor.GetAnchorId());
+        assert(RndStdIds::FLY_AT_CHAR == boxAnchor.GetAnchorId() || RndStdIds::FLY_AT_PARA == boxAnchor.GetAnchorId()
+        || boxAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE);
         SwFrameFormat* pDestTextBox = CopyLayoutFormat(*pSourceTextBox,
                 boxAnchor, bSetTextFlyAtt, bMakeFrames);
         SwAttrSet aSet(pDest->GetAttrSet());
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 34aed05a1fcf..e9ca4e46a219 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -141,6 +141,36 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape)
     text::WritingMode eMode;
     if (xShapePropertySet->getPropertyValue(UNO_NAME_TEXT_WRITINGMODE) >>= eMode)
         syncProperty(pShape, RES_FRAMEDIR, 0, uno::makeAny(sal_Int16(eMode)));
+
+    const SwFormatAnchor& rAnch = pShape->GetAnchor();
+    if ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE && rAnch.GetPageNum() != 0)
+        || ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA
+             || rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
+            && rAnch.GetContentAnchor()))
+    {
+        SfxItemSet aTxFrmSet(pFormat->GetDoc()->GetAttrPool(), aFrameFormatSetRange);
+        SwFormatAnchor aNewAnch = pFormat->GetAnchor();
+
+        if (pShape->GetAnchor().GetContentAnchor())
+            aNewAnch.SetAnchor(pShape->GetAnchor().GetContentAnchor());
+        if (pShape->GetAnchor().GetPageNum() > 0)
+            aNewAnch.SetPageNum(pShape->GetAnchor().GetPageNum());
+
+        aNewAnch.SetType(pShape->GetAnchor().GetAnchorId());
+        aTxFrmSet.Put(aNewAnch);
+
+        SwFormatVertOrient aVOri(pFormat->GetVertOrient());
+        SwFormatHoriOrient aHOri(pFormat->GetHoriOrient());
+        aVOri.SetVertOrient(pShape->GetVertOrient().GetVertOrient());
+        aHOri.SetHoriOrient(pShape->GetHoriOrient().GetHoriOrient());
+        aVOri.SetRelationOrient(pShape->GetVertOrient().GetRelationOrient());
+        aHOri.SetRelationOrient(pShape->GetHoriOrient().GetRelationOrient());
+        aTxFrmSet.Put(aVOri);
+        aTxFrmSet.Put(aHOri);
+
+        if (aTxFrmSet.Count())
+            pFormat->SetFormatAttr(aTxFrmSet);
+    }
 }
 
 void SwTextBoxHelper::destroy(SwFrameFormat* pShape)
@@ -685,14 +715,22 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const&
 
         SfxItemIter aIter(rSet);
         const SfxPoolItem* pItem = aIter.GetCurItem();
+
+        const RndStdIds aAnchId = rShape.GetAnchor().GetAnchorId();
+        if ((aAnchId == RndStdIds::FLY_AT_PAGE && rShape.GetAnchor().GetPageNum() != 0)
+            || ((aAnchId == RndStdIds::FLY_AT_PARA || aAnchId == RndStdIds::FLY_AT_CHAR)
+                && rShape.GetAnchor().GetContentAnchor()))
+        {
+            SwFormatAnchor aNewAnch = pFormat->GetAnchor();
+            if (rShape.GetAnchor().GetContentAnchor())
+                aNewAnch.SetAnchor(rShape.GetAnchor().GetContentAnchor());
+            if (rShape.GetAnchor().GetPageNum() > 0)
+                aNewAnch.SetPageNum(rShape.GetAnchor().GetPageNum());
+            aNewAnch.SetType(rShape.GetAnchor().GetAnchorId());
+            aTextBoxSet.Put(aNewAnch);
+        }
         do
         {
-            if (rShape.GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
-            {
-                SwFormatAnchor pShapeAnch = rShape.GetAnchor();
-                aTextBoxSet.Put(pShapeAnch);
-            }
-
             switch (pItem->Which())
             {
                 case RES_VERT_ORIENT:
@@ -704,10 +742,9 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const&
                     if (!aRect.IsEmpty())
                         aOrient.SetPos(aOrient.GetPos() + aRect.getY());
 
-                    if (rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE)
-                    {
+                    if (rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE
+                        && rShape.GetAnchor().GetPageNum() != 0)
                         aOrient.SetRelationOrient(rShape.GetVertOrient().GetRelationOrient());
-                    }
                     aTextBoxSet.Put(aOrient);
 
                     // restore height (shrunk for extending beyond the page bottom - tdf#91260)
@@ -728,10 +765,9 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const&
                     if (!aRect.IsEmpty())
                         aOrient.SetPos(aOrient.GetPos() + aRect.getX());
 
-                    if (rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE)
-                    {
+                    if (rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE
+                        && rShape.GetAnchor().GetPageNum() != 0)
                         aOrient.SetRelationOrient(rShape.GetHoriOrient().GetRelationOrient());
-                    }
                     aTextBoxSet.Put(aOrient);
                 }
                 break;
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 8bb00f312bf4..ab6f5f4365ba 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -617,6 +617,10 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, bool bMoveIt )
                                 new SwHandleAnchorNodeChg( *pFlyFrameFormat, aAnch ));
                         }
                         rFormat.GetDoc()->SetAttr( aAnch, rFormat );
+                        if (SwTextBoxHelper::getOtherTextBoxFormat(&rFormat, RES_DRAWFRMFMT))
+                        {
+                            SwTextBoxHelper::syncFlyFrameAttr(rFormat, rFormat.GetAttrSet());
+                        }
                     }
                     // #i28701# - no call of method
                     // <CheckCharRectAndTopOfLine()> for to-character anchored


More information about the Libreoffice-commits mailing list