sw/source/core/inc/flyfrms.hxx | 2 ++ sw/source/core/inc/frame.hxx | 1 + sw/source/core/layout/flowfrm.cxx | 4 ++++ sw/source/core/layout/flycnt.cxx | 21 +++++++++++++++++++++ 4 files changed, 28 insertions(+)
New commits: commit 27fbab13557a75b5402c11a1697541edc124116a Author: Miklos Vajna <[email protected]> AuthorDate: Mon Feb 6 08:21:02 2023 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Feb 6 13:46:12 2023 +0000 sw: implement SwFrame::GetPrevFlyLeaf() This is much easier than the "next" case, since here we can nullptr when there is no previous leaf instead of creating one. With this, if the MoveBwd() call in SwContentFrame::MakeAll() is disabled, some simple fly frame can be split across 2 pages if it's positioned in a way that the rectangle of the fly would not fit into the body frame without changing the position, in SW_FORCE_FLY_SPLIT=1 mode. Towards an initial layout for multi-page fly frames. Change-Id: I3b6ba85ad66117b5595a113d688e2fcb97bcf745 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146571 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx index 61a40d8a8f8c..39f9c1dbf2f5 100644 --- a/sw/source/core/inc/flyfrms.hxx +++ b/sw/source/core/inc/flyfrms.hxx @@ -195,6 +195,8 @@ public: virtual bool IsFormatPossible() const override; const SwFlyAtContentFrame* GetFollow() const; SwFlyAtContentFrame* GetFollow(); + const SwFlyAtContentFrame* GetPrecede() const; + SwFlyAtContentFrame* GetPrecede(); }; // 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 8102a7e26e56..e610de6eab70 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -549,6 +549,7 @@ public: SwLayoutFrame *GetPrevLeaf (); SwLayoutFrame *GetPrevFootnoteLeaf( MakePageType eMakeFootnote ); SwLayoutFrame *GetPrevSctLeaf(); + SwLayoutFrame *GetPrevFlyLeaf(); SwLayoutFrame *GetPrevCellLeaf(); const SwLayoutFrame *GetLeaf ( MakePageType eMakePage, bool bFwd, const SwFrame *pAnch ) const; diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 9939dceafa1b..e53d32b9fa20 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -883,6 +883,10 @@ SwLayoutFrame *SwFrame::GetLeaf( MakePageType eMakePage, bool bFwd ) { return GetNextFlyLeaf(eMakePage); } + else + { + return GetPrevFlyLeaf(); + } } return bFwd ? GetNextLeaf( eMakePage ) : GetPrevLeaf(); diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 427ac5b9c37b..2d4c9a373796 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1586,4 +1586,25 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType eMakePage ) return pLayLeaf; } +const SwFlyAtContentFrame* SwFlyAtContentFrame::GetPrecede() const +{ + return static_cast<const SwFlyAtContentFrame*>(SwFlowFrame::GetPrecede()); +} + +SwFlyAtContentFrame* SwFlyAtContentFrame::GetPrecede() +{ + return static_cast<SwFlyAtContentFrame*>(SwFlowFrame::GetPrecede()); +} + +SwLayoutFrame* SwFrame::GetPrevFlyLeaf() +{ + auto pFly = dynamic_cast<SwFlyAtContentFrame*>(FindFlyFrame()); + if (!pFly->IsFlySplitAllowed()) + { + return nullptr; + } + + return pFly->GetPrecede(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
