[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/source
Bakos Attila (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jan 6 10:36:54 UTC 2021
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 b3097f355b755ded53058ae8a104af08a3f24452
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: Wed Jan 6 11:36:21 2021 +0100
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/+/108855
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 8d5cc79dc648..7df5d2871f91 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -472,7 +472,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 9a2cc95dc0d7..d00d039647d4 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -142,6 +142,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)
@@ -682,14 +712,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:
@@ -701,10 +739,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)
@@ -725,10 +762,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 4ad00716414c..5602e729c1d3 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -610,6 +610,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