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(+)

New commits:
commit 66d235012c0c02db3b25f91a0fc981c66ed7388e
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Jan 30 08:59:15 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Jan 30 08:51:21 2023 +0000

    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 <vmik...@collabora.com>
    Tested-by: Jenkins

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 <MakeAll()> 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<const SwFlyAtContentFrame*>(SwFlowFrame::GetFollow());
+}
+
+SwFlyAtContentFrame* SwFlyAtContentFrame::GetFollow()
+{
+    return static_cast<SwFlyAtContentFrame*>(SwFlowFrame::GetFollow());
+}
+
+SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType eMakePage )
+{
+    auto pFly = dynamic_cast<SwFlyAtContentFrame*>(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<SwContentFrame*>(pTmp);
+                }
+                if (pNxt)
+                {
+                    pNxt->MoveSubTree(pLayLeaf, pNew->GetNext());
+                }
+            }
+        }
+        pLayLeaf = pNew;
+    }
+    return pLayLeaf;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to