summaryrefslogtreecommitdiffstats
path: root/sw/source/core/layout/layact.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/layout/layact.cxx')
-rw-r--r--sw/source/core/layout/layact.cxx44
1 files changed, 43 insertions, 1 deletions
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 50d5b1fa6b7a..74fe4e85bcfd 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -62,6 +62,8 @@
#include <sortedobjs.hxx>
#include <objectformatter.hxx>
#include <fntcache.hxx>
+#include <fmtanchr.hxx>
+#include <comphelper/scopeguard.hxx>
#include <vector>
// Save some typing work to avoid accessing destroyed pages.
@@ -1602,8 +1604,48 @@ bool SwLayAction::FormatLayoutTab( SwTabFrame *pTab, bool bAddRect )
return bChanged;
}
-bool SwLayAction::FormatContent( const SwPageFrame *pPage )
+bool SwLayAction::FormatContent(SwPageFrame *const pPage)
{
+ ::comphelper::ScopeGuard g([this, pPage]() {
+ if (IsAgain())
+ {
+ return; // pPage probably deleted
+ }
+ if (auto const* pObjs = pPage->GetSortedObjs())
+ {
+ std::vector<std::pair<SwAnchoredObject*, SwPageFrame*>> moved;
+ for (auto const pObj : *pObjs)
+ {
+ assert(!pObj->AnchorFrame()->IsTextFrame()
+ || !static_cast<SwTextFrame const*>(pObj->AnchorFrame())->IsFollow());
+ SwPageFrame *const pAnchorPage(pObj->AnchorFrame()->FindPageFrame());
+ assert(pAnchorPage);
+ if (pAnchorPage != pPage
+ && pPage->GetPhyPageNum() < pAnchorPage->GetPhyPageNum()
+ && pObj->GetFrameFormat().GetAnchor().GetAnchorId()
+ != RndStdIds::FLY_AS_CHAR)
+ {
+ moved.emplace_back(pObj, pAnchorPage);
+ }
+ }
+ for (auto const& [pObj, pAnchorPage] : moved)
+ {
+ SAL_INFO("sw.layout", "SwLayAction::FormatContent: move anchored " << pObj << " from " << pPage->GetPhyPageNum() << " to " << pAnchorPage->GetPhyPageNum());
+ pObj->RegisterAtPage(*pAnchorPage);
+ ::Notify_Background(pObj->GetDrawObj(), pPage,
+ pObj->GetObjRect(), PREP_FLY_LEAVE, false);
+ }
+ if (!moved.empty())
+ {
+ pPage->InvalidateFlyLayout();
+ if (auto *const pContent = pPage->FindLastBodyContent())
+ {
+ pContent->InvalidateSize();
+ }
+ }
+ }
+ });
+
const SwContentFrame *pContent = pPage->ContainsContent();
const SwViewShell *pSh = m_pRoot->GetCurrShell();
const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();