summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-02-02 08:27:33 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-02-02 09:27:30 +0000
commit4c6c317e1743166ee772ab03413f0fa59c59f859 (patch)
treeea1d7fdb1698df76caea8fc7ccc13f86470f4d10 /sw
parent9f698ac2d8d4db274793678efdfbcdde15347e31 (diff)
sw: call GetNextFlyLeaf() in SwFrame::GetLeaf()
- improve SwFrame::GetLeaf() so that in case we are in a fly frame and that is allowed to split, then we call GetNextFlyLeaf() - GetNextFlyLeaf() uses GetNextLayoutLeaf(), if that finds nothing then calls InsertPage() and then tries again. The second GetNextLayoutLeaf() is meant to find the follow frame's parent, but fly frames don't in general have uppers, so teach it about split fly frames - finally improve SwFrame::GetNextFlyLeaf() a bit, so that it does fly insertion similar to AppendObj(): first move the anchor to the next page then append the just created fly there With this, a fly frame with 2 paragraphs crossing the bottom of the body frame is split, although the second fly frame contains both paragraphs, which still needs fixing. Towards an initial layout for multi-page fly frames. Change-Id: Iec038e9fed462b1f8ee0b48fbb3fd76641c96d5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146485 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/layout/findfrm.cxx10
-rw-r--r--sw/source/core/layout/flowfrm.cxx8
-rw-r--r--sw/source/core/layout/flycnt.cxx19
3 files changed, 29 insertions, 8 deletions
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index a58c74afa876..07290dee5f2a 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -360,6 +360,16 @@ const SwLayoutFrame *SwFrame::ImplGetNextLayoutLeaf( bool bFwd ) const
// I cannot go forward, because there is no next frame.
// I'll try to go up:
p = pFrame->GetUpper();
+
+ if (!p && pFrame->IsFlyFrame())
+ {
+ const SwFlyFrame* pFlyFrame = pFrame->FindFlyFrame();
+ if (pFlyFrame->IsFlySplitAllowed())
+ {
+ p = pFlyFrame->GetAnchorFrame();
+ }
+ }
+
bGoingUp = nullptr != p;
if ( !bGoingUp )
{
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 0e762f371aa4..9939dceafa1b 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -877,6 +877,14 @@ SwLayoutFrame *SwFrame::GetLeaf( MakePageType eMakePage, bool bFwd )
if ( bInSct )
return bFwd ? GetNextSctLeaf( eMakePage ) : GetPrevSctLeaf();
+ if (IsInFly() && FindFlyFrame()->IsFlySplitAllowed())
+ {
+ if (bFwd)
+ {
+ return GetNextFlyLeaf(eMakePage);
+ }
+ }
+
return bFwd ? GetNextLeaf( eMakePage ) : GetPrevLeaf();
}
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 0fc135b48b5f..c2fd6bc28666 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -83,7 +83,8 @@ SwFlyAtContentFrame::SwFlyAtContentFrame( SwFlyFrameFormat *pFormat, SwFrame* pS
}
SwFlyAtContentFrame::SwFlyAtContentFrame(SwFlyAtContentFrame& rPrecede)
- : SwFlyAtContentFrame(rPrecede.GetFormat(), rPrecede.getRootFrame(), /*pAnchor=*/nullptr)
+ : SwFlyAtContentFrame(rPrecede.GetFormat(), const_cast<SwFrame*>(rPrecede.GetAnchorFrame()),
+ const_cast<SwFrame*>(rPrecede.GetAnchorFrame()))
{
SetFollow(rPrecede.GetFollow());
rPrecede.SetFollow(this);
@@ -1560,21 +1561,23 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType eMakePage )
if( pLayLeaf )
{
SwFlyAtContentFrame* pNew = nullptr;
+ SwFrame* pFlyAnchor = const_cast<SwFrame*>(pFly->GetAnchorFrame());
+ if (pFlyAnchor)
{
- pNew = new SwFlyAtContentFrame( *pFly );
- pNew->InsertBefore( pLayLeaf, pLayLeaf->Lower() );
-
- SwFrame* pTmp = pFly->GetNext();
- if( pTmp && pTmp != pFly->GetFollow() )
+ SwFrame* pTmp = pFlyAnchor->GetNext();
+ if (pTmp)
{
SwFlowFrame* pNxt = nullptr;
- if( pTmp->IsContentFrame() )
+ if (pTmp->IsContentFrame())
{
pNxt = static_cast<SwContentFrame*>(pTmp);
}
if (pNxt)
{
- pNxt->MoveSubTree(pLayLeaf, pNew->GetNext());
+ pNxt->MoveSubTree(pLayLeaf);
+
+ pNew = new SwFlyAtContentFrame( *pFly );
+ pNxt->GetFrame().AppendFly( pNew );
}
}
}