34#include <osl/diagnose.h>
41class SwForbidFollowFormat
45 const bool bOldFollowFormatAllowed;
48 explicit SwForbidFollowFormat(
SwTextFrame& _rTextFrame )
49 : mrTextFrame( _rTextFrame ),
50 bOldFollowFormatAllowed( _rTextFrame.FollowFormatAllowed() )
55 ~SwForbidFollowFormat()
57 if ( bOldFollowFormatAllowed )
71 mrAnchorTextFrame( _rAnchorTextFrame ),
72 mpMasterAnchorTextFrame( _pMasterAnchorTextFrame )
85 std::unique_ptr<SwObjectFormatterTextFrame> pObjFormatter;
89 if ( _rAnchorTextFrame.IsFollow() )
91 pMasterOfAnchorFrame = _rAnchorTextFrame.
FindMaster();
92 while ( pMasterOfAnchorFrame && pMasterOfAnchorFrame->IsFollow() )
94 pMasterOfAnchorFrame = pMasterOfAnchorFrame->
FindMaster();
101 ( pMasterOfAnchorFrame && pMasterOfAnchorFrame->
GetDrawObjs() ) )
105 pMasterOfAnchorFrame, _pLayAction ));
108 return pObjFormatter;
118 const bool _bCheckForMovedFwd )
127 bool bSuccess(
true );
147 const bool bRestart =
170 ( _bCheckForMovedFwd ||
173 GetWrapInfluenceOnObjPos(
true ) ==
175 text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ) )
195 bool bInsert(
true );
196 sal_uInt32 nToPageNum( 0 );
201 if ( nToPageNum < pAnchorPageFrame->GetPhyPageNum() )
217 OSL_FAIL(
"<SwObjectFormatterTextFrame::DoFormatObj(..)> - anchor frame not marked to move forward" );
226 OSL_ENSURE( nIdx > 0,
227 "<SwObjectFormatterTextFrame::DoFormatObj(..)> - anchored object not collected!?" );
230 sal_uInt32 nToPageNum( 0 );
232 bool bDummy(
false );
233 bool bPageHasFlysAnchoredBelowThis(
false);
242 bPageHasFlysAnchoredBelowThis))
246 bool bInsert(
true );
247 sal_uInt32 nMovedFwdToPageNum( 0 );
252 if ( nMovedFwdToPageNum < nToPageNum )
254 if (!bPageHasFlysAnchoredBelowThis)
266 if (!bPageHasFlysAnchoredBelowThis)
286 OSL_FAIL(
"<SwObjectFormatterTextFrame::DoFormatObj(..)> - anchor frame not marked to move forward" );
320 OSL_FAIL(
"<SwObjectFormatterTextFrame::DoFormatObjs()> called for invalidate anchor text frame." );
326 bool bSuccess(
true );
336 "SwObjectFormatterTextFrame::DoFormatObjs() - missing 'master' anchor text frame" );
369 sal_uInt32 nToPageNum( 0 );
371 bool bInFollow(
false );
372 bool bPageHasFlysAnchoredBelowThis(
false);
378 text::WrapInfluenceOnPosition::ONCE_CONCURRENT,
379 nToPageNum, bInFollow, bPageHasFlysAnchoredBelowThis );
393 bool bInsert(
true );
394 sal_uInt32 nTmpToPageNum( 0 );
399 if ( nTmpToPageNum < pAnchorPageFrame->GetPhyPageNum() )
401 if (!bPageHasFlysAnchoredBelowThis)
411 if (!bPageHasFlysAnchoredBelowThis)
423 OSL_FAIL(
"<SwObjectFormatterTextFrame::DoFormatObjs(..)> - anchor frame not marked to move forward" );
427 else if ( pObj && bDoesAnchorHadPrev )
433 bool bInsert(
true );
434 sal_uInt32 nMovedFwdToPageNum( 0 );
439 if ( nMovedFwdToPageNum < nToPageNum )
464 OSL_FAIL(
"<SwObjectFormatterTextFrame::DoFormatObjs(..)> - anchor frame not marked to move forward" );
489 GetWrapInfluenceOnObjPos(
true ) !=
491 text::WrapInfluenceOnPosition::ONCE_CONCURRENT )
506 GetWrapInfluenceOnObjPos(
true ) ==
508 text::WrapInfluenceOnPosition::ONCE_CONCURRENT )
523 for (
size_t i = pObjs->
ListPosOf( _rAnchoredObj ) + 1; i < pObjs->
size(); ++
i )
532 const sal_Int16 _nWrapInfluenceOnPosition,
533 sal_uInt32& _noToPageNum,
535 bool& o_rbPageHasFlysAnchoredBelowThis)
538 OSL_ENSURE( _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
539 _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_CONCURRENT,
540 "<SwObjectFormatterTextFrame::GetFirstObjWithMovedFwdAnchor(..)> - invalid value for parameter <_nWrapInfluenceOnPosition>" );
551 GetWrapInfluenceOnObjPos(
true ) == _nWrapInfluenceOnPosition )
562 _noToPageNum, _boInFollow,
563 o_rbPageHasFlysAnchoredBelowThis) )
565 pRetAnchoredObj = pAnchoredObj;
571 return pRetAnchoredObj;
611 const bool _bAnchoredAtMasterBeforeFormatAnchor,
612 sal_uInt32& _noToPageNum,
614 bool& o_rbPageHasFlysAnchoredBelowThis)
616 const sal_uInt32 _nFromPageNum(rFromPageFrame.
GetPhyPageNum());
617 bool bAnchorIsMovedForward(
false );
620 if ( pPageFrameOfAnchor )
622 const sal_uInt32 nPageNum = pPageFrameOfAnchor->
GetPhyPageNum();
623 if ( nPageNum > _nFromPageNum )
625 _noToPageNum = nPageNum;
632 if ( _noToPageNum > (_nFromPageNum + 1) )
635 if ( pAnchorFrame->
IsInTab() &&
638 _noToPageNum = _nFromPageNum + 1;
641 bAnchorIsMovedForward =
true;
649 if ( !bAnchorIsMovedForward &&
650 _bAnchoredAtMasterBeforeFormatAnchor &&
656 "<SwObjectFormatterTextFrame::CheckMovedFwdCondition(..) - wrong type of anchor frame>" );
658 bool bCheck(
false );
659 if ( pAnchorTextFrame->IsFollow() )
663 else if( pAnchorTextFrame->
IsInTab() )
677 while ( pColFrame && !pColFrame->
GetNext() )
681 if ( !pColFrame || !pColFrame->
GetNext() )
683 _noToPageNum = _nFromPageNum + 1;
684 bAnchorIsMovedForward =
true;
691 if (bAnchorIsMovedForward)
701 SwPageFrame const*
const pObjAnchorPage(pObj->FindPageFrameOfAnchor());
702 assert(pObjAnchorPage);
703 if ((pObjAnchorPage == &rFromPageFrame
706 && pObj->GetFrameFormat().GetAnchor().GetAnchorId()
707 != RndStdIds::FLY_AS_CHAR)
711 SAL_INFO(
"sw.layout",
"SwObjectFormatterTextFrame::CheckMovedFwdCondition(): o_rbPageHasFlysAnchoredBelowThis because next page");
712 o_rbPageHasFlysAnchoredBelowThis =
true;
720 if (pInBodyFrameObj && pInBodyFrameAnchoredObj)
722 bool isBreakMore(
false);
728 if (pInBodyFrameObj == pContentFrame)
733 if (!pInBodyFrameAnchoredObj->
IsInTab()
737 SAL_INFO(
"sw.layout",
"SwObjectFormatterTextFrame::CheckMovedFwdCondition(): o_rbPageHasFlysAnchoredBelowThis because next chain on same page");
738 o_rbPageHasFlysAnchoredBelowThis =
true;
754 return bAnchorIsMovedForward;
769 assert(pFootnote->IsFootnoteFrame());
771 if (!pFootnote->IsDeleteForbidden() && !pFootnote->GetLower() && !pFootnote->IsColLocked() &&
777 pFootnote = pNextNote;
785 SwFrame* pLastLowerFrame =
nullptr )
788 while ( pLowerFrame )
791 if ( pLastLowerFrame && pLowerFrame == pLastLowerFrame )
827 if ( !_rAnchorTextFrame.IsFollow() )
833 SwFrame * pColFrameOfAnchor(
nullptr);
835 pUpper !=
nullptr; pUpper = pUpper->
GetUpper())
837 if (pUpper->IsCellFrame())
841 if (pUpper->IsFootnoteFrame())
844 "sw.layout",
"tdf#122894 skipping column for footnote in column");
847 if (pUpper->IsSctFrame())
849 pColFrameOfAnchor =
nullptr;
853 if (pColFrameOfAnchor !=
nullptr)
857 if (pUpper->IsColumnFrame())
859 pColFrameOfAnchor = pUpper;
872 _rAnchorTextFrame.LockJoin();
877 while ( pFrame && pFrame != pSectFrame )
889 &_rAnchorTextFrame );
891 _rAnchorTextFrame.UnlockJoin();
898 if (pColFrameOfAnchor)
902 _rAnchorTextFrame.LockJoin();
905 while ( pColFrame != pColFrameOfAnchor )
918 pColFrame = pColFrame->
GetNext();
921 _rAnchorTextFrame.UnlockJoin();
928 if ( _rAnchorTextFrame.
IsInTab() )
930 SwForbidFollowFormat aForbidFollowFormat( _rAnchorTextFrame );
956 if ( pObjs && pObjs->
size() > 1 )
960 if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
wrapper class for the positioning of Writer fly frames and drawing objects
const SwFrame * GetAnchorFrame() const
bool PositionLocked() const
void SetClearedEnvironment(const bool _bClearedEnvironment)
SwFrame * GetAnchorFrameContainingAnchPos()
determine anchor frame containing the anchor position
void InvalidateObjPosForConsiderWrapInfluence()
method to perform necessary invalidations for the positioning of objects, for whose the wrapping styl...
bool RestartLayoutProcess() const
bool ConsiderObjWrapInfluenceOnObjPos() const
method to determine, if wrapping style influence of the anchored object has to be considered on the o...
virtual SwFrameFormat & GetFrameFormat()=0
SwPageFrame * GetPageFrame()
SwPageFrame * FindPageFrameOfAnchor()
method to determine the page frame, on which the 'anchor' of the given anchored object is.
bool HasClearedEnvironment() const
method to determine, if due to anchored object size and wrapping style, its layout environment is cle...
virtual bool IsFormatPossible() const
method to determine, if a format on the anchored object is possible
void SetRestartLayoutProcess(const bool _bRestartLayoutProcess)
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
SwTextFrame * FindMaster() const
bool isFrameAreaDefinitionValid() const
Base class of the Writer layout elements.
bool IsFootnoteContFrame() const
SwFrame * GetIndPrev() const
SwFlyFrame * FindFlyFrame()
bool IsColumnFrame() const
bool IsInFootnote() const
virtual void Calc(vcl::RenderContext *pRenderContext) const
const SwSortedObjs * GetDrawObjs() const
SwRowFrame * FindRowFrame()
const SwRowFrame * IsInFollowFlowRow() const
SwLayoutFrame * GetUpper()
SwRootFrame * getRootFrame()
bool IsContentFrame() const
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
SwPageFrame * FindPageFrame()
SwFrame * FindFooterOrHeader()
SwFootnoteFrame * FindFootnoteFrame()
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
bool IsLayoutFrame() const
The usage of LayAction is always the same:
void SetAgain(bool bAgain)
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
virtual const SwFrameFormat * GetFormat() const
static void InsertMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rMovedFwdFrameByObjPos, const sal_uInt32 _nToPageNum)
static bool FrameMovedFwdByObjPos(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame, sal_uInt32 &_ornToPageNum)
static void RemoveMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame)
void InvalidateFollowObjs(SwAnchoredObject &_rAnchoredObj)
method to invalidate objects, anchored after the given object at the page frame
SwObjectFormatterTextFrame(SwTextFrame &_rAnchorTextFrame, const SwPageFrame &_rPageFrame, SwTextFrame *_pMasterAnchorTextFrame, SwLayAction *_pLayAction)
SwTextFrame & mrAnchorTextFrame
SwAnchoredObject * GetFirstObjWithMovedFwdAnchor(const sal_Int16 _nWrapInfluenceOnPosition, sal_uInt32 &_noToPageNum, bool &_boInFollow, bool &o_rbPageHasFlysAnchoredBelowThis)
method to determine first anchored object, whose 'anchor is moved forward'.
virtual bool DoFormatObjs() override
intrinsic method to format all floating screen objects
void InvalidatePrevObjs(SwAnchoredObject &_rAnchoredObj)
method to invalidate objects, anchored previous to given object at the anchor text frame
SwTextFrame * mpMasterAnchorTextFrame
bool AtLeastOneObjIsTmpConsiderWrapInfluence()
method to determine if at least one anchored object has state <temporarily consider wrapping style in...
static void FormatAnchorFrameAndItsPrevs(SwTextFrame &_rAnchorTextFrame)
method to format given anchor text frame and its previous frames
virtual ~SwObjectFormatterTextFrame() override
virtual bool DoFormatObj(SwAnchoredObject &_rAnchoredObj, const bool _bCheckForMovedFwd=false) override
intrinsic method to format a certain floating screen object
virtual SwFrame & GetAnchorFrame() override
static std::unique_ptr< SwObjectFormatterTextFrame > CreateObjFormatter(SwTextFrame &_rAnchorTextFrame, const SwPageFrame &_rPageFrame, SwLayAction *_pLayAction)
method to create an instance of <SwObjectFormatterTextFrame> is necessary.
void FormatAnchorFrameForCheckMoveFwd()
method to format the anchor frame for checking of the move forward condition
static bool CheckMovedFwdCondition(SwAnchoredObject &_rAnchoredObj, SwPageFrame const &rFromPageFrame, const bool _bAnchoredAtMasterBeforeFormatAnchor, sal_uInt32 &_noToPageNum, bool &_boInFollow, bool &o_rbPageHasFlysAnchoredBelowThis)
method to check the conditions, if 'anchor is moved forward'
A page of the document layout.
sal_uInt16 GetPhyPageNum() const
const SwSortedObjs * GetSortedObjs() const
SwViewShell * GetCurrShell() const
SwRowFrame is one table row in the document layout.
class for collecting anchored objects
size_t ListPosOf(const SwAnchoredObject &_rAnchoredObj) const
Position of object <_rAnchoredObj> in sorted list.
Represents the visualization of a paragraph.
SwTextFrame * GetFollow()
TextFrameIndex GetOffset() const
void ForbidFollowFormat()
vcl::RenderContext * GetOut() const
#define SAL_INFO_IF(condition, area, stream)
#define SAL_INFO(area, stream)