summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-02-06 08:21:02 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-02-06 13:46:12 +0000
commit27fbab13557a75b5402c11a1697541edc124116a (patch)
tree50f473ab6137b5fb74b2ef89792d234494a3fe20 /sw
parent6966957aa42dea54eff933665b49e3976b32eff0 (diff)
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 <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-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/flowfrm.cxx4
-rw-r--r--sw/source/core/layout/flycnt.cxx21
4 files changed, 28 insertions, 0 deletions
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: */