34 #include <osl/diagnose.h>
41 class 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;
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;
589 if (pAnchor->IsPageFrame() || pAnchor->FindFooterOrHeader())
593 if (pAnchor->IsInFly())
597 if (pAnchor->IsInFootnote())
601 assert(pAnchor->IsInDocBody());
602 assert(pAnchor->IsContentFrame());
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
705 : rFromPageFrame.
GetPhyPageNum() < pObjAnchorPage->GetPhyPageNum())
706 && pObj->GetFrameFormat().GetAnchor().GetAnchorId()
707 != RndStdIds::FLY_AS_CHAR)
709 if (pPageFrameOfAnchor->
GetPhyPageNum() < pObjAnchorPage->GetPhyPageNum())
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;
877 while ( pFrame && pFrame != pSectFrame )
889 &_rAnchorTextFrame );
898 if (pColFrameOfAnchor)
905 while ( pColFrame != pColFrameOfAnchor )
918 pColFrame = pColFrame->
GetNext();
928 if ( _rAnchorTextFrame.
IsInTab() )
930 SwForbidFollowFormat aForbidFollowFormat( _rAnchorTextFrame );
956 if ( pObjs && pObjs->
size() > 1 )
960 if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
vcl::RenderContext * GetOut() const
virtual bool DoFormatObj(SwAnchoredObject &_rAnchoredObj, const bool _bCheckForMovedFwd=false) override
intrinsic method to format a certain floating screen object
Base class of the Writer layout elements.
Represents the visualization of a paragraph.
const SwSortedObjs * GetDrawObjs() const
void SetClearedEnvironment(const bool _bClearedEnvironment)
virtual SwFrame & GetAnchorFrame() override
static std::unique_ptr< SwObjectFormatterTextFrame > CreateObjFormatter(SwTextFrame &_rAnchorTextFrame, const SwPageFrame &_rPageFrame, SwLayAction *_pLayAction)
method to create an instance of is necessary.
bool AtLeastOneObjIsTmpConsiderWrapInfluence()
method to determine if at least one anchored object has state
#define SAL_INFO_IF(condition, area, stream)
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
virtual void Calc(vcl::RenderContext *pRenderContext) const
bool isFrameAreaDefinitionValid() const
sal_uInt16 GetPhyPageNum() const
void InvalidateObjPosForConsiderWrapInfluence()
method to perform necessary invalidations for the positioning of objects, for whose the wrapping styl...
wrapper class for the positioning of Writer fly frames and drawing objects
SwRowFrame * FindRowFrame()
void InvalidatePrevObjs(SwAnchoredObject &_rAnchoredObj)
method to invalidate objects, anchored previous to given object at the anchor text frame ...
SwTextFrame * GetFollow()
TextFrameIndex GetOffset() const
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'
bool IsColumnFrame() const
SwFootnoteFrame * FindFootnoteFrame()
SwFrame * GetIndPrev() const
const SwSortedObjs * GetSortedObjs() const
The usage of LayAction is always the same:
SwPageFrame * FindPageFrame()
SwTextFrame * mpMasterAnchorTextFrame
static void RemoveMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame)
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
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'.
SwLayoutFrame * GetUpper()
const SwRowFrame * IsInFollowFlowRow() const
void FormatAnchorFrameForCheckMoveFwd()
method to format the anchor frame for checking of the move forward condition
A page of the document layout.
SwFrame * GetAnchorFrameContainingAnchPos()
determine anchor frame containing the anchor position
bool RestartLayoutProcess() const
void InvalidateFollowObjs(SwAnchoredObject &_rAnchoredObj)
method to invalidate objects, anchored after the given object at the page frame
bool IsLayoutFrame() const
SwTextFrame & mrAnchorTextFrame
virtual bool IsFormatPossible() const
method to determine, if a format on the anchored object is possible
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 * FindPageFrameOfAnchor()
method to determine the page frame, on which the 'anchor' of the given anchored object is...
SwTextFrame * FindMaster() const
SwPageFrame * GetPageFrame()
sal_uInt16 GetPhyPageNum() const
bool HasClearedEnvironment() const
method to determine, if due to anchored object size and wrapping style, its layout environment is cle...
void ForbidFollowFormat()
#define SAL_INFO(area, stream)
virtual ~SwObjectFormatterTextFrame() override
size_t ListPosOf(const SwAnchoredObject &_rAnchoredObj) const
Position of object <_rAnchoredObj> in sorted list.
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
const SwFrame * GetAnchorFrame() const
static bool FrameMovedFwdByObjPos(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame, sal_uInt32 &_ornToPageNum)
bool IsFootnoteContFrame() const
static void FormatAnchorFrameAndItsPrevs(SwTextFrame &_rAnchorTextFrame)
method to format given anchor text frame and its previous frames
bool PositionLocked() const
SwViewShell * GetCurrShell() const
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
class for collecting anchored objects
virtual bool DoFormatObjs() override
intrinsic method to format all floating screen objects
void SetRestartLayoutProcess(const bool _bRestartLayoutProcess)
void SetAgain(bool bAgain)
SwObjectFormatterTextFrame(SwTextFrame &_rAnchorTextFrame, const SwPageFrame &_rPageFrame, SwTextFrame *_pMasterAnchorTextFrame, SwLayAction *_pLayAction)
SwRootFrame * getRootFrame()
static void InsertMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rMovedFwdFrameByObjPos, const sal_uInt32 _nToPageNum)
SwRowFrame is one table row in the document layout.
virtual const SwFrameFormat * GetFormat() const