From 66d235012c0c02db3b25f91a0fc981c66ed7388e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 30 Jan 2023 08:59:15 +0100 Subject: sw: add an initial SwFrame::GetNextFlyLeaf() To be called by SwFrame::GetLeaf() in the future. Towards an initial layout for multi-page fly frames. Change-Id: I62f895c2db89513fe124113c81c9f14bfb8ed697 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146337 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/source/core/inc/flyfrms.hxx | 2 ++ sw/source/core/inc/frame.hxx | 1 + sw/source/core/layout/flycnt.cxx | 51 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) (limited to 'sw') diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx index 4f6bc91922f2..01ac3872dcd6 100644 --- a/sw/source/core/inc/flyfrms.hxx +++ b/sw/source/core/inc/flyfrms.hxx @@ -193,6 +193,8 @@ public: format isn't possible, if method is already in progress. */ virtual bool IsFormatPossible() const override; + const SwFlyAtContentFrame* GetFollow() const; + SwFlyAtContentFrame* GetFollow(); }; // Flys that are bound to a character in Content diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index e5b4c4c9bf5c..8102a7e26e56 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -544,6 +544,7 @@ public: SwLayoutFrame *GetNextLeaf ( MakePageType eMakePage ); SwLayoutFrame *GetNextFootnoteLeaf( MakePageType eMakePage ); SwLayoutFrame *GetNextSctLeaf( MakePageType eMakePage ); + SwLayoutFrame *GetNextFlyLeaf( MakePageType eMakePage ); SwLayoutFrame *GetNextCellLeaf(); SwLayoutFrame *GetPrevLeaf (); SwLayoutFrame *GetPrevFootnoteLeaf( MakePageType eMakeFootnote ); diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index afe01a91897f..0fc135b48b5f 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1532,4 +1532,55 @@ bool SwFlyAtContentFrame::ShouldBwdMoved(SwLayoutFrame* /*pNewUpper*/, bool& /*r return false; } +const SwFlyAtContentFrame* SwFlyAtContentFrame::GetFollow() const +{ + return static_cast(SwFlowFrame::GetFollow()); +} + +SwFlyAtContentFrame* SwFlyAtContentFrame::GetFollow() +{ + return static_cast(SwFlowFrame::GetFollow()); +} + +SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType eMakePage ) +{ + auto pFly = dynamic_cast(FindFlyFrame()); + assert(pFly && "GetNextFlyLeaf: missing fly frame"); + + SwLayoutFrame *pLayLeaf = GetNextLayoutLeaf(); + if (!pLayLeaf) + { + if (eMakePage == MAKEPAGE_INSERT) + { + InsertPage(FindPageFrame(), false); + pLayLeaf = GetNextLayoutLeaf(); + } + } + + if( pLayLeaf ) + { + SwFlyAtContentFrame* pNew = nullptr; + { + pNew = new SwFlyAtContentFrame( *pFly ); + pNew->InsertBefore( pLayLeaf, pLayLeaf->Lower() ); + + SwFrame* pTmp = pFly->GetNext(); + if( pTmp && pTmp != pFly->GetFollow() ) + { + SwFlowFrame* pNxt = nullptr; + if( pTmp->IsContentFrame() ) + { + pNxt = static_cast(pTmp); + } + if (pNxt) + { + pNxt->MoveSubTree(pLayLeaf, pNew->GetNext()); + } + } + } + pLayLeaf = pNew; + } + return pLayLeaf; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit