summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-01-30 08:59:15 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-01-30 08:51:21 +0000
commit66d235012c0c02db3b25f91a0fc981c66ed7388e (patch)
treece8d5747f2f52e951139dbdee154fb199a13f779
parentea093514e4fc3a66f57e07486863c22e32db4245 (diff)
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 <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/source/core/inc/flyfrms.hxx2
-rw-r--r--sw/source/core/inc/frame.hxx1
-rw-r--r--sw/source/core/layout/flycnt.cxx51
3 files changed, 54 insertions, 0 deletions
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: */