diff options
-rw-r--r-- | sw/inc/anchoreddrawobject.hxx | 1 | ||||
-rw-r--r-- | sw/inc/anchoredobject.hxx | 5 | ||||
-rw-r--r-- | sw/source/core/inc/flyfrm.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/inc/flyfrms.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/inc/layact.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/anchoreddrawobject.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/layout/fly.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/layout/flycnt.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/layout/layact.cxx | 44 |
9 files changed, 81 insertions, 10 deletions
diff --git a/sw/inc/anchoreddrawobject.hxx b/sw/inc/anchoreddrawobject.hxx index e4f57f3e09ff..b1729b3eaca1 100644 --- a/sw/inc/anchoreddrawobject.hxx +++ b/sw/inc/anchoreddrawobject.hxx @@ -95,6 +95,7 @@ class SW_DLLPUBLIC SwAnchoredDrawObject : public SwAnchoredObject page frame */ virtual void RegisterAtCorrectPage() override; + virtual void RegisterAtPage(SwPageFrame &) override; virtual bool SetObjTop_( const SwTwips _nTop) override; virtual bool SetObjLeft_( const SwTwips _nLeft) override; diff --git a/sw/inc/anchoredobject.hxx b/sw/inc/anchoredobject.hxx index 2a5c192f2af5..746b9ca3b69a 100644 --- a/sw/inc/anchoredobject.hxx +++ b/sw/inc/anchoredobject.hxx @@ -46,7 +46,8 @@ class SW_DLLPUBLIC SwAnchoredObject private: // drawing object representing the anchored object in the drawing layer SdrObject* mpDrawObj; - // frame the object is anchored at + /// Frame the object is anchored at. + /// For at-char/at-para anchor, this is always the master SwTextFrame. SwFrame* mpAnchorFrame; // #i28701 - page frame the object is registered at // note: no page frame for as-character anchored objects @@ -295,6 +296,8 @@ class SW_DLLPUBLIC SwAnchoredObject /** method to invalidate position of the anchored object */ virtual void InvalidateObjPos() = 0; + virtual void RegisterAtPage(SwPageFrame &) = 0; + /** method to perform necessary invalidations for the positioning of objects, for whose the wrapping style influence has to be considered on the object positioning. diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx index c44725f73a6b..a0fcdeb1eb57 100644 --- a/sw/source/core/inc/flyfrm.hxx +++ b/sw/source/core/inc/flyfrm.hxx @@ -134,6 +134,7 @@ protected: page frame */ virtual void RegisterAtCorrectPage() override; + virtual void RegisterAtPage(SwPageFrame &) override; virtual bool SetObjTop_( const SwTwips _nTop ) override; virtual bool SetObjLeft_( const SwTwips _nLeft ) override; diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx index 8e167b9490f5..04b505ddd548 100644 --- a/sw/source/core/inc/flyfrms.hxx +++ b/sw/source/core/inc/flyfrms.hxx @@ -170,6 +170,7 @@ protected: #i28701# */ virtual void RegisterAtCorrectPage() override; + virtual void RegisterAtPage(SwPageFrame &) override; virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override; public: diff --git a/sw/source/core/inc/layact.hxx b/sw/source/core/inc/layact.hxx index da2250e7fb49..2b1b17a4afd2 100644 --- a/sw/source/core/inc/layact.hxx +++ b/sw/source/core/inc/layact.hxx @@ -111,7 +111,7 @@ class SwLayAction bool FormatLayout( OutputDevice* pRenderContext, SwLayoutFrame *, bool bAddRect = true ); bool FormatLayoutTab( SwTabFrame *, bool bAddRect ); - bool FormatContent( const SwPageFrame* pPage ); + bool FormatContent(SwPageFrame * pPage); void FormatContent_( const SwContentFrame* pContent, const SwPageFrame* pPage ); bool IsShortCut( SwPageFrame *& ); diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index de969773d8b9..5660fa118c3d 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -840,10 +840,18 @@ void SwAnchoredDrawObject::RegisterAtCorrectPage() } if ( pPageFrame && GetPageFrame() != pPageFrame ) { - if ( GetPageFrame() ) - GetPageFrame()->RemoveDrawObjFromPage( *this ); - pPageFrame->AppendDrawObjToPage( *this ); + RegisterAtPage(*pPageFrame); } } +void SwAnchoredDrawObject::RegisterAtPage(SwPageFrame & rPageFrame) +{ + assert(GetPageFrame() != &rPageFrame); + if (GetPageFrame()) + { + GetPageFrame()->RemoveDrawObjFromPage( *this ); + } + rPageFrame.AppendDrawObjToPage( *this ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 1f566f373125..ef654ca8fc2b 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -2796,6 +2796,11 @@ void SwFlyFrame::RegisterAtCorrectPage() // default behaviour is to do nothing. } +void SwFlyFrame::RegisterAtPage(SwPageFrame &) +{ + // default behaviour is to do nothing. +} + /** method to determine, if a <MakeAll()> on the Writer fly frame is possible OD 2004-05-11 #i28701# diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index f3c442ac8cfa..7ac4cf41740a 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1396,10 +1396,20 @@ void SwFlyAtContentFrame::RegisterAtCorrectPage() } if ( pPageFrame && GetPageFrame() != pPageFrame ) { - if ( GetPageFrame() ) - GetPageFrame()->MoveFly( this, pPageFrame ); - else - pPageFrame->AppendFlyToPage( this ); + RegisterAtPage(*pPageFrame); + } +} + +void SwFlyAtContentFrame::RegisterAtPage(SwPageFrame & rPageFrame) +{ + assert(GetPageFrame() != &rPageFrame); + if (GetPageFrame()) + { + GetPageFrame()->MoveFly( this, &rPageFrame ); + } + else + { + rPageFrame.AppendFlyToPage( this ); } } 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(); |